-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/metadata object and settings post merge (#2269)
* WIP * WIP2 * Seed views standard objects * Migrate views to the new data model --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
- Loading branch information
1 parent
dc82590
commit 10a9d2c
Showing
30 changed files
with
616 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
front/src/modules/metadata/components/ObjectTableEffect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { useEffect } from 'react'; | ||
import { useSetRecoilState } from 'recoil'; | ||
|
||
import { availableTableColumnsScopedState } from '@/ui/data/data-table/states/availableTableColumnsScopedState'; | ||
import { useView } from '@/views/hooks/useView'; | ||
import { ViewType } from '~/generated/graphql'; | ||
|
||
import { useMetadataObjectInContext } from '../hooks/useMetadataObjectInContext'; | ||
|
||
export const ObjectTableEffect = () => { | ||
console.log('ObjectTableEffect'); | ||
|
||
const { | ||
setAvailableSorts, | ||
setAvailableFilters, | ||
setAvailableFields, | ||
setViewType, | ||
setViewObjectId, | ||
} = useView(); | ||
|
||
// const [, setTableColumns] = useRecoilScopedState( | ||
// tableColumnsScopedState, | ||
// TableRecoilScopeContext, | ||
// ); | ||
|
||
// const [, setTableSorts] = useRecoilScopedState( | ||
// tableSortsScopedState, | ||
// TableRecoilScopeContext, | ||
// ); | ||
|
||
// const [, setTableFilters] = useRecoilScopedState( | ||
// tableFiltersScopedState, | ||
// TableRecoilScopeContext, | ||
// ); | ||
|
||
const { columnDefinitions, objectNamePlural } = useMetadataObjectInContext(); | ||
|
||
const setAvailableTableColumns = useSetRecoilState( | ||
availableTableColumnsScopedState(objectNamePlural ?? ''), | ||
); | ||
|
||
useEffect(() => { | ||
setAvailableSorts?.([]); // TODO: extract from metadata fields | ||
setAvailableFilters?.([]); // TODO: extract from metadata fields | ||
setAvailableFields?.(columnDefinitions); | ||
setViewObjectId?.(objectNamePlural); | ||
setViewType?.(ViewType.Table); | ||
|
||
setAvailableTableColumns(columnDefinitions); | ||
}, [ | ||
setAvailableFields, | ||
setAvailableFilters, | ||
setAvailableSorts, | ||
setAvailableTableColumns, | ||
setViewObjectId, | ||
setViewType, | ||
columnDefinitions, | ||
objectNamePlural, | ||
]); | ||
|
||
// useEffect(() => { | ||
// if (currentViewFields) { | ||
// setTableColumns([...currentViewFields].sort((a, b) => a.index - b.index)); | ||
// } | ||
// }, [currentViewFields, setTableColumns]); | ||
|
||
// useEffect(() => { | ||
// if (currentViewSorts) { | ||
// setTableSorts(currentViewSorts); | ||
// } | ||
// }, [currentViewFields, currentViewSorts, setTableColumns, setTableSorts]); | ||
|
||
// useEffect(() => { | ||
// if (currentViewFilters) { | ||
// setTableFilters(currentViewFilters); | ||
// } | ||
// }, [ | ||
// currentViewFields, | ||
// currentViewFilters, | ||
// setTableColumns, | ||
// setTableFilters, | ||
// setTableSorts, | ||
// ]); | ||
|
||
return <></>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
import { PaginatedObjectTypeResults } from './PaginatedObjectTypeResults'; | ||
|
||
export type PaginatedObjectType<ObjectType extends { id: string }> = { | ||
[objectNamePlural: string]: { | ||
edges: { | ||
node: ObjectType; | ||
cursor: string; | ||
}[]; | ||
}; | ||
[objectNamePlural: string]: PaginatedObjectTypeResults<ObjectType>; | ||
}; |
6 changes: 6 additions & 0 deletions
6
front/src/modules/metadata/types/PaginatedObjectTypeResults.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type PaginatedObjectTypeResults<ObjectType extends { id: string }> = { | ||
edges: { | ||
node: ObjectType; | ||
cursor: string; | ||
}[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.