-
Notifications
You must be signed in to change notification settings - Fork 276
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
refactor menu to use constants #1087
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some places were changed without any reasoning, so I mostly highlighted those
getCurrentTranslation(MenuConstants.Labels.YES), | ||
getCurrentTranslation(MenuConstants.Labels.NO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changed from "Copy" and "ok" to "Yes" and "no". Please confirm it was intentional and if so, this should be on a separate commit, as it is a bug fix.
const options = { | ||
title: getCurrentTranslation('$Menu.export-db-to-file'), | ||
title: getCurrentTranslation(MenuConstants.Labels.EXPORT_DATABASE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to be $Menu.export-db-to-file
, not $Menu.export-database
defaultPath: `time_to_leave_${getCurrentDateTimeStr()}`, | ||
buttonLabel: getCurrentTranslation('$Menu.export'), | ||
|
||
buttonLabel: getCurrentTranslation(MenuConstants.Labels.EXPORT_DATABASE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to be $Menu.export
, not $Menu.export-database
title: getCurrentTranslation(MenuConstants.Labels.IMPORT_DATABASE), | ||
buttonLabel: getCurrentTranslation(MenuConstants.Labels.IMPORT_DATABASE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changed similar to the export
exportDatabaseToFile(response); | ||
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { | ||
title: 'Time to Leave', | ||
message: getCurrentTranslation('$Menu.database-export'), | ||
message: getCurrentTranslation(MenuConstants.Labels.DATABASE_WAS_EXPORTED), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to be database-export
not database-was-exported
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { | ||
title: 'Time to Leave', | ||
message: getCurrentTranslation('$Menu.database-imported'), | ||
message: getCurrentTranslation(MenuConstants.Labels.DATABASE_IMPORTED), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same change as in export.
} ${getCurrentTranslation('$Menu.could-not-be-loaded')}`; | ||
} else if (importResult['failed'] !== 0) { | ||
const message = `${importResult['failed']}/${importResult['total']} ${getCurrentTranslation( | ||
MenuConstants.Labels.FAILED_ENTRIES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to be could-not-be-loaded
mainWindow.webContents.send('RELOAD_CALENDAR'); | ||
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { | ||
title: 'Time to Leave', | ||
message: getCurrentTranslation('$Menu.clear-database'), | ||
message: getCurrentTranslation(MenuConstants.Labels.ALL_CLEAR), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to be clear-database
getCurrentTranslation(MenuConstants.Labels.NO), | ||
getCurrentTranslation(MenuConstants.Labels.YES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped the cancel button and is listing buttons in a different order
Related issue
https://github.com/thamara/time-to-leave/issues/1085
Context / Background
Currently, menu labels in the menu.js file are hardcoded across multiple functions, which makes the code harder to maintain and increases the chance of inconsistencies. Updating a menu label or shortcut requires finding each occurrence, making changes more time-consuming and prone to error. This PR introduces a set of centralized constants for menu labels. By using constants, menu items can be updated in one place, improving maintainability, readability, and reducing redundancy across the codebase.
What change is being introduced by this PR?
How will this be tested?