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

Use menu contributions to build menus #790

Merged
merged 5 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion assets/localization/eng.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
{
"insertNote": "Insert Note",
"mainMenu_aboutPlatformBible": "About Platform.Bible",
"mainMenu_downloadSlashInstallResources": "Download/Install Resources",
"mainMenu_downloadSlashUpdateProject": "Download/Update Project",
"mainMenu_exit": "Exit",
"mainMenu_help": "Help",
"mainMenu_layout": "Layout",
"mainMenu_openHelloWorldProject": "Open Hello World Project",
"mainMenu_openProject": "Open Project",
"mainMenu_openResourceViewer": "Open Resource Viewer",
"mainMenu_project": "Project",
"mainMenu_settings": "Settings",
"mainMenu_visitSupportBible": "Visit Support.Bible",
"mainMenu_window": "Window",
"some_localization_key": "This is the English text for %some_localization_key%.",
"submitButton": "Submit"
"submitButton": "Submit",
"webView_edit": "Edit",
"webView_project": "Project",
"webView_projectAssignmentsAndProgress": "Assignments and Progress",
"webView_projectSendReceive": "Send/Receive this project",
"wordList": "Word List"
}
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"asyncs",
"autodocs",
"biblionexus",
"camelcase",
"Consts",
"deuterocanon",
"dockbox",
"electronmon",
Expand Down
10 changes: 9 additions & 1 deletion extensions/src/hello-world/contributions/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"mainMenu": {
"columns": {},
"groups": {},
"items": []
"items": [
{
"label": "%mainMenu_openHelloWorldProject%",
"localizeNotes": "Application main menu > Project > Open Hello World Project",
"group": "platform.projectProjects",
"order": 1000.1,
"command": "helloWorld.openProject"
}
]
},
"defaultWebViewTopMenu": {
"columns": {},
Expand Down
56 changes: 10 additions & 46 deletions lib/papi-dts/papi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4815,11 +4815,11 @@ declare module 'shared/services/menu-data.service-model' {
MultiColumnMenu,
ReferencedItem,
WebViewMenu,
Localized,
} from 'platform-bible-utils';
import {
DataProviderDataType,
DataProviderSubscriberOptions,
DataProviderUpdateInstructions,
} from 'shared/models/data-provider.model';
import { IDataProvider } from '@papi/core';
/**
Expand All @@ -4837,8 +4837,8 @@ declare module 'shared/services/menu-data.service-model' {
dataProviderName: 'platform.menuDataServiceDataProvider';
}>;
export type MenuDataDataTypes = {
MainMenu: DataProviderDataType<undefined, MultiColumnMenu, never>;
WebViewMenu: DataProviderDataType<ReferencedItem, WebViewMenu, never>;
MainMenu: DataProviderDataType<undefined, Localized<MultiColumnMenu>, never>;
WebViewMenu: DataProviderDataType<ReferencedItem, Localized<WebViewMenu>, never>;
};
module 'papi-shared-types' {
interface DataProviders {
Expand All @@ -4850,44 +4850,19 @@ declare module 'shared/services/menu-data.service-model' {
* Service that allows to get and store menu data
*/
export type IMenuDataService = {
/**
*
* Get menu content for the main menu
*
* @param mainMenuType Does not have to be defined
* @returns MultiColumnMenu object of main menu content
*/
getMainMenu(mainMenuType: undefined): Promise<MultiColumnMenu>;
/**
*
* Get menu content for the main menu
*
* @param mainMenuType Does not have to be defined
* @returns MultiColumnMenu object of main menu content
*/
getMainMenu(): Promise<MultiColumnMenu>;
/**
* This data cannot be changed. Trying to use this setter this will always throw
*
* @param mainMenuType Does not have to be defined
* @param value MultiColumnMenu object to set as the main menu
* @returns Unsubscriber function
*/
setMainMenu(
mainMenuType: undefined,
value: never,
): Promise<DataProviderUpdateInstructions<MenuDataDataTypes>>;
/** Rebuild the menus with the latest inputs from all extensions. */
rebuildMenus(): Promise<void>;
/** Get menu content for the main menu */
getMainMenu(): Promise<Localized<MultiColumnMenu>>;
/**
* Subscribe to run a callback function when the main menu data is changed
*
* @param mainMenuType Does not have to be defined
* @param callback Function to run with the updated menuContent for this selector
* @param options Various options to adjust how the subscriber emits updates
* @returns Unsubscriber function (run to unsubscribe from listening for updates)
*/
subscribeMainMenu(
mainMenuType: undefined,
callback: (menuContent: MultiColumnMenu) => void,
callback: (menuContent: Localized<MultiColumnMenu>) => void,
options?: DataProviderSubscriberOptions,
): Promise<UnsubscriberAsync>;
/**
Expand All @@ -4896,18 +4871,7 @@ declare module 'shared/services/menu-data.service-model' {
* @param webViewType The type of webview for which a menu should be retrieved
* @returns WebViewMenu object of web view menu content
*/
getWebViewMenu(webViewType: ReferencedItem): Promise<WebViewMenu>;
/**
* This data cannot be changed. Trying to use this setter this will always throw
*
* @param webViewType The type of webview for which a menu should be set
* @param value Menu of specified webViewType
* @returns Unsubscriber function
*/
setWebViewMenu(
webViewType: ReferencedItem,
value: never,
): Promise<DataProviderUpdateInstructions<MenuDataDataTypes>>;
getWebViewMenu(webViewType: ReferencedItem): Promise<Localized<WebViewMenu>>;
/**
* Subscribe to run a callback function when the web view menu data is changed
*
Expand All @@ -4918,7 +4882,7 @@ declare module 'shared/services/menu-data.service-model' {
*/
subscribeWebViewMenu(
webViewType: ReferencedItem,
callback: (menuContent: WebViewMenu) => void,
callback: (menuContent: Localized<WebViewMenu>) => void,
options?: DataProviderSubscriberOptions,
): Promise<UnsubscriberAsync>;
} & OnDidDispose &
Expand Down
Loading
Loading