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

Hide tabs #7841

Merged
merged 19 commits into from
Nov 11, 2024
Merged

Hide tabs #7841

merged 19 commits into from
Nov 11, 2024

Conversation

ehconitin
Copy link
Contributor

@FelixMalfait WDYT?
We can refactor shouldDisplay Files/Tasks/Notes Tab etc into a hook.

@FelixMalfait
Copy link
Member

Discussed in DM - It works but it would be cool to move to progressively to something a bit more abstract, like that

image

@FelixMalfait
Copy link
Member

Let's aim to close this soon as it's been open for 2 weeks now! Or maybe close the PR and re-open it when it's ready?

@ehconitin
Copy link
Contributor Author

@FelixMalfait for now I have shoved everything into a single file --- but how about this? :)
ps: ignore new type and constant files --- those do nothing as of now -- forgot to cleanup

loading || baseHide || objectsDontExist || relationsDontExist;

// Special case handling from original code
if (!isHidden) {
Copy link
Member

@FelixMalfait FelixMalfait Nov 8, 2024

Choose a reason for hiding this comment

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

Hey, this is a good step forward but I was hoping you'd get rid of most of this code!
The goal is not to have to create

case 'Note':
            return isNotesObjectActive;

But instead directly pass CoreObjectNameSingular.Note etc

CoreObjectNameSingular.WorkflowRun,
].includes(obj),
),
},
},
{
id: 'emails',
Copy link
Member

Choose a reason for hiding this comment

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

Let's transform this array to an object and use the ID as the key of the array, this will make it easier to over write layouts. Let's maybe do the same for the Cards.
(for inheritance then we can quickly overwrite a given tab/card)

@FelixMalfait FelixMalfait marked this pull request as ready for review November 11, 2024 07:54
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR refactors tab visibility and card rendering logic by introducing a more structured and maintainable approach using configuration-based layouts and centralized component mapping.

  • Added CardComponents.tsx to centralize card rendering with a type-safe mapping between CardType enum and React components
  • Introduced BaseRecordLayout constant for configurable tab definitions with granular visibility rules based on context, features, and dependencies
  • Added new types (RecordLayoutTab, TabVisibilityConfig, LayoutCard) to support structured tab configuration and visibility control
  • Refactored useRecordShowContainerTabs to use position-based ordering and evaluate visibility based on metadata, features, and relations
  • Modified ShowPageSubContainer to use the new card component mapping system, replacing the previous switch statement implementation

11 file(s) reviewed, 11 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +19 to +30
const StyledGreyBox = styled.div<{ isInRightDrawer?: boolean }>`
background: ${({ theme, isInRightDrawer }) =>
isInRightDrawer ? theme.background.secondary : ''};
border: ${({ isInRightDrawer, theme }) =>
isInRightDrawer ? `1px solid ${theme.border.color.medium}` : ''};
border-radius: ${({ isInRightDrawer, theme }) =>
isInRightDrawer ? theme.border.radius.md : ''};
height: ${({ isInRightDrawer }) => (isInRightDrawer ? 'auto' : '100%')};

margin: ${({ isInRightDrawer, theme }) =>
isInRightDrawer ? theme.spacing(4) : ''};
`;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: StyledGreyBox uses empty strings as fallback values which could lead to invalid CSS. Consider using 'transparent' for background and 'none' for border/border-radius instead of empty strings.

Comment on lines +167 to +168
position: 0,
Icon: IconPrinter,
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Multiple workflow components have position: 0 which may cause unpredictable tab ordering

ifMobile: boolean;
ifDesktop: boolean;
ifInRightDrawer: boolean;
ifFeaturesDisabled: FeatureFlagKey[];
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider renaming ifFeaturesDisabled to ifFeatureFlagsDisabled for clarity since it specifically refers to feature flags

@FelixMalfait FelixMalfait merged commit c19e54f into twentyhq:main Nov 11, 2024
16 checks passed
Copy link
Contributor

Thanks @ehconitin for your contribution!
This marks your 53rd PR on the repo. You're top 1% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants