fix: don't use previous view group state when creating a new view (#8370)
When creating a new view we don't want to use view-groups from previous view.
This commit is contained in:
@ -18,7 +18,6 @@ import { GraphQLView } from '@/views/types/GraphQLView';
|
|||||||
import { View } from '@/views/types/View';
|
import { View } from '@/views/types/View';
|
||||||
import { ViewGroup } from '@/views/types/ViewGroup';
|
import { ViewGroup } from '@/views/types/ViewGroup';
|
||||||
import { ViewType } from '@/views/types/ViewType';
|
import { ViewType } from '@/views/types/ViewType';
|
||||||
import { isNonEmptyArray } from '@sniptt/guards';
|
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { useRecoilCallback } from 'recoil';
|
import { useRecoilCallback } from 'recoil';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
@ -113,7 +112,6 @@ export const useCreateViewFromCurrentView = (viewBarComponentId?: string) => {
|
|||||||
await createViewFieldRecords(sourceView.viewFields, newView);
|
await createViewFieldRecords(sourceView.viewFields, newView);
|
||||||
|
|
||||||
if (type === ViewType.Kanban) {
|
if (type === ViewType.Kanban) {
|
||||||
if (!isNonEmptyArray(sourceView.viewGroups)) {
|
|
||||||
if (!isDefined(kanbanFieldMetadataId)) {
|
if (!isDefined(kanbanFieldMetadataId)) {
|
||||||
throw new Error('Kanban view must have a kanban field');
|
throw new Error('Kanban view must have a kanban field');
|
||||||
}
|
}
|
||||||
@ -143,9 +141,6 @@ export const useCreateViewFromCurrentView = (viewBarComponentId?: string) => {
|
|||||||
} satisfies ViewGroup);
|
} satisfies ViewGroup);
|
||||||
|
|
||||||
await createViewGroupRecords(viewGroupsToCreate, newView);
|
await createViewGroupRecords(viewGroupsToCreate, newView);
|
||||||
} else {
|
|
||||||
await createViewGroupRecords(sourceView.viewGroups, newView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldCopyFiltersAndSorts === true) {
|
if (shouldCopyFiltersAndSorts === true) {
|
||||||
|
|||||||
Reference in New Issue
Block a user