Load empty board if view type is kanban (#3605)

* Load empty board if view type is kanban

* Fix tests

* Revert
This commit is contained in:
Charles Bochet
2024-01-24 16:17:47 +01:00
committed by GitHub
parent c811206c47
commit ccbf773fd4
21 changed files with 210 additions and 124 deletions

View File

@ -22,8 +22,6 @@ import { ViewScope } from '@/views/scopes/ViewScope';
import { entityCountInCurrentViewScopedState } from '@/views/states/entityCountInCurrentViewScopedState';
import { viewEditModeScopedState } from '@/views/states/viewEditModeScopedState';
import { viewObjectMetadataIdScopeState } from '@/views/states/viewObjectMetadataIdScopeState';
import { viewTypeScopedState } from '@/views/states/viewTypeScopedState';
import { ViewType } from '@/views/types/ViewType';
jest.mock('@/object-metadata/hooks/useMapFieldMetadataToGraphQLQuery', () => {
return {
@ -225,25 +223,6 @@ describe('useViewBar', () => {
expect(result.current.metadataId).toBe('newId');
});
it('should update view type', async () => {
const { result } = renderHook(
() => ({
viewBar: useViewBar({ viewBarId }),
ViewType: useRecoilState(
getScopedStateDeprecated(viewTypeScopedState, viewBarId),
)[0],
}),
renderHookConfig,
);
expect(result.current.ViewType).toBe('table');
await act(async () => {
result.current.viewBar.setViewType(ViewType.Kanban);
});
expect(result.current.ViewType).toBe('kanban');
});
it('should update count in current view', async () => {
const { result } = renderHook(
() => ({

View File

@ -40,6 +40,7 @@ export const useViewScopedStates = (args?: { viewScopeId?: string }) => {
onViewFieldsChangeState,
onViewFiltersChangeState,
onViewSortsChangeState,
onViewTypeChangeState,
savedViewFieldsByKeySelector,
savedViewFieldsState,
savedViewFiltersByKeySelector,
@ -72,6 +73,7 @@ export const useViewScopedStates = (args?: { viewScopeId?: string }) => {
onViewFieldsChangeState,
onViewFiltersChangeState,
onViewSortsChangeState,
onViewTypeChangeState,
savedViewFieldsByKeySelector,
savedViewFieldsState,
savedViewFiltersByKeySelector,

View File

@ -43,7 +43,6 @@ export const useViewBar = (props?: UseViewProps) => {
availableSortDefinitionsState,
entityCountInCurrentViewState,
viewObjectMetadataIdState,
viewTypeState,
} = useViewScopedStates({
viewScopeId: scopeId,
});
@ -79,7 +78,6 @@ export const useViewBar = (props?: UseViewProps) => {
const setViewEditMode = useSetRecoilState(viewEditModeState);
const setViewObjectMetadataId = useSetRecoilState(viewObjectMetadataIdState);
const setViewType = useSetRecoilState(viewTypeState);
const [_, setSearchParams] = useSearchParams();
@ -237,16 +235,18 @@ export const useViewBar = (props?: UseViewProps) => {
(viewId: string) => {
setCurrentViewId?.(viewId);
const { currentView } = getViewScopedStateValuesFromSnapshot({
snapshot,
viewScopeId: scopeId,
viewId,
});
const { currentView, onViewTypeChange } =
getViewScopedStateValuesFromSnapshot({
snapshot,
viewScopeId: scopeId,
viewId,
});
if (!currentView) {
return;
}
onViewTypeChange?.(currentView.type);
loadViewFields(currentView.viewFields, viewId);
loadViewFilters(currentView.viewFilters, viewId);
loadViewSorts(currentView.viewSorts, viewId);
@ -418,7 +418,6 @@ export const useViewBar = (props?: UseViewProps) => {
setViewEditMode,
setViewObjectMetadataId,
setViewType,
setEntityCountInCurrentView,
setAvailableFieldDefinitions,