-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement soft delete on standards and custom objects. This is a temporary solution, when we drop `pg_graphql` we should rely on the `softDelete` functions of TypeORM. --------- Co-authored-by: Félix Malfait <[email protected]> Co-authored-by: Lucas Bordeau <[email protected]>
- Loading branch information
1 parent
20d8475
commit db54469
Showing
118 changed files
with
1,670 additions
and
487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...c/modules/information-banner/components/deleted-record/InformationBannerDeletedRecord.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { InformationBanner } from '@/information-banner/components/InformationBanner'; | ||
import { useRestoreManyRecords } from '@/object-record/hooks/useRestoreManyRecords'; | ||
import styled from '@emotion/styled'; | ||
import { IconRefresh } from 'twenty-ui'; | ||
|
||
const StyledInformationBannerDeletedRecord = styled.div` | ||
height: 40px; | ||
position: relative; | ||
&:empty { | ||
height: 0; | ||
} | ||
`; | ||
|
||
export const InformationBannerDeletedRecord = ({ | ||
recordId, | ||
objectNameSingular, | ||
}: { | ||
recordId: string; | ||
objectNameSingular: string; | ||
}) => { | ||
const { restoreManyRecords } = useRestoreManyRecords({ | ||
objectNameSingular, | ||
}); | ||
|
||
return ( | ||
<StyledInformationBannerDeletedRecord> | ||
<InformationBanner | ||
variant="danger" | ||
message={`This record has been deleted`} | ||
buttonTitle="Restore" | ||
buttonIcon={IconRefresh} | ||
buttonOnClick={() => restoreManyRecords([recordId])} | ||
/> | ||
</StyledInformationBannerDeletedRecord> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/twenty-front/src/modules/information-banner/constants/InformationBannerHeight.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const INFORMATION_BANNER_HEIGHT = '40px'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/twenty-front/src/modules/object-record/hooks/useDestroyManyRecordMutation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; | ||
import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation'; | ||
import { getDestroyManyRecordsMutationResponseField } from '@/object-record/utils/getDestroyManyRecordsMutationResponseField'; | ||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull'; | ||
import { capitalize } from '~/utils/string/capitalize'; | ||
|
||
export const useDestroyManyRecordsMutation = ({ | ||
objectNameSingular, | ||
}: { | ||
objectNameSingular: string; | ||
}) => { | ||
const { objectMetadataItem } = useObjectMetadataItem({ | ||
objectNameSingular, | ||
}); | ||
|
||
if (isUndefinedOrNull(objectMetadataItem)) { | ||
return { destroyManyRecordsMutation: EMPTY_MUTATION }; | ||
} | ||
|
||
const capitalizedObjectName = capitalize(objectMetadataItem.namePlural); | ||
|
||
const mutationResponseField = getDestroyManyRecordsMutationResponseField( | ||
objectMetadataItem.namePlural, | ||
); | ||
|
||
const destroyManyRecordsMutation = gql` | ||
mutation DestroyMany${capitalizedObjectName}($filter: ${capitalize( | ||
objectMetadataItem.nameSingular, | ||
)}FilterInput!) { | ||
${mutationResponseField}(filter: $filter) { | ||
id | ||
} | ||
} | ||
`; | ||
|
||
return { | ||
destroyManyRecordsMutation, | ||
}; | ||
}; |
Oops, something went wrong.