Skip to content

Commit

Permalink
(fix): Resolve untranslated text and enhance workspace prompts with m…
Browse files Browse the repository at this point in the history
…odule name translation
  • Loading branch information
Muppasanipraneeth committed Feb 17, 2025
1 parent 9400555 commit d38cf4c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/framework/esm-styleguide/src/workspaces/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { type WorkspaceWindowState } from '@openmrs/esm-globals';
import { navigate } from '@openmrs/esm-navigation';
import { getGlobalStore, createGlobalStore } from '@openmrs/esm-state';
import { getCoreTranslation } from '@openmrs/esm-translations';
import { getCoreTranslation, translateFrom } from '@openmrs/esm-translations';
import { useStore } from '@openmrs/esm-react-utils';
import type { StoreApi } from 'zustand/vanilla';

Expand Down Expand Up @@ -246,6 +246,7 @@ function promptBeforeLaunchingWorkspace(
) {
const { name, additionalProps } = newWorkspaceDetails;
const newWorkspaceRegistration = getWorkspaceRegistration(name);
const workspaceModuleName = workspace.moduleName;

const proceed = () => {
closeWorkspace(workspace.name, {
Expand All @@ -259,7 +260,12 @@ function promptBeforeLaunchingWorkspace(
};

if (!canCloseWorkspaceWithoutPrompting(workspace.name)) {
showWorkspacePrompts('closing-workspace-launching-new-workspace', proceed, workspace.title ?? workspace.name);
showWorkspacePrompts(
'closing-workspace-launching-new-workspace',
proceed,
workspace.title ?? workspace.name,
workspaceModuleName,
);
} else {
proceed();
}
Expand Down Expand Up @@ -568,6 +574,7 @@ export function showWorkspacePrompts(
promptType: PromptType,
onConfirmation: () => void = () => {},
workspaceTitle: string = '',
workspaceModuleName: string = ' ',
) {
const store = getWorkspaceStore();

Expand Down Expand Up @@ -618,7 +625,7 @@ export function showWorkspacePrompts(
body: getCoreTranslation(
'unsavedChangesInWorkspace',
'There may be unsaved changes in {{workspaceName}}. Please save them before opening another workspace.',
{ workspaceName: workspaceTitle },
{ workspaceName: translateFrom(workspaceModuleName, workspaceTitle) },
),
onConfirm: () => {
store.setState((state) => ({
Expand Down

0 comments on commit d38cf4c

Please sign in to comment.