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

chore: dynamically enable menu options #2621

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

alexzurbonsen
Copy link
Contributor

Summary of changes

This PR deactivates some menu options initially and activates them once a file is opened.

Ideally, I wanted to disable the entire Edit menu, but that does not come with nice UX. Instead I disabled individual options. The ones that come with a role, like cut and copy cannot be disabled in the same way. I left them as is.

I would have also liked to disable the Export submenu in the File menu. But if I do that I can't enable it in the same way as individual items. As an easy solution I just disabled the submenu items instead.

grafik grafik

Context and reason for change

Closes #2411

How can the changes be tested

Manually check that options are disabled and will be enabled once a file is opened.

@@ -176,6 +243,8 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
);
}
},
id: MENU_ITEMS.projectStatistics.id,
enabled: false,
},
{
icon: getIconBasedOnTheme(
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 was not sure about this option: 'Set Path to Sources'. Disabled it as well?

@alexzurbonsen alexzurbonsen marked this pull request as ready for review April 23, 2024 06:59

type Item = { label: string; id: string };

const MENU_ITEMS: Record<(typeof INITIALLY_DISABLED_MENU_ITEMS)[number], Item> =
Copy link
Collaborator

Choose a reason for hiding this comment

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

i find that calling this MENU_ITEMS is misleading, since this is only the disabled menu items.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I will come up with something else.

@alexzurbonsen alexzurbonsen force-pushed the dynamically-enable-menu-options branch from d31767d to 2be9cac Compare April 24, 2024 07:43
Signed-off-by: alexzurbonsen <alexander.zur.bonsen@tngtech.com>
@alexzurbonsen alexzurbonsen force-pushed the dynamically-enable-menu-options branch from 2be9cac to dbe5b62 Compare April 24, 2024 08:11
@alexzurbonsen alexzurbonsen merged commit 91ebb66 into main Apr 24, 2024
5 checks passed
@alexzurbonsen alexzurbonsen deleted the dynamically-enable-menu-options branch April 24, 2024 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Top bar menu enabled even when no project is opened
3 participants