New useNavigateApp (#9729)

Todo : 
- replace all instances of useNavigate(
- remove getSettingsPagePath
- add eslint rule to enfore usage of useNavigateApp instead of
useNavigate
This commit is contained in:
Félix Malfait
2025-01-18 13:58:12 +01:00
committed by GitHub
parent 8572471973
commit 152902d1be
115 changed files with 975 additions and 679 deletions

View File

@ -3,7 +3,7 @@ import { isLocationMatchingFavorite } from '../isLocationMatchingFavorite';
describe('isLocationMatchingFavorite', () => {
it('should return true if favorite link matches current path', () => {
const currentPath = '/app/objects/people';
const currentViewPath = '/app/objects/people?view=123';
const currentViewPath = '/app/objects/people?viewId=123';
const favorite = {
objectNameSingular: 'object',
link: '/app/objects/people',
@ -16,7 +16,7 @@ describe('isLocationMatchingFavorite', () => {
it('should return true if favorite link matches current view path', () => {
const currentPath = '/app/object/company/12';
const currentViewPath = '/app/object/company/12?view=123';
const currentViewPath = '/app/object/company/12?viewId=123';
const favorite = {
objectNameSingular: 'company',
link: '/app/object/company/12',
@ -29,7 +29,7 @@ describe('isLocationMatchingFavorite', () => {
it('should return false if favorite link does not match current path', () => {
const currentPath = '/app/objects/people';
const currentViewPath = '/app/objects/people?view=123';
const currentViewPath = '/app/objects/people?viewId=123';
const favorite = {
objectNameSingular: 'object',
link: '/app/objects/company',
@ -42,10 +42,10 @@ describe('isLocationMatchingFavorite', () => {
it('should return false if favorite link does not match current view path', () => {
const currentPath = '/app/objects/companies';
const currentViewPath = '/app/objects/companies?view=123';
const currentViewPath = '/app/objects/companies?viewId=123';
const favorite = {
objectNameSingular: 'view',
link: '/app/objects/companies/view=246',
link: '/app/objects/companies?viewId=246',
};
expect(

View File

@ -3,8 +3,10 @@ import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { ObjectRecordIdentifier } from '@/object-record/types/ObjectRecordIdentifier';
import { AppPath } from '@/types/AppPath';
import { View } from '@/views/types/View';
import { isDefined } from 'twenty-ui';
import { getAppPath } from '~/utils/navigation/getAppPath';
import { getObjectMetadataLabelPluralFromViewId } from './getObjectMetadataLabelPluralFromViewId';
export type ProcessedFavorite = Favorite & {
@ -40,7 +42,11 @@ export const sortFavorites = (
avatarType: 'icon',
avatarUrl: '',
labelIdentifier: view?.name,
link: `/objects/${labelPlural.toLocaleLowerCase()}${favorite.viewId ? `?view=${favorite.viewId}` : ''}`,
link: getAppPath(
AppPath.RecordIndexPage,
{ objectNamePlural: labelPlural.toLowerCase() },
favorite.viewId ? { viewId: favorite.viewId } : undefined,
),
workspaceMemberId: favorite.workspaceMemberId,
favoriteFolderId: favorite.favoriteFolderId,
objectNameSingular: 'view',