Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: settings object slug link #6228

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
import { useRecoilValue, useSetRecoilState } from 'recoil';

import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { getObjectSlug } from '@/object-metadata/utils/getObjectSlug';
import { useRecordActionBar } from '@/object-record/record-action-bar/hooks/useRecordActionBar';
import { useRecordBoard } from '@/object-record/record-board/hooks/useRecordBoard';
import { useRecordBoardSelection } from '@/object-record/record-board/hooks/useRecordBoardSelection';
Expand Down Expand Up @@ -59,10 +60,9 @@ export const RecordIndexBoardDataLoaderEffect = ({
}, [recordIndexFieldDefinitions, setFieldDefinitions]);

const navigate = useNavigate();

const navigateToSelectSettings = useCallback(() => {
navigate(`/settings/objects/${objectMetadataItem.namePlural}`);
}, [navigate, objectMetadataItem.namePlural]);
navigate(`/settings/objects/${getObjectSlug(objectMetadataItem)}`);
}, [navigate, objectMetadataItem]);

const { resetRecordSelection } = useRecordBoardSelection(recordBoardId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from '@emotion/styled';
import { useRecoilValue } from 'recoil';
import { IconSettings, useIcons } from 'twenty-ui';

import { getObjectSlug } from '@/object-metadata/utils/getObjectSlug';
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
import { RecordTableContext } from '@/object-record/record-table/contexts/RecordTableContext';
import { useRecordTableStates } from '@/object-record/record-table/hooks/internal/useRecordTableStates';
Expand Down Expand Up @@ -57,7 +58,7 @@ export const RecordTableHeaderPlusButtonContent = () => {
)}
<DropdownMenuItemsContainer>
<StyledMenuItemLink
to={`/settings/objects/${objectMetadataItem.namePlural}`}
to={`/settings/objects/${getObjectSlug(objectMetadataItem)}`}
>
<MenuItem LeftIcon={IconSettings} text="Customize fields" />
</StyledMenuItemLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styled from '@emotion/styled';
import { IconChevronDown, useIcons } from 'twenty-ui';

import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { getObjectSlug } from '@/object-metadata/utils/getObjectSlug';
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import { ObjectFieldRow } from '@/settings/data-model/graph-overview/components/SettingsDataModelOverviewField';
import { SettingsDataModelObjectTypeTag } from '@/settings/data-model/objects/SettingsDataModelObjectTypeTag';
Expand Down Expand Up @@ -111,7 +112,7 @@ export const SettingsDataModelOverviewObject = ({
<StyledNode>
<StyledHeader>
<StyledObjectName onMouseEnter={() => {}} onMouseLeave={() => {}}>
<StyledObjectLink to={'/settings/objects/' + data.namePlural}>
<StyledObjectLink to={`/settings/objects/${getObjectSlug(data)}`}>
{Icon && <Icon size={theme.icon.size.md} />}
{capitalize(data.namePlural)}
</StyledObjectLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { useRecoilValue, useSetRecoilState } from 'recoil';

import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
import { getObjectSlug } from '@/object-metadata/utils/getObjectSlug';
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
import { useViewStates } from '@/views/hooks/internal/useViewStates';
import { FieldMetadataType } from '~/generated-metadata/graphql';
Expand Down Expand Up @@ -34,16 +35,19 @@ export const useGetAvailableFieldsForKanban = () => {

if (isDefined(objectMetadataItem?.namePlural)) {
navigate(
`/settings/objects/${objectMetadataItem?.namePlural}/new-field/step-2`,
`/settings/objects/${getObjectSlug(
objectMetadataItem,
)}/new-field/step-2`,
);
} else {
navigate(`/settings/objects`);
}
}, [
navigate,
objectMetadataItem?.namePlural,
setNavigationMemorizedUrl,
location,
location.pathname,
location.search,
objectMetadataItem,
navigate,
]);

return {
Expand Down
Loading