Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4244-Kanban-Column-Menu #4640

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
import { useRecoilValue, useSetRecoilState } from 'recoil';

import { useObjectMetadataItemOnly } from '@/object-metadata/hooks/useObjectMetadataItemOnly';
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
import { useRecordActionBar } from '@/object-record/record-action-bar/hooks/useRecordActionBar';
import { useRecordBoard } from '@/object-record/record-board/hooks/useRecordBoard';
import { useRecordBoardSelection } from '@/object-record/record-board/hooks/useRecordBoardSelection';
Expand Down Expand Up @@ -62,9 +63,19 @@ export const RecordIndexBoardContainerEffect = ({
const navigate = useNavigate();

const navigateToSelectSettings = useCallback(() => {
navigate(`/settings/objects/${objectMetadataItem.namePlural}`);
navigate(`/settings/objects/${objectMetadataItem.namePlural}/stage`);
}, [navigate, objectMetadataItem.namePlural]);

const { createOneRecord: createOneObject } = useCreateOneRecord({
objectNameSingular,
});

const createEmptyObjectWithStage = useCallback(async () => {
await createOneObject?.({
position: 'first',
});
}, [createOneObject]);

const { resetRecordSelection } = useRecordBoardSelection(recordBoardId);

useEffect(() => {
Expand All @@ -77,10 +88,12 @@ export const RecordIndexBoardContainerEffect = ({
objectMetadataItem,
recordIndexKanbanFieldMetadataId ?? '',
navigateToSelectSettings,
createEmptyObjectWithStage,
),
);
}, [
navigateToSelectSettings,
createEmptyObjectWithStage,
objectMetadataItem,
objectNameSingular,
recordIndexKanbanFieldMetadataId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconPencil } from 'twenty-ui';
import { IconEyeOff, IconPlus, IconSettings } from 'twenty-ui';

import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
Expand All @@ -8,6 +8,7 @@ export const computeRecordBoardColumnDefinitionsFromObjectMetadata = (
objectMetadataItem: ObjectMetadataItem,
kanbanFieldMetadataId: string,
navigateToSelectSettings: () => void,
createEmptyObjectWithStage: () => void,
): RecordBoardColumnDefinition[] => {
const selectFieldMetadataItem = objectMetadataItem.fields.find(
(field) =>
Expand All @@ -34,11 +35,25 @@ export const computeRecordBoardColumnDefinitionsFromObjectMetadata = (
actions: [
{
id: 'edit',
label: 'Edit from settings',
icon: IconPencil,
label: 'Edit',
icon: IconSettings,
position: 0,
callback: navigateToSelectSettings,
},
{
id: 'hide',
lucasbordeau marked this conversation as resolved.
Show resolved Hide resolved
label: 'Hide',
icon: IconEyeOff,
position: 0,
callback: navigateToSelectSettings,
},
{
id: 'add',
label: 'Add record',
icon: IconPlus,
position: 0,
callback: createEmptyObjectWithStage,
},
],
}));
};
Loading