Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Data settings new layout - anchor navigation #8334

Merged
merged 36 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6ba2970
Implement object fields and settings new layout
gitstart-twenty Oct 25, 2024
5628299
update `if` block to fix eslint error
gitstart-twenty Oct 25, 2024
d7f7232
Merge branch 'main' of github.com:twentyhq/twenty into TWNTY-5491-new…
ijreilly Oct 28, 2024
4d9644a
Fix form saving
ijreilly Oct 28, 2024
3fb0300
Fix renaming applied to other workspaces
ijreilly Oct 29, 2024
3216337
Refactor
ijreilly Oct 29, 2024
0e93fa4
disable toggle for standard object
ijreilly Oct 29, 2024
29e04cd
fix object metadata renaming
Weiko Oct 29, 2024
8d81b38
Merge branch 'main' of github.com:twentyhq/twenty into TWNTY-5491-new…
ijreilly Oct 29, 2024
ef14dc0
Fix after merge and add workspaceId as arg
ijreilly Oct 29, 2024
039c4ed
fix missing workspaceId
Weiko Oct 29, 2024
a5eb182
some design fixes
ijreilly Oct 30, 2024
3c034a7
fix activeTabId
ijreilly Nov 4, 2024
ffc32c1
Merge branch 'main' of github.com:twentyhq/twenty into TWNTY-5491-new…
ijreilly Nov 4, 2024
c53cf5b
other design fixes
ijreilly Nov 4, 2024
c2f334c
wip - stories fix
ijreilly Nov 4, 2024
60e7d6e
write new storybook test
ijreilly Nov 4, 2024
8bdfd35
Merge branch 'main' of github.com:twentyhq/twenty into TWNTY-5491-new…
ijreilly Nov 4, 2024
ec78125
Fix design after merging main
ijreilly Nov 5, 2024
ec4095e
Navigation between tabs changes url
ijreilly Nov 5, 2024
dd7e2ed
Merge branch 'main' of github.com:twentyhq/twenty into new-layout-anc…
ijreilly Nov 7, 2024
a8fd2f0
finish merge
ijreilly Nov 7, 2024
aa02a45
Merge branch 'main' of github.com:twentyhq/twenty into new-layout-anc…
ijreilly Nov 8, 2024
35cd287
use Link in Tab to benefit from anchor navigation
ijreilly Nov 8, 2024
10856a1
move shared consts to a file in constants folder
ijreilly Nov 8, 2024
6fc2831
remove console
ijreilly Nov 8, 2024
1d3f119
Merge branch 'main' into new-layout-anchor-navigation
charlesBochet Nov 9, 2024
50d6630
Merge branch 'main' into new-layout-anchor-navigation
charlesBochet Nov 11, 2024
10ca2bf
Fix console.log
charlesBochet Nov 11, 2024
3f3de5b
Fix
charlesBochet Nov 11, 2024
856f85d
Fix
charlesBochet Nov 11, 2024
4bc1233
Fix
charlesBochet Nov 11, 2024
e478821
Fix
charlesBochet Nov 11, 2024
3ba8078
Fix
charlesBochet Nov 11, 2024
8738065
Fix
charlesBochet Nov 11, 2024
7f4c4ef
Fix CI
charlesBochet Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const SettingsDataModelObjectAboutForm = ({
defaultValue={objectMetadataItem?.labelSingular}
render={({ field: { onChange, value } }) => (
<TextInput
label={'Singular'}
label={'Label Singular'}
placeholder={'Listing'}
value={value}
onChange={(value) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { useLocation, useNavigate, useParams } from 'react-router-dom';

import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
Expand Down Expand Up @@ -49,6 +49,7 @@ const StyledTabListContainer = styled.div`

const StyledContentContainer = styled.div`
flex: 1;
overflow-y: auto;
width: 100%;
padding-left: 0;
`;
Expand All @@ -68,8 +69,11 @@ const FIELDS_TAB_ID = 'fields';
const SETTINGS_TAB_ID = 'settings';
const INDEXES_TAB_ID = 'indexes';

const validHashes = [FIELDS_TAB_ID, SETTINGS_TAB_ID, INDEXES_TAB_ID];

export const SettingsObjectDetailPage = () => {
const navigate = useNavigate();
const location = useLocation();

const { objectSlug = '' } = useParams();
const { findActiveObjectMetadataItemBySlug } =
Expand All @@ -83,13 +87,33 @@ export const SettingsObjectDetailPage = () => {
findActiveObjectMetadataItemBySlug(updatedObjectSlug);

const { activeTabIdState } = useTabList(TAB_LIST_COMPONENT_ID);
const { setActiveTabId } = useTabList(TAB_LIST_COMPONENT_ID);
const activeTabId = useRecoilValue(activeTabIdState);

const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState);
const isUniqueIndexesEnabled = useIsFeatureEnabled(
'IS_UNIQUE_INDEXES_ENABLED',
);

const hash = location.hash.replace('#', '');

useEffect(() => {
if (!hash) {
const initialTabId = activeTabId ?? FIELDS_TAB_ID;
navigate(`${location.pathname}#${initialTabId}`, { replace: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaargh! Can we avoid useEffects? We should update the location when the user actually navigates / clicks

}
}, [activeTabId, hash, location.pathname, navigate]);

useEffect(() => {
if (hash === activeTabId) return;

if (isDefined(activeTabId)) {
navigate(`${location.pathname}#${activeTabId}`, { replace: true });
} else if (validHashes.includes(hash)) {
setActiveTabId(hash);
}
}, [hash, activeTabId, navigate, location.pathname, setActiveTabId]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This effect could cause an infinite loop if hash is invalid - need to handle invalid hash values


useEffect(() => {
if (objectSlug === updatedObjectSlug) setUpdatedObjectSlug('');
if (!isDefined(objectMetadataItem)) navigate(AppPath.NotFound);
Expand Down Expand Up @@ -142,12 +166,6 @@ export const SettingsObjectDetailPage = () => {

return (
<SubMenuTopBarContainer
title={
<StyledTitleContainer>
<H3Title title={objectMetadataItem.labelPlural} />
<StyledObjectTypeTag objectTypeLabel={objectTypeLabel} />
</StyledTitleContainer>
}
links={[
{
children: 'Workspace',
Expand All @@ -173,6 +191,10 @@ export const SettingsObjectDetailPage = () => {
}
>
<SettingsPageContainer>
<StyledTitleContainer>
<H3Title title={objectMetadataItem.labelPlural} />
<StyledObjectTypeTag objectTypeLabel={objectTypeLabel} />
</StyledTitleContainer>
<StyledTabListContainer>
<TabList
tabListId={TAB_LIST_COMPONENT_ID}
Expand Down
Loading