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:
@ -388,7 +388,6 @@ export enum FeatureFlagKey {
|
|||||||
IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled',
|
IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled',
|
||||||
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
||||||
IsCopilotEnabled = 'IsCopilotEnabled',
|
IsCopilotEnabled = 'IsCopilotEnabled',
|
||||||
IsCrmMigrationEnabled = 'IsCrmMigrationEnabled',
|
|
||||||
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
||||||
IsFreeAccessEnabled = 'IsFreeAccessEnabled',
|
IsFreeAccessEnabled = 'IsFreeAccessEnabled',
|
||||||
IsFunctionSettingsEnabled = 'IsFunctionSettingsEnabled',
|
IsFunctionSettingsEnabled = 'IsFunctionSettingsEnabled',
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
import * as Apollo from '@apollo/client';
|
import * as Apollo from '@apollo/client';
|
||||||
|
import { gql } from '@apollo/client';
|
||||||
export type Maybe<T> = T | null;
|
export type Maybe<T> = T | null;
|
||||||
export type InputMaybe<T> = Maybe<T>;
|
export type InputMaybe<T> = Maybe<T>;
|
||||||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
||||||
@ -321,7 +321,6 @@ export enum FeatureFlagKey {
|
|||||||
IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled',
|
IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled',
|
||||||
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
||||||
IsCopilotEnabled = 'IsCopilotEnabled',
|
IsCopilotEnabled = 'IsCopilotEnabled',
|
||||||
IsCrmMigrationEnabled = 'IsCrmMigrationEnabled',
|
|
||||||
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
||||||
IsFreeAccessEnabled = 'IsFreeAccessEnabled',
|
IsFreeAccessEnabled = 'IsFreeAccessEnabled',
|
||||||
IsFunctionSettingsEnabled = 'IsFunctionSettingsEnabled',
|
IsFunctionSettingsEnabled = 'IsFunctionSettingsEnabled',
|
||||||
|
|||||||
@ -0,0 +1,72 @@
|
|||||||
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { MemoryRouter, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
useNavigate: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Wrapper = ({ children }: { children: React.ReactNode }) => (
|
||||||
|
<MemoryRouter>{children}</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
|
describe('useNavigateApp', () => {
|
||||||
|
const mockNavigate = jest.fn();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
(useNavigate as jest.Mock).mockReturnValue(mockNavigate);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate to the correct path without params', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateApp(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
result.current(AppPath.Index);
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith('/', undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate to the correct path with params', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateApp(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
result.current(AppPath.RecordShowPage, {
|
||||||
|
objectNameSingular: CoreObjectNameSingular.Company,
|
||||||
|
objectRecordId: '123',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith('/object/company/123', undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate with query params', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateApp(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
const queryParams = { viewId: '123', filter: 'test' };
|
||||||
|
result.current(AppPath.Index, undefined, queryParams);
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith(
|
||||||
|
'/?viewId=123&filter=test',
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate with options', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateApp(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
const options = { replace: true, state: { test: true } };
|
||||||
|
result.current(AppPath.Index, undefined, undefined, options);
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith('/', options);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { MemoryRouter, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
useNavigate: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Wrapper = ({ children }: { children: React.ReactNode }) => (
|
||||||
|
<MemoryRouter>{children}</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
|
describe('useNavigateSettings', () => {
|
||||||
|
const mockNavigate = jest.fn();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
(useNavigate as jest.Mock).mockReturnValue(mockNavigate);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate to the correct settings path without params', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateSettings(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
result.current(SettingsPath.Accounts);
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith('/settings/accounts', undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate to the correct settings path with params', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateSettings(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
result.current(SettingsPath.ObjectFieldEdit, {
|
||||||
|
objectNamePlural: 'companies',
|
||||||
|
fieldName: 'name',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith(
|
||||||
|
'/settings/objects/companies/name',
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate with query params', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateSettings(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
const queryParams = { viewId: '123', filter: 'test' };
|
||||||
|
result.current(SettingsPath.Accounts, undefined, queryParams);
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith(
|
||||||
|
'/settings/accounts?viewId=123&filter=test',
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate with options', () => {
|
||||||
|
const { result } = renderHook(() => useNavigateSettings(), {
|
||||||
|
wrapper: Wrapper,
|
||||||
|
});
|
||||||
|
|
||||||
|
const options = { replace: true, state: { test: true } };
|
||||||
|
result.current(SettingsPath.Accounts, undefined, undefined, options);
|
||||||
|
|
||||||
|
expect(mockNavigate).toHaveBeenCalledWith('/settings/accounts', options);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,20 +1,16 @@
|
|||||||
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
|
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
|
||||||
import { AppPath } from '@/types/AppPath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { useRecoilValue, useResetRecoilState } from 'recoil';
|
import { useRecoilValue, useResetRecoilState } from 'recoil';
|
||||||
|
import { isDefined } from 'twenty-ui';
|
||||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||||
|
|
||||||
import { isDefined } from '~/utils/isDefined';
|
|
||||||
|
|
||||||
export const useCleanRecoilState = () => {
|
export const useCleanRecoilState = () => {
|
||||||
const isMatchingLocation = useIsMatchingLocation();
|
const isMatchingLocation = useIsMatchingLocation();
|
||||||
const resetApiKeyToken = useResetRecoilState(apiKeyTokenState);
|
const resetApiKeyToken = useResetRecoilState(apiKeyTokenState);
|
||||||
const apiKeyToken = useRecoilValue(apiKeyTokenState);
|
const apiKeyToken = useRecoilValue(apiKeyTokenState);
|
||||||
const cleanRecoilState = () => {
|
const cleanRecoilState = () => {
|
||||||
if (
|
if (
|
||||||
!isMatchingLocation(
|
!isMatchingLocation(SettingsPath.DevelopersApiKeyDetail) &&
|
||||||
`${AppPath.Settings}/${AppPath.Developers}/${SettingsPath.DevelopersApiKeyDetail}`,
|
|
||||||
) &&
|
|
||||||
isDefined(apiKeyToken)
|
isDefined(apiKeyToken)
|
||||||
) {
|
) {
|
||||||
resetApiKeyToken();
|
resetApiKeyToken();
|
||||||
|
|||||||
20
packages/twenty-front/src/hooks/useNavigateApp.ts
Normal file
20
packages/twenty-front/src/hooks/useNavigateApp.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
|
||||||
|
export const useNavigateApp = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
return <T extends AppPath>(
|
||||||
|
to: T,
|
||||||
|
params?: Parameters<typeof getAppPath<T>>[1],
|
||||||
|
queryParams?: Record<string, any>,
|
||||||
|
options?: {
|
||||||
|
replace?: boolean;
|
||||||
|
state?: any;
|
||||||
|
},
|
||||||
|
) => {
|
||||||
|
const path = getAppPath(to, params, queryParams);
|
||||||
|
return navigate(path, options);
|
||||||
|
};
|
||||||
|
};
|
||||||
20
packages/twenty-front/src/hooks/useNavigateSettings.ts
Normal file
20
packages/twenty-front/src/hooks/useNavigateSettings.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
|
export const useNavigateSettings = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
return <T extends SettingsPath>(
|
||||||
|
to: T,
|
||||||
|
params?: Parameters<typeof getSettingsPath<T>>[1],
|
||||||
|
queryParams?: Record<string, any>,
|
||||||
|
options?: {
|
||||||
|
replace?: boolean;
|
||||||
|
state?: any;
|
||||||
|
},
|
||||||
|
) => {
|
||||||
|
const path = getSettingsPath(to, params, queryParams);
|
||||||
|
return navigate(path, options);
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,10 +1,11 @@
|
|||||||
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
||||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { useActiveWorkflowVersion } from '@/workflow/hooks/useActiveWorkflowVersion';
|
import { useActiveWorkflowVersion } from '@/workflow/hooks/useActiveWorkflowVersion';
|
||||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useSeeActiveVersionWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
export const useSeeActiveVersionWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||||
() => {
|
() => {
|
||||||
@ -16,7 +17,7 @@ export const useSeeActiveVersionWorkflowSingleRecordAction: ActionHookWithoutObj
|
|||||||
|
|
||||||
const workflowActiveVersion = useActiveWorkflowVersion(recordId);
|
const workflowActiveVersion = useActiveWorkflowVersion(recordId);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const shouldBeRegistered = isDefined(workflowActiveVersion) && isDraft;
|
const shouldBeRegistered = isDefined(workflowActiveVersion) && isDraft;
|
||||||
|
|
||||||
@ -25,9 +26,10 @@ export const useSeeActiveVersionWorkflowSingleRecordAction: ActionHookWithoutObj
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(
|
navigateApp(AppPath.RecordShowPage, {
|
||||||
`/object/${CoreObjectNameSingular.WorkflowVersion}/${workflowActiveVersion.id}`,
|
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
|
||||||
);
|
objectRecordId: workflowActiveVersion.id,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
||||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||||
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||||
import qs from 'qs';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useSeeRunsWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
export const useSeeRunsWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||||
() => {
|
() => {
|
||||||
@ -13,7 +13,7 @@ export const useSeeRunsWorkflowSingleRecordAction: ActionHookWithoutObjectMetada
|
|||||||
|
|
||||||
const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(recordId);
|
const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(recordId);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
||||||
|
|
||||||
@ -22,20 +22,21 @@ export const useSeeRunsWorkflowSingleRecordAction: ActionHookWithoutObjectMetada
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterQueryParams = {
|
navigateApp(
|
||||||
filter: {
|
AppPath.RecordIndexPage,
|
||||||
workflow: {
|
{
|
||||||
[ViewFilterOperand.Is]: {
|
objectNamePlural: CoreObjectNamePlural.WorkflowRun,
|
||||||
selectedRecordIds: [workflowWithCurrentVersion.id],
|
},
|
||||||
|
{
|
||||||
|
filter: {
|
||||||
|
workflow: {
|
||||||
|
[ViewFilterOperand.Is]: {
|
||||||
|
selectedRecordIds: [workflowWithCurrentVersion.id],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
);
|
||||||
const filterLinkHref = `/objects/${CoreObjectNamePlural.WorkflowRun}?${qs.stringify(
|
|
||||||
filterQueryParams,
|
|
||||||
)}`;
|
|
||||||
|
|
||||||
navigate(filterLinkHref);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
||||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||||
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||||
import qs from 'qs';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useSeeVersionsWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
export const useSeeVersionsWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||||
() => {
|
() => {
|
||||||
@ -13,29 +13,28 @@ export const useSeeVersionsWorkflowSingleRecordAction: ActionHookWithoutObjectMe
|
|||||||
|
|
||||||
const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(recordId);
|
const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(recordId);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
if (!shouldBeRegistered) {
|
if (!shouldBeRegistered) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filterQueryParams = {
|
navigateApp(
|
||||||
filter: {
|
AppPath.RecordIndexPage,
|
||||||
workflow: {
|
{
|
||||||
[ViewFilterOperand.Is]: {
|
objectNamePlural: CoreObjectNamePlural.WorkflowVersion,
|
||||||
selectedRecordIds: [workflowWithCurrentVersion.id],
|
},
|
||||||
|
{
|
||||||
|
filter: {
|
||||||
|
workflow: {
|
||||||
|
[ViewFilterOperand.Is]: {
|
||||||
|
selectedRecordIds: [workflowWithCurrentVersion.id],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
);
|
||||||
const filterLinkHref = `/objects/${CoreObjectNamePlural.WorkflowVersion}?${qs.stringify(
|
|
||||||
filterQueryParams,
|
|
||||||
)}`;
|
|
||||||
|
|
||||||
navigate(filterLinkHref);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -2,12 +2,12 @@ import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions
|
|||||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||||
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
||||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||||
import qs from 'qs';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useSeeRunsWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
export const useSeeRunsWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||||
() => {
|
() => {
|
||||||
@ -19,32 +19,33 @@ export const useSeeRunsWorkflowVersionSingleRecordAction: ActionHookWithoutObjec
|
|||||||
workflowVersion?.workflow.id,
|
workflowVersion?.workflow.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
if (!shouldBeRegistered) return;
|
if (!shouldBeRegistered) return;
|
||||||
|
|
||||||
const filterQueryParams = {
|
navigateApp(
|
||||||
filter: {
|
AppPath.RecordIndexPage,
|
||||||
workflow: {
|
{
|
||||||
[ViewFilterOperand.Is]: {
|
objectNamePlural: CoreObjectNamePlural.WorkflowRun,
|
||||||
selectedRecordIds: [workflowWithCurrentVersion.id],
|
},
|
||||||
|
{
|
||||||
|
filter: {
|
||||||
|
workflow: {
|
||||||
|
[ViewFilterOperand.Is]: {
|
||||||
|
selectedRecordIds: [workflowWithCurrentVersion.id],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
workflowVersion: {
|
||||||
workflowVersion: {
|
[ViewFilterOperand.Is]: {
|
||||||
[ViewFilterOperand.Is]: {
|
selectedRecordIds: [recordId],
|
||||||
selectedRecordIds: [recordId],
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
);
|
||||||
const filterLinkHref = `/objects/${CoreObjectNamePlural.WorkflowRun}?${qs.stringify(
|
|
||||||
filterQueryParams,
|
|
||||||
)}`;
|
|
||||||
|
|
||||||
navigate(filterLinkHref);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -2,12 +2,12 @@ import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions
|
|||||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||||
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
||||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||||
import qs from 'qs';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useSeeVersionsWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
export const useSeeVersionsWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||||
() => {
|
() => {
|
||||||
@ -19,29 +19,28 @@ export const useSeeVersionsWorkflowVersionSingleRecordAction: ActionHookWithoutO
|
|||||||
workflowVersion?.workflowId,
|
workflowVersion?.workflowId,
|
||||||
);
|
);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
const shouldBeRegistered = isDefined(workflowWithCurrentVersion);
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
if (!shouldBeRegistered) {
|
if (!shouldBeRegistered) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filterQueryParams = {
|
navigateApp(
|
||||||
filter: {
|
AppPath.RecordIndexPage,
|
||||||
workflow: {
|
{
|
||||||
[ViewFilterOperand.Is]: {
|
objectNamePlural: CoreObjectNamePlural.WorkflowVersion,
|
||||||
selectedRecordIds: [workflowWithCurrentVersion.id],
|
},
|
||||||
|
{
|
||||||
|
filter: {
|
||||||
|
workflow: {
|
||||||
|
[ViewFilterOperand.Is]: {
|
||||||
|
selectedRecordIds: [workflowWithCurrentVersion.id],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
);
|
||||||
const filterLinkHref = `/objects/${CoreObjectNamePlural.WorkflowVersion}?${qs.stringify(
|
|
||||||
filterQueryParams,
|
|
||||||
)}`;
|
|
||||||
|
|
||||||
navigate(filterLinkHref);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
|
||||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
import { buildShowPageURL } from '@/object-record/record-show/utils/buildShowPageURL';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { OverrideWorkflowDraftConfirmationModal } from '@/workflow/components/OverrideWorkflowDraftConfirmationModal';
|
import { OverrideWorkflowDraftConfirmationModal } from '@/workflow/components/OverrideWorkflowDraftConfirmationModal';
|
||||||
import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';
|
import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';
|
||||||
import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
|
import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
|
||||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||||
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
|
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useUseAsDraftWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
export const useUseAsDraftWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||||
() => {
|
() => {
|
||||||
@ -28,7 +28,7 @@ export const useUseAsDraftWorkflowVersionSingleRecordAction: ActionHookWithoutOb
|
|||||||
openOverrideWorkflowDraftConfirmationModalState,
|
openOverrideWorkflowDraftConfirmationModalState,
|
||||||
);
|
);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
|
|
||||||
const hasAlreadyDraftVersion =
|
const hasAlreadyDraftVersion =
|
||||||
workflow?.versions.some((version) => version.status === 'DRAFT') || false;
|
workflow?.versions.some((version) => version.status === 'DRAFT') || false;
|
||||||
@ -48,13 +48,10 @@ export const useUseAsDraftWorkflowVersionSingleRecordAction: ActionHookWithoutOb
|
|||||||
workflowId: workflowVersion.workflow.id,
|
workflowId: workflowVersion.workflow.id,
|
||||||
workflowVersionIdToCopy: workflowVersion.id,
|
workflowVersionIdToCopy: workflowVersion.id,
|
||||||
});
|
});
|
||||||
|
navigate(AppPath.RecordShowPage, {
|
||||||
navigate(
|
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||||
buildShowPageURL(
|
objectRecordId: workflowVersion.workflow.id,
|
||||||
CoreObjectNameSingular.Workflow,
|
});
|
||||||
workflowVersion.workflow.id,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,9 +11,6 @@ export const AppRouter = () => {
|
|||||||
const isFreeAccessEnabled = useIsFeatureEnabled(
|
const isFreeAccessEnabled = useIsFeatureEnabled(
|
||||||
FeatureFlagKey.IsFreeAccessEnabled,
|
FeatureFlagKey.IsFreeAccessEnabled,
|
||||||
);
|
);
|
||||||
const isCRMMigrationEnabled = useIsFeatureEnabled(
|
|
||||||
FeatureFlagKey.IsCrmMigrationEnabled,
|
|
||||||
);
|
|
||||||
const isServerlessFunctionSettingsEnabled = useIsFeatureEnabled(
|
const isServerlessFunctionSettingsEnabled = useIsFeatureEnabled(
|
||||||
FeatureFlagKey.IsFunctionSettingsEnabled,
|
FeatureFlagKey.IsFunctionSettingsEnabled,
|
||||||
);
|
);
|
||||||
@ -29,7 +26,6 @@ export const AppRouter = () => {
|
|||||||
<RouterProvider
|
<RouterProvider
|
||||||
router={useCreateAppRouter(
|
router={useCreateAppRouter(
|
||||||
isBillingPageEnabled,
|
isBillingPageEnabled,
|
||||||
isCRMMigrationEnabled,
|
|
||||||
isServerlessFunctionSettingsEnabled,
|
isServerlessFunctionSettingsEnabled,
|
||||||
isAdminPageEnabled,
|
isAdminPageEnabled,
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { lazy, Suspense } from 'react';
|
|||||||
import { Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
|
|
||||||
import { SettingsSkeletonLoader } from '@/settings/components/SettingsSkeletonLoader';
|
import { SettingsSkeletonLoader } from '@/settings/components/SettingsSkeletonLoader';
|
||||||
import { AppPath } from '@/types/AppPath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
|
|
||||||
const SettingsAccountsCalendars = lazy(() =>
|
const SettingsAccountsCalendars = lazy(() =>
|
||||||
@ -226,14 +225,6 @@ const SettingsObjectFieldEdit = lazy(() =>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
const SettingsCRMMigration = lazy(() =>
|
|
||||||
import('~/pages/settings/crm-migration/SettingsCRMMigration').then(
|
|
||||||
(module) => ({
|
|
||||||
default: module.SettingsCRMMigration,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
const SettingsSecurity = lazy(() =>
|
const SettingsSecurity = lazy(() =>
|
||||||
import('~/pages/settings/security/SettingsSecurity').then((module) => ({
|
import('~/pages/settings/security/SettingsSecurity').then((module) => ({
|
||||||
default: module.SettingsSecurity,
|
default: module.SettingsSecurity,
|
||||||
@ -264,14 +255,12 @@ const SettingsAdminContent = lazy(() =>
|
|||||||
|
|
||||||
type SettingsRoutesProps = {
|
type SettingsRoutesProps = {
|
||||||
isBillingEnabled?: boolean;
|
isBillingEnabled?: boolean;
|
||||||
isCRMMigrationEnabled?: boolean;
|
|
||||||
isServerlessFunctionSettingsEnabled?: boolean;
|
isServerlessFunctionSettingsEnabled?: boolean;
|
||||||
isAdminPageEnabled?: boolean;
|
isAdminPageEnabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SettingsRoutes = ({
|
export const SettingsRoutes = ({
|
||||||
isBillingEnabled,
|
isBillingEnabled,
|
||||||
isCRMMigrationEnabled,
|
|
||||||
isServerlessFunctionSettingsEnabled,
|
isServerlessFunctionSettingsEnabled,
|
||||||
isAdminPageEnabled,
|
isAdminPageEnabled,
|
||||||
}: SettingsRoutesProps) => (
|
}: SettingsRoutesProps) => (
|
||||||
@ -310,34 +299,22 @@ export const SettingsRoutes = ({
|
|||||||
/>
|
/>
|
||||||
<Route path={SettingsPath.NewObject} element={<SettingsNewObject />} />
|
<Route path={SettingsPath.NewObject} element={<SettingsNewObject />} />
|
||||||
<Route path={SettingsPath.Developers} element={<SettingsDevelopers />} />
|
<Route path={SettingsPath.Developers} element={<SettingsDevelopers />} />
|
||||||
{isCRMMigrationEnabled && (
|
|
||||||
<Route
|
|
||||||
path={SettingsPath.CRMMigration}
|
|
||||||
element={<SettingsCRMMigration />}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Route
|
<Route
|
||||||
path={AppPath.DevelopersCatchAll}
|
path={SettingsPath.DevelopersNewApiKey}
|
||||||
element={
|
element={<SettingsDevelopersApiKeysNew />}
|
||||||
<Routes>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={SettingsPath.DevelopersNewApiKey}
|
path={SettingsPath.DevelopersApiKeyDetail}
|
||||||
element={<SettingsDevelopersApiKeysNew />}
|
element={<SettingsDevelopersApiKeyDetail />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={SettingsPath.DevelopersApiKeyDetail}
|
path={SettingsPath.DevelopersNewWebhook}
|
||||||
element={<SettingsDevelopersApiKeyDetail />}
|
element={<SettingsDevelopersWebhooksNew />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={SettingsPath.DevelopersNewWebhook}
|
path={SettingsPath.DevelopersNewWebhookDetail}
|
||||||
element={<SettingsDevelopersWebhooksNew />}
|
element={<SettingsDevelopersWebhooksDetail />}
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path={SettingsPath.DevelopersNewWebhookDetail}
|
|
||||||
element={<SettingsDevelopersWebhooksDetail />}
|
|
||||||
/>
|
|
||||||
</Routes>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
{isServerlessFunctionSettingsEnabled && (
|
{isServerlessFunctionSettingsEnabled && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -28,7 +28,6 @@ import { SyncEmails } from '~/pages/onboarding/SyncEmails';
|
|||||||
|
|
||||||
export const useCreateAppRouter = (
|
export const useCreateAppRouter = (
|
||||||
isBillingEnabled?: boolean,
|
isBillingEnabled?: boolean,
|
||||||
isCRMMigrationEnabled?: boolean,
|
|
||||||
isServerlessFunctionSettingsEnabled?: boolean,
|
isServerlessFunctionSettingsEnabled?: boolean,
|
||||||
isAdminPageEnabled?: boolean,
|
isAdminPageEnabled?: boolean,
|
||||||
) =>
|
) =>
|
||||||
@ -63,7 +62,6 @@ export const useCreateAppRouter = (
|
|||||||
element={
|
element={
|
||||||
<SettingsRoutes
|
<SettingsRoutes
|
||||||
isBillingEnabled={isBillingEnabled}
|
isBillingEnabled={isBillingEnabled}
|
||||||
isCRMMigrationEnabled={isCRMMigrationEnabled}
|
|
||||||
isServerlessFunctionSettingsEnabled={
|
isServerlessFunctionSettingsEnabled={
|
||||||
isServerlessFunctionSettingsEnabled
|
isServerlessFunctionSettingsEnabled
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { useAuth } from '@/auth/hooks/useAuth';
|
import { useAuth } from '@/auth/hooks/useAuth';
|
||||||
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
||||||
@ -9,6 +9,7 @@ import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/Snac
|
|||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const VerifyEffect = () => {
|
export const VerifyEffect = () => {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@ -18,7 +19,7 @@ export const VerifyEffect = () => {
|
|||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
|
|
||||||
const isLogged = useIsLogged();
|
const isLogged = useIsLogged();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
|
|
||||||
const { verify } = useAuth();
|
const { verify } = useAuth();
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,8 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
|||||||
|
|
||||||
import { useReadCaptchaToken } from '@/captcha/hooks/useReadCaptchaToken';
|
import { useReadCaptchaToken } from '@/captcha/hooks/useReadCaptchaToken';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
import { EmailVerificationSent } from '../sign-in-up/components/EmailVerificationSent';
|
import { EmailVerificationSent } from '../sign-in-up/components/EmailVerificationSent';
|
||||||
|
|
||||||
export const VerifyEmailEffect = () => {
|
export const VerifyEmailEffect = () => {
|
||||||
@ -18,7 +19,7 @@ export const VerifyEmailEffect = () => {
|
|||||||
const email = searchParams.get('email');
|
const email = searchParams.get('email');
|
||||||
const emailVerificationToken = searchParams.get('emailVerificationToken');
|
const emailVerificationToken = searchParams.get('emailVerificationToken');
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
const { readCaptchaToken } = useReadCaptchaToken();
|
const { readCaptchaToken } = useReadCaptchaToken();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -44,7 +45,7 @@ export const VerifyEmailEffect = () => {
|
|||||||
variant: SnackBarVariant.Success,
|
variant: SnackBarVariant.Success,
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate(`${AppPath.Verify}?loginToken=${loginToken.token}`);
|
navigate(AppPath.Verify, undefined, { loginToken: loginToken.token });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
enqueueSnackBar('Email verification failed.', {
|
enqueueSnackBar('Email verification failed.', {
|
||||||
dedupeKey: 'email-verification-dedupe-key',
|
dedupeKey: 'email-verification-dedupe-key',
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||||
@ -10,11 +10,12 @@ import { isDefaultLayoutAuthModalVisibleState } from '@/ui/layout/states/isDefau
|
|||||||
|
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { useGetWorkspaceFromInviteHashQuery } from '~/generated/graphql';
|
import { useGetWorkspaceFromInviteHashQuery } from '~/generated/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
|
||||||
export const useWorkspaceFromInviteHash = () => {
|
export const useWorkspaceFromInviteHash = () => {
|
||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
const workspaceInviteHash = useParams().workspaceInviteHash;
|
const workspaceInviteHash = useParams().workspaceInviteHash;
|
||||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||||
const [initiallyLoggedIn] = useState(isDefined(currentWorkspace));
|
const [initiallyLoggedIn] = useState(isDefined(currentWorkspace));
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { AppPath } from '@/types/AppPath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
@ -8,6 +7,7 @@ import {
|
|||||||
SubscriptionInterval,
|
SubscriptionInterval,
|
||||||
} from '~/generated-metadata/graphql';
|
} from '~/generated-metadata/graphql';
|
||||||
import { useCheckoutSessionMutation } from '~/generated/graphql';
|
import { useCheckoutSessionMutation } from '~/generated/graphql';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const useHandleCheckoutSession = ({
|
export const useHandleCheckoutSession = ({
|
||||||
recurringInterval,
|
recurringInterval,
|
||||||
@ -29,7 +29,7 @@ export const useHandleCheckoutSession = ({
|
|||||||
const { data } = await checkoutSession({
|
const { data } = await checkoutSession({
|
||||||
variables: {
|
variables: {
|
||||||
recurringInterval,
|
recurringInterval,
|
||||||
successUrlPath: `${AppPath.Settings}/${SettingsPath.Billing}`,
|
successUrlPath: getSettingsPath(SettingsPath.Billing),
|
||||||
plan,
|
plan,
|
||||||
requirePaymentMethod,
|
requirePaymentMethod,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -6,12 +6,19 @@ import {
|
|||||||
IconUser,
|
IconUser,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
|
|
||||||
|
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import { Command, CommandType } from '../types/Command';
|
import { Command, CommandType } from '../types/Command';
|
||||||
|
|
||||||
export const COMMAND_MENU_NAVIGATE_COMMANDS: { [key: string]: Command } = {
|
export const COMMAND_MENU_NAVIGATE_COMMANDS: { [key: string]: Command } = {
|
||||||
people: {
|
people: {
|
||||||
id: 'go-to-people',
|
id: 'go-to-people',
|
||||||
to: '/objects/people',
|
to: getAppPath(AppPath.RecordIndexPage, {
|
||||||
|
objectNamePlural: CoreObjectNamePlural.Person,
|
||||||
|
}),
|
||||||
label: 'Go to People',
|
label: 'Go to People',
|
||||||
type: CommandType.Navigate,
|
type: CommandType.Navigate,
|
||||||
firstHotKey: 'G',
|
firstHotKey: 'G',
|
||||||
@ -21,7 +28,9 @@ export const COMMAND_MENU_NAVIGATE_COMMANDS: { [key: string]: Command } = {
|
|||||||
},
|
},
|
||||||
companies: {
|
companies: {
|
||||||
id: 'go-to-companies',
|
id: 'go-to-companies',
|
||||||
to: '/objects/companies',
|
to: getAppPath(AppPath.RecordIndexPage, {
|
||||||
|
objectNamePlural: CoreObjectNamePlural.Company,
|
||||||
|
}),
|
||||||
label: 'Go to Companies',
|
label: 'Go to Companies',
|
||||||
type: CommandType.Navigate,
|
type: CommandType.Navigate,
|
||||||
firstHotKey: 'G',
|
firstHotKey: 'G',
|
||||||
@ -31,7 +40,9 @@ export const COMMAND_MENU_NAVIGATE_COMMANDS: { [key: string]: Command } = {
|
|||||||
},
|
},
|
||||||
opportunities: {
|
opportunities: {
|
||||||
id: 'go-to-activities',
|
id: 'go-to-activities',
|
||||||
to: '/objects/opportunities',
|
to: getAppPath(AppPath.RecordIndexPage, {
|
||||||
|
objectNamePlural: CoreObjectNamePlural.Opportunity,
|
||||||
|
}),
|
||||||
label: 'Go to Opportunities',
|
label: 'Go to Opportunities',
|
||||||
type: CommandType.Navigate,
|
type: CommandType.Navigate,
|
||||||
firstHotKey: 'G',
|
firstHotKey: 'G',
|
||||||
@ -41,7 +52,7 @@ export const COMMAND_MENU_NAVIGATE_COMMANDS: { [key: string]: Command } = {
|
|||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
id: 'go-to-settings',
|
id: 'go-to-settings',
|
||||||
to: '/settings/profile',
|
to: getSettingsPath(SettingsPath.ProfilePage),
|
||||||
label: 'Go to Settings',
|
label: 'Go to Settings',
|
||||||
type: CommandType.Navigate,
|
type: CommandType.Navigate,
|
||||||
firstHotKey: 'G',
|
firstHotKey: 'G',
|
||||||
@ -51,7 +62,9 @@ export const COMMAND_MENU_NAVIGATE_COMMANDS: { [key: string]: Command } = {
|
|||||||
},
|
},
|
||||||
tasks: {
|
tasks: {
|
||||||
id: 'go-to-tasks',
|
id: 'go-to-tasks',
|
||||||
to: '/objects/tasks',
|
to: getAppPath(AppPath.RecordIndexPage, {
|
||||||
|
objectNamePlural: CoreObjectNamePlural.Task,
|
||||||
|
}),
|
||||||
label: 'Go to Tasks',
|
label: 'Go to Tasks',
|
||||||
type: CommandType.Navigate,
|
type: CommandType.Navigate,
|
||||||
firstHotKey: 'G',
|
firstHotKey: 'G',
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { isLocationMatchingFavorite } from '../isLocationMatchingFavorite';
|
|||||||
describe('isLocationMatchingFavorite', () => {
|
describe('isLocationMatchingFavorite', () => {
|
||||||
it('should return true if favorite link matches current path', () => {
|
it('should return true if favorite link matches current path', () => {
|
||||||
const currentPath = '/app/objects/people';
|
const currentPath = '/app/objects/people';
|
||||||
const currentViewPath = '/app/objects/people?view=123';
|
const currentViewPath = '/app/objects/people?viewId=123';
|
||||||
const favorite = {
|
const favorite = {
|
||||||
objectNameSingular: 'object',
|
objectNameSingular: 'object',
|
||||||
link: '/app/objects/people',
|
link: '/app/objects/people',
|
||||||
@ -16,7 +16,7 @@ describe('isLocationMatchingFavorite', () => {
|
|||||||
|
|
||||||
it('should return true if favorite link matches current view path', () => {
|
it('should return true if favorite link matches current view path', () => {
|
||||||
const currentPath = '/app/object/company/12';
|
const currentPath = '/app/object/company/12';
|
||||||
const currentViewPath = '/app/object/company/12?view=123';
|
const currentViewPath = '/app/object/company/12?viewId=123';
|
||||||
const favorite = {
|
const favorite = {
|
||||||
objectNameSingular: 'company',
|
objectNameSingular: 'company',
|
||||||
link: '/app/object/company/12',
|
link: '/app/object/company/12',
|
||||||
@ -29,7 +29,7 @@ describe('isLocationMatchingFavorite', () => {
|
|||||||
|
|
||||||
it('should return false if favorite link does not match current path', () => {
|
it('should return false if favorite link does not match current path', () => {
|
||||||
const currentPath = '/app/objects/people';
|
const currentPath = '/app/objects/people';
|
||||||
const currentViewPath = '/app/objects/people?view=123';
|
const currentViewPath = '/app/objects/people?viewId=123';
|
||||||
const favorite = {
|
const favorite = {
|
||||||
objectNameSingular: 'object',
|
objectNameSingular: 'object',
|
||||||
link: '/app/objects/company',
|
link: '/app/objects/company',
|
||||||
@ -42,10 +42,10 @@ describe('isLocationMatchingFavorite', () => {
|
|||||||
|
|
||||||
it('should return false if favorite link does not match current view path', () => {
|
it('should return false if favorite link does not match current view path', () => {
|
||||||
const currentPath = '/app/objects/companies';
|
const currentPath = '/app/objects/companies';
|
||||||
const currentViewPath = '/app/objects/companies?view=123';
|
const currentViewPath = '/app/objects/companies?viewId=123';
|
||||||
const favorite = {
|
const favorite = {
|
||||||
objectNameSingular: 'view',
|
objectNameSingular: 'view',
|
||||||
link: '/app/objects/companies/view=246',
|
link: '/app/objects/companies?viewId=246',
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@ -3,8 +3,10 @@ import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
|||||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||||
import { ObjectRecordIdentifier } from '@/object-record/types/ObjectRecordIdentifier';
|
import { ObjectRecordIdentifier } from '@/object-record/types/ObjectRecordIdentifier';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { View } from '@/views/types/View';
|
import { View } from '@/views/types/View';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
import { getObjectMetadataLabelPluralFromViewId } from './getObjectMetadataLabelPluralFromViewId';
|
import { getObjectMetadataLabelPluralFromViewId } from './getObjectMetadataLabelPluralFromViewId';
|
||||||
|
|
||||||
export type ProcessedFavorite = Favorite & {
|
export type ProcessedFavorite = Favorite & {
|
||||||
@ -40,7 +42,11 @@ export const sortFavorites = (
|
|||||||
avatarType: 'icon',
|
avatarType: 'icon',
|
||||||
avatarUrl: '',
|
avatarUrl: '',
|
||||||
labelIdentifier: view?.name,
|
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,
|
workspaceMemberId: favorite.workspaceMemberId,
|
||||||
favoriteFolderId: favorite.favoriteFolderId,
|
favoriteFolderId: favorite.favoriteFolderId,
|
||||||
objectNameSingular: 'view',
|
objectNameSingular: 'view',
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { InformationBanner } from '@/information-banner/components/InformationBanner';
|
import { InformationBanner } from '@/information-banner/components/InformationBanner';
|
||||||
import { AppPath } from '@/types/AppPath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
import { useBillingPortalSessionQuery } from '~/generated/graphql';
|
import { useBillingPortalSessionQuery } from '~/generated/graphql';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const InformationBannerBillingSubscriptionPaused = () => {
|
export const InformationBannerBillingSubscriptionPaused = () => {
|
||||||
const { data, loading } = useBillingPortalSessionQuery({
|
const { data, loading } = useBillingPortalSessionQuery({
|
||||||
variables: {
|
variables: {
|
||||||
returnUrlPath: `${AppPath.Settings}/${SettingsPath.Billing}`,
|
returnUrlPath: getSettingsPath(SettingsPath.Billing),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { InformationBanner } from '@/information-banner/components/InformationBanner';
|
import { InformationBanner } from '@/information-banner/components/InformationBanner';
|
||||||
import { AppPath } from '@/types/AppPath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
import { useBillingPortalSessionQuery } from '~/generated/graphql';
|
import { useBillingPortalSessionQuery } from '~/generated/graphql';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const InformationBannerFailPaymentInfo = () => {
|
export const InformationBannerFailPaymentInfo = () => {
|
||||||
const { data, loading } = useBillingPortalSessionQuery({
|
const { data, loading } = useBillingPortalSessionQuery({
|
||||||
variables: {
|
variables: {
|
||||||
returnUrlPath: `${AppPath.Settings}/${SettingsPath.Billing}`,
|
returnUrlPath: getSettingsPath(SettingsPath.Billing),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ describe('useDefaultHomePagePath', () => {
|
|||||||
setupMockPrefetchedData('viewId');
|
setupMockPrefetchedData('viewId');
|
||||||
const { result } = renderHooks(true);
|
const { result } = renderHooks(true);
|
||||||
expect(result.current.defaultHomePagePath).toEqual(
|
expect(result.current.defaultHomePagePath).toEqual(
|
||||||
'/objects/companies?view=viewId',
|
'/objects/companies?viewId=viewId',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import { View } from '@/views/types/View';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
|
||||||
export const useDefaultHomePagePath = () => {
|
export const useDefaultHomePagePath = () => {
|
||||||
const currentUser = useRecoilValue(currentUserState);
|
const currentUser = useRecoilValue(currentUserState);
|
||||||
@ -79,11 +80,13 @@ export const useDefaultHomePagePath = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const namePlural = defaultObjectPathInfo.objectMetadataItem?.namePlural;
|
const namePlural = defaultObjectPathInfo.objectMetadataItem?.namePlural;
|
||||||
const viewParam = defaultObjectPathInfo.view
|
const viewId = defaultObjectPathInfo.view?.id;
|
||||||
? `?view=${defaultObjectPathInfo.view.id}`
|
|
||||||
: '';
|
|
||||||
|
|
||||||
return `/objects/${namePlural}${viewParam}`;
|
return getAppPath(
|
||||||
|
AppPath.RecordIndexPage,
|
||||||
|
{ objectNamePlural: namePlural },
|
||||||
|
viewId ? { viewId } : undefined,
|
||||||
|
);
|
||||||
}, [currentUser, defaultObjectPathInfo]);
|
}, [currentUser, defaultObjectPathInfo]);
|
||||||
|
|
||||||
return { defaultHomePagePath };
|
return { defaultHomePagePath };
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||||
import { lastVisitedObjectMetadataItemIdStateSelector } from '@/navigation/states/selectors/lastVisitedObjectMetadataItemIdStateSelector';
|
import { lastVisitedObjectMetadataItemIdStateSelector } from '@/navigation/states/selectors/lastVisitedObjectMetadataItemIdStateSelector';
|
||||||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||||
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
|
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
|
||||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
|
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
|
||||||
export const useLastVisitedObjectMetadataItem = () => {
|
export const useLastVisitedObjectMetadataItem = () => {
|
||||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||||
@ -44,7 +46,9 @@ export const useLastVisitedObjectMetadataItem = () => {
|
|||||||
if (isDeactivateDefault) {
|
if (isDeactivateDefault) {
|
||||||
setLastVisitedObjectMetadataItemId(newFallbackObjectMetadataItem.id);
|
setLastVisitedObjectMetadataItemId(newFallbackObjectMetadataItem.id);
|
||||||
setNavigationMemorizedUrl(
|
setNavigationMemorizedUrl(
|
||||||
`/objects/${newFallbackObjectMetadataItem.namePlural}`,
|
getAppPath(AppPath.RecordIndexPage, {
|
||||||
|
objectNamePlural: newFallbackObjectMetadataItem.namePlural,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { useLastVisitedView } from '@/navigation/hooks/useLastVisitedView';
|
|||||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||||
import { usePrefetchedData } from '@/prefetch/hooks/usePrefetchedData';
|
import { usePrefetchedData } from '@/prefetch/hooks/usePrefetchedData';
|
||||||
import { PrefetchKey } from '@/prefetch/types/PrefetchKey';
|
import { PrefetchKey } from '@/prefetch/types/PrefetchKey';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
|
import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
|
||||||
import { NavigationDrawerItemsCollapsableContainer } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemsCollapsableContainer';
|
import { NavigationDrawerItemsCollapsableContainer } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemsCollapsableContainer';
|
||||||
import { NavigationDrawerSubItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem';
|
import { NavigationDrawerSubItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem';
|
||||||
@ -10,6 +11,7 @@ import { View } from '@/views/types/View';
|
|||||||
import { getObjectMetadataItemViews } from '@/views/utils/getObjectMetadataItemViews';
|
import { getObjectMetadataItemViews } from '@/views/utils/getObjectMetadataItemViews';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { AnimatedExpandableContainer, useIcons } from 'twenty-ui';
|
import { AnimatedExpandableContainer, useIcons } from 'twenty-ui';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
|
||||||
export type NavigationDrawerItemForObjectMetadataItemProps = {
|
export type NavigationDrawerItemForObjectMetadataItemProps = {
|
||||||
objectMetadataItem: ObjectMetadataItem;
|
objectMetadataItem: ObjectMetadataItem;
|
||||||
@ -35,13 +37,23 @@ export const NavigationDrawerItemForObjectMetadataItem = ({
|
|||||||
|
|
||||||
const viewId = lastVisitedViewId ?? objectMetadataViews[0]?.id;
|
const viewId = lastVisitedViewId ?? objectMetadataViews[0]?.id;
|
||||||
|
|
||||||
const navigationPath = `/objects/${objectMetadataItem.namePlural}${
|
const navigationPath = getAppPath(
|
||||||
viewId ? `?view=${viewId}` : ''
|
AppPath.RecordIndexPage,
|
||||||
}`;
|
{ objectNamePlural: objectMetadataItem.namePlural },
|
||||||
|
viewId ? { viewId } : undefined,
|
||||||
|
);
|
||||||
|
|
||||||
const isActive =
|
const isActive =
|
||||||
currentPath === `/objects/${objectMetadataItem.namePlural}` ||
|
currentPath ===
|
||||||
currentPath.includes(`object/${objectMetadataItem.nameSingular}/`);
|
getAppPath(AppPath.RecordIndexPage, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
}) ||
|
||||||
|
currentPath.includes(
|
||||||
|
getAppPath(AppPath.RecordShowPage, {
|
||||||
|
objectNameSingular: objectMetadataItem.nameSingular,
|
||||||
|
objectRecordId: '',
|
||||||
|
}).slice(0, -1),
|
||||||
|
);
|
||||||
|
|
||||||
const shouldSubItemsBeDisplayed = isActive && objectMetadataViews.length > 1;
|
const shouldSubItemsBeDisplayed = isActive && objectMetadataViews.length > 1;
|
||||||
|
|
||||||
@ -76,7 +88,11 @@ export const NavigationDrawerItemForObjectMetadataItem = ({
|
|||||||
{sortedObjectMetadataViews.map((view, index) => (
|
{sortedObjectMetadataViews.map((view, index) => (
|
||||||
<NavigationDrawerSubItem
|
<NavigationDrawerSubItem
|
||||||
label={view.name}
|
label={view.name}
|
||||||
to={`/objects/${objectMetadataItem.namePlural}?view=${view.id}`}
|
to={getAppPath(
|
||||||
|
AppPath.RecordIndexPage,
|
||||||
|
{ objectNamePlural: objectMetadataItem.namePlural },
|
||||||
|
{ viewId: view.id },
|
||||||
|
)}
|
||||||
active={viewId === view.id}
|
active={viewId === view.id}
|
||||||
subItemState={getNavigationSubItemLeftAdornment({
|
subItemState={getNavigationSubItemLeftAdornment({
|
||||||
index,
|
index,
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import { useObjectNamePluralFromSingular } from '@/object-metadata/hooks/useObje
|
|||||||
import { useObjectOptionsForBoard } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsForBoard';
|
import { useObjectOptionsForBoard } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsForBoard';
|
||||||
import { useObjectOptionsForTable } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsForTable';
|
import { useObjectOptionsForTable } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsForTable';
|
||||||
import { useOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useOptionsDropdown';
|
import { useOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useOptionsDropdown';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
@ -20,6 +19,7 @@ import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownM
|
|||||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||||
import { ViewFieldsVisibilityDropdownSection } from '@/views/components/ViewFieldsVisibilityDropdownSection';
|
import { ViewFieldsVisibilityDropdownSection } from '@/views/components/ViewFieldsVisibilityDropdownSection';
|
||||||
import { ViewType } from '@/views/types/ViewType';
|
import { ViewType } from '@/views/types/ViewType';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const ObjectOptionsDropdownHiddenFieldsContent = () => {
|
export const ObjectOptionsDropdownHiddenFieldsContent = () => {
|
||||||
const {
|
const {
|
||||||
@ -34,7 +34,7 @@ export const ObjectOptionsDropdownHiddenFieldsContent = () => {
|
|||||||
objectNameSingular: objectMetadataItem.nameSingular,
|
objectNameSingular: objectMetadataItem.nameSingular,
|
||||||
});
|
});
|
||||||
|
|
||||||
const settingsUrl = getSettingsPagePath(SettingsPath.ObjectDetail, {
|
const settingsUrl = getSettingsPath(SettingsPath.ObjectDetail, {
|
||||||
objectNamePlural,
|
objectNamePlural,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,6 @@ import { RecordGroupsVisibilityDropdownSection } from '@/object-record/record-gr
|
|||||||
import { useRecordGroupVisibility } from '@/object-record/record-group/hooks/useRecordGroupVisibility';
|
import { useRecordGroupVisibility } from '@/object-record/record-group/hooks/useRecordGroupVisibility';
|
||||||
import { recordGroupFieldMetadataComponentState } from '@/object-record/record-group/states/recordGroupFieldMetadataComponentState';
|
import { recordGroupFieldMetadataComponentState } from '@/object-record/record-group/states/recordGroupFieldMetadataComponentState';
|
||||||
import { hiddenRecordGroupIdsComponentSelector } from '@/object-record/record-group/states/selectors/hiddenRecordGroupIdsComponentSelector';
|
import { hiddenRecordGroupIdsComponentSelector } from '@/object-record/record-group/states/selectors/hiddenRecordGroupIdsComponentSelector';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
@ -22,6 +21,7 @@ import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMe
|
|||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const ObjectOptionsDropdownHiddenRecordGroupsContent = () => {
|
export const ObjectOptionsDropdownHiddenRecordGroupsContent = () => {
|
||||||
const {
|
const {
|
||||||
@ -51,13 +51,10 @@ export const ObjectOptionsDropdownHiddenRecordGroupsContent = () => {
|
|||||||
viewType,
|
viewType,
|
||||||
});
|
});
|
||||||
|
|
||||||
const viewGroupSettingsUrl = getSettingsPagePath(
|
const viewGroupSettingsUrl = getSettingsPath(SettingsPath.ObjectFieldEdit, {
|
||||||
SettingsPath.ObjectFieldEdit,
|
objectNamePlural,
|
||||||
{
|
fieldName: recordGroupFieldMetadata?.name ?? '',
|
||||||
objectNamePlural,
|
});
|
||||||
fieldName: recordGroupFieldMetadata?.name ?? '',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const setNavigationMemorizedUrl = useSetRecoilState(
|
const setNavigationMemorizedUrl = useSetRecoilState(
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import { useSearchRecordGroupField } from '@/object-record/object-options-dropdo
|
|||||||
import { recordGroupFieldMetadataComponentState } from '@/object-record/record-group/states/recordGroupFieldMetadataComponentState';
|
import { recordGroupFieldMetadataComponentState } from '@/object-record/record-group/states/recordGroupFieldMetadataComponentState';
|
||||||
import { hiddenRecordGroupIdsComponentSelector } from '@/object-record/record-group/states/selectors/hiddenRecordGroupIdsComponentSelector';
|
import { hiddenRecordGroupIdsComponentSelector } from '@/object-record/record-group/states/selectors/hiddenRecordGroupIdsComponentSelector';
|
||||||
import { useHandleRecordGroupField } from '@/object-record/record-index/hooks/useHandleRecordGroupField';
|
import { useHandleRecordGroupField } from '@/object-record/record-index/hooks/useHandleRecordGroupField';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
@ -29,6 +28,7 @@ import { useLocation } from 'react-router-dom';
|
|||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const ObjectOptionsDropdownRecordGroupFieldsContent = () => {
|
export const ObjectOptionsDropdownRecordGroupFieldsContent = () => {
|
||||||
const { getIcon } = useIcons();
|
const { getIcon } = useIcons();
|
||||||
@ -68,7 +68,7 @@ export const ObjectOptionsDropdownRecordGroupFieldsContent = () => {
|
|||||||
viewBarComponentId: recordIndexId,
|
viewBarComponentId: recordIndexId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const newSelectFieldSettingsUrl = getSettingsPagePath(
|
const newSelectFieldSettingsUrl = getSettingsPath(
|
||||||
SettingsPath.ObjectNewFieldConfigure,
|
SettingsPath.ObjectNewFieldConfigure,
|
||||||
{
|
{
|
||||||
objectNamePlural,
|
objectNamePlural,
|
||||||
|
|||||||
@ -4,13 +4,15 @@ import { useRecordGroupVisibility } from '@/object-record/record-group/hooks/use
|
|||||||
import { recordGroupFieldMetadataComponentState } from '@/object-record/record-group/states/recordGroupFieldMetadataComponentState';
|
import { recordGroupFieldMetadataComponentState } from '@/object-record/record-group/states/recordGroupFieldMetadataComponentState';
|
||||||
import { RecordGroupAction } from '@/object-record/record-group/types/RecordGroupActions';
|
import { RecordGroupAction } from '@/object-record/record-group/types/RecordGroupActions';
|
||||||
import { useRecordIndexContextOrThrow } from '@/object-record/record-index/contexts/RecordIndexContext';
|
import { useRecordIndexContextOrThrow } from '@/object-record/record-index/contexts/RecordIndexContext';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||||
import { ViewType } from '@/views/types/ViewType';
|
import { ViewType } from '@/views/types/ViewType';
|
||||||
import { useCallback, useContext, useMemo } from 'react';
|
import { useCallback, useContext, useMemo } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { IconEyeOff, IconSettings, isDefined } from 'twenty-ui';
|
import { IconEyeOff, IconSettings, isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
type UseRecordGroupActionsParams = {
|
type UseRecordGroupActionsParams = {
|
||||||
viewType: ViewType;
|
viewType: ViewType;
|
||||||
@ -19,7 +21,7 @@ type UseRecordGroupActionsParams = {
|
|||||||
export const useRecordGroupActions = ({
|
export const useRecordGroupActions = ({
|
||||||
viewType,
|
viewType,
|
||||||
}: UseRecordGroupActionsParams) => {
|
}: UseRecordGroupActionsParams) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const { objectNameSingular, recordIndexId } = useRecordIndexContextOrThrow();
|
const { objectNameSingular, recordIndexId } = useRecordIndexContextOrThrow();
|
||||||
@ -53,9 +55,10 @@ export const useRecordGroupActions = ({
|
|||||||
throw new Error('recordGroupFieldMetadata is not a non-empty string');
|
throw new Error('recordGroupFieldMetadata is not a non-empty string');
|
||||||
}
|
}
|
||||||
|
|
||||||
const settingsPath = `/settings/objects/${objectMetadataItem.namePlural}/${recordGroupFieldMetadata.name}`;
|
navigate(SettingsPath.ObjectFieldEdit, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
navigate(settingsPath);
|
fieldName: recordGroupFieldMetadata.name,
|
||||||
|
});
|
||||||
}, [
|
}, [
|
||||||
setNavigationMemorizedUrl,
|
setNavigationMemorizedUrl,
|
||||||
location.pathname,
|
location.pathname,
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||||
import { buildShowPageURL } from '@/object-record/record-show/utils/buildShowPageURL';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||||
import { currentViewIdComponentState } from '@/views/states/currentViewIdComponentState';
|
import { currentViewIdComponentState } from '@/views/states/currentViewIdComponentState';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
|
||||||
export const useHandleIndexIdentifierClick = ({
|
export const useHandleIndexIdentifierClick = ({
|
||||||
objectMetadataItem,
|
objectMetadataItem,
|
||||||
@ -16,12 +17,16 @@ export const useHandleIndexIdentifierClick = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const indexIdentifierUrl = (recordId: string) => {
|
const indexIdentifierUrl = (recordId: string) => {
|
||||||
const showPageURL = buildShowPageURL(
|
return getAppPath(
|
||||||
objectMetadataItem.nameSingular,
|
AppPath.RecordShowPage,
|
||||||
recordId,
|
{
|
||||||
currentViewId,
|
objectNameSingular: objectMetadataItem.nameSingular,
|
||||||
|
objectRecordId: recordId,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
viewId: currentViewId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
return showPageURL;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return { indexIdentifierUrl };
|
return { indexIdentifierUrl };
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
import { isNonEmptyString } from '@sniptt/guards';
|
import { isNonEmptyString } from '@sniptt/guards';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
import { useParams, useSearchParams } from 'react-router-dom';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||||
import { lastShowPageRecordIdState } from '@/object-record/record-field/states/lastShowPageRecordId';
|
import { lastShowPageRecordIdState } from '@/object-record/record-field/states/lastShowPageRecordId';
|
||||||
import { useRecordIdsFromFindManyCacheRootQuery } from '@/object-record/record-show/hooks/useRecordIdsFromFindManyCacheRootQuery';
|
import { useRecordIdsFromFindManyCacheRootQuery } from '@/object-record/record-show/hooks/useRecordIdsFromFindManyCacheRootQuery';
|
||||||
import { buildShowPageURL } from '@/object-record/record-show/utils/buildShowPageURL';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { buildIndexTablePageURL } from '@/object-record/record-table/utils/buildIndexTableURL';
|
|
||||||
import { useQueryVariablesFromActiveFieldsOfViewOrDefaultView } from '@/views/hooks/useQueryVariablesFromActiveFieldsOfViewOrDefaultView';
|
import { useQueryVariablesFromActiveFieldsOfViewOrDefaultView } from '@/views/hooks/useQueryVariablesFromActiveFieldsOfViewOrDefaultView';
|
||||||
import { capitalize } from 'twenty-shared';
|
import { capitalize } from 'twenty-shared';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useRecordShowPagePagination = (
|
export const useRecordShowPagePagination = (
|
||||||
propsObjectNameSingular: string,
|
propsObjectNameSingular: string,
|
||||||
@ -22,9 +22,9 @@ export const useRecordShowPagePagination = (
|
|||||||
objectRecordId: paramObjectRecordId,
|
objectRecordId: paramObjectRecordId,
|
||||||
} = useParams();
|
} = useParams();
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const viewIdQueryParam = searchParams.get('view');
|
const viewIdQueryParam = searchParams.get('viewId');
|
||||||
|
|
||||||
const setLastShowPageRecordId = useSetRecoilState(lastShowPageRecordIdState);
|
const setLastShowPageRecordId = useSetRecoilState(lastShowPageRecordIdState);
|
||||||
|
|
||||||
@ -130,22 +130,32 @@ export const useRecordShowPagePagination = (
|
|||||||
!isFirstRecord || (isFirstRecord && cacheIsAvailableForNavigation);
|
!isFirstRecord || (isFirstRecord && cacheIsAvailableForNavigation);
|
||||||
|
|
||||||
const navigateToPreviousRecord = () => {
|
const navigateToPreviousRecord = () => {
|
||||||
if (isFirstRecord) {
|
if (isFirstRecord || !recordBefore) {
|
||||||
if (cacheIsAvailableForNavigation) {
|
if (cacheIsAvailableForNavigation) {
|
||||||
const lastRecordIdFromCache =
|
const lastRecordIdFromCache =
|
||||||
recordIdsInCache[recordIdsInCache.length - 1];
|
recordIdsInCache[recordIdsInCache.length - 1];
|
||||||
|
|
||||||
navigate(
|
navigate(
|
||||||
buildShowPageURL(
|
AppPath.RecordShowPage,
|
||||||
|
{
|
||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
lastRecordIdFromCache,
|
objectRecordId: lastRecordIdFromCache,
|
||||||
viewIdQueryParam,
|
},
|
||||||
),
|
{
|
||||||
|
viewId: viewIdQueryParam,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
navigate(
|
navigate(
|
||||||
buildShowPageURL(objectNameSingular, recordBefore.id, viewIdQueryParam),
|
AppPath.RecordShowPage,
|
||||||
|
{
|
||||||
|
objectNameSingular,
|
||||||
|
objectRecordId: recordBefore.id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
viewId: viewIdQueryParam,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -154,34 +164,47 @@ export const useRecordShowPagePagination = (
|
|||||||
!isLastRecord || (isLastRecord && cacheIsAvailableForNavigation);
|
!isLastRecord || (isLastRecord && cacheIsAvailableForNavigation);
|
||||||
|
|
||||||
const navigateToNextRecord = () => {
|
const navigateToNextRecord = () => {
|
||||||
if (isLastRecord) {
|
if (isLastRecord || !recordAfter) {
|
||||||
if (cacheIsAvailableForNavigation) {
|
if (cacheIsAvailableForNavigation) {
|
||||||
const firstRecordIdFromCache = recordIdsInCache[0];
|
const firstRecordIdFromCache = recordIdsInCache[0];
|
||||||
|
|
||||||
navigate(
|
navigate(
|
||||||
buildShowPageURL(
|
AppPath.RecordShowPage,
|
||||||
|
{
|
||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
firstRecordIdFromCache,
|
objectRecordId: firstRecordIdFromCache,
|
||||||
viewIdQueryParam,
|
},
|
||||||
),
|
{
|
||||||
|
viewId: viewIdQueryParam,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
navigate(
|
navigate(
|
||||||
buildShowPageURL(objectNameSingular, recordAfter.id, viewIdQueryParam),
|
AppPath.RecordShowPage,
|
||||||
|
{
|
||||||
|
objectNameSingular,
|
||||||
|
objectRecordId: recordAfter.id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
viewId: viewIdQueryParam,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const navigateToIndexView = () => {
|
const navigateToIndexView = () => {
|
||||||
const indexTableURL = buildIndexTablePageURL(
|
|
||||||
objectMetadataItem.namePlural,
|
|
||||||
viewIdQueryParam,
|
|
||||||
);
|
|
||||||
|
|
||||||
setLastShowPageRecordId(objectRecordId);
|
setLastShowPageRecordId(objectRecordId);
|
||||||
|
|
||||||
navigate(indexTableURL);
|
navigate(
|
||||||
|
AppPath.RecordIndexPage,
|
||||||
|
{
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
viewId: viewIdQueryParam,
|
||||||
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const rankInView = recordIdsInCache.findIndex((id) => id === objectRecordId);
|
const rankInView = recordIdsInCache.findIndex((id) => id === objectRecordId);
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import qs from 'qs';
|
|
||||||
import { useCallback, useContext } from 'react';
|
import { useCallback, useContext } from 'react';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { IconForbid, IconPencil, IconPlus, LightIconButton } from 'twenty-ui';
|
import { IconForbid, IconPencil, IconPlus, LightIconButton } from 'twenty-ui';
|
||||||
@ -26,6 +25,7 @@ import { RecordForSelect } from '@/object-record/relation-picker/types/RecordFor
|
|||||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||||
import { usePrefetchedData } from '@/prefetch/hooks/usePrefetchedData';
|
import { usePrefetchedData } from '@/prefetch/hooks/usePrefetchedData';
|
||||||
import { PrefetchKey } from '@/prefetch/types/PrefetchKey';
|
import { PrefetchKey } from '@/prefetch/types/PrefetchKey';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||||
import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope';
|
import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope';
|
||||||
@ -33,6 +33,7 @@ import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
|||||||
import { View } from '@/views/types/View';
|
import { View } from '@/views/types/View';
|
||||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
type RecordDetailRelationSectionProps = {
|
type RecordDetailRelationSectionProps = {
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
};
|
};
|
||||||
@ -139,9 +140,13 @@ export const RecordDetailRelationSection = ({
|
|||||||
view: indexView?.id,
|
view: indexView?.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterLinkHref = `/objects/${
|
const filterLinkHref = getAppPath(
|
||||||
relationObjectMetadataItem.namePlural
|
AppPath.RecordIndexPage,
|
||||||
}?${qs.stringify(filterQueryParams)}`;
|
{
|
||||||
|
objectNamePlural: relationObjectMetadataItem.namePlural,
|
||||||
|
},
|
||||||
|
filterQueryParams,
|
||||||
|
);
|
||||||
|
|
||||||
const showContent = () => {
|
const showContent = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
export const buildShowPageURL = (
|
|
||||||
objectNameSingular: string,
|
|
||||||
recordId: string,
|
|
||||||
viewId?: string | null | undefined,
|
|
||||||
) => {
|
|
||||||
return `/object/${objectNameSingular}/${recordId}${
|
|
||||||
viewId ? `?view=${viewId}` : ''
|
|
||||||
}`;
|
|
||||||
};
|
|
||||||
@ -2,13 +2,14 @@
|
|||||||
import { IconSettings } from 'twenty-ui';
|
import { IconSettings } from 'twenty-ui';
|
||||||
|
|
||||||
import { RecordTableEmptyStateDisplay } from '@/object-record/record-table/empty-state/components/RecordTableEmptyStateDisplay';
|
import { RecordTableEmptyStateDisplay } from '@/object-record/record-table/empty-state/components/RecordTableEmptyStateDisplay';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
export const RecordTableEmptyStateRemote = () => {
|
export const RecordTableEmptyStateRemote = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
const handleButtonClick = () => {
|
const handleButtonClick = () => {
|
||||||
navigate('/settings/integrations');
|
navigate(SettingsPath.Integrations);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -8,11 +8,13 @@ import { useRecordTableContextOrThrow } from '@/object-record/record-table/conte
|
|||||||
import { useTableColumns } from '@/object-record/record-table/hooks/useTableColumns';
|
import { useTableColumns } from '@/object-record/record-table/hooks/useTableColumns';
|
||||||
import { hiddenTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/hiddenTableColumnsComponentSelector';
|
import { hiddenTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/hiddenTableColumnsComponentSelector';
|
||||||
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
|
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';
|
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';
|
||||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const RecordTableHeaderPlusButtonContent = () => {
|
export const RecordTableHeaderPlusButtonContent = () => {
|
||||||
const { objectMetadataItem } = useRecordTableContextOrThrow();
|
const { objectMetadataItem } = useRecordTableContextOrThrow();
|
||||||
@ -55,7 +57,9 @@ export const RecordTableHeaderPlusButtonContent = () => {
|
|||||||
<DropdownMenuItemsContainer scrollable={false}>
|
<DropdownMenuItemsContainer scrollable={false}>
|
||||||
<UndecoratedLink
|
<UndecoratedLink
|
||||||
fullWidth
|
fullWidth
|
||||||
to={`/settings/objects/${objectMetadataItem.namePlural}`}
|
to={getSettingsPath(SettingsPath.Objects, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
})}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setNavigationMemorizedUrl(location.pathname + location.search);
|
setNavigationMemorizedUrl(location.pathname + location.search);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
export const buildIndexTablePageURL = (
|
|
||||||
objectNamePlural: string,
|
|
||||||
viewId?: string | null | undefined,
|
|
||||||
) => {
|
|
||||||
return `/objects/${objectNamePlural}${viewId ? `?view=${viewId}` : ''}`;
|
|
||||||
};
|
|
||||||
@ -1,16 +1,15 @@
|
|||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { IconComponent, IconGoogle, IconMicrosoft } from 'twenty-ui';
|
import { IconComponent, IconGoogle, IconMicrosoft } from 'twenty-ui';
|
||||||
|
|
||||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||||
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
|
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
|
|
||||||
import { SettingsAccountsConnectedAccountsRowRightContainer } from '@/settings/accounts/components/SettingsAccountsConnectedAccountsRowRightContainer';
|
|
||||||
import { SettingsListCard } from '../../components/SettingsListCard';
|
|
||||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||||
|
import { SettingsAccountsConnectedAccountsRowRightContainer } from '@/settings/accounts/components/SettingsAccountsConnectedAccountsRowRightContainer';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
import { SettingsListCard } from '../../components/SettingsListCard';
|
||||||
|
|
||||||
const ProviderIcons: { [k: string]: IconComponent } = {
|
const ProviderIcons: { [k: string]: IconComponent } = {
|
||||||
google: IconGoogle,
|
google: IconGoogle,
|
||||||
@ -24,7 +23,7 @@ export const SettingsAccountsConnectedAccountsListCard = ({
|
|||||||
accounts: ConnectedAccount[];
|
accounts: ConnectedAccount[];
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||||
|
|
||||||
if (!accounts.length) {
|
if (!accounts.length) {
|
||||||
@ -47,9 +46,7 @@ export const SettingsAccountsConnectedAccountsListCard = ({
|
|||||||
)}
|
)}
|
||||||
hasFooter={atLeastOneProviderAvailable}
|
hasFooter={atLeastOneProviderAvailable}
|
||||||
footerButtonLabel="Add account"
|
footerButtonLabel="Add account"
|
||||||
onFooterButtonClick={() =>
|
onFooterButtonClick={() => navigate(SettingsPath.NewAccount)}
|
||||||
navigate(getSettingsPagePath(SettingsPath.NewAccount))
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import {
|
import {
|
||||||
IconCalendarEvent,
|
IconCalendarEvent,
|
||||||
IconDotsVertical,
|
IconDotsVertical,
|
||||||
@ -13,9 +12,11 @@ import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
|||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
import { useDestroyOneRecord } from '@/object-record/hooks/useDestroyOneRecord';
|
import { useDestroyOneRecord } from '@/object-record/hooks/useDestroyOneRecord';
|
||||||
import { useTriggerApisOAuth } from '@/settings/accounts/hooks/useTriggerApiOAuth';
|
import { useTriggerApisOAuth } from '@/settings/accounts/hooks/useTriggerApiOAuth';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
type SettingsAccountsRowDropdownMenuProps = {
|
type SettingsAccountsRowDropdownMenuProps = {
|
||||||
account: ConnectedAccount;
|
account: ConnectedAccount;
|
||||||
@ -26,7 +27,7 @@ export const SettingsAccountsRowDropdownMenu = ({
|
|||||||
}: SettingsAccountsRowDropdownMenuProps) => {
|
}: SettingsAccountsRowDropdownMenuProps) => {
|
||||||
const dropdownId = `settings-account-row-${account.id}`;
|
const dropdownId = `settings-account-row-${account.id}`;
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const { closeDropdown } = useDropdown(dropdownId);
|
const { closeDropdown } = useDropdown(dropdownId);
|
||||||
|
|
||||||
const { destroyOneRecord } = useDestroyOneRecord({
|
const { destroyOneRecord } = useDestroyOneRecord({
|
||||||
@ -49,7 +50,7 @@ export const SettingsAccountsRowDropdownMenu = ({
|
|||||||
LeftIcon={IconMail}
|
LeftIcon={IconMail}
|
||||||
text="Emails settings"
|
text="Emails settings"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate(`/settings/accounts/emails`);
|
navigate(SettingsPath.AccountsEmails);
|
||||||
closeDropdown();
|
closeDropdown();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -57,7 +58,7 @@ export const SettingsAccountsRowDropdownMenu = ({
|
|||||||
LeftIcon={IconCalendarEvent}
|
LeftIcon={IconCalendarEvent}
|
||||||
text="Calendar settings"
|
text="Calendar settings"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate(`/settings/accounts/calendars`);
|
navigate(SettingsPath.AccountsCalendars);
|
||||||
closeDropdown();
|
closeDropdown();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import {
|
|||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
|
|
||||||
import { SettingsCard } from '@/settings/components/SettingsCard';
|
import { SettingsCard } from '@/settings/components/SettingsCard';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const StyledCardsContainer = styled.div`
|
const StyledCardsContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -32,7 +32,7 @@ export const SettingsAccountsSettingsSection = () => {
|
|||||||
description="Configure your emails and calendar settings."
|
description="Configure your emails and calendar settings."
|
||||||
/>
|
/>
|
||||||
<StyledCardsContainer>
|
<StyledCardsContainer>
|
||||||
<UndecoratedLink to={getSettingsPagePath(SettingsPath.AccountsEmails)}>
|
<UndecoratedLink to={getSettingsPath(SettingsPath.AccountsEmails)}>
|
||||||
<SettingsCard
|
<SettingsCard
|
||||||
Icon={
|
Icon={
|
||||||
<IconMailCog
|
<IconMailCog
|
||||||
@ -44,9 +44,7 @@ export const SettingsAccountsSettingsSection = () => {
|
|||||||
description="Set email visibility, manage your blocklist and more."
|
description="Set email visibility, manage your blocklist and more."
|
||||||
/>
|
/>
|
||||||
</UndecoratedLink>
|
</UndecoratedLink>
|
||||||
<UndecoratedLink
|
<UndecoratedLink to={getSettingsPath(SettingsPath.AccountsCalendars)}>
|
||||||
to={getSettingsPagePath(SettingsPath.AccountsCalendars)}
|
|
||||||
>
|
|
||||||
<SettingsCard
|
<SettingsCard
|
||||||
Icon={
|
Icon={
|
||||||
<IconCalendarEvent
|
<IconCalendarEvent
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { useMatch, useResolvedPath } from 'react-router-dom';
|
import { useMatch, useResolvedPath } from 'react-router-dom';
|
||||||
|
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import {
|
import {
|
||||||
NavigationDrawerItem,
|
NavigationDrawerItem,
|
||||||
NavigationDrawerItemProps,
|
NavigationDrawerItemProps,
|
||||||
} from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
|
} from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
|
||||||
import { NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerSubItemState';
|
import { NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerSubItemState';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type SettingsNavigationDrawerItemProps = Pick<
|
type SettingsNavigationDrawerItemProps = Pick<
|
||||||
NavigationDrawerItemProps,
|
NavigationDrawerItemProps,
|
||||||
@ -26,7 +26,7 @@ export const SettingsNavigationDrawerItem = ({
|
|||||||
soon,
|
soon,
|
||||||
subItemState,
|
subItemState,
|
||||||
}: SettingsNavigationDrawerItemProps) => {
|
}: SettingsNavigationDrawerItemProps) => {
|
||||||
const href = getSettingsPagePath(path);
|
const href = getSettingsPath(path);
|
||||||
const pathName = useResolvedPath(href).pathname;
|
const pathName = useResolvedPath(href).pathname;
|
||||||
|
|
||||||
const isActive = !!useMatch({
|
const isActive = !!useMatch({
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import { currentUserState } from '@/auth/states/currentUserState';
|
|||||||
import { billingState } from '@/client-config/states/billingState';
|
import { billingState } from '@/client-config/states/billingState';
|
||||||
import { AdvancedSettingsWrapper } from '@/settings/components/AdvancedSettingsWrapper';
|
import { AdvancedSettingsWrapper } from '@/settings/components/AdvancedSettingsWrapper';
|
||||||
import { SettingsNavigationDrawerItem } from '@/settings/components/SettingsNavigationDrawerItem';
|
import { SettingsNavigationDrawerItem } from '@/settings/components/SettingsNavigationDrawerItem';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import {
|
import {
|
||||||
NavigationDrawerItem,
|
NavigationDrawerItem,
|
||||||
@ -37,6 +36,7 @@ import { getNavigationSubItemLeftAdornment } from '@/ui/navigation/navigation-dr
|
|||||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||||
import { matchPath, resolvePath, useLocation } from 'react-router-dom';
|
import { matchPath, resolvePath, useLocation } from 'react-router-dom';
|
||||||
import { FeatureFlagKey } from '~/generated/graphql';
|
import { FeatureFlagKey } from '~/generated/graphql';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type SettingsNavigationItem = {
|
type SettingsNavigationItem = {
|
||||||
label: string;
|
label: string;
|
||||||
@ -56,9 +56,6 @@ export const SettingsNavigationDrawerItems = () => {
|
|||||||
const isFreeAccessEnabled = useIsFeatureEnabled(
|
const isFreeAccessEnabled = useIsFeatureEnabled(
|
||||||
FeatureFlagKey.IsFreeAccessEnabled,
|
FeatureFlagKey.IsFreeAccessEnabled,
|
||||||
);
|
);
|
||||||
const isCRMMigrationEnabled = useIsFeatureEnabled(
|
|
||||||
FeatureFlagKey.IsCrmMigrationEnabled,
|
|
||||||
);
|
|
||||||
const isBillingPageEnabled =
|
const isBillingPageEnabled =
|
||||||
billing?.isBillingEnabled && !isFreeAccessEnabled;
|
billing?.isBillingEnabled && !isFreeAccessEnabled;
|
||||||
|
|
||||||
@ -83,7 +80,7 @@ export const SettingsNavigationDrawerItems = () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const selectedIndex = accountSubSettings.findIndex((accountSubSetting) => {
|
const selectedIndex = accountSubSettings.findIndex((accountSubSetting) => {
|
||||||
const href = getSettingsPagePath(accountSubSetting.path);
|
const href = getSettingsPath(accountSubSetting.path);
|
||||||
const pathName = resolvePath(href).pathname;
|
const pathName = resolvePath(href).pathname;
|
||||||
|
|
||||||
return matchPath(
|
return matchPath(
|
||||||
@ -161,13 +158,6 @@ export const SettingsNavigationDrawerItems = () => {
|
|||||||
path={SettingsPath.Integrations}
|
path={SettingsPath.Integrations}
|
||||||
Icon={IconApps}
|
Icon={IconApps}
|
||||||
/>
|
/>
|
||||||
{isCRMMigrationEnabled && (
|
|
||||||
<SettingsNavigationDrawerItem
|
|
||||||
label="CRM Migration"
|
|
||||||
path={SettingsPath.CRMMigration}
|
|
||||||
Icon={IconCode}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<AdvancedSettingsWrapper navigationDrawerItem={true}>
|
<AdvancedSettingsWrapper navigationDrawerItem={true}>
|
||||||
<SettingsNavigationDrawerItem
|
<SettingsNavigationDrawerItem
|
||||||
label="Security"
|
label="Security"
|
||||||
|
|||||||
@ -1,17 +1,14 @@
|
|||||||
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||||
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import {
|
import { useLocation, useParams, useSearchParams } from 'react-router-dom';
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
useParams,
|
|
||||||
useSearchParams,
|
|
||||||
} from 'react-router-dom';
|
|
||||||
import { Button, IconChevronDown, isDefined, MenuItem } from 'twenty-ui';
|
import { Button, IconChevronDown, isDefined, MenuItem } from 'twenty-ui';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
const StyledContainer = styled.div`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -66,7 +63,7 @@ const StyledButton = styled(Button)`
|
|||||||
export const SettingsDataModelNewFieldBreadcrumbDropDown = () => {
|
export const SettingsDataModelNewFieldBreadcrumbDropDown = () => {
|
||||||
const dropdownId = `settings-object-new-field-breadcrumb-dropdown`;
|
const dropdownId = `settings-object-new-field-breadcrumb-dropdown`;
|
||||||
const { closeDropdown } = useDropdown(dropdownId);
|
const { closeDropdown } = useDropdown(dropdownId);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { objectNamePlural = '' } = useParams();
|
const { objectNamePlural = '' } = useParams();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@ -78,11 +75,15 @@ export const SettingsDataModelNewFieldBreadcrumbDropDown = () => {
|
|||||||
const handleClick = (step: 'select' | 'configure') => {
|
const handleClick = (step: 'select' | 'configure') => {
|
||||||
if (step === 'configure' && isDefined(fieldType)) {
|
if (step === 'configure' && isDefined(fieldType)) {
|
||||||
navigate(
|
navigate(
|
||||||
`/settings/objects/${objectNamePlural}/new-field/configure?fieldType=${fieldType}`,
|
SettingsPath.ObjectNewFieldConfigure,
|
||||||
|
{ objectNamePlural },
|
||||||
|
{ fieldType },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
navigate(
|
navigate(
|
||||||
`/settings/objects/${objectNamePlural}/new-field/select${fieldType ? `?fieldType=${fieldType}` : ''}`,
|
SettingsPath.ObjectNewFieldSelect,
|
||||||
|
{ objectNamePlural },
|
||||||
|
fieldType ? { fieldType } : undefined,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
closeDropdown();
|
closeDropdown();
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { useBooleanSettingsFormInitialValues } from '@/settings/data-model/field
|
|||||||
import { useCurrencySettingsFormInitialValues } from '@/settings/data-model/fields/forms/currency/hooks/useCurrencySettingsFormInitialValues';
|
import { useCurrencySettingsFormInitialValues } from '@/settings/data-model/fields/forms/currency/hooks/useCurrencySettingsFormInitialValues';
|
||||||
import { useSelectSettingsFormInitialValues } from '@/settings/data-model/fields/forms/select/hooks/useSelectSettingsFormInitialValues';
|
import { useSelectSettingsFormInitialValues } from '@/settings/data-model/fields/forms/select/hooks/useSelectSettingsFormInitialValues';
|
||||||
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { TextInput } from '@/ui/input/components/TextInput';
|
import { TextInput } from '@/ui/input/components/TextInput';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
@ -17,6 +18,7 @@ import { Controller, useFormContext } from 'react-hook-form';
|
|||||||
import { H2Title, IconSearch, UndecoratedLink } from 'twenty-ui';
|
import { H2Title, IconSearch, UndecoratedLink } from 'twenty-ui';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
import { SettingsDataModelFieldTypeFormValues } from '~/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldSelect';
|
import { SettingsDataModelFieldTypeFormValues } from '~/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldSelect';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type SettingsObjectNewFieldSelectorProps = {
|
type SettingsObjectNewFieldSelectorProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -128,7 +130,15 @@ export const SettingsObjectNewFieldSelector = ({
|
|||||||
.map(([key, config]) => (
|
.map(([key, config]) => (
|
||||||
<StyledCardContainer key={key}>
|
<StyledCardContainer key={key}>
|
||||||
<UndecoratedLink
|
<UndecoratedLink
|
||||||
to={`/settings/objects/${objectNamePlural}/new-field/configure?fieldType=${key}`}
|
to={getSettingsPath(
|
||||||
|
SettingsPath.ObjectNewFieldConfigure,
|
||||||
|
{
|
||||||
|
objectNamePlural,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldType: key,
|
||||||
|
},
|
||||||
|
)}
|
||||||
fullWidth
|
fullWidth
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setValue('type', key as SettingsFieldType);
|
setValue('type', key as SettingsFieldType);
|
||||||
|
|||||||
@ -13,8 +13,10 @@ import { capitalize } from 'twenty-shared';
|
|||||||
import { FieldMetadataType } from '~/generated/graphql';
|
import { FieldMetadataType } from '~/generated/graphql';
|
||||||
|
|
||||||
import { ObjectFieldRowWithoutRelation } from '@/settings/data-model/graph-overview/components/SettingsDataModelOverviewFieldWithoutRelation';
|
import { ObjectFieldRowWithoutRelation } from '@/settings/data-model/graph-overview/components/SettingsDataModelOverviewFieldWithoutRelation';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import '@xyflow/react/dist/style.css';
|
import '@xyflow/react/dist/style.css';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type SettingsDataModelOverviewObjectNode = Node<ObjectMetadataItem, 'object'>;
|
type SettingsDataModelOverviewObjectNode = Node<ObjectMetadataItem, 'object'>;
|
||||||
type SettingsDataModelOverviewObjectProps =
|
type SettingsDataModelOverviewObjectProps =
|
||||||
@ -122,7 +124,9 @@ export const SettingsDataModelOverviewObject = ({
|
|||||||
<StyledHeader>
|
<StyledHeader>
|
||||||
<StyledObjectName onMouseEnter={() => {}} onMouseLeave={() => {}}>
|
<StyledObjectName onMouseEnter={() => {}} onMouseLeave={() => {}}>
|
||||||
<StyledObjectLink
|
<StyledObjectLink
|
||||||
to={`/settings/objects/${objectMetadataItem.namePlural}`}
|
to={getSettingsPath(SettingsPath.Objects, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
{Icon && <Icon size={theme.icon.size.md} />}
|
{Icon && <Icon size={theme.icon.size.md} />}
|
||||||
{capitalize(objectMetadataItem.namePlural)}
|
{capitalize(objectMetadataItem.namePlural)}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import { SettingsObjectFieldActiveActionDropdown } from '@/settings/data-model/o
|
|||||||
import { SettingsObjectFieldInactiveActionDropdown } from '@/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown';
|
import { SettingsObjectFieldInactiveActionDropdown } from '@/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown';
|
||||||
import { settingsObjectFieldsFamilyState } from '@/settings/data-model/object-details/states/settingsObjectFieldsFamilyState';
|
import { settingsObjectFieldsFamilyState } from '@/settings/data-model/object-details/states/settingsObjectFieldsFamilyState';
|
||||||
import { isFieldTypeSupportedInSettings } from '@/settings/data-model/utils/isFieldTypeSupportedInSettings';
|
import { isFieldTypeSupportedInSettings } from '@/settings/data-model/utils/isFieldTypeSupportedInSettings';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { TableCell } from '@/ui/layout/table/components/TableCell';
|
import { TableCell } from '@/ui/layout/table/components/TableCell';
|
||||||
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
||||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||||
@ -19,7 +20,6 @@ import { View } from '@/views/types/View';
|
|||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
import {
|
import {
|
||||||
IconMinus,
|
IconMinus,
|
||||||
@ -30,7 +30,9 @@ import {
|
|||||||
useIcons,
|
useIcons,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { SettingsObjectDetailTableItem } from '~/pages/settings/data-model/types/SettingsObjectDetailTableItem';
|
import { SettingsObjectDetailTableItem } from '~/pages/settings/data-model/types/SettingsObjectDetailTableItem';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import { RELATION_TYPES } from '../../constants/RelationTypes';
|
import { RELATION_TYPES } from '../../constants/RelationTypes';
|
||||||
import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType';
|
import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType';
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ export const SettingsObjectFieldItemTableRow = ({
|
|||||||
|
|
||||||
const variant = objectMetadataItem.isCustom ? 'identifier' : 'field-type';
|
const variant = objectMetadataItem.isCustom ? 'identifier' : 'field-type';
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
const [navigationMemorizedUrl, setNavigationMemorizedUrl] = useRecoilState(
|
const [navigationMemorizedUrl, setNavigationMemorizedUrl] = useRecoilState(
|
||||||
navigationMemorizedUrlState,
|
navigationMemorizedUrlState,
|
||||||
@ -108,7 +110,10 @@ export const SettingsObjectFieldItemTableRow = ({
|
|||||||
!isLabelIdentifier &&
|
!isLabelIdentifier &&
|
||||||
LABEL_IDENTIFIER_FIELD_METADATA_TYPES.includes(fieldMetadataItem.type);
|
LABEL_IDENTIFIER_FIELD_METADATA_TYPES.includes(fieldMetadataItem.type);
|
||||||
|
|
||||||
const linkToNavigate = `./${fieldMetadataItem.name}`;
|
const linkToNavigate = getSettingsPath(SettingsPath.ObjectFieldEdit, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
fieldName: fieldMetadataItem.name,
|
||||||
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
activateMetadataField,
|
activateMetadataField,
|
||||||
@ -212,7 +217,15 @@ export const SettingsObjectFieldItemTableRow = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledObjectFieldTableRow
|
<StyledObjectFieldTableRow
|
||||||
onClick={mode === 'view' ? () => navigate(linkToNavigate) : undefined}
|
onClick={
|
||||||
|
mode === 'view'
|
||||||
|
? () =>
|
||||||
|
navigate(SettingsPath.ObjectFieldEdit, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
fieldName: fieldMetadataItem.name,
|
||||||
|
})
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<UndecoratedLink to={linkToNavigate}>
|
<UndecoratedLink to={linkToNavigate}>
|
||||||
<StyledNameTableCell>
|
<StyledNameTableCell>
|
||||||
@ -244,7 +257,9 @@ export const SettingsObjectFieldItemTableRow = ({
|
|||||||
}
|
}
|
||||||
to={
|
to={
|
||||||
isRelatedObjectLinkable
|
isRelatedObjectLinkable
|
||||||
? `/settings/objects/${relationObjectMetadataItem.namePlural}`
|
? getSettingsPath(SettingsPath.Objects, {
|
||||||
|
objectNamePlural: relationObjectMetadataItem.namePlural,
|
||||||
|
})
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
value={fieldType}
|
value={fieldType}
|
||||||
@ -261,7 +276,12 @@ export const SettingsObjectFieldItemTableRow = ({
|
|||||||
<SettingsObjectFieldActiveActionDropdown
|
<SettingsObjectFieldActiveActionDropdown
|
||||||
isCustomField={fieldMetadataItem.isCustom === true}
|
isCustomField={fieldMetadataItem.isCustom === true}
|
||||||
scopeKey={fieldMetadataItem.id}
|
scopeKey={fieldMetadataItem.id}
|
||||||
onEdit={() => navigate(linkToNavigate)}
|
onEdit={() =>
|
||||||
|
navigate(SettingsPath.ObjectFieldEdit, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
fieldName: fieldMetadataItem.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
onSetAsLabelIdentifier={
|
onSetAsLabelIdentifier={
|
||||||
canBeSetAsLabelIdentifier
|
canBeSetAsLabelIdentifier
|
||||||
? () => handleSetLabelIdentifierField(fieldMetadataItem)
|
? () => handleSetLabelIdentifierField(fieldMetadataItem)
|
||||||
@ -286,7 +306,12 @@ export const SettingsObjectFieldItemTableRow = ({
|
|||||||
<SettingsObjectFieldInactiveActionDropdown
|
<SettingsObjectFieldInactiveActionDropdown
|
||||||
isCustomField={fieldMetadataItem.isCustom === true}
|
isCustomField={fieldMetadataItem.isCustom === true}
|
||||||
scopeKey={fieldMetadataItem.id}
|
scopeKey={fieldMetadataItem.id}
|
||||||
onEdit={() => navigate(linkToNavigate)}
|
onEdit={() =>
|
||||||
|
navigate(SettingsPath.ObjectFieldEdit, {
|
||||||
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
fieldName: fieldMetadataItem.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
onActivate={() =>
|
onActivate={() =>
|
||||||
activateMetadataField(fieldMetadataItem.id, objectMetadataItem.id)
|
activateMetadataField(fieldMetadataItem.id, objectMetadataItem.id)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { Button, H2Title, IconArchive, Section } from 'twenty-ui';
|
import { Button, H2Title, IconArchive, Section } from 'twenty-ui';
|
||||||
import { z, ZodError } from 'zod';
|
import { z, ZodError } from 'zod';
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ import {
|
|||||||
import { settingsDataModelObjectIdentifiersFormSchema } from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectIdentifiersForm';
|
import { settingsDataModelObjectIdentifiersFormSchema } from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectIdentifiersForm';
|
||||||
import { SettingsDataModelObjectSettingsFormCard } from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectSettingsFormCard';
|
import { SettingsDataModelObjectSettingsFormCard } from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectSettingsFormCard';
|
||||||
import { settingsUpdateObjectInputSchema } from '@/settings/data-model/validation-schemas/settingsUpdateObjectInputSchema';
|
import { settingsUpdateObjectInputSchema } from '@/settings/data-model/validation-schemas/settingsUpdateObjectInputSchema';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
@ -27,8 +26,10 @@ import styled from '@emotion/styled';
|
|||||||
import isEmpty from 'lodash.isempty';
|
import isEmpty from 'lodash.isempty';
|
||||||
import pick from 'lodash.pick';
|
import pick from 'lodash.pick';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { updatedObjectNamePluralState } from '~/pages/settings/data-model/states/updatedObjectNamePluralState';
|
import { updatedObjectNamePluralState } from '~/pages/settings/data-model/states/updatedObjectNamePluralState';
|
||||||
import { computeMetadataNameFromLabel } from '~/pages/settings/data-model/utils/compute-metadata-name-from-label.utils';
|
import { computeMetadataNameFromLabel } from '~/pages/settings/data-model/utils/compute-metadata-name-from-label.utils';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
|
||||||
const objectEditFormSchema = z
|
const objectEditFormSchema = z
|
||||||
.object({})
|
.object({})
|
||||||
@ -54,7 +55,7 @@ const StyledFormSection = styled(Section)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const ObjectSettings = ({ objectMetadataItem }: ObjectSettingsProps) => {
|
export const ObjectSettings = ({ objectMetadataItem }: ObjectSettingsProps) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
const setUpdatedObjectNamePlural = useSetRecoilState(
|
const setUpdatedObjectNamePlural = useSetRecoilState(
|
||||||
updatedObjectNamePluralState,
|
updatedObjectNamePluralState,
|
||||||
@ -65,8 +66,6 @@ export const ObjectSettings = ({ objectMetadataItem }: ObjectSettingsProps) => {
|
|||||||
useLastVisitedObjectMetadataItem();
|
useLastVisitedObjectMetadataItem();
|
||||||
const { getLastVisitedViewIdFromObjectMetadataItemId } = useLastVisitedView();
|
const { getLastVisitedViewIdFromObjectMetadataItemId } = useLastVisitedView();
|
||||||
|
|
||||||
const settingsObjectsPagePath = getSettingsPagePath(SettingsPath.Objects);
|
|
||||||
|
|
||||||
const formConfig = useForm<SettingsDataModelObjectEditFormValues>({
|
const formConfig = useForm<SettingsDataModelObjectEditFormValues>({
|
||||||
mode: 'onTouched',
|
mode: 'onTouched',
|
||||||
resolver: zodResolver(objectEditFormSchema),
|
resolver: zodResolver(objectEditFormSchema),
|
||||||
@ -147,11 +146,17 @@ export const ObjectSettings = ({ objectMetadataItem }: ObjectSettingsProps) => {
|
|||||||
objectMetadataItem.id,
|
objectMetadataItem.id,
|
||||||
);
|
);
|
||||||
setNavigationMemorizedUrl(
|
setNavigationMemorizedUrl(
|
||||||
`/objects/${objectNamePluralForRedirection}?view=${lastVisitedView}`,
|
getAppPath(
|
||||||
|
AppPath.RecordIndexPage,
|
||||||
|
{ objectNamePlural: objectNamePluralForRedirection },
|
||||||
|
{ viewId: lastVisitedView },
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(`${settingsObjectsPagePath}/${objectNamePluralForRedirection}`);
|
navigate(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural: objectNamePluralForRedirection,
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof ZodError) {
|
if (error instanceof ZodError) {
|
||||||
enqueueSnackBar(error.issues[0].message, {
|
enqueueSnackBar(error.issues[0].message, {
|
||||||
@ -170,7 +175,7 @@ export const ObjectSettings = ({ objectMetadataItem }: ObjectSettingsProps) => {
|
|||||||
idToUpdate: objectMetadataItem.id,
|
idToUpdate: objectMetadataItem.id,
|
||||||
updatePayload: { isActive: false },
|
updatePayload: { isActive: false },
|
||||||
});
|
});
|
||||||
navigate(settingsObjectsPagePath);
|
navigate(SettingsPath.Objects);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -2,15 +2,15 @@ import { useDeleteOneDatabaseConnection } from '@/databases/hooks/useDeleteOneDa
|
|||||||
import { SettingsIntegrationDatabaseConnectionSummaryCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard';
|
import { SettingsIntegrationDatabaseConnectionSummaryCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard';
|
||||||
import { SettingsIntegrationDatabaseTablesListCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseTablesListCard';
|
import { SettingsIntegrationDatabaseTablesListCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseTablesListCard';
|
||||||
import { useDatabaseConnection } from '@/settings/integrations/database-connection/hooks/useDatabaseConnection';
|
import { useDatabaseConnection } from '@/settings/integrations/database-connection/hooks/useDatabaseConnection';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
||||||
import { Section } from '@react-email/components';
|
import { Section } from '@react-email/components';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { H2Title } from 'twenty-ui';
|
import { H2Title } from 'twenty-ui';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsIntegrationDatabaseConnectionShowContainer = () => {
|
export const SettingsIntegrationDatabaseConnectionShowContainer = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const { connection, integration, databaseKey, tables } =
|
const { connection, integration, databaseKey, tables } =
|
||||||
useDatabaseConnection({ fetchPolicy: 'network-only' });
|
useDatabaseConnection({ fetchPolicy: 'network-only' });
|
||||||
|
|
||||||
@ -23,10 +23,12 @@ export const SettingsIntegrationDatabaseConnectionShowContainer = () => {
|
|||||||
const deleteConnection = async () => {
|
const deleteConnection = async () => {
|
||||||
await deleteOneDatabaseConnection({ id: connection.id });
|
await deleteOneDatabaseConnection({ id: connection.id });
|
||||||
|
|
||||||
navigate(`${settingsIntegrationsPagePath}/${databaseKey}`);
|
navigate(SettingsPath.IntegrationDatabase, {
|
||||||
|
databaseKey,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const settingsIntegrationsPagePath = getSettingsPagePath(
|
const settingsIntegrationsPagePath = getSettingsPath(
|
||||||
SettingsPath.Integrations,
|
SettingsPath.Integrations,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { IconChevronRight, LightIconButton } from 'twenty-ui';
|
import { IconChevronRight, LightIconButton } from 'twenty-ui';
|
||||||
|
|
||||||
import { SettingsListCard } from '@/settings/components/SettingsListCard';
|
import { SettingsListCard } from '@/settings/components/SettingsListCard';
|
||||||
import { SettingsIntegrationDatabaseConnectionSyncStatus } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSyncStatus';
|
import { SettingsIntegrationDatabaseConnectionSyncStatus } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSyncStatus';
|
||||||
import { SettingsIntegration } from '@/settings/integrations/types/SettingsIntegration';
|
import { SettingsIntegration } from '@/settings/integrations/types/SettingsIntegration';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { RemoteServer } from '~/generated-metadata/graphql';
|
import { RemoteServer } from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
type SettingsIntegrationDatabaseConnectionsListCardProps = {
|
type SettingsIntegrationDatabaseConnectionsListCardProps = {
|
||||||
integration: SettingsIntegration;
|
integration: SettingsIntegration;
|
||||||
@ -34,7 +35,7 @@ export const SettingsIntegrationDatabaseConnectionsListCard = ({
|
|||||||
integration,
|
integration,
|
||||||
connections,
|
connections,
|
||||||
}: SettingsIntegrationDatabaseConnectionsListCardProps) => {
|
}: SettingsIntegrationDatabaseConnectionsListCardProps) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsListCard
|
<SettingsListCard
|
||||||
@ -52,11 +53,20 @@ export const SettingsIntegrationDatabaseConnectionsListCard = ({
|
|||||||
<LightIconButton Icon={IconChevronRight} accent="tertiary" />
|
<LightIconButton Icon={IconChevronRight} accent="tertiary" />
|
||||||
</StyledRowRightContainer>
|
</StyledRowRightContainer>
|
||||||
)}
|
)}
|
||||||
onRowClick={(connection) => navigate(`./${connection.id}`)}
|
onRowClick={(connection) =>
|
||||||
|
navigate(SettingsPath.IntegrationDatabaseConnection, {
|
||||||
|
databaseKey: integration.from.key,
|
||||||
|
connectionId: connection.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
getItemLabel={(connection) => connection.label}
|
getItemLabel={(connection) => connection.label}
|
||||||
hasFooter
|
hasFooter
|
||||||
footerButtonLabel="Add connection"
|
footerButtonLabel="Add connection"
|
||||||
onFooterButtonClick={() => navigate('./new')}
|
onFooterButtonClick={() =>
|
||||||
|
navigate(SettingsPath.IntegrationNewDatabaseConnection, {
|
||||||
|
databaseKey: integration.from.key,
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import {
|
|||||||
getFormDefaultValuesFromConnection,
|
getFormDefaultValuesFromConnection,
|
||||||
} from '@/settings/integrations/database-connection/utils/editDatabaseConnection';
|
} from '@/settings/integrations/database-connection/utils/editDatabaseConnection';
|
||||||
import { SettingsIntegration } from '@/settings/integrations/types/SettingsIntegration';
|
import { SettingsIntegration } from '@/settings/integrations/types/SettingsIntegration';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
@ -17,7 +16,6 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|||||||
import { Section } from '@react-email/components';
|
import { Section } from '@react-email/components';
|
||||||
import pick from 'lodash.pick';
|
import pick from 'lodash.pick';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { H2Title, Info } from 'twenty-ui';
|
import { H2Title, Info } from 'twenty-ui';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import {
|
import {
|
||||||
@ -25,6 +23,8 @@ import {
|
|||||||
RemoteTable,
|
RemoteTable,
|
||||||
RemoteTableStatus,
|
RemoteTableStatus,
|
||||||
} from '~/generated-metadata/graphql';
|
} from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsIntegrationEditDatabaseConnectionContent = ({
|
export const SettingsIntegrationEditDatabaseConnectionContent = ({
|
||||||
connection,
|
connection,
|
||||||
@ -38,7 +38,7 @@ export const SettingsIntegrationEditDatabaseConnectionContent = ({
|
|||||||
tables: RemoteTable[];
|
tables: RemoteTable[];
|
||||||
}) => {
|
}) => {
|
||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
const editConnectionSchema = getEditionSchemaForForm(databaseKey);
|
const editConnectionSchema = getEditionSchemaForForm(databaseKey);
|
||||||
type SettingsIntegrationEditConnectionFormValues = z.infer<
|
type SettingsIntegrationEditConnectionFormValues = z.infer<
|
||||||
@ -56,7 +56,7 @@ export const SettingsIntegrationEditDatabaseConnectionContent = ({
|
|||||||
|
|
||||||
const { updateOneDatabaseConnection } = useUpdateOneDatabaseConnection();
|
const { updateOneDatabaseConnection } = useUpdateOneDatabaseConnection();
|
||||||
|
|
||||||
const settingsIntegrationsPagePath = getSettingsPagePath(
|
const settingsIntegrationsPagePath = getSettingsPath(
|
||||||
SettingsPath.Integrations,
|
SettingsPath.Integrations,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -82,9 +82,10 @@ export const SettingsIntegrationEditDatabaseConnectionContent = ({
|
|||||||
id: connection?.id ?? '',
|
id: connection?.id ?? '',
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate(
|
navigate(SettingsPath.IntegrationDatabaseConnection, {
|
||||||
`${settingsIntegrationsPagePath}/${databaseKey}/${connection?.id}`,
|
databaseKey,
|
||||||
);
|
connectionId: connection?.id,
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
enqueueSnackBar((error as Error).message, {
|
enqueueSnackBar((error as Error).message, {
|
||||||
variant: SnackBarVariant.Error,
|
variant: SnackBarVariant.Error,
|
||||||
@ -116,7 +117,9 @@ export const SettingsIntegrationEditDatabaseConnectionContent = ({
|
|||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled={!canSave}
|
isSaveDisabled={!canSave}
|
||||||
onCancel={() =>
|
onCancel={() =>
|
||||||
navigate(`${settingsIntegrationsPagePath}/${databaseKey}`)
|
navigate(SettingsPath.IntegrationDatabase, {
|
||||||
|
databaseKey,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import { WatchQueryFetchPolicy } from '@apollo/client';
|
import { WatchQueryFetchPolicy } from '@apollo/client';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { useGetDatabaseConnection } from '@/databases/hooks/useGetDatabaseConnection';
|
import { useGetDatabaseConnection } from '@/databases/hooks/useGetDatabaseConnection';
|
||||||
import { useGetDatabaseConnectionTables } from '@/databases/hooks/useGetDatabaseConnectionTables';
|
import { useGetDatabaseConnectionTables } from '@/databases/hooks/useGetDatabaseConnectionTables';
|
||||||
import { useIsSettingsIntegrationEnabled } from '@/settings/integrations/hooks/useIsSettingsIntegrationEnabled';
|
import { useIsSettingsIntegrationEnabled } from '@/settings/integrations/hooks/useIsSettingsIntegrationEnabled';
|
||||||
import { useSettingsIntegrationCategories } from '@/settings/integrations/hooks/useSettingsIntegrationCategories';
|
import { useSettingsIntegrationCategories } from '@/settings/integrations/hooks/useSettingsIntegrationCategories';
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const useDatabaseConnection = ({
|
export const useDatabaseConnection = ({
|
||||||
fetchPolicy,
|
fetchPolicy,
|
||||||
@ -14,7 +15,7 @@ export const useDatabaseConnection = ({
|
|||||||
fetchPolicy?: WatchQueryFetchPolicy;
|
fetchPolicy?: WatchQueryFetchPolicy;
|
||||||
}) => {
|
}) => {
|
||||||
const { databaseKey = '', connectionId = '' } = useParams();
|
const { databaseKey = '', connectionId = '' } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const [integrationCategoryAll] = useSettingsIntegrationCategories();
|
const [integrationCategoryAll] = useSettingsIntegrationCategories();
|
||||||
const integration = integrationCategoryAll.integrations.find(
|
const integration = integrationCategoryAll.integrations.find(
|
||||||
@ -34,12 +35,12 @@ export const useDatabaseConnection = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isIntegrationAvailable || (!loading && !connection)) {
|
if (!isIntegrationAvailable || (!loading && !connection)) {
|
||||||
navigate(AppPath.NotFound);
|
navigateApp(AppPath.NotFound);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
integration,
|
integration,
|
||||||
databaseKey,
|
databaseKey,
|
||||||
navigate,
|
navigateApp,
|
||||||
isIntegrationAvailable,
|
isIntegrationAvailable,
|
||||||
connection,
|
connection,
|
||||||
loading,
|
loading,
|
||||||
|
|||||||
@ -2,20 +2,20 @@
|
|||||||
|
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
|
|
||||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||||
import { SettingsCard } from '@/settings/components/SettingsCard';
|
import { SettingsCard } from '@/settings/components/SettingsCard';
|
||||||
import { SettingsSSOIdentitiesProvidersListCardWrapper } from '@/settings/security/components/SettingsSSOIdentitiesProvidersListCardWrapper';
|
import { SettingsSSOIdentitiesProvidersListCardWrapper } from '@/settings/security/components/SettingsSSOIdentitiesProvidersListCardWrapper';
|
||||||
|
import { SSOIdentitiesProvidersState } from '@/settings/security/states/SSOIdentitiesProvidersState';
|
||||||
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
import isPropValid from '@emotion/is-prop-valid';
|
import isPropValid from '@emotion/is-prop-valid';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useRecoilValue, useRecoilState } from 'recoil';
|
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||||
import { IconKey } from 'twenty-ui';
|
import { IconKey } from 'twenty-ui';
|
||||||
import { useListSsoIdentityProvidersByWorkspaceIdQuery } from '~/generated/graphql';
|
import { useListSsoIdentityProvidersByWorkspaceIdQuery } from '~/generated/graphql';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import { SSOIdentitiesProvidersState } from '@/settings/security/states/SSOIdentitiesProvidersState';
|
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
|
||||||
|
|
||||||
const StyledLink = styled(Link, {
|
const StyledLink = styled(Link, {
|
||||||
shouldForwardProp: (prop) => isPropValid(prop) && prop !== 'isDisabled',
|
shouldForwardProp: (prop) => isPropValid(prop) && prop !== 'isDisabled',
|
||||||
@ -49,7 +49,7 @@ export const SettingsSSOIdentitiesProvidersListCard = () => {
|
|||||||
|
|
||||||
return loading || !SSOIdentitiesProviders.length ? (
|
return loading || !SSOIdentitiesProviders.length ? (
|
||||||
<StyledLink
|
<StyledLink
|
||||||
to={getSettingsPagePath(SettingsPath.NewSSOIdentityProvider)}
|
to={getSettingsPath(SettingsPath.NewSSOIdentityProvider)}
|
||||||
isDisabled={currentWorkspace?.hasValidEntrepriseKey !== true}
|
isDisabled={currentWorkspace?.hasValidEntrepriseKey !== true}
|
||||||
>
|
>
|
||||||
<SettingsCard
|
<SettingsCard
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
/* @license Enterprise */
|
/* @license Enterprise */
|
||||||
|
|
||||||
import { guessSSOIdentityProviderIconByUrl } from '@/settings/security/utils/guessSSOIdentityProviderIconByUrl';
|
|
||||||
import { SettingsSSOIdentityProviderRowRightContainer } from '@/settings/security/components/SettingsSSOIdentityProviderRowRightContainer';
|
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
|
||||||
import { SettingsListCard } from '@/settings/components/SettingsListCard';
|
import { SettingsListCard } from '@/settings/components/SettingsListCard';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { SettingsSSOIdentityProviderRowRightContainer } from '@/settings/security/components/SettingsSSOIdentityProviderRowRightContainer';
|
||||||
import { SSOIdentitiesProvidersState } from '@/settings/security/states/SSOIdentitiesProvidersState';
|
import { SSOIdentitiesProvidersState } from '@/settings/security/states/SSOIdentitiesProvidersState';
|
||||||
|
import { guessSSOIdentityProviderIconByUrl } from '@/settings/security/utils/guessSSOIdentityProviderIconByUrl';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
export const SettingsSSOIdentitiesProvidersListCardWrapper = () => {
|
export const SettingsSSOIdentitiesProvidersListCardWrapper = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
const SSOIdentitiesProviders = useRecoilValue(SSOIdentitiesProvidersState);
|
const SSOIdentitiesProviders = useRecoilValue(SSOIdentitiesProvidersState);
|
||||||
|
|
||||||
@ -28,9 +27,7 @@ export const SettingsSSOIdentitiesProvidersListCardWrapper = () => {
|
|||||||
)}
|
)}
|
||||||
hasFooter
|
hasFooter
|
||||||
footerButtonLabel="Add SSO Identity Provider"
|
footerButtonLabel="Add SSO Identity Provider"
|
||||||
onFooterButtonClick={() =>
|
onFooterButtonClick={() => navigate(SettingsPath.NewSSOIdentityProvider)}
|
||||||
navigate(getSettingsPagePath(SettingsPath.NewSSOIdentityProvider))
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { SettingsPageContainer } from '@/settings/components/SettingsPageContain
|
|||||||
import { SettingsServerlessFunctionsFieldItemTableRow } from '@/settings/serverless-functions/components/SettingsServerlessFunctionsFieldItemTableRow';
|
import { SettingsServerlessFunctionsFieldItemTableRow } from '@/settings/serverless-functions/components/SettingsServerlessFunctionsFieldItemTableRow';
|
||||||
import { SettingsServerlessFunctionsTableEmpty } from '@/settings/serverless-functions/components/SettingsServerlessFunctionsTableEmpty';
|
import { SettingsServerlessFunctionsTableEmpty } from '@/settings/serverless-functions/components/SettingsServerlessFunctionsTableEmpty';
|
||||||
import { useGetManyServerlessFunctions } from '@/settings/serverless-functions/hooks/useGetManyServerlessFunctions';
|
import { useGetManyServerlessFunctions } from '@/settings/serverless-functions/hooks/useGetManyServerlessFunctions';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { Table } from '@/ui/layout/table/components/Table';
|
import { Table } from '@/ui/layout/table/components/Table';
|
||||||
import { TableBody } from '@/ui/layout/table/components/TableBody';
|
import { TableBody } from '@/ui/layout/table/components/TableBody';
|
||||||
@ -10,6 +9,7 @@ import { TableHeader } from '@/ui/layout/table/components/TableHeader';
|
|||||||
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { ServerlessFunction } from '~/generated-metadata/graphql';
|
import { ServerlessFunction } from '~/generated-metadata/graphql';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const StyledTableRow = styled(TableRow)`
|
const StyledTableRow = styled(TableRow)`
|
||||||
grid-template-columns: 312px 132px 68px;
|
grid-template-columns: 312px 132px 68px;
|
||||||
@ -38,7 +38,7 @@ export const SettingsServerlessFunctionsTable = () => {
|
|||||||
<SettingsServerlessFunctionsFieldItemTableRow
|
<SettingsServerlessFunctionsFieldItemTableRow
|
||||||
key={serverlessFunction.id}
|
key={serverlessFunction.id}
|
||||||
serverlessFunction={serverlessFunction}
|
serverlessFunction={serverlessFunction}
|
||||||
to={getSettingsPagePath(SettingsPath.ServerlessFunctions, {
|
to={getSettingsPath(SettingsPath.ServerlessFunctions, {
|
||||||
id: serverlessFunction.id,
|
id: serverlessFunction.id,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import {
|
import {
|
||||||
@ -11,6 +10,7 @@ import {
|
|||||||
EMPTY_PLACEHOLDER_TRANSITION_PROPS,
|
EMPTY_PLACEHOLDER_TRANSITION_PROPS,
|
||||||
IconPlus,
|
IconPlus,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const StyledEmptyFunctionsContainer = styled.div`
|
const StyledEmptyFunctionsContainer = styled.div`
|
||||||
height: 60vh;
|
height: 60vh;
|
||||||
@ -35,7 +35,7 @@ export const SettingsServerlessFunctionsTableEmpty = () => {
|
|||||||
<Button
|
<Button
|
||||||
Icon={IconPlus}
|
Icon={IconPlus}
|
||||||
title="New function"
|
title="New function"
|
||||||
to={getSettingsPagePath(SettingsPath.NewServerlessFunction)}
|
to={getSettingsPath(SettingsPath.NewServerlessFunction)}
|
||||||
/>
|
/>
|
||||||
</AnimatedPlaceholderEmptyContainer>
|
</AnimatedPlaceholderEmptyContainer>
|
||||||
</StyledEmptyFunctionsContainer>
|
</StyledEmptyFunctionsContainer>
|
||||||
|
|||||||
@ -4,13 +4,11 @@ import {
|
|||||||
} from '@/settings/serverless-functions/components/SettingsServerlessFunctionCodeEditor';
|
} from '@/settings/serverless-functions/components/SettingsServerlessFunctionCodeEditor';
|
||||||
import { SETTINGS_SERVERLESS_FUNCTION_TAB_LIST_COMPONENT_ID } from '@/settings/serverless-functions/constants/SettingsServerlessFunctionTabListComponentId';
|
import { SETTINGS_SERVERLESS_FUNCTION_TAB_LIST_COMPONENT_ID } from '@/settings/serverless-functions/constants/SettingsServerlessFunctionTabListComponentId';
|
||||||
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { TabList } from '@/ui/layout/tab/components/TabList';
|
import { TabList } from '@/ui/layout/tab/components/TabList';
|
||||||
import { useTabList } from '@/ui/layout/tab/hooks/useTabList';
|
import { useTabList } from '@/ui/layout/tab/hooks/useTabList';
|
||||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { Key } from 'ts-key-enum';
|
import { Key } from 'ts-key-enum';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -22,6 +20,7 @@ import {
|
|||||||
Section,
|
Section,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
const StyledTabList = styled(TabList)`
|
const StyledTabList = styled(TabList)`
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
@ -91,7 +90,7 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
useHotkeyScopeOnMount(
|
useHotkeyScopeOnMount(
|
||||||
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionEditorTab,
|
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionEditorTab,
|
||||||
);
|
);
|
||||||
@ -99,7 +98,7 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
|
|||||||
useScopedHotkeys(
|
useScopedHotkeys(
|
||||||
[Key.Escape],
|
[Key.Escape],
|
||||||
() => {
|
() => {
|
||||||
navigate(getSettingsPagePath(SettingsPath.ServerlessFunctions));
|
navigate(SettingsPath.ServerlessFunctions);
|
||||||
},
|
},
|
||||||
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionEditorTab,
|
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionEditorTab,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,19 +2,18 @@ import { AnalyticsActivityGraph } from '@/analytics/components/AnalyticsActivity
|
|||||||
import { AnalyticsGraphEffect } from '@/analytics/components/AnalyticsGraphEffect';
|
import { AnalyticsGraphEffect } from '@/analytics/components/AnalyticsGraphEffect';
|
||||||
import { AnalyticsGraphDataInstanceContext } from '@/analytics/states/contexts/AnalyticsGraphDataInstanceContext';
|
import { AnalyticsGraphDataInstanceContext } from '@/analytics/states/contexts/AnalyticsGraphDataInstanceContext';
|
||||||
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { Key } from 'ts-key-enum';
|
import { Key } from 'ts-key-enum';
|
||||||
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
export const SettingsServerlessFunctionMonitoringTab = ({
|
export const SettingsServerlessFunctionMonitoringTab = ({
|
||||||
serverlessFunctionId,
|
serverlessFunctionId,
|
||||||
}: {
|
}: {
|
||||||
serverlessFunctionId: string;
|
serverlessFunctionId: string;
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
useHotkeyScopeOnMount(
|
useHotkeyScopeOnMount(
|
||||||
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionSettingsTab,
|
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionSettingsTab,
|
||||||
@ -23,7 +22,7 @@ export const SettingsServerlessFunctionMonitoringTab = ({
|
|||||||
useScopedHotkeys(
|
useScopedHotkeys(
|
||||||
[Key.Escape],
|
[Key.Escape],
|
||||||
() => {
|
() => {
|
||||||
navigate(getSettingsPagePath(SettingsPath.ServerlessFunctions));
|
navigate(SettingsPath.ServerlessFunctions);
|
||||||
},
|
},
|
||||||
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionSettingsTab,
|
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionSettingsTab,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,15 +3,14 @@ import { SettingsServerlessFunctionTabEnvironmentVariablesSection } from '@/sett
|
|||||||
import { useDeleteOneServerlessFunction } from '@/settings/serverless-functions/hooks/useDeleteOneServerlessFunction';
|
import { useDeleteOneServerlessFunction } from '@/settings/serverless-functions/hooks/useDeleteOneServerlessFunction';
|
||||||
import { ServerlessFunctionFormValues } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';
|
import { ServerlessFunctionFormValues } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';
|
||||||
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { Key } from 'ts-key-enum';
|
import { Key } from 'ts-key-enum';
|
||||||
import { Button, H2Title, Section } from 'twenty-ui';
|
import { Button, H2Title, Section } from 'twenty-ui';
|
||||||
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
export const SettingsServerlessFunctionSettingsTab = ({
|
export const SettingsServerlessFunctionSettingsTab = ({
|
||||||
formValues,
|
formValues,
|
||||||
@ -24,14 +23,14 @@ export const SettingsServerlessFunctionSettingsTab = ({
|
|||||||
onChange: (key: string) => (value: string) => void;
|
onChange: (key: string) => (value: string) => void;
|
||||||
onCodeChange: (filePath: string, value: string) => void;
|
onCodeChange: (filePath: string, value: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const [isDeleteFunctionModalOpen, setIsDeleteFunctionModalOpen] =
|
const [isDeleteFunctionModalOpen, setIsDeleteFunctionModalOpen] =
|
||||||
useState(false);
|
useState(false);
|
||||||
const { deleteOneServerlessFunction } = useDeleteOneServerlessFunction();
|
const { deleteOneServerlessFunction } = useDeleteOneServerlessFunction();
|
||||||
|
|
||||||
const deleteFunction = async () => {
|
const deleteFunction = async () => {
|
||||||
await deleteOneServerlessFunction({ id: serverlessFunctionId });
|
await deleteOneServerlessFunction({ id: serverlessFunctionId });
|
||||||
navigate('/settings/functions');
|
navigate(SettingsPath.ServerlessFunctions);
|
||||||
};
|
};
|
||||||
|
|
||||||
useHotkeyScopeOnMount(
|
useHotkeyScopeOnMount(
|
||||||
@ -49,7 +48,7 @@ export const SettingsServerlessFunctionSettingsTab = ({
|
|||||||
useScopedHotkeys(
|
useScopedHotkeys(
|
||||||
[Key.Escape],
|
[Key.Escape],
|
||||||
() => {
|
() => {
|
||||||
navigate(getSettingsPagePath(SettingsPath.ServerlessFunctions));
|
navigate(SettingsPath.ServerlessFunctions);
|
||||||
},
|
},
|
||||||
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionSettingsTab,
|
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionSettingsTab,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -7,17 +7,16 @@ import {
|
|||||||
Section,
|
Section,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
|
|
||||||
|
import { ServerlessFunctionExecutionResult } from '@/serverless-functions/components/ServerlessFunctionExecutionResult';
|
||||||
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
import { SettingsServerlessFunctionHotkeyScope } from '@/settings/serverless-functions/types/SettingsServerlessFunctionHotKeyScope';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||||
|
import { serverlessFunctionTestDataFamilyState } from '@/workflow/states/serverlessFunctionTestDataFamilyState';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
import { Key } from 'ts-key-enum';
|
import { Key } from 'ts-key-enum';
|
||||||
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
import { useHotkeyScopeOnMount } from '~/hooks/useHotkeyScopeOnMount';
|
||||||
import { ServerlessFunctionExecutionResult } from '@/serverless-functions/components/ServerlessFunctionExecutionResult';
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { serverlessFunctionTestDataFamilyState } from '@/workflow/states/serverlessFunctionTestDataFamilyState';
|
|
||||||
|
|
||||||
const StyledInputsContainer = styled.div`
|
const StyledInputsContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -47,7 +46,7 @@ export const SettingsServerlessFunctionTestTab = ({
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
useHotkeyScopeOnMount(
|
useHotkeyScopeOnMount(
|
||||||
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionTestTab,
|
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionTestTab,
|
||||||
);
|
);
|
||||||
@ -55,7 +54,7 @@ export const SettingsServerlessFunctionTestTab = ({
|
|||||||
useScopedHotkeys(
|
useScopedHotkeys(
|
||||||
[Key.Escape],
|
[Key.Escape],
|
||||||
() => {
|
() => {
|
||||||
navigate(getSettingsPagePath(SettingsPath.ServerlessFunctions));
|
navigate(SettingsPath.ServerlessFunctions);
|
||||||
},
|
},
|
||||||
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionTestTab,
|
SettingsServerlessFunctionHotkeyScope.ServerlessFunctionTestTab,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
|
||||||
|
|
||||||
describe('getSettingsPagePath', () => {
|
|
||||||
test('should compute page path', () => {
|
|
||||||
expect(getSettingsPagePath(SettingsPath.ServerlessFunctions)).toEqual(
|
|
||||||
'/settings/functions',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
test('should compute page path with id', () => {
|
|
||||||
expect(
|
|
||||||
getSettingsPagePath(SettingsPath.ServerlessFunctions, { id: 'id' }),
|
|
||||||
).toEqual('/settings/functions/id');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
import { ExtractPathParams } from '@/types/ExtractPathParams';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
|
||||||
import { isDefined } from '~/utils/isDefined';
|
|
||||||
|
|
||||||
type Params<V extends string> = {
|
|
||||||
[K in ExtractPathParams<V>]: string;
|
|
||||||
} & {
|
|
||||||
id?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getSettingsPagePath = <Path extends SettingsPath>(
|
|
||||||
path: Path,
|
|
||||||
params?: Params<Path>,
|
|
||||||
searchParams?: Record<string, string>,
|
|
||||||
) => {
|
|
||||||
let resultPath = `/settings/${path}`;
|
|
||||||
|
|
||||||
if (isDefined(params)) {
|
|
||||||
resultPath = resultPath.replace(/:([a-zA-Z]+)/g, (_, key) => {
|
|
||||||
const value = params[key as keyof Params<Path>];
|
|
||||||
|
|
||||||
return value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isDefined(params?.id)) {
|
|
||||||
resultPath = `${resultPath}/${params?.id}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isDefined(searchParams)) {
|
|
||||||
const searchParamsString = new URLSearchParams(searchParams).toString();
|
|
||||||
|
|
||||||
resultPath = `${resultPath}?${searchParamsString}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return resultPath;
|
|
||||||
};
|
|
||||||
@ -4,9 +4,7 @@ export enum SettingsPath {
|
|||||||
Accounts = 'accounts',
|
Accounts = 'accounts',
|
||||||
NewAccount = 'accounts/new',
|
NewAccount = 'accounts/new',
|
||||||
AccountsCalendars = 'accounts/calendars',
|
AccountsCalendars = 'accounts/calendars',
|
||||||
AccountsCalendarsSettings = 'accounts/calendars/:accountUuid',
|
|
||||||
AccountsEmails = 'accounts/emails',
|
AccountsEmails = 'accounts/emails',
|
||||||
AccountsEmailsInboxSettings = 'accounts/emails/:accountUuid',
|
|
||||||
Billing = 'billing',
|
Billing = 'billing',
|
||||||
Objects = 'objects',
|
Objects = 'objects',
|
||||||
ObjectOverview = 'objects/overview',
|
ObjectOverview = 'objects/overview',
|
||||||
@ -15,16 +13,15 @@ export enum SettingsPath {
|
|||||||
ObjectNewFieldConfigure = 'objects/:objectNamePlural/new-field/configure',
|
ObjectNewFieldConfigure = 'objects/:objectNamePlural/new-field/configure',
|
||||||
ObjectFieldEdit = 'objects/:objectNamePlural/:fieldName',
|
ObjectFieldEdit = 'objects/:objectNamePlural/:fieldName',
|
||||||
NewObject = 'objects/new',
|
NewObject = 'objects/new',
|
||||||
|
ServerlessFunctions = 'functions',
|
||||||
NewServerlessFunction = 'functions/new',
|
NewServerlessFunction = 'functions/new',
|
||||||
ServerlessFunctionDetail = 'functions/:serverlessFunctionId',
|
ServerlessFunctionDetail = 'functions/:serverlessFunctionId',
|
||||||
WorkspaceMembersPage = 'workspace-members',
|
WorkspaceMembersPage = 'workspace-members',
|
||||||
Workspace = 'workspace',
|
Workspace = 'workspace',
|
||||||
Domain = 'domain',
|
Domain = 'domain',
|
||||||
CRMMigration = 'crm-migration',
|
|
||||||
Developers = 'developers',
|
Developers = 'developers',
|
||||||
ServerlessFunctions = 'functions',
|
DevelopersNewApiKey = 'developers/api-keys/new',
|
||||||
DevelopersNewApiKey = 'api-keys/new',
|
DevelopersApiKeyDetail = 'developers/api-keys/:apiKeyId',
|
||||||
DevelopersApiKeyDetail = 'api-keys/:apiKeyId',
|
|
||||||
Integrations = 'integrations',
|
Integrations = 'integrations',
|
||||||
IntegrationDatabase = 'integrations/:databaseKey',
|
IntegrationDatabase = 'integrations/:databaseKey',
|
||||||
IntegrationDatabaseConnection = 'integrations/:databaseKey/:connectionId',
|
IntegrationDatabaseConnection = 'integrations/:databaseKey/:connectionId',
|
||||||
@ -33,8 +30,8 @@ export enum SettingsPath {
|
|||||||
Security = 'security',
|
Security = 'security',
|
||||||
NewSSOIdentityProvider = 'security/sso/new',
|
NewSSOIdentityProvider = 'security/sso/new',
|
||||||
EditSSOIdentityProvider = 'security/sso/:identityProviderId',
|
EditSSOIdentityProvider = 'security/sso/:identityProviderId',
|
||||||
DevelopersNewWebhook = 'webhooks/new',
|
DevelopersNewWebhook = 'developers/webhooks/new',
|
||||||
DevelopersNewWebhookDetail = 'webhooks/:webhookId',
|
DevelopersNewWebhookDetail = 'developers/webhooks/:webhookId',
|
||||||
Releases = 'releases',
|
Releases = 'releases',
|
||||||
AdminPanel = 'admin-panel',
|
AdminPanel = 'admin-panel',
|
||||||
FeatureFlags = 'admin-panel/feature-flags',
|
FeatureFlags = 'admin-panel/feature-flags',
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import {
|
|||||||
|
|
||||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
||||||
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
|
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
|
||||||
@ -36,6 +35,7 @@ import { mockedWorkspaceMemberData } from '~/testing/mock-data/users';
|
|||||||
|
|
||||||
import { CurrentWorkspaceMemberFavoritesFolders } from '@/favorites/components/CurrentWorkspaceMemberFavoritesFolders';
|
import { CurrentWorkspaceMemberFavoritesFolders } from '@/favorites/components/CurrentWorkspaceMemberFavoritesFolders';
|
||||||
import { NavigationDrawerSubItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem';
|
import { NavigationDrawerSubItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import jsonPage from '../../../../../../../package.json';
|
import jsonPage from '../../../../../../../package.json';
|
||||||
import { NavigationDrawer } from '../NavigationDrawer';
|
import { NavigationDrawer } from '../NavigationDrawer';
|
||||||
import { NavigationDrawerItem } from '../NavigationDrawerItem';
|
import { NavigationDrawerItem } from '../NavigationDrawerItem';
|
||||||
@ -136,30 +136,30 @@ export const Settings: Story = {
|
|||||||
<NavigationDrawerSectionTitle label="User" />
|
<NavigationDrawerSectionTitle label="User" />
|
||||||
<NavigationDrawerItem
|
<NavigationDrawerItem
|
||||||
label="Profile"
|
label="Profile"
|
||||||
to={getSettingsPagePath(SettingsPath.ProfilePage)}
|
to={getSettingsPath(SettingsPath.ProfilePage)}
|
||||||
Icon={IconUserCircle}
|
Icon={IconUserCircle}
|
||||||
active
|
active
|
||||||
/>
|
/>
|
||||||
<NavigationDrawerItem
|
<NavigationDrawerItem
|
||||||
label="Appearance"
|
label="Appearance"
|
||||||
to={getSettingsPagePath(SettingsPath.Experience)}
|
to={getSettingsPath(SettingsPath.Experience)}
|
||||||
Icon={IconColorSwatch}
|
Icon={IconColorSwatch}
|
||||||
/>
|
/>
|
||||||
<NavigationDrawerItemGroup>
|
<NavigationDrawerItemGroup>
|
||||||
<NavigationDrawerItem
|
<NavigationDrawerItem
|
||||||
label="Accounts"
|
label="Accounts"
|
||||||
to={getSettingsPagePath(SettingsPath.Accounts)}
|
to={getSettingsPath(SettingsPath.Accounts)}
|
||||||
Icon={IconAt}
|
Icon={IconAt}
|
||||||
/>
|
/>
|
||||||
<NavigationDrawerSubItem
|
<NavigationDrawerSubItem
|
||||||
label="Emails"
|
label="Emails"
|
||||||
to={getSettingsPagePath(SettingsPath.AccountsEmails)}
|
to={getSettingsPath(SettingsPath.AccountsEmails)}
|
||||||
Icon={IconMail}
|
Icon={IconMail}
|
||||||
subItemState="intermediate-before-selected"
|
subItemState="intermediate-before-selected"
|
||||||
/>
|
/>
|
||||||
<NavigationDrawerSubItem
|
<NavigationDrawerSubItem
|
||||||
label="Calendar"
|
label="Calendar"
|
||||||
to={getSettingsPagePath(SettingsPath.AccountsCalendars)}
|
to={getSettingsPath(SettingsPath.AccountsCalendars)}
|
||||||
Icon={IconCalendarEvent}
|
Icon={IconCalendarEvent}
|
||||||
subItemState="last-selected"
|
subItemState="last-selected"
|
||||||
/>
|
/>
|
||||||
@ -170,12 +170,12 @@ export const Settings: Story = {
|
|||||||
<NavigationDrawerSectionTitle label="Workspace" />
|
<NavigationDrawerSectionTitle label="Workspace" />
|
||||||
<NavigationDrawerItem
|
<NavigationDrawerItem
|
||||||
label="General"
|
label="General"
|
||||||
to={getSettingsPagePath(SettingsPath.Workspace)}
|
to={getSettingsPath(SettingsPath.Workspace)}
|
||||||
Icon={IconSettings}
|
Icon={IconSettings}
|
||||||
/>
|
/>
|
||||||
<NavigationDrawerItem
|
<NavigationDrawerItem
|
||||||
label="Members"
|
label="Members"
|
||||||
to={getSettingsPagePath(SettingsPath.WorkspaceMembersPage)}
|
to={getSettingsPath(SettingsPath.WorkspaceMembersPage)}
|
||||||
Icon={IconUsers}
|
Icon={IconUsers}
|
||||||
/>
|
/>
|
||||||
</NavigationDrawerSection>
|
</NavigationDrawerSection>
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||||
import { viewObjectMetadataIdComponentState } from '@/views/states/viewObjectMetadataIdComponentState';
|
import { viewObjectMetadataIdComponentState } from '@/views/states/viewObjectMetadataIdComponentState';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
|
||||||
export const useGetAvailableFieldsForKanban = () => {
|
export const useGetAvailableFieldsForKanban = () => {
|
||||||
@ -28,19 +30,23 @@ export const useGetAvailableFieldsForKanban = () => {
|
|||||||
(field) => field.type === FieldMetadataType.Select,
|
(field) => field.type === FieldMetadataType.Select,
|
||||||
) ?? [];
|
) ?? [];
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
const navigateToSelectSettings = useCallback(() => {
|
const navigateToSelectSettings = useCallback(() => {
|
||||||
setNavigationMemorizedUrl(location.pathname + location.search);
|
setNavigationMemorizedUrl(location.pathname + location.search);
|
||||||
|
|
||||||
if (isDefined(objectMetadataItem?.namePlural)) {
|
if (isDefined(objectMetadataItem?.namePlural)) {
|
||||||
navigate(
|
navigate(
|
||||||
`/settings/objects/${
|
SettingsPath.ObjectNewFieldConfigure,
|
||||||
objectMetadataItem.namePlural
|
{
|
||||||
}/new-field/configure?fieldType=${FieldMetadataType.Select}`,
|
objectNamePlural: objectMetadataItem.namePlural,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldType: FieldMetadataType.Select,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
navigate(`/settings/objects`);
|
navigate(SettingsPath.Objects);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
setNavigationMemorizedUrl,
|
setNavigationMemorizedUrl,
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
import { buildShowPageURL } from '@/object-record/record-show/utils/buildShowPageURL';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import {
|
import {
|
||||||
ConfirmationModal,
|
ConfirmationModal,
|
||||||
StyledCenteredButton,
|
StyledCenteredButton,
|
||||||
} from '@/ui/layout/modal/components/ConfirmationModal';
|
} from '@/ui/layout/modal/components/ConfirmationModal';
|
||||||
import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';
|
import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';
|
||||||
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
|
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||||
|
|
||||||
export const OverrideWorkflowDraftConfirmationModal = ({
|
export const OverrideWorkflowDraftConfirmationModal = ({
|
||||||
workflowId,
|
workflowId,
|
||||||
@ -24,7 +25,7 @@ export const OverrideWorkflowDraftConfirmationModal = ({
|
|||||||
const { createDraftFromWorkflowVersion } =
|
const { createDraftFromWorkflowVersion } =
|
||||||
useCreateDraftFromWorkflowVersion();
|
useCreateDraftFromWorkflowVersion();
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
|
|
||||||
const handleOverrideDraft = async () => {
|
const handleOverrideDraft = async () => {
|
||||||
await createDraftFromWorkflowVersion({
|
await createDraftFromWorkflowVersion({
|
||||||
@ -32,7 +33,10 @@ export const OverrideWorkflowDraftConfirmationModal = ({
|
|||||||
workflowVersionIdToCopy,
|
workflowVersionIdToCopy,
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate(buildShowPageURL(CoreObjectNameSingular.Workflow, workflowId));
|
navigate(AppPath.RecordShowPage, {
|
||||||
|
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||||
|
objectRecordId: workflowId,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -46,7 +50,10 @@ export const OverrideWorkflowDraftConfirmationModal = ({
|
|||||||
deleteButtonText={'Override Draft'}
|
deleteButtonText={'Override Draft'}
|
||||||
AdditionalButtons={
|
AdditionalButtons={
|
||||||
<StyledCenteredButton
|
<StyledCenteredButton
|
||||||
to={buildShowPageURL(CoreObjectNameSingular.Workflow, workflowId)}
|
to={getAppPath(AppPath.RecordShowPage, {
|
||||||
|
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||||
|
objectRecordId: workflowId,
|
||||||
|
})}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpenOverrideWorkflowDraftConfirmationModal(false);
|
setOpenOverrideWorkflowDraftConfirmationModal(false);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||||
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
|
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
|
||||||
import { buildShowPageURL } from '@/object-record/record-show/utils/buildShowPageURL';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { OverrideWorkflowDraftConfirmationModal } from '@/workflow/components/OverrideWorkflowDraftConfirmationModal';
|
import { OverrideWorkflowDraftConfirmationModal } from '@/workflow/components/OverrideWorkflowDraftConfirmationModal';
|
||||||
import { useActivateWorkflowVersion } from '@/workflow/hooks/useActivateWorkflowVersion';
|
import { useActivateWorkflowVersion } from '@/workflow/hooks/useActivateWorkflowVersion';
|
||||||
import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';
|
import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';
|
||||||
@ -9,7 +9,6 @@ import { useDeactivateWorkflowVersion } from '@/workflow/hooks/useDeactivateWork
|
|||||||
import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
|
import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
|
||||||
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
|
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
|
||||||
import { Workflow, WorkflowVersion } from '@/workflow/types/Workflow';
|
import { Workflow, WorkflowVersion } from '@/workflow/types/Workflow';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -18,6 +17,7 @@ import {
|
|||||||
IconPower,
|
IconPower,
|
||||||
isDefined,
|
isDefined,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
|
||||||
export const RecordShowPageWorkflowVersionHeader = ({
|
export const RecordShowPageWorkflowVersionHeader = ({
|
||||||
workflowVersionId,
|
workflowVersionId,
|
||||||
@ -81,7 +81,7 @@ export const RecordShowPageWorkflowVersionHeader = ({
|
|||||||
openOverrideWorkflowDraftConfirmationModalState,
|
openOverrideWorkflowDraftConfirmationModalState,
|
||||||
);
|
);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -100,12 +100,10 @@ export const RecordShowPageWorkflowVersionHeader = ({
|
|||||||
workflowVersionIdToCopy: workflowVersion.id,
|
workflowVersionIdToCopy: workflowVersion.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate(
|
navigate(AppPath.RecordShowPage, {
|
||||||
buildShowPageURL(
|
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||||
CoreObjectNameSingular.Workflow,
|
objectRecordId: workflowVersion.workflow.id,
|
||||||
workflowVersion.workflow.id,
|
});
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { useRedirect } from '@/domain-manager/hooks/useRedirect';
|
||||||
import { MainButton, UndecoratedLink } from 'twenty-ui';
|
import { MainButton, UndecoratedLink } from 'twenty-ui';
|
||||||
import { useAuthorizeAppMutation } from '~/generated/graphql';
|
import { useAuthorizeAppMutation } from '~/generated/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
import { useRedirect } from '@/domain-manager/hooks/useRedirect';
|
|
||||||
|
|
||||||
type App = { id: string; name: string; logo: string };
|
type App = { id: string; name: string; logo: string };
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ const StyledButtonContainer = styled.div`
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
`;
|
`;
|
||||||
export const Authorize = () => {
|
export const Authorize = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
const [searchParam] = useSearchParams();
|
const [searchParam] = useSearchParams();
|
||||||
const { redirect } = useRedirect();
|
const { redirect } = useRedirect();
|
||||||
//TODO: Replace with db call for registered third party apps
|
//TODO: Replace with db call for registered third party apps
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Logo } from '@/auth/components/Logo';
|
|||||||
import { Title } from '@/auth/components/Title';
|
import { Title } from '@/auth/components/Title';
|
||||||
import { useAuth } from '@/auth/hooks/useAuth';
|
import { useAuth } from '@/auth/hooks/useAuth';
|
||||||
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
||||||
|
import { workspacePublicDataState } from '@/auth/states/workspacePublicDataState';
|
||||||
import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex';
|
import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex';
|
||||||
import { useReadCaptchaToken } from '@/captcha/hooks/useReadCaptchaToken';
|
import { useReadCaptchaToken } from '@/captcha/hooks/useReadCaptchaToken';
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
@ -18,16 +19,16 @@ import { motion } from 'framer-motion';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Controller, useForm } from 'react-hook-form';
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useSetRecoilState, useRecoilValue } from 'recoil';
|
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||||
import { AnimatedEaseIn, MainButton } from 'twenty-ui';
|
import { AnimatedEaseIn, MainButton } from 'twenty-ui';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import {
|
import {
|
||||||
useUpdatePasswordViaResetTokenMutation,
|
useUpdatePasswordViaResetTokenMutation,
|
||||||
useValidatePasswordResetTokenQuery,
|
useValidatePasswordResetTokenQuery,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
import { logError } from '~/utils/logError';
|
import { logError } from '~/utils/logError';
|
||||||
import { workspacePublicDataState } from '@/auth/states/workspacePublicDataState';
|
|
||||||
|
|
||||||
const validationSchema = z
|
const validationSchema = z
|
||||||
.object({
|
.object({
|
||||||
@ -74,7 +75,7 @@ export const PasswordReset = () => {
|
|||||||
|
|
||||||
const workspacePublicData = useRecoilValue(workspacePublicDataState);
|
const workspacePublicData = useRecoilValue(workspacePublicDataState);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
|
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [isTokenValid, setIsTokenValid] = useState(false);
|
const [isTokenValid, setIsTokenValid] = useState(false);
|
||||||
|
|||||||
@ -12,15 +12,14 @@ import {
|
|||||||
import { SubTitle } from '@/auth/components/SubTitle';
|
import { SubTitle } from '@/auth/components/SubTitle';
|
||||||
import { Title } from '@/auth/components/Title';
|
import { Title } from '@/auth/components/Title';
|
||||||
import { currentUserState } from '@/auth/states/currentUserState';
|
import { currentUserState } from '@/auth/states/currentUserState';
|
||||||
|
import { useOnboardingStatus } from '@/onboarding/hooks/useOnboardingStatus';
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
|
||||||
import {
|
import {
|
||||||
OnboardingStatus,
|
OnboardingStatus,
|
||||||
useGetCurrentUserLazyQuery,
|
useGetCurrentUserLazyQuery,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
import { useOnboardingStatus } from '@/onboarding/hooks/useOnboardingStatus';
|
|
||||||
import { AppPath } from '@/types/AppPath';
|
|
||||||
import React from 'react';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
|
|
||||||
const StyledCheckContainer = styled.div`
|
const StyledCheckContainer = styled.div`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -41,7 +40,7 @@ const StyledButtonContainer = styled.div`
|
|||||||
|
|
||||||
export const PaymentSuccess = () => {
|
export const PaymentSuccess = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
const subscriptionStatus = useSubscriptionStatus();
|
const subscriptionStatus = useSubscriptionStatus();
|
||||||
const onboardingStatus = useOnboardingStatus();
|
const onboardingStatus = useOnboardingStatus();
|
||||||
const [getCurrentUser] = useGetCurrentUserLazyQuery();
|
const [getCurrentUser] = useGetCurrentUserLazyQuery();
|
||||||
|
|||||||
@ -8,10 +8,10 @@ import { unified } from 'unified';
|
|||||||
import { visit } from 'unist-util-visit';
|
import { visit } from 'unist-util-visit';
|
||||||
|
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
|
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type ReleaseNote = {
|
type ReleaseNote = {
|
||||||
slug: string;
|
slug: string;
|
||||||
@ -112,7 +112,7 @@ export const Releases = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>Workspace</Trans>,
|
children: <Trans>Workspace</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: <Trans>Releases</Trans> },
|
{ children: <Trans>Releases</Trans> },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -14,7 +14,6 @@ import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
|||||||
import { SettingsBillingCoverImage } from '@/billing/components/SettingsBillingCoverImage';
|
import { SettingsBillingCoverImage } from '@/billing/components/SettingsBillingCoverImage';
|
||||||
import { useOnboardingStatus } from '@/onboarding/hooks/useOnboardingStatus';
|
import { useOnboardingStatus } from '@/onboarding/hooks/useOnboardingStatus';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
@ -28,6 +27,7 @@ import {
|
|||||||
useUpdateBillingSubscriptionMutation,
|
useUpdateBillingSubscriptionMutation,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type SwitchInfo = {
|
type SwitchInfo = {
|
||||||
newInterval: SubscriptionInterval;
|
newInterval: SubscriptionInterval;
|
||||||
@ -130,7 +130,7 @@ export const SettingsBilling = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>Workspace</Trans>,
|
children: <Trans>Workspace</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: <Trans>Billing</Trans> },
|
{ children: <Trans>Billing</Trans> },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -7,9 +7,9 @@ import { DeleteAccount } from '@/settings/profile/components/DeleteAccount';
|
|||||||
import { EmailField } from '@/settings/profile/components/EmailField';
|
import { EmailField } from '@/settings/profile/components/EmailField';
|
||||||
import { NameFields } from '@/settings/profile/components/NameFields';
|
import { NameFields } from '@/settings/profile/components/NameFields';
|
||||||
import { ProfilePictureUploader } from '@/settings/profile/components/ProfilePictureUploader';
|
import { ProfilePictureUploader } from '@/settings/profile/components/ProfilePictureUploader';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsProfile = () => {
|
export const SettingsProfile = () => {
|
||||||
const { t } = useLingui();
|
const { t } = useLingui();
|
||||||
@ -20,7 +20,7 @@ export const SettingsProfile = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>User</Trans>,
|
children: <Trans>User</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.ProfilePage),
|
href: getSettingsPath(SettingsPath.ProfilePage),
|
||||||
},
|
},
|
||||||
{ children: <Trans>Profile</Trans> },
|
{ children: <Trans>Profile</Trans> },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -12,12 +12,12 @@ import { isMultiWorkspaceEnabledState } from '@/client-config/states/isMultiWork
|
|||||||
import { SettingsCard } from '@/settings/components/SettingsCard';
|
import { SettingsCard } from '@/settings/components/SettingsCard';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { DeleteWorkspace } from '@/settings/profile/components/DeleteWorkspace';
|
import { DeleteWorkspace } from '@/settings/profile/components/DeleteWorkspace';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { NameField } from '@/settings/workspace/components/NameField';
|
import { NameField } from '@/settings/workspace/components/NameField';
|
||||||
import { ToggleImpersonate } from '@/settings/workspace/components/ToggleImpersonate';
|
import { ToggleImpersonate } from '@/settings/workspace/components/ToggleImpersonate';
|
||||||
import { WorkspaceLogoUploader } from '@/settings/workspace/components/WorkspaceLogoUploader';
|
import { WorkspaceLogoUploader } from '@/settings/workspace/components/WorkspaceLogoUploader';
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import packageJson from '../../../package.json';
|
import packageJson from '../../../package.json';
|
||||||
|
|
||||||
export const SettingsWorkspace = () => {
|
export const SettingsWorkspace = () => {
|
||||||
@ -30,7 +30,7 @@ export const SettingsWorkspace = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: t`Workspace`,
|
children: t`Workspace`,
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: t`General` },
|
{ children: t`General` },
|
||||||
]}
|
]}
|
||||||
@ -51,7 +51,7 @@ export const SettingsWorkspace = () => {
|
|||||||
title={t`Domain`}
|
title={t`Domain`}
|
||||||
description={t`Edit your subdomain name or set a custom domain.`}
|
description={t`Edit your subdomain name or set a custom domain.`}
|
||||||
/>
|
/>
|
||||||
<UndecoratedLink to={getSettingsPagePath(SettingsPath.Domain)}>
|
<UndecoratedLink to={getSettingsPath(SettingsPath.Domain)}>
|
||||||
<SettingsCard
|
<SettingsCard
|
||||||
title={t`Customize Domain`}
|
title={t`Customize Domain`}
|
||||||
Icon={<IconWorld />}
|
Icon={<IconWorld />}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
|
|||||||
import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord';
|
import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord';
|
||||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
@ -37,6 +36,7 @@ import { WorkspaceInviteTeam } from '@/workspace/components/WorkspaceInviteTeam'
|
|||||||
import { formatDistanceToNow } from 'date-fns';
|
import { formatDistanceToNow } from 'date-fns';
|
||||||
import { useGetWorkspaceInvitationsQuery } from '~/generated/graphql';
|
import { useGetWorkspaceInvitationsQuery } from '~/generated/graphql';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import { TableCell } from '../../modules/ui/layout/table/components/TableCell';
|
import { TableCell } from '../../modules/ui/layout/table/components/TableCell';
|
||||||
import { TableRow } from '../../modules/ui/layout/table/components/TableRow';
|
import { TableRow } from '../../modules/ui/layout/table/components/TableRow';
|
||||||
import { useDeleteWorkspaceInvitation } from '../../modules/workspace-invitation/hooks/useDeleteWorkspaceInvitation';
|
import { useDeleteWorkspaceInvitation } from '../../modules/workspace-invitation/hooks/useDeleteWorkspaceInvitation';
|
||||||
@ -144,7 +144,7 @@ export const SettingsWorkspaceMembers = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>Workspace</Trans>,
|
children: <Trans>Workspace</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: <Trans>Members</Trans> },
|
{ children: <Trans>Members</Trans> },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { within } from '@storybook/test';
|
import { within } from '@storybook/test';
|
||||||
|
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import {
|
import {
|
||||||
PageDecorator,
|
PageDecorator,
|
||||||
@ -10,13 +9,14 @@ import {
|
|||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
import { sleep } from '~/utils/sleep';
|
import { sleep } from '~/utils/sleep';
|
||||||
|
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import { SettingsBilling } from '../SettingsBilling';
|
import { SettingsBilling } from '../SettingsBilling';
|
||||||
|
|
||||||
const meta: Meta<PageDecoratorArgs> = {
|
const meta: Meta<PageDecoratorArgs> = {
|
||||||
title: 'Pages/Settings/SettingsBilling',
|
title: 'Pages/Settings/SettingsBilling',
|
||||||
component: SettingsBilling,
|
component: SettingsBilling,
|
||||||
decorators: [PageDecorator],
|
decorators: [PageDecorator],
|
||||||
args: { routePath: getSettingsPagePath(SettingsPath.Billing) },
|
args: { routePath: getSettingsPath(SettingsPath.Billing) },
|
||||||
parameters: {
|
parameters: {
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -12,9 +12,9 @@ import { SettingsAccountsBlocklistSection } from '@/settings/accounts/components
|
|||||||
import { SettingsAccountsConnectedAccountsListCard } from '@/settings/accounts/components/SettingsAccountsConnectedAccountsListCard';
|
import { SettingsAccountsConnectedAccountsListCard } from '@/settings/accounts/components/SettingsAccountsConnectedAccountsListCard';
|
||||||
import { SettingsAccountsSettingsSection } from '@/settings/accounts/components/SettingsAccountsSettingsSection';
|
import { SettingsAccountsSettingsSection } from '@/settings/accounts/components/SettingsAccountsSettingsSection';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsAccounts = () => {
|
export const SettingsAccounts = () => {
|
||||||
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
|
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
|
||||||
@ -39,7 +39,7 @@ export const SettingsAccounts = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'User',
|
children: 'User',
|
||||||
href: getSettingsPagePath(SettingsPath.ProfilePage),
|
href: getSettingsPath(SettingsPath.ProfilePage),
|
||||||
},
|
},
|
||||||
{ children: 'Account' },
|
{ children: 'Account' },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { SettingsAccountsCalendarChannelsContainer } from '@/settings/accounts/components/SettingsAccountsCalendarChannelsContainer';
|
import { SettingsAccountsCalendarChannelsContainer } from '@/settings/accounts/components/SettingsAccountsCalendarChannelsContainer';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { Trans, useLingui } from '@lingui/react/macro';
|
import { Trans, useLingui } from '@lingui/react/macro';
|
||||||
import { Section } from 'twenty-ui';
|
import { Section } from 'twenty-ui';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsAccountsCalendars = () => {
|
export const SettingsAccountsCalendars = () => {
|
||||||
const { t } = useLingui();
|
const { t } = useLingui();
|
||||||
@ -15,11 +15,11 @@ export const SettingsAccountsCalendars = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>User</Trans>,
|
children: <Trans>User</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.ProfilePage),
|
href: getSettingsPath(SettingsPath.ProfilePage),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: <Trans>Accounts</Trans>,
|
children: <Trans>Accounts</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Accounts),
|
href: getSettingsPath(SettingsPath.Accounts),
|
||||||
},
|
},
|
||||||
{ children: <Trans>Calendars</Trans> },
|
{ children: <Trans>Calendars</Trans> },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { SettingsAccountsMessageChannelsContainer } from '@/settings/accounts/components/SettingsAccountsMessageChannelsContainer';
|
import { SettingsAccountsMessageChannelsContainer } from '@/settings/accounts/components/SettingsAccountsMessageChannelsContainer';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { Section } from 'twenty-ui';
|
import { Section } from 'twenty-ui';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsAccountsEmails = () => (
|
export const SettingsAccountsEmails = () => (
|
||||||
<SubMenuTopBarContainer
|
<SubMenuTopBarContainer
|
||||||
@ -11,11 +11,11 @@ export const SettingsAccountsEmails = () => (
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'User',
|
children: 'User',
|
||||||
href: getSettingsPagePath(SettingsPath.ProfilePage),
|
href: getSettingsPath(SettingsPath.ProfilePage),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Accounts',
|
children: 'Accounts',
|
||||||
href: getSettingsPagePath(SettingsPath.Accounts),
|
href: getSettingsPath(SettingsPath.Accounts),
|
||||||
},
|
},
|
||||||
{ children: 'Emails' },
|
{ children: 'Emails' },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { SettingsNewAccountSection } from '@/settings/accounts/components/SettingsNewAccountSection';
|
import { SettingsNewAccountSection } from '@/settings/accounts/components/SettingsNewAccountSection';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsNewAccount = () => {
|
export const SettingsNewAccount = () => {
|
||||||
return (
|
return (
|
||||||
@ -11,11 +11,11 @@ export const SettingsNewAccount = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'User',
|
children: 'User',
|
||||||
href: getSettingsPagePath(SettingsPath.ProfilePage),
|
href: getSettingsPath(SettingsPath.ProfilePage),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Accounts',
|
children: 'Accounts',
|
||||||
href: getSettingsPagePath(SettingsPath.Accounts),
|
href: getSettingsPath(SettingsPath.Accounts),
|
||||||
},
|
},
|
||||||
{ children: `New` },
|
{ children: `New` },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
|
import { SettingsAdminContent } from '@/settings/admin-panel/components/SettingsAdminContent';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { SettingsAdminContent } from '@/settings/admin-panel/components/SettingsAdminContent';
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsAdmin = () => {
|
export const SettingsAdmin = () => {
|
||||||
return (
|
return (
|
||||||
@ -11,7 +11,7 @@ export const SettingsAdmin = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Other',
|
children: 'Other',
|
||||||
href: getSettingsPagePath(SettingsPath.AdminPanel),
|
href: getSettingsPath(SettingsPath.AdminPanel),
|
||||||
},
|
},
|
||||||
{ children: 'Server Admin Panel' },
|
{ children: 'Server Admin Panel' },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
// @ts-expect-error external library has a typing issue
|
|
||||||
import { RevertConnect } from '@revertdotdev/revert-react';
|
|
||||||
|
|
||||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
|
||||||
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
|
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
|
||||||
import { SettingsReadDocumentationButton } from '@/settings/developers/components/SettingsReadDocumentationButton';
|
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
|
||||||
import { Trans, useLingui } from '@lingui/react/macro';
|
|
||||||
import { useRecoilValue } from 'recoil';
|
|
||||||
import { Section } from 'twenty-ui';
|
|
||||||
|
|
||||||
const REVERT_PUBLIC_KEY = 'pk_live_a87fee8c-28c7-494f-99a3-996ff89f9918';
|
|
||||||
|
|
||||||
export const SettingsCRMMigration = () => {
|
|
||||||
const { t } = useLingui();
|
|
||||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
|
||||||
return (
|
|
||||||
<SubMenuTopBarContainer
|
|
||||||
title={t`Migrate`}
|
|
||||||
links={[
|
|
||||||
{
|
|
||||||
children: <Trans>Workspace</Trans>,
|
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
|
||||||
},
|
|
||||||
{ children: <Trans>Migrate</Trans> },
|
|
||||||
]}
|
|
||||||
actionButton={<SettingsReadDocumentationButton />}
|
|
||||||
>
|
|
||||||
<SettingsPageContainer>
|
|
||||||
<SettingsHeaderContainer></SettingsHeaderContainer>
|
|
||||||
<Section>
|
|
||||||
<RevertConnect
|
|
||||||
config={{
|
|
||||||
revertToken: REVERT_PUBLIC_KEY,
|
|
||||||
tenantId: currentWorkspace?.id,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Section>
|
|
||||||
</SettingsPageContainer>
|
|
||||||
</SubMenuTopBarContainer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { Trans, useLingui } from '@lingui/react/macro';
|
import { Trans, useLingui } from '@lingui/react/macro';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { H2Title, Section } from 'twenty-ui';
|
import { H2Title, Section } from 'twenty-ui';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
@ -13,18 +12,19 @@ import {
|
|||||||
settingsDataModelObjectAboutFormSchema,
|
settingsDataModelObjectAboutFormSchema,
|
||||||
} from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm';
|
} from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm';
|
||||||
import { settingsCreateObjectInputSchema } from '@/settings/data-model/validation-schemas/settingsCreateObjectInputSchema';
|
import { settingsCreateObjectInputSchema } from '@/settings/data-model/validation-schemas/settingsCreateObjectInputSchema';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const newObjectFormSchema = settingsDataModelObjectAboutFormSchema;
|
const newObjectFormSchema = settingsDataModelObjectAboutFormSchema;
|
||||||
|
|
||||||
type SettingsDataModelNewObjectFormValues = z.infer<typeof newObjectFormSchema>;
|
type SettingsDataModelNewObjectFormValues = z.infer<typeof newObjectFormSchema>;
|
||||||
|
|
||||||
export const SettingsNewObject = () => {
|
export const SettingsNewObject = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const { t } = useLingui();
|
const { t } = useLingui();
|
||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export const SettingsNewObject = () => {
|
|||||||
variant: SnackBarVariant.Success,
|
variant: SnackBarVariant.Success,
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate(getSettingsPagePath(SettingsPath.Objects));
|
navigate(SettingsPath.Objects);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof z.ZodError) {
|
if (error instanceof z.ZodError) {
|
||||||
enqueueSnackBar(t`Invalid object data`, {
|
enqueueSnackBar(t`Invalid object data`, {
|
||||||
@ -68,11 +68,11 @@ export const SettingsNewObject = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>Workspace</Trans>,
|
children: <Trans>Workspace</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: <Trans>Objects</Trans>,
|
children: <Trans>Objects</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Objects),
|
href: getSettingsPath(SettingsPath.Objects),
|
||||||
},
|
},
|
||||||
{ children: <Trans>New</Trans> },
|
{ children: <Trans>New</Trans> },
|
||||||
]}
|
]}
|
||||||
@ -89,9 +89,7 @@ export const SettingsNewObject = () => {
|
|||||||
<SettingsDataModelObjectAboutForm />
|
<SettingsDataModelObjectAboutForm />
|
||||||
</Section>
|
</Section>
|
||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
onCancel={() =>
|
onCancel={() => navigate(SettingsPath.Objects)}
|
||||||
navigate(getSettingsPagePath(SettingsPath.Objects))
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
@ -8,7 +8,6 @@ import { ObjectIndexes } from '@/settings/data-model/object-details/components/t
|
|||||||
import { ObjectSettings } from '@/settings/data-model/object-details/components/tabs/ObjectSettings';
|
import { ObjectSettings } from '@/settings/data-model/object-details/components/tabs/ObjectSettings';
|
||||||
import { SettingsDataModelObjectTypeTag } from '@/settings/data-model/objects/components/SettingsDataModelObjectTypeTag';
|
import { SettingsDataModelObjectTypeTag } from '@/settings/data-model/objects/components/SettingsDataModelObjectTypeTag';
|
||||||
import { getObjectTypeLabel } from '@/settings/data-model/utils/getObjectTypeLabel';
|
import { getObjectTypeLabel } from '@/settings/data-model/utils/getObjectTypeLabel';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
@ -31,8 +30,10 @@ import {
|
|||||||
isDefined,
|
isDefined,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
import { FeatureFlagKey } from '~/generated/graphql';
|
import { FeatureFlagKey } from '~/generated/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
import { SETTINGS_OBJECT_DETAIL_TABS } from '~/pages/settings/data-model/constants/SettingsObjectDetailTabs';
|
import { SETTINGS_OBJECT_DETAIL_TABS } from '~/pages/settings/data-model/constants/SettingsObjectDetailTabs';
|
||||||
import { updatedObjectNamePluralState } from '~/pages/settings/data-model/states/updatedObjectNamePluralState';
|
import { updatedObjectNamePluralState } from '~/pages/settings/data-model/states/updatedObjectNamePluralState';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const StyledContentContainer = styled.div`
|
const StyledContentContainer = styled.div`
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -51,7 +52,7 @@ const StyledTitleContainer = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const SettingsObjectDetailPage = () => {
|
export const SettingsObjectDetailPage = () => {
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const { objectNamePlural = '' } = useParams();
|
const { objectNamePlural = '' } = useParams();
|
||||||
const { findActiveObjectMetadataItemByNamePlural } =
|
const { findActiveObjectMetadataItemByNamePlural } =
|
||||||
@ -76,10 +77,10 @@ export const SettingsObjectDetailPage = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (objectNamePlural === updatedObjectNamePlural)
|
if (objectNamePlural === updatedObjectNamePlural)
|
||||||
setUpdatedObjectNamePlural('');
|
setUpdatedObjectNamePlural('');
|
||||||
if (!isDefined(objectMetadataItem)) navigate(AppPath.NotFound);
|
if (!isDefined(objectMetadataItem)) navigateApp(AppPath.NotFound);
|
||||||
}, [
|
}, [
|
||||||
objectMetadataItem,
|
objectMetadataItem,
|
||||||
navigate,
|
navigateApp,
|
||||||
objectNamePlural,
|
objectNamePlural,
|
||||||
updatedObjectNamePlural,
|
updatedObjectNamePlural,
|
||||||
setUpdatedObjectNamePlural,
|
setUpdatedObjectNamePlural,
|
||||||
@ -142,9 +143,9 @@ export const SettingsObjectDetailPage = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: getSettingsPath(SettingsPath.Objects) },
|
||||||
{
|
{
|
||||||
children: objectMetadataItem.labelPlural,
|
children: objectMetadataItem.labelPlural,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import omit from 'lodash.omit';
|
|||||||
import pick from 'lodash.pick';
|
import pick from 'lodash.pick';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
H2Title,
|
H2Title,
|
||||||
@ -28,14 +28,16 @@ import { SettingsDataModelFieldIconLabelForm } from '@/settings/data-model/field
|
|||||||
import { SettingsDataModelFieldSettingsFormCard } from '@/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard';
|
import { SettingsDataModelFieldSettingsFormCard } from '@/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard';
|
||||||
import { settingsFieldFormSchema } from '@/settings/data-model/fields/forms/validation-schemas/settingsFieldFormSchema';
|
import { settingsFieldFormSchema } from '@/settings/data-model/fields/forms/validation-schemas/settingsFieldFormSchema';
|
||||||
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
//TODO: fix this type
|
//TODO: fix this type
|
||||||
type SettingsDataModelFieldEditFormValues = z.infer<
|
type SettingsDataModelFieldEditFormValues = z.infer<
|
||||||
@ -44,7 +46,9 @@ type SettingsDataModelFieldEditFormValues = z.infer<
|
|||||||
any;
|
any;
|
||||||
|
|
||||||
export const SettingsObjectFieldEdit = () => {
|
export const SettingsObjectFieldEdit = () => {
|
||||||
const navigate = useNavigate();
|
const navigateSettings = useNavigateSettings();
|
||||||
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
|
|
||||||
const { objectNamePlural = '', fieldName = '' } = useParams();
|
const { objectNamePlural = '', fieldName = '' } = useParams();
|
||||||
@ -78,9 +82,9 @@ export const SettingsObjectFieldEdit = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!objectMetadataItem || !fieldMetadataItem) {
|
if (!objectMetadataItem || !fieldMetadataItem) {
|
||||||
navigate(AppPath.NotFound);
|
navigateApp(AppPath.NotFound);
|
||||||
}
|
}
|
||||||
}, [navigate, objectMetadataItem, fieldMetadataItem]);
|
}, [navigateApp, objectMetadataItem, fieldMetadataItem]);
|
||||||
|
|
||||||
const { isDirty, isValid, isSubmitting } = formConfig.formState;
|
const { isDirty, isValid, isSubmitting } = formConfig.formState;
|
||||||
const canSave = isDirty && isValid && !isSubmitting;
|
const canSave = isDirty && isValid && !isSubmitting;
|
||||||
@ -127,7 +131,9 @@ export const SettingsObjectFieldEdit = () => {
|
|||||||
Object.keys(otherDirtyFields),
|
Object.keys(otherDirtyFields),
|
||||||
);
|
);
|
||||||
|
|
||||||
navigate(`/settings/objects/${objectNamePlural}`);
|
navigateSettings(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
});
|
||||||
|
|
||||||
await updateOneFieldMetadataItem({
|
await updateOneFieldMetadataItem({
|
||||||
objectMetadataId: objectMetadataItem.id,
|
objectMetadataId: objectMetadataItem.id,
|
||||||
@ -144,12 +150,16 @@ export const SettingsObjectFieldEdit = () => {
|
|||||||
|
|
||||||
const handleDeactivate = async () => {
|
const handleDeactivate = async () => {
|
||||||
await deactivateMetadataField(fieldMetadataItem.id, objectMetadataItem.id);
|
await deactivateMetadataField(fieldMetadataItem.id, objectMetadataItem.id);
|
||||||
navigate(`/settings/objects/${objectNamePlural}`);
|
navigateSettings(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleActivate = async () => {
|
const handleActivate = async () => {
|
||||||
await activateMetadataField(fieldMetadataItem.id, objectMetadataItem.id);
|
await activateMetadataField(fieldMetadataItem.id, objectMetadataItem.id);
|
||||||
navigate(`/settings/objects/${objectNamePlural}`);
|
navigateSettings(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -161,15 +171,17 @@ export const SettingsObjectFieldEdit = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Objects',
|
children: 'Objects',
|
||||||
href: '/settings/objects',
|
href: getSettingsPath(SettingsPath.Objects),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: objectMetadataItem.labelPlural,
|
children: objectMetadataItem.labelPlural,
|
||||||
href: `/settings/objects/${objectNamePlural}`,
|
href: getSettingsPath(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: fieldMetadataItem.label,
|
children: fieldMetadataItem.label,
|
||||||
@ -179,7 +191,11 @@ export const SettingsObjectFieldEdit = () => {
|
|||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled={!canSave}
|
isSaveDisabled={!canSave}
|
||||||
isCancelDisabled={isSubmitting}
|
isCancelDisabled={isSubmitting}
|
||||||
onCancel={() => navigate(`/settings/objects/${objectNamePlural}`)}
|
onCancel={() =>
|
||||||
|
navigateSettings(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
})
|
||||||
|
}
|
||||||
onSave={formConfig.handleSubmit(handleSave)}
|
onSave={formConfig.handleSubmit(handleSave)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { SettingsDataModelFieldSettingsFormCard } from '@/settings/data-model/fi
|
|||||||
import { settingsFieldFormSchema } from '@/settings/data-model/fields/forms/validation-schemas/settingsFieldFormSchema';
|
import { settingsFieldFormSchema } from '@/settings/data-model/fields/forms/validation-schemas/settingsFieldFormSchema';
|
||||||
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
@ -24,13 +25,16 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|||||||
import pick from 'lodash.pick';
|
import pick from 'lodash.pick';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
import { useParams, useSearchParams } from 'react-router-dom';
|
||||||
import { H2Title, Section } from 'twenty-ui';
|
import { H2Title, Section } from 'twenty-ui';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { DEFAULT_ICONS_BY_FIELD_TYPE } from '~/pages/settings/data-model/constants/DefaultIconsByFieldType';
|
import { DEFAULT_ICONS_BY_FIELD_TYPE } from '~/pages/settings/data-model/constants/DefaultIconsByFieldType';
|
||||||
import { computeMetadataNameFromLabel } from '~/pages/settings/data-model/utils/compute-metadata-name-from-label.utils';
|
import { computeMetadataNameFromLabel } from '~/pages/settings/data-model/utils/compute-metadata-name-from-label.utils';
|
||||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type SettingsDataModelNewFieldFormValues = z.infer<
|
type SettingsDataModelNewFieldFormValues = z.infer<
|
||||||
ReturnType<typeof settingsFieldFormSchema>
|
ReturnType<typeof settingsFieldFormSchema>
|
||||||
@ -40,7 +44,9 @@ type SettingsDataModelNewFieldFormValues = z.infer<
|
|||||||
const DEFAULT_ICON_FOR_NEW_FIELD = 'IconUsers';
|
const DEFAULT_ICON_FOR_NEW_FIELD = 'IconUsers';
|
||||||
|
|
||||||
export const SettingsObjectNewFieldConfigure = () => {
|
export const SettingsObjectNewFieldConfigure = () => {
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
const { objectNamePlural = '' } = useParams();
|
const { objectNamePlural = '' } = useParams();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const fieldType =
|
const fieldType =
|
||||||
@ -115,9 +121,9 @@ export const SettingsObjectNewFieldConfigure = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!activeObjectMetadataItem) {
|
if (!activeObjectMetadataItem) {
|
||||||
navigate(AppPath.NotFound);
|
navigateApp(AppPath.NotFound);
|
||||||
}
|
}
|
||||||
}, [activeObjectMetadataItem, navigate]);
|
}, [activeObjectMetadataItem, navigateApp]);
|
||||||
|
|
||||||
if (!activeObjectMetadataItem) return null;
|
if (!activeObjectMetadataItem) return null;
|
||||||
|
|
||||||
@ -163,7 +169,9 @@ export const SettingsObjectNewFieldConfigure = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(`/settings/objects/${objectNamePlural}`);
|
navigate(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: fix optimistic update logic
|
// TODO: fix optimistic update logic
|
||||||
// Forcing a refetch for now but it's not ideal
|
// Forcing a refetch for now but it's not ideal
|
||||||
@ -190,7 +198,9 @@ export const SettingsObjectNewFieldConfigure = () => {
|
|||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
{
|
{
|
||||||
children: activeObjectMetadataItem.labelPlural,
|
children: activeObjectMetadataItem.labelPlural,
|
||||||
href: `/settings/objects/${objectNamePlural}`,
|
href: getSettingsPath(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
{ children: <SettingsDataModelNewFieldBreadcrumbDropDown /> },
|
{ children: <SettingsDataModelNewFieldBreadcrumbDropDown /> },
|
||||||
@ -201,7 +211,13 @@ export const SettingsObjectNewFieldConfigure = () => {
|
|||||||
isCancelDisabled={isSubmitting}
|
isCancelDisabled={isSubmitting}
|
||||||
onCancel={() =>
|
onCancel={() =>
|
||||||
navigate(
|
navigate(
|
||||||
`/settings/objects/${objectNamePlural}/new-field/select?fieldType=${fieldType}`,
|
SettingsPath.ObjectNewFieldSelect,
|
||||||
|
{
|
||||||
|
objectNamePlural,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldType,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
onSave={formConfig.handleSubmit(handleSave)}
|
onSave={formConfig.handleSubmit(handleSave)}
|
||||||
|
|||||||
@ -6,14 +6,17 @@ import { SETTINGS_FIELD_TYPE_CONFIGS } from '@/settings/data-model/constants/Set
|
|||||||
import { SettingsObjectNewFieldSelector } from '@/settings/data-model/fields/forms/components/SettingsObjectNewFieldSelector';
|
import { SettingsObjectNewFieldSelector } from '@/settings/data-model/fields/forms/components/SettingsObjectNewFieldSelector';
|
||||||
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const settingsDataModelFieldTypeFormSchema = z.object({
|
export const settingsDataModelFieldTypeFormSchema = z.object({
|
||||||
type: z.enum(
|
type: z.enum(
|
||||||
@ -29,7 +32,7 @@ export type SettingsDataModelFieldTypeFormValues = z.infer<
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
export const SettingsObjectNewFieldSelect = () => {
|
export const SettingsObjectNewFieldSelect = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateApp();
|
||||||
const { objectNamePlural = '' } = useParams();
|
const { objectNamePlural = '' } = useParams();
|
||||||
const { findActiveObjectMetadataItemByNamePlural } =
|
const { findActiveObjectMetadataItemByNamePlural } =
|
||||||
useFilteredObjectMetadataItems();
|
useFilteredObjectMetadataItems();
|
||||||
@ -69,7 +72,9 @@ export const SettingsObjectNewFieldSelect = () => {
|
|||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
{
|
{
|
||||||
children: activeObjectMetadataItem.labelPlural,
|
children: activeObjectMetadataItem.labelPlural,
|
||||||
href: `/settings/objects/${objectNamePlural}`,
|
href: getSettingsPath(SettingsPath.ObjectDetail, {
|
||||||
|
objectNamePlural,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
{ children: <SettingsDataModelNewFieldBreadcrumbDropDown /> },
|
{ children: <SettingsDataModelNewFieldBreadcrumbDropDown /> },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { ReactFlowProvider } from '@xyflow/react';
|
import { ReactFlowProvider } from '@xyflow/react';
|
||||||
|
|
||||||
import { SettingsDataModelOverview } from '@/settings/data-model/graph-overview/components/SettingsDataModelOverview';
|
import { SettingsDataModelOverview } from '@/settings/data-model/graph-overview/components/SettingsDataModelOverview';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsObjectOverview = () => {
|
export const SettingsObjectOverview = () => {
|
||||||
return (
|
return (
|
||||||
@ -11,7 +11,7 @@ export const SettingsObjectOverview = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import {
|
|||||||
import { SettingsObjectCoverImage } from '@/settings/data-model/objects/components/SettingsObjectCoverImage';
|
import { SettingsObjectCoverImage } from '@/settings/data-model/objects/components/SettingsObjectCoverImage';
|
||||||
import { SettingsObjectInactiveMenuDropDown } from '@/settings/data-model/objects/components/SettingsObjectInactiveMenuDropDown';
|
import { SettingsObjectInactiveMenuDropDown } from '@/settings/data-model/objects/components/SettingsObjectInactiveMenuDropDown';
|
||||||
import { getObjectTypeLabel } from '@/settings/data-model/utils/getObjectTypeLabel';
|
import { getObjectTypeLabel } from '@/settings/data-model/utils/getObjectTypeLabel';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { TextInput } from '@/ui/input/components/TextInput';
|
import { TextInput } from '@/ui/input/components/TextInput';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
@ -35,6 +34,7 @@ import {
|
|||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
import { GET_SETTINGS_OBJECT_TABLE_METADATA } from '~/pages/settings/data-model/constants/SettingsObjectTableMetadata';
|
import { GET_SETTINGS_OBJECT_TABLE_METADATA } from '~/pages/settings/data-model/constants/SettingsObjectTableMetadata';
|
||||||
import { SettingsObjectTableItem } from '~/pages/settings/data-model/types/SettingsObjectTableItem';
|
import { SettingsObjectTableItem } from '~/pages/settings/data-model/types/SettingsObjectTableItem';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const StyledIconChevronRight = styled(IconChevronRight)`
|
const StyledIconChevronRight = styled(IconChevronRight)`
|
||||||
color: ${({ theme }) => theme.font.color.tertiary};
|
color: ${({ theme }) => theme.font.color.tertiary};
|
||||||
@ -143,7 +143,7 @@ export const SettingsObjects = () => {
|
|||||||
<SubMenuTopBarContainer
|
<SubMenuTopBarContainer
|
||||||
title={t`Data model`}
|
title={t`Data model`}
|
||||||
actionButton={
|
actionButton={
|
||||||
<UndecoratedLink to={getSettingsPagePath(SettingsPath.NewObject)}>
|
<UndecoratedLink to={getSettingsPath(SettingsPath.NewObject)}>
|
||||||
<Button
|
<Button
|
||||||
Icon={IconPlus}
|
Icon={IconPlus}
|
||||||
title={t`Add object`}
|
title={t`Add object`}
|
||||||
@ -155,7 +155,7 @@ export const SettingsObjects = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>Workspace</Trans>,
|
children: <Trans>Workspace</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: <Trans>Objects</Trans> },
|
{ children: <Trans>Objects</Trans> },
|
||||||
]}
|
]}
|
||||||
@ -205,9 +205,10 @@ export const SettingsObjects = () => {
|
|||||||
stroke={theme.icon.stroke.sm}
|
stroke={theme.icon.stroke.sm}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
link={`/settings/objects/${
|
link={getSettingsPath(SettingsPath.ObjectDetail, {
|
||||||
objectSettingsItem.objectMetadataItem.namePlural
|
objectNamePlural:
|
||||||
}`}
|
objectSettingsItem.objectMetadataItem.namePlural,
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -2,13 +2,13 @@ import { SettingsPageContainer } from '@/settings/components/SettingsPageContain
|
|||||||
import { SettingsApiKeysTable } from '@/settings/developers/components/SettingsApiKeysTable';
|
import { SettingsApiKeysTable } from '@/settings/developers/components/SettingsApiKeysTable';
|
||||||
import { SettingsReadDocumentationButton } from '@/settings/developers/components/SettingsReadDocumentationButton';
|
import { SettingsReadDocumentationButton } from '@/settings/developers/components/SettingsReadDocumentationButton';
|
||||||
import { SettingsWebhooksTable } from '@/settings/developers/components/SettingsWebhooksTable';
|
import { SettingsWebhooksTable } from '@/settings/developers/components/SettingsWebhooksTable';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Trans, useLingui } from '@lingui/react/macro';
|
import { Trans, useLingui } from '@lingui/react/macro';
|
||||||
import { Button, H2Title, IconPlus, MOBILE_VIEWPORT, Section } from 'twenty-ui';
|
import { Button, H2Title, IconPlus, MOBILE_VIEWPORT, Section } from 'twenty-ui';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const StyledButtonContainer = styled.div`
|
const StyledButtonContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -37,7 +37,7 @@ export const SettingsDevelopers = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: <Trans>Workspace</Trans>,
|
children: <Trans>Workspace</Trans>,
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{ children: <Trans>Developers</Trans> },
|
{ children: <Trans>Developers</Trans> },
|
||||||
]}
|
]}
|
||||||
@ -56,7 +56,7 @@ export const SettingsDevelopers = () => {
|
|||||||
title={t`Create API key`}
|
title={t`Create API key`}
|
||||||
size="small"
|
size="small"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
to={'/settings/developers/api-keys/new'}
|
to={getSettingsPath(SettingsPath.DevelopersNewApiKey)}
|
||||||
/>
|
/>
|
||||||
</StyledButtonContainer>
|
</StyledButtonContainer>
|
||||||
</Section>
|
</Section>
|
||||||
@ -72,7 +72,7 @@ export const SettingsDevelopers = () => {
|
|||||||
title={t`Create Webhook`}
|
title={t`Create Webhook`}
|
||||||
size="small"
|
size="small"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
to={'/settings/developers/webhooks/new'}
|
to={getSettingsPath(SettingsPath.DevelopersNewWebhook)}
|
||||||
/>
|
/>
|
||||||
</StyledButtonContainer>
|
</StyledButtonContainer>
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { userEvent, within } from '@storybook/test';
|
import { userEvent, within } from '@storybook/test';
|
||||||
|
|
||||||
@ -7,12 +8,13 @@ import {
|
|||||||
PageDecoratorArgs,
|
PageDecoratorArgs,
|
||||||
} from '~/testing/decorators/PageDecorator';
|
} from '~/testing/decorators/PageDecorator';
|
||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const meta: Meta<PageDecoratorArgs> = {
|
const meta: Meta<PageDecoratorArgs> = {
|
||||||
title: 'Pages/Settings/Developers/ApiKeys/SettingsDevelopersApiKeysNew',
|
title: 'Pages/Settings/Developers/ApiKeys/SettingsDevelopersApiKeysNew',
|
||||||
component: SettingsDevelopersApiKeysNew,
|
component: SettingsDevelopersApiKeysNew,
|
||||||
decorators: [PageDecorator],
|
decorators: [PageDecorator],
|
||||||
args: { routePath: '/settings/developers/api-keys/new' },
|
args: { routePath: getSettingsPath(SettingsPath.DevelopersNewApiKey) },
|
||||||
parameters: {
|
parameters: {
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import styled from '@emotion/styled';
|
|||||||
import { isNonEmptyString } from '@sniptt/guards';
|
import { isNonEmptyString } from '@sniptt/guards';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
import { Button, H2Title, IconRepeat, IconTrash, Section } from 'twenty-ui';
|
import { Button, H2Title, IconRepeat, IconTrash, Section } from 'twenty-ui';
|
||||||
|
|
||||||
@ -17,7 +17,6 @@ import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTo
|
|||||||
import { ApiKey } from '@/settings/developers/types/api-key/ApiKey';
|
import { ApiKey } from '@/settings/developers/types/api-key/ApiKey';
|
||||||
import { computeNewExpirationDate } from '@/settings/developers/utils/computeNewExpirationDate';
|
import { computeNewExpirationDate } from '@/settings/developers/utils/computeNewExpirationDate';
|
||||||
import { formatExpiration } from '@/settings/developers/utils/formatExpiration';
|
import { formatExpiration } from '@/settings/developers/utils/formatExpiration';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
@ -25,6 +24,8 @@ import { TextInput } from '@/ui/input/components/TextInput';
|
|||||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { useGenerateApiKeyTokenMutation } from '~/generated/graphql';
|
import { useGenerateApiKeyTokenMutation } from '~/generated/graphql';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const StyledInfo = styled.span`
|
const StyledInfo = styled.span`
|
||||||
color: ${({ theme }) => theme.font.color.light};
|
color: ${({ theme }) => theme.font.color.light};
|
||||||
@ -47,7 +48,7 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
|||||||
const [isDeleteApiKeyModalOpen, setIsDeleteApiKeyModalOpen] = useState(false);
|
const [isDeleteApiKeyModalOpen, setIsDeleteApiKeyModalOpen] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const { apiKeyId = '' } = useParams();
|
const { apiKeyId = '' } = useParams();
|
||||||
|
|
||||||
const [apiKeyToken, setApiKeyToken] = useRecoilState(apiKeyTokenState);
|
const [apiKeyToken, setApiKeyToken] = useRecoilState(apiKeyTokenState);
|
||||||
@ -68,7 +69,6 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
|||||||
setApiKeyName(record.name);
|
setApiKeyName(record.name);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const developerPath = getSettingsPagePath(SettingsPath.Developers);
|
|
||||||
|
|
||||||
const deleteIntegration = async (redirect = true) => {
|
const deleteIntegration = async (redirect = true) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@ -79,7 +79,7 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
|||||||
updateOneRecordInput: { revokedAt: DateTime.now().toString() },
|
updateOneRecordInput: { revokedAt: DateTime.now().toString() },
|
||||||
});
|
});
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
navigate(developerPath);
|
navigate(SettingsPath.Developers);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
enqueueSnackBar(`Error deleting api key: ${err}`, {
|
enqueueSnackBar(`Error deleting api key: ${err}`, {
|
||||||
@ -114,6 +114,7 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
|||||||
token: tokenData.data?.generateApiKeyToken.token,
|
token: tokenData.data?.generateApiKeyToken.token,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const regenerateApiKey = async () => {
|
const regenerateApiKey = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
@ -127,7 +128,9 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
|||||||
|
|
||||||
if (isNonEmptyString(apiKey?.token)) {
|
if (isNonEmptyString(apiKey?.token)) {
|
||||||
setApiKeyToken(apiKey.token);
|
setApiKeyToken(apiKey.token);
|
||||||
navigate(`/settings/developers/api-keys/${apiKey.id}`);
|
navigate(SettingsPath.DevelopersApiKeyDetail, {
|
||||||
|
apiKeyId: apiKey.id,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -147,9 +150,12 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
children: 'Developers',
|
||||||
|
href: getSettingsPath(SettingsPath.Developers),
|
||||||
},
|
},
|
||||||
{ children: 'Developers', href: developerPath },
|
|
||||||
{ children: `${apiKeyName} API Key` },
|
{ children: `${apiKeyName} API Key` },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { H2Title, Section } from 'twenty-ui';
|
import { H2Title, Section } from 'twenty-ui';
|
||||||
|
|
||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
@ -10,7 +9,6 @@ import { SettingsPageContainer } from '@/settings/components/SettingsPageContain
|
|||||||
import { EXPIRATION_DATES } from '@/settings/developers/constants/ExpirationDates';
|
import { EXPIRATION_DATES } from '@/settings/developers/constants/ExpirationDates';
|
||||||
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
|
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
|
||||||
import { ApiKey } from '@/settings/developers/types/api-key/ApiKey';
|
import { ApiKey } from '@/settings/developers/types/api-key/ApiKey';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { Select } from '@/ui/input/components/Select';
|
import { Select } from '@/ui/input/components/Select';
|
||||||
import { TextInput } from '@/ui/input/components/TextInput';
|
import { TextInput } from '@/ui/input/components/TextInput';
|
||||||
@ -18,11 +16,13 @@ import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBa
|
|||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { Key } from 'ts-key-enum';
|
import { Key } from 'ts-key-enum';
|
||||||
import { useGenerateApiKeyTokenMutation } from '~/generated/graphql';
|
import { useGenerateApiKeyTokenMutation } from '~/generated/graphql';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsDevelopersApiKeysNew = () => {
|
export const SettingsDevelopersApiKeysNew = () => {
|
||||||
const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation();
|
const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation();
|
||||||
const navigate = useNavigate();
|
const navigateSettings = useNavigateSettings();
|
||||||
const setApiKeyToken = useSetRecoilState(apiKeyTokenState);
|
const setApiKeyToken = useSetRecoilState(apiKeyTokenState);
|
||||||
const [formValues, setFormValues] = useState<{
|
const [formValues, setFormValues] = useState<{
|
||||||
name: string;
|
name: string;
|
||||||
@ -58,7 +58,9 @@ export const SettingsDevelopersApiKeysNew = () => {
|
|||||||
});
|
});
|
||||||
if (isDefined(tokenData.data?.generateApiKeyToken)) {
|
if (isDefined(tokenData.data?.generateApiKeyToken)) {
|
||||||
setApiKeyToken(tokenData.data.generateApiKeyToken.token);
|
setApiKeyToken(tokenData.data.generateApiKeyToken.token);
|
||||||
navigate(`/settings/developers/api-keys/${newApiKey.id}`);
|
navigateSettings(SettingsPath.DevelopersApiKeyDetail, {
|
||||||
|
apiKeyId: newApiKey.id,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const canSave = !!formValues.name && createOneApiKey;
|
const canSave = !!formValues.name && createOneApiKey;
|
||||||
@ -68,11 +70,11 @@ export const SettingsDevelopersApiKeysNew = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Developers',
|
children: 'Developers',
|
||||||
href: getSettingsPagePath(SettingsPath.Developers),
|
href: getSettingsPath(SettingsPath.Developers),
|
||||||
},
|
},
|
||||||
{ children: 'New Key' },
|
{ children: 'New Key' },
|
||||||
]}
|
]}
|
||||||
@ -80,7 +82,7 @@ export const SettingsDevelopersApiKeysNew = () => {
|
|||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled={!canSave}
|
isSaveDisabled={!canSave}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
navigate('/settings/developers');
|
navigateSettings(SettingsPath.Developers);
|
||||||
}}
|
}}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
H2Title,
|
H2Title,
|
||||||
@ -28,7 +28,6 @@ import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
|||||||
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { Webhook } from '@/settings/developers/types/webhook/Webhook';
|
import { Webhook } from '@/settings/developers/types/webhook/Webhook';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { Select, SelectOption } from '@/ui/input/components/Select';
|
import { Select, SelectOption } from '@/ui/input/components/Select';
|
||||||
import { TextArea } from '@/ui/input/components/TextArea';
|
import { TextArea } from '@/ui/input/components/TextArea';
|
||||||
@ -38,8 +37,10 @@ import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBa
|
|||||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { FeatureFlagKey } from '~/generated/graphql';
|
import { FeatureFlagKey } from '~/generated/graphql';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
import { WEBHOOK_EMPTY_OPERATION } from '~/pages/settings/developers/webhooks/constants/WebhookEmptyOperation';
|
import { WEBHOOK_EMPTY_OPERATION } from '~/pages/settings/developers/webhooks/constants/WebhookEmptyOperation';
|
||||||
import { WebhookOperationType } from '~/pages/settings/developers/webhooks/types/WebhookOperationsType';
|
import { WebhookOperationType } from '~/pages/settings/developers/webhooks/types/WebhookOperationsType';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const OBJECT_DROPDOWN_WIDTH = 340;
|
const OBJECT_DROPDOWN_WIDTH = 340;
|
||||||
const ACTION_DROPDOWN_WIDTH = 140;
|
const ACTION_DROPDOWN_WIDTH = 140;
|
||||||
@ -66,7 +67,7 @@ export const SettingsDevelopersWebhooksDetail = () => {
|
|||||||
const { objectMetadataItems } = useObjectMetadataItems();
|
const { objectMetadataItems } = useObjectMetadataItems();
|
||||||
const isAnalyticsEnabled = useRecoilValue(isAnalyticsEnabledState);
|
const isAnalyticsEnabled = useRecoilValue(isAnalyticsEnabledState);
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
const { webhookId = '' } = useParams();
|
const { webhookId = '' } = useParams();
|
||||||
|
|
||||||
const [isDeleteWebhookModalOpen, setIsDeleteWebhookModalOpen] =
|
const [isDeleteWebhookModalOpen, setIsDeleteWebhookModalOpen] =
|
||||||
@ -108,11 +109,9 @@ export const SettingsDevelopersWebhooksDetail = () => {
|
|||||||
objectNameSingular: CoreObjectNameSingular.Webhook,
|
objectNameSingular: CoreObjectNameSingular.Webhook,
|
||||||
});
|
});
|
||||||
|
|
||||||
const developerPath = getSettingsPagePath(SettingsPath.Developers);
|
|
||||||
|
|
||||||
const deleteWebhook = () => {
|
const deleteWebhook = () => {
|
||||||
deleteOneWebhook(webhookId);
|
deleteOneWebhook(webhookId);
|
||||||
navigate(developerPath);
|
navigate(SettingsPath.Developers);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isAnalyticsV2Enabled = useIsFeatureEnabled(
|
const isAnalyticsV2Enabled = useIsFeatureEnabled(
|
||||||
@ -163,7 +162,7 @@ export const SettingsDevelopersWebhooksDetail = () => {
|
|||||||
secret: secret,
|
secret: secret,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
navigate(developerPath);
|
navigate(SettingsPath.Developers);
|
||||||
};
|
};
|
||||||
|
|
||||||
const addEmptyOperationIfNecessary = (
|
const addEmptyOperationIfNecessary = (
|
||||||
@ -210,16 +209,19 @@ export const SettingsDevelopersWebhooksDetail = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
children: 'Developers',
|
||||||
|
href: getSettingsPath(SettingsPath.Developers),
|
||||||
},
|
},
|
||||||
{ children: 'Developers', href: developerPath },
|
|
||||||
{ children: 'Webhook' },
|
{ children: 'Webhook' },
|
||||||
]}
|
]}
|
||||||
actionButton={
|
actionButton={
|
||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled={!isDirty}
|
isSaveDisabled={!isDirty}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
navigate(developerPath);
|
navigate(SettingsPath.Developers);
|
||||||
}}
|
}}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { H2Title, isDefined, Section } from 'twenty-ui';
|
import { H2Title, isDefined, Section } from 'twenty-ui';
|
||||||
|
|
||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
@ -7,14 +6,16 @@ import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
|
|||||||
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { Webhook } from '@/settings/developers/types/webhook/Webhook';
|
import { Webhook } from '@/settings/developers/types/webhook/Webhook';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { TextInput } from '@/ui/input/components/TextInput';
|
import { TextInput } from '@/ui/input/components/TextInput';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
import { isValidUrl } from '~/utils/url/isValidUrl';
|
import { isValidUrl } from '~/utils/url/isValidUrl';
|
||||||
|
|
||||||
export const SettingsDevelopersWebhooksNew = () => {
|
export const SettingsDevelopersWebhooksNew = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
|
||||||
const [formValues, setFormValues] = useState<{
|
const [formValues, setFormValues] = useState<{
|
||||||
targetUrl: string;
|
targetUrl: string;
|
||||||
operations: string[];
|
operations: string[];
|
||||||
@ -40,7 +41,9 @@ export const SettingsDevelopersWebhooksNew = () => {
|
|||||||
if (!newWebhook) {
|
if (!newWebhook) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navigate(`/settings/developers/webhooks/${newWebhook.id}`);
|
navigate(SettingsPath.DevelopersNewWebhookDetail, {
|
||||||
|
webhookId: newWebhook.id,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const canSave =
|
const canSave =
|
||||||
@ -67,11 +70,11 @@ export const SettingsDevelopersWebhooksNew = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Developers',
|
children: 'Developers',
|
||||||
href: getSettingsPagePath(SettingsPath.Developers),
|
href: getSettingsPath(SettingsPath.Developers),
|
||||||
},
|
},
|
||||||
{ children: 'New Webhook' },
|
{ children: 'New Webhook' },
|
||||||
]}
|
]}
|
||||||
@ -79,7 +82,7 @@ export const SettingsDevelopersWebhooksNew = () => {
|
|||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled={!canSave}
|
isSaveDisabled={!canSave}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
navigate(getSettingsPagePath(SettingsPath.Developers));
|
navigate(SettingsPath.Developers);
|
||||||
}}
|
}}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { H2Title, Section } from 'twenty-ui';
|
import { H2Title, Section } from 'twenty-ui';
|
||||||
|
|
||||||
import { useGetDatabaseConnections } from '@/databases/hooks/useGetDatabaseConnections';
|
import { useGetDatabaseConnections } from '@/databases/hooks/useGetDatabaseConnections';
|
||||||
@ -8,14 +8,15 @@ import { SettingsIntegrationPreview } from '@/settings/integrations/components/S
|
|||||||
import { SettingsIntegrationDatabaseConnectionsListCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionsListCard';
|
import { SettingsIntegrationDatabaseConnectionsListCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionsListCard';
|
||||||
import { useIsSettingsIntegrationEnabled } from '@/settings/integrations/hooks/useIsSettingsIntegrationEnabled';
|
import { useIsSettingsIntegrationEnabled } from '@/settings/integrations/hooks/useIsSettingsIntegrationEnabled';
|
||||||
import { useSettingsIntegrationCategories } from '@/settings/integrations/hooks/useSettingsIntegrationCategories';
|
import { useSettingsIntegrationCategories } from '@/settings/integrations/hooks/useSettingsIntegrationCategories';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsIntegrationDatabase = () => {
|
export const SettingsIntegrationDatabase = () => {
|
||||||
const { databaseKey = '' } = useParams();
|
const { databaseKey = '' } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const [integrationCategoryAll] = useSettingsIntegrationCategories();
|
const [integrationCategoryAll] = useSettingsIntegrationCategories();
|
||||||
const integration = integrationCategoryAll.integrations.find(
|
const integration = integrationCategoryAll.integrations.find(
|
||||||
@ -28,9 +29,9 @@ export const SettingsIntegrationDatabase = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isIntegrationAvailable) {
|
if (!isIntegrationAvailable) {
|
||||||
navigate(AppPath.NotFound);
|
navigateApp(AppPath.NotFound);
|
||||||
}
|
}
|
||||||
}, [integration, databaseKey, navigate, isIntegrationAvailable]);
|
}, [integration, databaseKey, navigateApp, isIntegrationAvailable]);
|
||||||
|
|
||||||
const { connections } = useGetDatabaseConnections({
|
const { connections } = useGetDatabaseConnections({
|
||||||
databaseKey,
|
databaseKey,
|
||||||
@ -45,11 +46,11 @@ export const SettingsIntegrationDatabase = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Integrations',
|
children: 'Integrations',
|
||||||
href: getSettingsPagePath(SettingsPath.Integrations),
|
href: getSettingsPath(SettingsPath.Integrations),
|
||||||
},
|
},
|
||||||
{ children: integration.text },
|
{ children: integration.text },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { SettingsIntegrationEditDatabaseConnectionContainer } from '@/settings/integrations/database-connection/components/SettingsIntegrationEditDatabaseConnectionContainer';
|
import { SettingsIntegrationEditDatabaseConnectionContainer } from '@/settings/integrations/database-connection/components/SettingsIntegrationEditDatabaseConnectionContainer';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
export const SettingsIntegrationEditDatabaseConnection = () => {
|
export const SettingsIntegrationEditDatabaseConnection = () => {
|
||||||
return (
|
return (
|
||||||
@ -11,11 +11,11 @@ export const SettingsIntegrationEditDatabaseConnection = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Integrations',
|
children: 'Integrations',
|
||||||
href: getSettingsPagePath(SettingsPath.Integrations),
|
href: getSettingsPath(SettingsPath.Integrations),
|
||||||
},
|
},
|
||||||
{ children: 'Edit connection' },
|
{ children: 'Edit connection' },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { useCreateOneDatabaseConnection } from '@/databases/hooks/useCreateOneDatabaseConnection';
|
import { useCreateOneDatabaseConnection } from '@/databases/hooks/useCreateOneDatabaseConnection';
|
||||||
@ -15,7 +15,6 @@ import {
|
|||||||
} from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionForm';
|
} from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionForm';
|
||||||
import { useIsSettingsIntegrationEnabled } from '@/settings/integrations/hooks/useIsSettingsIntegrationEnabled';
|
import { useIsSettingsIntegrationEnabled } from '@/settings/integrations/hooks/useIsSettingsIntegrationEnabled';
|
||||||
import { useSettingsIntegrationCategories } from '@/settings/integrations/hooks/useSettingsIntegrationCategories';
|
import { useSettingsIntegrationCategories } from '@/settings/integrations/hooks/useSettingsIntegrationCategories';
|
||||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { SettingsPath } from '@/types/SettingsPath';
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
@ -23,6 +22,9 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
|||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { H2Title, Section } from 'twenty-ui';
|
import { H2Title, Section } from 'twenty-ui';
|
||||||
import { CreateRemoteServerInput } from '~/generated-metadata/graphql';
|
import { CreateRemoteServerInput } from '~/generated-metadata/graphql';
|
||||||
|
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||||
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
const createRemoteServerInputPostgresSchema =
|
const createRemoteServerInputPostgresSchema =
|
||||||
settingsIntegrationPostgreSQLConnectionFormSchema.transform<CreateRemoteServerInput>(
|
settingsIntegrationPostgreSQLConnectionFormSchema.transform<CreateRemoteServerInput>(
|
||||||
@ -67,7 +69,8 @@ type SettingsIntegrationNewConnectionFormValues =
|
|||||||
|
|
||||||
export const SettingsIntegrationNewDatabaseConnection = () => {
|
export const SettingsIntegrationNewDatabaseConnection = () => {
|
||||||
const { databaseKey = '' } = useParams();
|
const { databaseKey = '' } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigateSettings();
|
||||||
|
const navigateApp = useNavigateApp();
|
||||||
|
|
||||||
const [integrationCategoryAll] = useSettingsIntegrationCategories();
|
const [integrationCategoryAll] = useSettingsIntegrationCategories();
|
||||||
const integration = integrationCategoryAll.integrations.find(
|
const integration = integrationCategoryAll.integrations.find(
|
||||||
@ -83,9 +86,9 @@ export const SettingsIntegrationNewDatabaseConnection = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isIntegrationAvailable) {
|
if (!isIntegrationAvailable) {
|
||||||
navigate(AppPath.NotFound);
|
navigateApp(AppPath.NotFound);
|
||||||
}
|
}
|
||||||
}, [integration, databaseKey, navigate, isIntegrationAvailable]);
|
}, [integration, databaseKey, navigateApp, isIntegrationAvailable]);
|
||||||
|
|
||||||
const newConnectionSchema =
|
const newConnectionSchema =
|
||||||
databaseKey === 'postgresql'
|
databaseKey === 'postgresql'
|
||||||
@ -99,7 +102,7 @@ export const SettingsIntegrationNewDatabaseConnection = () => {
|
|||||||
|
|
||||||
if (!isIntegrationAvailable) return null;
|
if (!isIntegrationAvailable) return null;
|
||||||
|
|
||||||
const settingsIntegrationsPagePath = getSettingsPagePath(
|
const settingsIntegrationsPagePath = getSettingsPath(
|
||||||
SettingsPath.Integrations,
|
SettingsPath.Integrations,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -118,9 +121,14 @@ export const SettingsIntegrationNewDatabaseConnection = () => {
|
|||||||
|
|
||||||
const connectionId = createdConnection.data?.createOneRemoteServer.id;
|
const connectionId = createdConnection.data?.createOneRemoteServer.id;
|
||||||
|
|
||||||
navigate(
|
if (!connectionId) {
|
||||||
`${settingsIntegrationsPagePath}/${databaseKey}/${connectionId}`,
|
throw new Error('Failed to create connection');
|
||||||
);
|
}
|
||||||
|
|
||||||
|
navigate(SettingsPath.IntegrationDatabaseConnection, {
|
||||||
|
databaseKey,
|
||||||
|
connectionId,
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
enqueueSnackBar((error as Error).message, {
|
enqueueSnackBar((error as Error).message, {
|
||||||
variant: SnackBarVariant.Error,
|
variant: SnackBarVariant.Error,
|
||||||
@ -134,7 +142,7 @@ export const SettingsIntegrationNewDatabaseConnection = () => {
|
|||||||
links={[
|
links={[
|
||||||
{
|
{
|
||||||
children: 'Workspace',
|
children: 'Workspace',
|
||||||
href: getSettingsPagePath(SettingsPath.Workspace),
|
href: getSettingsPath(SettingsPath.Workspace),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: 'Integrations',
|
children: 'Integrations',
|
||||||
@ -150,7 +158,9 @@ export const SettingsIntegrationNewDatabaseConnection = () => {
|
|||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled={!canSave}
|
isSaveDisabled={!canSave}
|
||||||
onCancel={() =>
|
onCancel={() =>
|
||||||
navigate(`${settingsIntegrationsPagePath}/${databaseKey}`)
|
navigate(SettingsPath.IntegrationDatabase, {
|
||||||
|
databaseKey,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user