Skip to content

Commit

Permalink
fix names
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-ubs committed Nov 22, 2024
1 parent 1b38fbd commit 40f842a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/website-viewer/contributions/localizedStrings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"metadata": {},
"localizedStrings": {
"en": {
"%mainMenu_websiteViewer%": "Web Viewer",
"%websiteViewer_title_format%": "Web Viewer: {resourceName}",
"%mainMenu_websiteViewer%": "Website Viewer",
"%websiteViewer_title_format%": "{resourceName} (website viewer)",
"%websiteViewerMenu_codeSandbox%": "Open codesandbox Settings UI mockup",
"%websiteViewerMenu_openPT9VideoWebsiteViewer%": "Video: What is PT9 (Vimeo)",
"%websiteViewerMenu_openPT9HelpWebsiteViewer%": "Watch Paratext 9 training videos (paratext.org)",
Expand Down
22 changes: 11 additions & 11 deletions src/website-viewer/contributions/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@
"mainMenu": {
"columns": {},
"groups": {
"websiteViewer.openGroup": {
"menuItem": "websiteViewer.mainMenu",
"website-viewer.openGroup": {
"menuItem": "website-viewer.mainMenu",
"order": 2711
}
},
"items": [
{
"label": "%mainMenu_websiteViewer%",
"localizeNotes": "Application main menu > Open Web Viewer",
"localizeNotes": "Application main menu > Open Website",
"group": "platform.projectResources",
"order": -84,
"id": "websiteViewer.mainMenu"
"id": "website-viewer.mainMenu"
},
{
"label": "%websiteViewerMenu_codeSandbox%",
"group": "websiteViewer.openGroup",
"group": "website-viewer.openGroup",
"order": -99,
"command": "websiteViewer.openCodeSandbox"
},
{
"label": "%websiteViewerMenu_openPT9VideoWebsiteViewer%",
"group": "websiteViewer.openGroup",
"group": "website-viewer.openGroup",
"order": -5,
"command": "websiteViewer.openPT9Video"
},
{
"label": "%websiteViewerMenu_openPT9HelpWebsiteViewer%",
"group": "websiteViewer.openGroup",
"group": "website-viewer.openGroup",
"order": -4,
"command": "websiteViewer.openPT9Help"
},
{
"label": "%websiteViewerMenu_openUsfmDocsHelpWebsiteViewer%",
"group": "websiteViewer.openGroup",
"group": "website-viewer.openGroup",
"order": -3,
"command": "websiteViewer.openUsfmDocs"
},
{
"label": "%websiteViewerMenu_openOTNWebsiteViewer%",
"group": "websiteViewer.openGroup",
"group": "website-viewer.openGroup",
"order": 0,
"command": "websiteViewer.openOTN"
},
{
"label": "%websiteViewerMenu_openMarbleWebsiteViewer%",
"group": "websiteViewer.openGroup",
"group": "website-viewer.openGroup",
"order": 1,
"command": "websiteViewer.openMarble"
},
{
"label": "%websiteViewerMenu_openWiBiLexWebsiteViewer%",
"group": "websiteViewer.openGroup",
"group": "website-viewer.openGroup",
"order": 2,
"command": "websiteViewer.openWiBiLex"
}
Expand Down
13 changes: 7 additions & 6 deletions src/website-viewer/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ let websiteOptions: Map<keyof CommandHandlers, WebsiteViewerOptions>;
const commandByWebViewId = new Map<string, keyof CommandHandlers>();
const scrollGroupInfoByWebViewId = new Map<string, ScrollGroupInfo>();

/** Function to open a Web Viewer. Registered as a command handler. */
/** Function to open a Website Viewer. Registered as a command handler. */
async function openWebsiteViewerOfType({
openWebsiteCommand,
}: BasicWebsiteViewerOptions): Promise<string | undefined> {
logger.info(`web-viewer: retrieved command to open a web viewer`);
logger.info(`website-viewer: retrieved command to open a Website`);
const webViewOptions = {
openWebsiteCommand,
// use existing id to open only 1 instance of a web view type.
Expand All @@ -63,14 +63,15 @@ async function openWebsiteViewerOfType({
return papi.webViews.openWebView(WEBSITE_VIEWER_WEBVIEW_TYPE, undefined, webViewOptions);
}

// TODO: combine with openWebsiteViewerOfType
function reOpenWebsiteViewerFromExistingId(existingWebViewId: string) {
// get webView by existingId (without the possibility to pass WebsiteViewer specific options)
return papi.webViews.openWebView(WEBSITE_VIEWER_WEBVIEW_TYPE, undefined, {
existingId: existingWebViewId,
});
}

/** Simple web view provider that provides Web Viewer web views when papi requests them */
/** Simple web view provider that provides Website Viewer web views when papi requests them */
const websiteViewerWebViewProvider: IWebViewProvider = {
async getWebView(
savedWebView: SavedWebViewDefinition,
Expand Down Expand Up @@ -210,7 +211,7 @@ export async function activate(context: ExecutionActivationContext): Promise<voi
// This is not fired in case of "no scroll group", this is handled inside the scroll group change code
papi.scrollGroups.onDidUpdateScrRef((scrollGroupUpdateInfo: ScrollGroupUpdateInfo) => {
logger.debug(
`web-viewer: ScriptureRef changed for scrollGroup ${scrollGroupUpdateInfo.scrollGroupId}: ${commandByWebViewId.size} web viewer webviews in memory`,
`website-viewer: ScriptureRef changed for scrollGroup ${scrollGroupUpdateInfo.scrollGroupId}: ${commandByWebViewId.size} Website Viewer web views in memory`,
);
const updateWebViewPromises = Array.from(commandByWebViewId.entries())
// filter web views of a type that is listening for ref changes
Expand All @@ -223,15 +224,15 @@ export async function activate(context: ExecutionActivationContext): Promise<voi
)
.map(([webViewId]) => {
logger.debug(
`web-viewer: Updating webview with id: ${webViewId}, command: ${commandByWebViewId.get(webViewId)}`,
`website-viewer: Updating webview with id: ${webViewId}, command: ${commandByWebViewId.get(webViewId)}`,
);
return reOpenWebsiteViewerFromExistingId(webViewId);
});

return Promise.all(updateWebViewPromises);
});

// listen to scroll group changes for web viewer web views
// listen to scroll group changes for Website Viewer web views
papi.webViews.onDidUpdateWebView((updateWebViewEvent: UpdateWebViewEvent) => {
const webViewId = updateWebViewEvent.webView.id;
if (!commandByWebViewId.has(webViewId)) return;
Expand Down
38 changes: 23 additions & 15 deletions src/website-viewer/src/types/website-viewer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,60 @@ declare module 'website-viewer' {}
declare module 'papi-shared-types' {
export interface CommandHandlers {
/**
* V0
* Opens a new Website Viewer web view with a code sandbox mockup and returns the web view id
*
* @returns WebView id for new WebView or `undefined` if the user canceled the dialog
* @returns From return value of openWebView: Promise that resolves to the ID of the webview we
* got or undefined if the provider did not create a WebView for this request
*/
'websiteViewer.openCodeSandbox': () => Promise<string | undefined>;

/**
* Opens a new Web Viewer Web View with a PT9 Video from Vimeo and returns the Web View id
* Opens a new Website Viewer web view with a PT9 Video from Vimeo and returns the web view id
*
* @returns WebView id for new WebView or `undefined` if the user canceled the dialog
* @returns From return value of openWebView: Promise that resolves to the ID of the webview we
* got or undefined if the provider did not create a WebView for this request
*/
'websiteViewer.openPT9Video': () => Promise<string | undefined>;

/**
* Opens a new Web Viewer Web View with the paratext.org Help website and returns the Web View
* id
* Opens a new Website Viewer web view with the paratext.org help website and returns the web
* view id
*
* @returns WebView id for new WebView or `undefined` if the user canceled the dialog
* @returns From return value of openWebView: Promise that resolves to the ID of the webview we
* got or undefined if the provider did not create a WebView for this request
*/
'websiteViewer.openPT9Help': () => Promise<string | undefined>;

/**
* Opens a new Web Viewer Web View with the USFM Docs website and returns the Web View id
* Opens a new Website Viewer web view with the USFM Docs website and returns the web view id
*
* @returns WebView id for new WebView or `undefined` if the user canceled the dialog
* @returns From return value of openWebView: Promise that resolves to the ID of the webview we
* got or undefined if the provider did not create a WebView for this request
*/
'websiteViewer.openUsfmDocs': () => Promise<string | undefined>;

/**
* Opens a new Web Viewer Web View for SIL Open Translator Notes and returns the Web View id
* Opens a new Website Viewer web view for SIL Open Translator Notes and returns the web view id
*
* @returns WebView id for new WebView or `undefined` if the user canceled the dialog
* @returns From return value of openWebView: Promise that resolves to the ID of the webview we
* got or undefined if the provider did not create a WebView for this request
*/
'websiteViewer.openOTN': () => Promise<string | undefined>;

/**
* Opens a new Web Viewer Web View for UBS Marble and returns the Web View id
* Opens a new Website Viewer web view for UBS Marble and returns the web view id
*
* @returns WebView id for new WebView or `undefined` if the user canceled the dialog
* @returns From return value of openWebView: Promise that resolves to the ID of the webview we
* got or undefined if the provider did not create a WebView for this request
*/
'websiteViewer.openMarble': () => Promise<string | undefined>;

/**
* Opens a new Web Viewer Web View for German Bible Society WiBiLex and returns the Web View id
* Opens a new Website Viewer web view for German Bible Society WiBiLex and returns the web view
* id
*
* @returns WebView id for new WebView or `undefined` if the user canceled the dialog
* @returns From return value of openWebView: Promise that resolves to the ID of the webview we
* got or undefined if the provider did not create a WebView for this request
*/
'websiteViewer.openWiBiLex': () => Promise<string | undefined>;

Expand Down
2 changes: 1 addition & 1 deletion src/website-viewer/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { formatReplacementString } from 'platform-bible-utils';
* Get the name of the web view based on the name of the project
*
* @param titleStringFormat String with `{resourceName}` in it to be replaced with the short name of
* the resource e.g. `Web Viewer: {resourceName}`
* the resource e.g. `Website Viewer: {resourceName}`
* @param resourceName Should be the short name of the web resource
* @returns Web view title
*/
Expand Down

0 comments on commit 40f842a

Please sign in to comment.