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

feat: add table columns #1056

Merged
merged 2 commits into from
Aug 4, 2023
Merged

feat: add table columns #1056

merged 2 commits into from
Aug 4, 2023

Conversation

thaisguigon
Copy link
Contributor

Closes #879

@thaisguigon thaisguigon changed the title feat: add table columns WIP: feat: add table columns Aug 2, 2023
@ergomake
Copy link

ergomake bot commented Aug 2, 2023

Hi 👋

Here's a preview environment 🚀

https://front-twentyhq-twenty-1056.env.ergomake.link

Environment Summary 📑

Container Source URL
front Dockerfile https://front-twentyhq-twenty-1056.env.ergomake.link
server Dockerfile https://server-twentyhq-twenty-1056.env.ergomake.link
postgres Dockerfile [not exposed - internal service]

Here are your environment's logs.

For questions or comments, join Discord.

Click here to disable Ergomake.

@thaisguigon thaisguigon force-pushed the feat/add-view-field branch 3 times, most recently from b97059d to 4848b61 Compare August 3, 2023 09:38
@thaisguigon thaisguigon marked this pull request as ready for review August 3, 2023 09:39
@thaisguigon thaisguigon changed the title WIP: feat: add table columns feat: add table columns Aug 3, 2023
Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

Looks good to me. Unfortunately they are conflicts with the branch I've merged this morning: #1061

In the idea, I've done a minor change to remove props drilling on EntityTableHeader as we are using recoil state anyway. hope it's not too painful to resolve! LGTM!

@emilienchvt
Copy link
Contributor

@thaisguigon any hints to test the feature ? I can not see the (+) button when trying locally:
Screenshot 2023-08-04 at 17 50 41

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

LGTM, minor comments that can be treated in this PR or in the next one!

children: React.ReactElement[];
};
children: React.ReactElement | React.ReactElement[];
} & Omit<ComponentProps<'div'>, 'children'>;
Copy link
Member

Choose a reason for hiding this comment

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

can we do it the other way?

type IconButtonGroupProps = ComponentProps<'div'> & {
  variant: IconButtonVariant;
  size: IconButtonSize;
  children: React.ReactElement | React.ReactElement[];
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I kept the Omit<..., 'children'> though, otherwise IconButtonGroupProps['children']'s type would then become ReactNode & (React.ReactElement | React.ReactElement[]).

}
`;

type EntityTableColumnMenuProps = {
Copy link
Member

Choose a reason for hiding this comment

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

we usually use type OwnProps in the codebase, I don't know what code convention we should choose. The one you use looks more flexible if we have multiple components in the same file

Copy link
Contributor Author

@thaisguigon thaisguigon Aug 4, 2023

Choose a reason for hiding this comment

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

I usually prefix the component name to the type name in case we need to export the Props type to reuse it later (in stories, in a parent component...). But if the Props are kept locally then it could be OwnProps. Would you rather I change it as OwnProps here?

Copy link
Member

Choose a reason for hiding this comment

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

I actually like your convention more, it looks more flexible. The only drawback is that when we rename a component, we have one more renaming to do but with IDEs capabilities this should not be a problem. Let's leave it like this and we will progressively replace the OwnProps. I will also add it to the doc

setIsColumnMenuOpen((previousValue) => !previousValue);
}, []);

const handleAddViewField = useCallback(
Copy link
Member

Choose a reason for hiding this comment

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

LGTM, but I feel we will need to extract that to a hook in the next PR as we will be able to add viewFields from two different places (Options menu and + icon in the table header)

} from '../types/ViewField';

export const viewFieldsState = atom<{
objectName: 'company' | 'person' | '';
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised about the '' possibility? Can we get rid of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an empty possibility because I was not sure what value to use by default: company or person? Not sure if it makes sense to choose one when no viewFields have been fetched yet.

Copy link
Member

Choose a reason for hiding this comment

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

Are forced to pass a default? Maybe it doesn't make sense for viewFields to have a default and it should always be set with something that makes sense

@thaisguigon
Copy link
Contributor Author

@thaisguigon any hints to test the feature ? I can not see the (+) button when trying locally: Screenshot 2023-08-04 at 17 50 41

To test it I delete a ViewField from the ViewFields table (for instance, a ViewField with "company" as objectName).
Then after refreshing the Company table should display a "+" on the top right corner and the deleted column should appear as an option.

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.

I see a (+) button on the column the most on the right with dropdown to add columns
3 participants