In this PR I layout the first steps to migrate Activity to a traditional Standard objects Since this is a big transition, I'd rather split it into several deployments / PRs <img width="1512" alt="image" src="https://github.com/user-attachments/assets/012e2bbf-9d1b-4723-aaf6-269ef588b050"> --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: bosiraphael <71827178+bosiraphael@users.noreply.github.com> Co-authored-by: Weiko <corentin@twenty.com> Co-authored-by: Faisal-imtiyaz123 <142205282+Faisal-imtiyaz123@users.noreply.github.com> Co-authored-by: Prateek Jain <prateekj1171998@gmail.com>
96 lines
2.8 KiB
TypeScript
96 lines
2.8 KiB
TypeScript
import styled from '@emotion/styled';
|
|
import { IconPlus } from 'twenty-ui';
|
|
|
|
import { SkeletonLoader } from '@/activities/components/SkeletonLoader';
|
|
import { useOpenCreateActivityDrawer } from '@/activities/hooks/useOpenCreateActivityDrawer';
|
|
import { NoteList } from '@/activities/notes/components/NoteList';
|
|
import { useNotes } from '@/activities/notes/hooks/useNotes';
|
|
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
|
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
|
import { Button } from '@/ui/input/button/components/Button';
|
|
import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder';
|
|
import {
|
|
AnimatedPlaceholderEmptyContainer,
|
|
AnimatedPlaceholderEmptySubTitle,
|
|
AnimatedPlaceholderEmptyTextContainer,
|
|
AnimatedPlaceholderEmptyTitle,
|
|
EMPTY_PLACEHOLDER_TRANSITION_PROPS,
|
|
} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled';
|
|
|
|
const StyledNotesContainer = styled.div`
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
overflow: auto;
|
|
`;
|
|
|
|
export const Notes = ({
|
|
targetableObject,
|
|
}: {
|
|
targetableObject: ActivityTargetableObject;
|
|
}) => {
|
|
const { notes, loading } = useNotes(targetableObject);
|
|
|
|
const openCreateActivity = useOpenCreateActivityDrawer({
|
|
activityObjectNameSingular: CoreObjectNameSingular.Note,
|
|
});
|
|
|
|
const isNotesEmpty = !notes || notes.length === 0;
|
|
|
|
if (loading && isNotesEmpty) {
|
|
return <SkeletonLoader />;
|
|
}
|
|
|
|
if (isNotesEmpty) {
|
|
return (
|
|
<AnimatedPlaceholderEmptyContainer
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
{...EMPTY_PLACEHOLDER_TRANSITION_PROPS}
|
|
>
|
|
<AnimatedPlaceholder type="noNote" />
|
|
<AnimatedPlaceholderEmptyTextContainer>
|
|
<AnimatedPlaceholderEmptyTitle>
|
|
No notes
|
|
</AnimatedPlaceholderEmptyTitle>
|
|
<AnimatedPlaceholderEmptySubTitle>
|
|
There are no associated notes with this record.
|
|
</AnimatedPlaceholderEmptySubTitle>
|
|
</AnimatedPlaceholderEmptyTextContainer>
|
|
<Button
|
|
Icon={IconPlus}
|
|
title="New note"
|
|
variant="secondary"
|
|
onClick={() =>
|
|
openCreateActivity({
|
|
targetableObjects: [targetableObject],
|
|
})
|
|
}
|
|
/>
|
|
</AnimatedPlaceholderEmptyContainer>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<StyledNotesContainer>
|
|
<NoteList
|
|
title="All"
|
|
notes={notes}
|
|
button={
|
|
<Button
|
|
Icon={IconPlus}
|
|
size="small"
|
|
variant="secondary"
|
|
title="Add note"
|
|
onClick={() =>
|
|
openCreateActivity({
|
|
targetableObjects: [targetableObject],
|
|
})
|
|
}
|
|
></Button>
|
|
}
|
|
/>
|
|
</StyledNotesContainer>
|
|
);
|
|
};
|