mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-26 21:53:48 +03:00
Force order in navigation panel for notes and tasks (#6557)
As title. Tasks and Notes order sometimes change
This commit is contained in:
parent
018b8220dc
commit
1ed31d9d68
@ -18,6 +18,14 @@ import { View } from '@/views/types/View';
|
|||||||
import { getObjectMetadataItemViews } from '@/views/utils/getObjectMetadataItemViews';
|
import { getObjectMetadataItemViews } from '@/views/utils/getObjectMetadataItemViews';
|
||||||
import { Theme, useTheme } from '@emotion/react';
|
import { Theme, useTheme } from '@emotion/react';
|
||||||
|
|
||||||
|
const ORDERED_STANDARD_OBJECTS = [
|
||||||
|
'person',
|
||||||
|
'company',
|
||||||
|
'opportunity',
|
||||||
|
'task',
|
||||||
|
'note',
|
||||||
|
];
|
||||||
|
|
||||||
const navItemsAnimationVariants = (theme: Theme) => ({
|
const navItemsAnimationVariants = (theme: Theme) => ({
|
||||||
hidden: {
|
hidden: {
|
||||||
height: 0,
|
height: 0,
|
||||||
@ -67,14 +75,15 @@ export const ObjectMetadataNavItems = ({ isRemote }: { isRemote: boolean }) => {
|
|||||||
[
|
[
|
||||||
...filteredActiveObjectMetadataItems
|
...filteredActiveObjectMetadataItems
|
||||||
.filter((item) =>
|
.filter((item) =>
|
||||||
['person', 'company', 'opportunity'].includes(
|
ORDERED_STANDARD_OBJECTS.includes(item.nameSingular),
|
||||||
item.nameSingular,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.sort((objectMetadataItemA, objectMetadataItemB) => {
|
.sort((objectMetadataItemA, objectMetadataItemB) => {
|
||||||
const order = ['person', 'company', 'opportunity'];
|
const indexA = ORDERED_STANDARD_OBJECTS.indexOf(
|
||||||
const indexA = order.indexOf(objectMetadataItemA.nameSingular);
|
objectMetadataItemA.nameSingular,
|
||||||
const indexB = order.indexOf(objectMetadataItemB.nameSingular);
|
);
|
||||||
|
const indexB = ORDERED_STANDARD_OBJECTS.indexOf(
|
||||||
|
objectMetadataItemB.nameSingular,
|
||||||
|
);
|
||||||
if (indexA === -1 || indexB === -1) {
|
if (indexA === -1 || indexB === -1) {
|
||||||
return objectMetadataItemA.nameSingular.localeCompare(
|
return objectMetadataItemA.nameSingular.localeCompare(
|
||||||
objectMetadataItemB.nameSingular,
|
objectMetadataItemB.nameSingular,
|
||||||
@ -84,10 +93,7 @@ export const ObjectMetadataNavItems = ({ isRemote }: { isRemote: boolean }) => {
|
|||||||
}),
|
}),
|
||||||
...filteredActiveObjectMetadataItems
|
...filteredActiveObjectMetadataItems
|
||||||
.filter(
|
.filter(
|
||||||
(item) =>
|
(item) => !ORDERED_STANDARD_OBJECTS.includes(item.nameSingular),
|
||||||
!['person', 'company', 'opportunity'].includes(
|
|
||||||
item.nameSingular,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.sort((objectMetadataItemA, objectMetadataItemB) => {
|
.sort((objectMetadataItemA, objectMetadataItemB) => {
|
||||||
return new Date(objectMetadataItemA.createdAt) <
|
return new Date(objectMetadataItemA.createdAt) <
|
||||||
|
Loading…
Reference in New Issue
Block a user