2282 Rename components to use the new naming convention part 3 (#2296)
part 3 of the renaming
This commit is contained in:
@ -1,38 +0,0 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { Icon123 } from '@/ui/input/constants/icons';
|
||||
import { useLazyLoadIcons } from '@/ui/input/hooks/useLazyLoadIcons';
|
||||
import NavItem from '@/ui/navigation/navbar/components/NavItem';
|
||||
|
||||
import { useFindManyMetadataObjects } from '../hooks/useFindManyMetadataObjects';
|
||||
|
||||
export const MetadataObjectNavItems = () => {
|
||||
const { metadataObjects } = useFindManyMetadataObjects();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { icons } = useLazyLoadIcons();
|
||||
|
||||
return (
|
||||
<>
|
||||
{metadataObjects
|
||||
.filter(
|
||||
(metadataObject) =>
|
||||
metadataObject.isActive &&
|
||||
!metadataObject.namePlural.endsWith('V2'),
|
||||
)
|
||||
.map((metadataObject) => {
|
||||
return (
|
||||
<NavItem
|
||||
key={metadataObject.id}
|
||||
label={metadataObject.labelPlural}
|
||||
to={`/objects/${metadataObject.namePlural}`}
|
||||
Icon={metadataObject.icon ? icons[metadataObject.icon] : Icon123}
|
||||
onClick={() => {
|
||||
navigate(`/objects/${metadataObject.namePlural}`);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,42 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { Icon123 } from '@/ui/input/constants/icons';
|
||||
import { useLazyLoadIcons } from '@/ui/input/hooks/useLazyLoadIcons';
|
||||
import NavItem from '@/ui/navigation/navbar/components/NavItem';
|
||||
|
||||
import { useFindManyObjectMetadataItems } from '../hooks/useFindManyObjectMetadataItems';
|
||||
|
||||
export const ObjectMetadataNavItems = () => {
|
||||
const { objectMetadataItems } = useFindManyObjectMetadataItems();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { icons } = useLazyLoadIcons();
|
||||
|
||||
return (
|
||||
<>
|
||||
{objectMetadataItems
|
||||
.filter(
|
||||
(objectMetadataItem) =>
|
||||
objectMetadataItem.isActive &&
|
||||
!objectMetadataItem.namePlural.endsWith('V2'),
|
||||
)
|
||||
.map((objectMetadataItem) => {
|
||||
return (
|
||||
<NavItem
|
||||
key={objectMetadataItem.id}
|
||||
label={objectMetadataItem.labelPlural}
|
||||
to={`/objects/${objectMetadataItem.namePlural}`}
|
||||
Icon={
|
||||
objectMetadataItem.icon
|
||||
? icons[objectMetadataItem.icon]
|
||||
: Icon123
|
||||
}
|
||||
onClick={() => {
|
||||
navigate(`/objects/${objectMetadataItem.namePlural}`);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@ -5,7 +5,7 @@ import { availableTableColumnsScopedState } from '@/ui/object/record-table/state
|
||||
import { useView } from '@/views/hooks/useView';
|
||||
import { ViewType } from '@/views/types/ViewType';
|
||||
|
||||
import { useMetadataObjectInContext } from '../hooks/useMetadataObjectInContext';
|
||||
import { useObjectMetadataItemInContext } from '../hooks/useObjectMetadataItemInContext';
|
||||
|
||||
export const ObjectTableEffect = () => {
|
||||
const {
|
||||
@ -20,20 +20,20 @@ export const ObjectTableEffect = () => {
|
||||
columnDefinitions,
|
||||
filterDefinitions,
|
||||
sortDefinitions,
|
||||
foundMetadataObject,
|
||||
} = useMetadataObjectInContext();
|
||||
foundObjectMetadataItem,
|
||||
} = useObjectMetadataItemInContext();
|
||||
|
||||
const tableScopeId = foundMetadataObject?.namePlural ?? '';
|
||||
const tableScopeId = foundObjectMetadataItem?.namePlural ?? '';
|
||||
|
||||
const setAvailableTableColumns = useSetRecoilState(
|
||||
availableTableColumnsScopedState(tableScopeId),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!foundMetadataObject) {
|
||||
if (!foundObjectMetadataItem) {
|
||||
return;
|
||||
}
|
||||
setViewObjectId?.(foundMetadataObject.id);
|
||||
setViewObjectId?.(foundObjectMetadataItem.id);
|
||||
setViewType?.(ViewType.Table);
|
||||
|
||||
setAvailableSortDefinitions?.(sortDefinitions);
|
||||
@ -49,7 +49,7 @@ export const ObjectTableEffect = () => {
|
||||
setAvailableSortDefinitions,
|
||||
setAvailableFilterDefinitions,
|
||||
setAvailableFieldDefinitions,
|
||||
foundMetadataObject,
|
||||
foundObjectMetadataItem,
|
||||
sortDefinitions,
|
||||
filterDefinitions,
|
||||
]);
|
||||
|
||||
@ -23,8 +23,8 @@ import { InlineCellHotkeyScope } from '@/ui/object/record-inline-cell/types/Inli
|
||||
import { PageTitle } from '@/ui/utilities/page-title/PageTitle';
|
||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||
|
||||
import { useFindOneMetadataObject } from '../hooks/useFindOneMetadataObject';
|
||||
import { useFindOneObject } from '../hooks/useFindOneObject';
|
||||
import { useFindOneObjectMetadataItem } from '../hooks/useFindOneObjectMetadataItem';
|
||||
import { useUpdateOneObject } from '../hooks/useUpdateOneObject';
|
||||
import { formatMetadataFieldAsColumnDefinition } from '../utils/formatMetadataFieldAsColumnDefinition';
|
||||
|
||||
@ -36,7 +36,7 @@ export const RecordShowPage = () => {
|
||||
|
||||
const { icons } = useLazyLoadIcons();
|
||||
|
||||
const { foundMetadataObject } = useFindOneMetadataObject({
|
||||
const { foundObjectMetadataItem } = useFindOneObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
@ -115,7 +115,7 @@ export const RecordShowPage = () => {
|
||||
avatarType="squared"
|
||||
/>
|
||||
<PropertyBox extraPadding={true}>
|
||||
{foundMetadataObject?.fields
|
||||
{foundObjectMetadataItem?.fields
|
||||
.toSorted((a, b) =>
|
||||
DateTime.fromISO(a.createdAt)
|
||||
.diff(DateTime.fromISO(b.createdAt))
|
||||
@ -132,7 +132,7 @@ export const RecordShowPage = () => {
|
||||
formatMetadataFieldAsColumnDefinition({
|
||||
field: metadataField,
|
||||
position: index,
|
||||
metadataObject: foundMetadataObject,
|
||||
objectMetadataItem: foundObjectMetadataItem,
|
||||
icons,
|
||||
}),
|
||||
useUpdateEntityMutation: useUpdateOneObjectMutation,
|
||||
|
||||
@ -17,9 +17,9 @@ import { viewFieldsToColumnDefinitions } from '@/views/utils/viewFieldsToColumnD
|
||||
import { viewFiltersToFilters } from '@/views/utils/viewFiltersToFilters';
|
||||
import { viewSortsToSorts } from '@/views/utils/viewSortsToSorts';
|
||||
|
||||
import { useMetadataObjectInContext } from '../hooks/useMetadataObjectInContext';
|
||||
import { useObjectMetadataItemInContext } from '../hooks/useObjectMetadataItemInContext';
|
||||
import { useUpdateOneObject } from '../hooks/useUpdateOneObject';
|
||||
import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier';
|
||||
import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier';
|
||||
|
||||
import { ObjectTableEffect } from './ObjectTableEffect';
|
||||
import { ObjectRecordTableEffect } from './RecordTableEffect';
|
||||
@ -32,7 +32,7 @@ const StyledContainer = styled.div`
|
||||
`;
|
||||
|
||||
export type ObjectTableProps = Pick<
|
||||
MetadataObjectIdentifier,
|
||||
ObjectMetadataItemIdentifier,
|
||||
'objectNamePlural'
|
||||
>;
|
||||
|
||||
@ -40,9 +40,9 @@ export const ObjectTable = ({ objectNamePlural }: ObjectTableProps) => {
|
||||
const { updateOneObject } = useUpdateOneObject({
|
||||
objectNamePlural,
|
||||
});
|
||||
const { columnDefinitions, foundMetadataObject } =
|
||||
useMetadataObjectInContext();
|
||||
const tableScopeId = foundMetadataObject?.namePlural ?? '';
|
||||
const { columnDefinitions, foundObjectMetadataItem } =
|
||||
useObjectMetadataItemInContext();
|
||||
const tableScopeId = foundObjectMetadataItem?.namePlural ?? '';
|
||||
const viewScopeId = objectNamePlural ?? '';
|
||||
|
||||
const { persistViewFields } = useViewFields(viewScopeId);
|
||||
|
||||
@ -9,11 +9,11 @@ import { tableSortsScopedState } from '@/ui/object/record-table/states/tableSort
|
||||
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
||||
|
||||
import { useFindManyObjects } from '../hooks/useFindManyObjects';
|
||||
import { useMetadataObjectInContext } from '../hooks/useMetadataObjectInContext';
|
||||
import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier';
|
||||
import { useObjectMetadataItemInContext } from '../hooks/useObjectMetadataItemInContext';
|
||||
import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier';
|
||||
|
||||
export type ObjectRecordTableEffectProps = Pick<
|
||||
MetadataObjectIdentifier,
|
||||
ObjectMetadataItemIdentifier,
|
||||
'objectNamePlural'
|
||||
>;
|
||||
|
||||
@ -22,7 +22,7 @@ export const ObjectRecordTableEffect = ({
|
||||
objectNamePlural,
|
||||
}: ObjectRecordTableEffectProps) => {
|
||||
const setRecordTableData = useSetRecordTableData();
|
||||
const { foundMetadataObject } = useMetadataObjectInContext();
|
||||
const { foundObjectMetadataItem } = useObjectMetadataItemInContext();
|
||||
|
||||
const tableFilters = useRecoilScopedValue(
|
||||
tableFiltersScopedState,
|
||||
@ -38,11 +38,11 @@ export const ObjectRecordTableEffect = ({
|
||||
objectNamePlural: objectNamePlural,
|
||||
filter: turnFiltersIntoWhereClauseV2(
|
||||
tableFilters,
|
||||
foundMetadataObject?.fields ?? [],
|
||||
foundObjectMetadataItem?.fields ?? [],
|
||||
),
|
||||
orderBy: turnSortsIntoOrderByV2(
|
||||
tableSorts,
|
||||
foundMetadataObject?.fields ?? [],
|
||||
foundObjectMetadataItem?.fields ?? [],
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { ObjectTable } from '@/metadata/components/RecordTable';
|
||||
import { MetadataObjectIdentifier } from '@/metadata/types/MetadataObjectIdentifier';
|
||||
import { ObjectMetadataItemIdentifier } from '@/metadata/types/ObjectMetadataItemIdentifier';
|
||||
import { IconBuildingSkyscraper } from '@/ui/display/icon';
|
||||
import { PageAddButton } from '@/ui/layout/page/PageAddButton';
|
||||
import { PageBody } from '@/ui/layout/page/PageBody';
|
||||
@ -16,8 +16,8 @@ import { TableRecoilScopeContext } from '@/ui/object/record-table/states/recoil-
|
||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||
|
||||
import { useCreateOneObject } from '../hooks/useCreateOneObject';
|
||||
import { useFindOneMetadataObject } from '../hooks/useFindOneMetadataObject';
|
||||
import { MetadataObjectScope } from '../scopes/MetadataObjectScope';
|
||||
import { useFindOneObjectMetadataItem } from '../hooks/useFindOneObjectMetadataItem';
|
||||
import { ObjectMetadataItemScope } from '../scopes/ObjectMetadataItemScope';
|
||||
|
||||
const StyledTableContainer = styled.div`
|
||||
display: flex;
|
||||
@ -25,14 +25,14 @@ const StyledTableContainer = styled.div`
|
||||
`;
|
||||
|
||||
export type RecordTablePageProps = Pick<
|
||||
MetadataObjectIdentifier,
|
||||
ObjectMetadataItemIdentifier,
|
||||
'objectNamePlural'
|
||||
>;
|
||||
|
||||
export const RecordTablePage = () => {
|
||||
const objectNamePlural = useParams().objectNamePlural ?? '';
|
||||
|
||||
const { objectNotFoundInMetadata, loading } = useFindOneMetadataObject({
|
||||
const { objectNotFoundInMetadata, loading } = useFindOneObjectMetadataItem({
|
||||
objectNamePlural,
|
||||
});
|
||||
|
||||
@ -64,9 +64,11 @@ export const RecordTablePage = () => {
|
||||
CustomRecoilScopeContext={TableRecoilScopeContext}
|
||||
>
|
||||
<StyledTableContainer>
|
||||
<MetadataObjectScope metadataObjectNamePlural={objectNamePlural}>
|
||||
<ObjectMetadataItemScope
|
||||
objectMetadataItemNamePlural={objectNamePlural}
|
||||
>
|
||||
<ObjectTable objectNamePlural={objectNamePlural} />
|
||||
</MetadataObjectScope>
|
||||
</ObjectMetadataItemScope>
|
||||
</StyledTableContainer>
|
||||
<RecordTableActionBar />
|
||||
<RecordTableContextMenu />
|
||||
|
||||
Reference in New Issue
Block a user