Skip to content

Commit

Permalink
feat(dialog): Adds a print when opening and hiding dialogs.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Jan 15, 2025
1 parent 4c37e0d commit 1b7668b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions react/features/base/dialog/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
OPEN_SHEET
} from './actionTypes';
import { isDialogOpen } from './functions';
import logger from './logger';

/**
* Signals Dialog to close its dialog.
Expand All @@ -23,6 +24,8 @@ import { isDialogOpen } from './functions';
* }}
*/
export function hideDialog(component?: ComponentType<any>) {
logger.info(`Hide dialog: ${getComponentDisplayName(component)}`);

return {
type: HIDE_DIALOG,
component
Expand Down Expand Up @@ -55,6 +58,8 @@ export function hideSheet() {
* }}
*/
export function openDialog(component: ComponentType<any>, componentProps?: Object) {
logger.info(`Open dialog: ${getComponentDisplayName(component)}`);

return {
type: OPEN_DIALOG,
component,
Expand Down Expand Up @@ -101,3 +106,21 @@ export function toggleDialog(component: ComponentType<any>, componentProps?: Obj
}
};
}

/**
* Extracts a printable name for a dialog component.
*
* @param {Object} component - The component to extract the name for.
*
* @returns {string} The display name.
*/
function getComponentDisplayName(component?: ComponentType<any>) {
if (!component) {
return '';
}

const name = component.displayName ?? component.name ?? 'Component';

return name.replace('withI18nextTranslation(Connect(', '') // dialogs with translations
.replace('))', ''); // dialogs with translations suffix
}

0 comments on commit 1b7668b

Please sign in to comment.