Skip to content

feat(workspaces): move tab rendering to the plugins COMPASS-9413 #6997

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

Merged
merged 9 commits into from
Jun 17, 2025

Conversation

Anemy
Copy link
Member

@Anemy Anemy commented Jun 10, 2025

COMPASS-9413

This pr refactors how we render the tab titles for workspace plugins. This makes it so that each plugin is now provides a header which is connected to their provider and rendered in the workspace.

The underlying motivation here is for the data modeling plugin to update it's title based on its store. Down the line I imagine we should have more uses for this. This should reduce coupling between workspaces and plugins and reduce the amount of plugin specific information we have in workspaces.

Screenshot 2025-06-10 at 5 34 46 PM

isNonExistent?: boolean;
iconGlyph: GlyphName | 'Logo' | 'Server';
tooltip?: [string, string][];
tabTheme?: Partial<TabTheme>;
Copy link
Member Author

Choose a reason for hiding this comment

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

We could get rid of this prop and instead use a provider.
Here's a branch with that provider: main...tab-theme-context-provider-example
I didn't include it in these changes, as it is something we could do as a follow up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense to me, and then we can also add it to all the shared workspace providers. Then we can also use these colors inside the workspaces UI easily if we need to

let isNonExistent: boolean | undefined;
if ('isNonExistent' in tab && tab.isNonExistent) {
if (tab.type === 'Collections') {
// TODO: Can/should we move this logic into the collections plugin title?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would expect it to be with the tab title rendering logic, yes

Copy link
Member Author

Choose a reason for hiding this comment

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

Created a ticket for this to do as a follow up COMPASS-9456. Neither of the plugins have this in their store so it would take some more work and I'm thinking we could do that seperately.

@Anemy Anemy changed the title WIP feat(workspaces): move tab rendering to the plugins COMPASS-9413 feat(workspaces): move tab rendering to the plugins COMPASS-9413 Jun 12, 2025
@Anemy Anemy marked this pull request as ready for review June 12, 2025 23:55
@Anemy Anemy requested a review from a team as a code owner June 12, 2025 23:55
@github-actions github-actions bot added the feat label Jun 12, 2025
@Anemy Anemy added feature flagged PRs labeled with this label will not be included in the release notes of the next release and removed feat feature flagged PRs labeled with this label will not be included in the release notes of the next release labels Jun 12, 2025
@github-actions github-actions bot added the feat label Jun 12, 2025
@Anemy Anemy added the no release notes Fix or feature not for release notes label Jun 12, 2025
}}
>
<WorkspaceTabContextProvider tab={tab} sectionType="tab-title">
<Provider>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should go inside the WorkspaceTabContextProvider and be added as the last wrapper over the rendered content there

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or at least I think so, maybe I'm missing why it shouldn't 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

sgtm, done!

<WorkspaceTabContent
// Cast to any as it can be any of the workspace types
// here.
{...(tab as any)}
Copy link
Collaborator

@gribnoysup gribnoysup Jun 16, 2025

Choose a reason for hiding this comment

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

If you look at the logic inside the WorkspaceTabContextProvider it's actually not all the props that need to be passed down, like you can do it, but as always it's better to be a bit more explicit. If you move the Provider inside WorkspaceTabContextProvider though this should be handled for you consistently (and there are some type guarantees provided by the method that picks those out)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated this to keep it all in WorkspaceTabContextProvider except for the isNonExistent which will be going away soon anyway.

Comment on lines 115 to 118
header: (props: {
tabProps: WorkspaceTabCoreProps;
workspaceProps: WorkspaceTabProps;
}) => ReturnType<typeof Tab>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because you mentioned that you're still wrangling types here, I'd maybe suggest to change this to:

Suggested change
header: (props: {
tabProps: WorkspaceTabCoreProps;
workspaceProps: WorkspaceTabProps;
}) => ReturnType<typeof Tab>;
header: (props: WorkspaceTabCoreProps & WorkspaceTabProps) => ReturnType<typeof Tab>;

That way provider can spread required ones easier I think

Copy link
Member Author

Choose a reason for hiding this comment

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

I like it, simplifies things, updated!

const { id: connectionId } = useConnectionInfo();

const { database, collection, ns } = toNS(namespace);
const connectionName = getConnectionById(connectionId)?.title || '';
Copy link
Collaborator

@gribnoysup gribnoysup Jun 17, 2025

Choose a reason for hiding this comment

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

There's a small issue with useConnectionInfo implementation (and so the types are correctly hiding that title is already returned here due to the test value fallback), but you can clean this up a bit and just access title from connectionInfo returned by the hook (but feel free to keep this out of this PR to avoid more changes piling up)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good callout. Tests are green now, I'll do that in a follow up!

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

Very neat, awesome work!

@Anemy Anemy merged commit 1e4eeed into main Jun 17, 2025
57 checks passed
@Anemy Anemy deleted the COMPASS-9413-workspaces-plugins-have-titles branch June 17, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants