feat: soft delete (#6576)
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 <felix.malfait@gmail.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { Button } from '@/ui/input/button/components/Button';
|
||||
import styled from '@emotion/styled';
|
||||
import { Banner, IconComponent } from 'twenty-ui';
|
||||
import { Banner, BannerVariant, IconComponent } from 'twenty-ui';
|
||||
|
||||
const StyledBanner = styled(Banner)`
|
||||
position: absolute;
|
||||
@ -14,26 +14,30 @@ const StyledText = styled.div`
|
||||
|
||||
export const InformationBanner = ({
|
||||
message,
|
||||
variant = 'default',
|
||||
buttonTitle,
|
||||
buttonIcon,
|
||||
buttonOnClick,
|
||||
}: {
|
||||
message: string;
|
||||
buttonTitle: string;
|
||||
variant?: BannerVariant;
|
||||
buttonTitle?: string;
|
||||
buttonIcon?: IconComponent;
|
||||
buttonOnClick: () => void;
|
||||
buttonOnClick?: () => void;
|
||||
}) => {
|
||||
return (
|
||||
<StyledBanner>
|
||||
<StyledBanner variant={variant}>
|
||||
<StyledText>{message}</StyledText>
|
||||
<Button
|
||||
variant="secondary"
|
||||
title={buttonTitle}
|
||||
Icon={buttonIcon}
|
||||
size="small"
|
||||
inverted
|
||||
onClick={buttonOnClick}
|
||||
/>
|
||||
{buttonTitle && buttonOnClick && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
title={buttonTitle}
|
||||
Icon={buttonIcon}
|
||||
size="small"
|
||||
inverted
|
||||
onClick={buttonOnClick}
|
||||
/>
|
||||
)}
|
||||
</StyledBanner>
|
||||
);
|
||||
};
|
||||
|
||||
@ -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>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user