bitwarden-estensione-browser/libs/components/src/dialog/dialog.service.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

128 lines
4.1 KiB
TypeScript
Raw Normal View History

import {
DEFAULT_DIALOG_CONFIG,
Dialog,
DialogConfig,
DialogRef,
DIALOG_SCROLL_STRATEGY,
} from "@angular/cdk/dialog";
import { ComponentType, Overlay, OverlayContainer } from "@angular/cdk/overlay";
import {
Inject,
Injectable,
Injector,
OnDestroy,
Optional,
SkipSelf,
TemplateRef,
} from "@angular/core";
import { NavigationEnd, Router } from "@angular/router";
import { filter, firstValueFrom, Subject, switchMap, takeUntil } from "rxjs";
Auth/ps 2298 reorg auth (#4564) * Move auth service factories to Auth team * Move authentication componenets to Auth team * Move auth guard services to Auth team * Move Duo content script to Auth team * Move auth CLI commands to Auth team * Move Desktop Account components to Auth Team * Move Desktop guards to Auth team * Move two-factor provider images to Auth team * Move web Accounts components to Auth Team * Move web settings components to Auth Team * Move web two factor images to Auth Team * Fix missed import changes for Auth Team * Fix Linting errors * Fix missed CLI imports * Fix missed Desktop imports * Revert images move * Fix missed imports in Web * Move angular lib components to Auth Team * Move angular auth guards to Auth team * Move strategy specs to Auth team * Update .eslintignore for new paths * Move lib common abstractions to Auth team * Move services to Auth team * Move common lib enums to Auth team * Move webauthn iframe to Auth team * Move lib common domain models to Auth team * Move common lib requests to Auth team * Move response models to Auth team * Clean up whitelist * Move bit web components to Auth team * Move SSO and SCIM files to Auth team * Revert move SCIM to Auth team SCIM belongs to Admin Console team * Move captcha to Auth team * Move key connector to Auth team * Move emergency access to auth team * Delete extra file * linter fixes * Move kdf config to auth team * Fix whitelist * Fix duo autoformat * Complete two factor provider request move * Fix whitelist names * Fix login capitalization * Revert hint dependency reordering * Revert hint dependency reordering * Revert hint component This components is being picked up as a move between clients * Move web hint component to Auth team * Move new files to auth team * Fix desktop build * Fix browser build
2023-02-06 22:53:37 +01:00
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
2022-08-05 17:45:36 +02:00
import { SimpleConfigurableDialogComponent } from "./simple-dialog/simple-configurable-dialog/simple-configurable-dialog.component";
import { SimpleDialogOptions, Translation } from "./simple-dialog/types";
Feature/SG-878 - Add open simple dialog method on dialog service (#4425) * SG-878 - First draft - Dialog service now has backwards compatible method for opening a configurable simple dialog. * SG-878 - People comp - test cases for simple dialog method - more testing required * SG-878 - Much more simple dialog work - investigating different approaches to see what will work best. Lots of WIP on this one. Includes first draft but working solution for solving placeholder support for non-localized strings. * SG-878 - (1) Broke out enums and types into separate files for better single responsibility (2) Allow null cancelButtonText for single accept button support * SG-878 - Configurable simple dialog - removed separate comp approach as it is a maint problem to have simple dialog implemented in two places. * SG-878 - Added js doc comments for dialog service openSimpleDialog method * SG-878 - Don't export ConfigurableSimpleDialogComp as only dialogService should use it * SG-878 - (1) Refactor configurable simple dialog to reduce icon class repetition in html (2) Update simple dialog options to use new Translation interface and update comp to properly process placeholders again * SG-878 - Reverting all simple dialog changes as, per discussion with Oscar, going to use composition and go with configurable-simple-dialog comp for use in the dialog service * SG-878 - Testing latest simple dialog changes * SG-878 - Update simple-dialog-options * SG-878 - (1) People & collections component now use dialogService.openSimpleDialog vs custom org upgrade dialog comp (2) Rename configurable-simple-dialog to simple-configurable-dialog for better folder placement * SG-878 - Update formatting of Simple dialog options js doc comments * SG-878 - Remove test code * SG-878 -Remove org upgrade dialog component as it has been replaced with dialog service openSimpleDialog method call * SG-878 - Move models to be near where they are used which is in the simple-configurable-dialog folder. * SG-878 - Refactor icon classes into simple getter per Oscar's suggestions * SG-878 - Refactor Translation placeholderValues to be just placeholders * SG-878 - Refactor Simple Dialog Options to remove isLocalized as it doesn't buy us that much to have it. We can just check if a passed in value is a string or a Translation object to determine if we need to translate it. * SG-878 - Dialog Svc - remove backdrop classes from openSimpleDialog method as standard open method applies them * SG-878 - (1) Refactor simple configurable dialog to use comp properties instead of re-using option props (2) Reduce html complexity (3) Create translate func for code simplification (4) Remove isTranslation type guard as simple object check is sufficient * SG-668 - Refactoring collections & people comps use of dialog service openSimpleDialog to condense options per PR feedback * SG-878 - SimpleConfigDialog - (1) Footer classes were missing so btns were not spaced out properly (2) cancel btn text fixed to reference component property * SG-878 - First pass at creating a storybook example for the new openSimpleDialog method on the dialogService. * SG-878 - SimpleConfigurableDialog storybook - now displays callout with dialog results for better example * SG-878 - SimpleConfigurableDialog - use text-main tailwind class for h2s so that text is colored properly on black background * SG-878 - SimpleConfigurableDialog - Remove unstyled buttons and colored text and replace with plain secondary buttons to fix visibility issues on dark background. * Update libs/components/src/dialog/simple-configurable-dialog/models/simple-dialog-type.enum.ts SG-878 - Remove early commentary about use of simple-dialog-type enum Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.html SG-878 - SimpleConfigurableDialog html - consolidate title html to 1 line Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigurableDialog comp ts - remove unnecessary comment. Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigDialog comp - remove unnecessary comment Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * SG-668 / SG-878 - Migrate Free Org Upgrade Flows logic from deprecated collections component to vault component * SG-878 - Refactor the free org upgrade dialog to leverage separate methods to improve code and decrease cyclomatic complexity Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
2023-01-24 22:38:14 +01:00
2022-08-05 17:45:36 +02:00
@Injectable()
export class DialogService extends Dialog implements OnDestroy {
private _destroy$ = new Subject<void>();
private backDropClasses = ["tw-fixed", "tw-bg-black", "tw-bg-opacity-30", "tw-inset-0"];
constructor(
/** Parent class constructor */
_overlay: Overlay,
_injector: Injector,
@Optional() @Inject(DEFAULT_DIALOG_CONFIG) _defaultOptions: DialogConfig,
@Optional() @SkipSelf() _parentDialog: Dialog,
_overlayContainer: OverlayContainer,
@Inject(DIALOG_SCROLL_STRATEGY) scrollStrategy: any,
/** Not in parent class */
@Optional() router: Router,
@Optional() authService: AuthService,
protected i18nService: I18nService,
) {
super(_overlay, _injector, _defaultOptions, _parentDialog, _overlayContainer, scrollStrategy);
/** Close all open dialogs if the vault locks */
if (router && authService) {
router.events
.pipe(
filter((event) => event instanceof NavigationEnd),
switchMap(() => authService.getAuthStatus()),
filter((v) => v !== AuthenticationStatus.Unlocked),
takeUntil(this._destroy$),
)
.subscribe(() => this.closeAll());
}
}
override ngOnDestroy(): void {
this._destroy$.next();
this._destroy$.complete();
super.ngOnDestroy();
}
Feature/SG-878 - Add open simple dialog method on dialog service (#4425) * SG-878 - First draft - Dialog service now has backwards compatible method for opening a configurable simple dialog. * SG-878 - People comp - test cases for simple dialog method - more testing required * SG-878 - Much more simple dialog work - investigating different approaches to see what will work best. Lots of WIP on this one. Includes first draft but working solution for solving placeholder support for non-localized strings. * SG-878 - (1) Broke out enums and types into separate files for better single responsibility (2) Allow null cancelButtonText for single accept button support * SG-878 - Configurable simple dialog - removed separate comp approach as it is a maint problem to have simple dialog implemented in two places. * SG-878 - Added js doc comments for dialog service openSimpleDialog method * SG-878 - Don't export ConfigurableSimpleDialogComp as only dialogService should use it * SG-878 - (1) Refactor configurable simple dialog to reduce icon class repetition in html (2) Update simple dialog options to use new Translation interface and update comp to properly process placeholders again * SG-878 - Reverting all simple dialog changes as, per discussion with Oscar, going to use composition and go with configurable-simple-dialog comp for use in the dialog service * SG-878 - Testing latest simple dialog changes * SG-878 - Update simple-dialog-options * SG-878 - (1) People & collections component now use dialogService.openSimpleDialog vs custom org upgrade dialog comp (2) Rename configurable-simple-dialog to simple-configurable-dialog for better folder placement * SG-878 - Update formatting of Simple dialog options js doc comments * SG-878 - Remove test code * SG-878 -Remove org upgrade dialog component as it has been replaced with dialog service openSimpleDialog method call * SG-878 - Move models to be near where they are used which is in the simple-configurable-dialog folder. * SG-878 - Refactor icon classes into simple getter per Oscar's suggestions * SG-878 - Refactor Translation placeholderValues to be just placeholders * SG-878 - Refactor Simple Dialog Options to remove isLocalized as it doesn't buy us that much to have it. We can just check if a passed in value is a string or a Translation object to determine if we need to translate it. * SG-878 - Dialog Svc - remove backdrop classes from openSimpleDialog method as standard open method applies them * SG-878 - (1) Refactor simple configurable dialog to use comp properties instead of re-using option props (2) Reduce html complexity (3) Create translate func for code simplification (4) Remove isTranslation type guard as simple object check is sufficient * SG-668 - Refactoring collections & people comps use of dialog service openSimpleDialog to condense options per PR feedback * SG-878 - SimpleConfigDialog - (1) Footer classes were missing so btns were not spaced out properly (2) cancel btn text fixed to reference component property * SG-878 - First pass at creating a storybook example for the new openSimpleDialog method on the dialogService. * SG-878 - SimpleConfigurableDialog storybook - now displays callout with dialog results for better example * SG-878 - SimpleConfigurableDialog - use text-main tailwind class for h2s so that text is colored properly on black background * SG-878 - SimpleConfigurableDialog - Remove unstyled buttons and colored text and replace with plain secondary buttons to fix visibility issues on dark background. * Update libs/components/src/dialog/simple-configurable-dialog/models/simple-dialog-type.enum.ts SG-878 - Remove early commentary about use of simple-dialog-type enum Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.html SG-878 - SimpleConfigurableDialog html - consolidate title html to 1 line Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigurableDialog comp ts - remove unnecessary comment. Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigDialog comp - remove unnecessary comment Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * SG-668 / SG-878 - Migrate Free Org Upgrade Flows logic from deprecated collections component to vault component * SG-878 - Refactor the free org upgrade dialog to leverage separate methods to improve code and decrease cyclomatic complexity Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
2023-01-24 22:38:14 +01:00
override open<R = unknown, D = unknown, C = unknown>(
componentOrTemplateRef: ComponentType<C> | TemplateRef<C>,
config?: DialogConfig<D, DialogRef<R, C>>,
): DialogRef<R, C> {
config = {
backdropClass: this.backDropClasses,
...config,
};
return super.open(componentOrTemplateRef, config);
}
/**
* Opens a simple dialog, returns true if the user accepted the dialog.
*
* @param {SimpleDialogOptions} simpleDialogOptions - An object containing options for the dialog.
* @returns `boolean` - True if the user accepted the dialog, false otherwise.
*/
async openSimpleDialog(simpleDialogOptions: SimpleDialogOptions): Promise<boolean> {
const dialogRef = this.openSimpleDialogRef(simpleDialogOptions);
return firstValueFrom(dialogRef.closed);
}
Feature/SG-878 - Add open simple dialog method on dialog service (#4425) * SG-878 - First draft - Dialog service now has backwards compatible method for opening a configurable simple dialog. * SG-878 - People comp - test cases for simple dialog method - more testing required * SG-878 - Much more simple dialog work - investigating different approaches to see what will work best. Lots of WIP on this one. Includes first draft but working solution for solving placeholder support for non-localized strings. * SG-878 - (1) Broke out enums and types into separate files for better single responsibility (2) Allow null cancelButtonText for single accept button support * SG-878 - Configurable simple dialog - removed separate comp approach as it is a maint problem to have simple dialog implemented in two places. * SG-878 - Added js doc comments for dialog service openSimpleDialog method * SG-878 - Don't export ConfigurableSimpleDialogComp as only dialogService should use it * SG-878 - (1) Refactor configurable simple dialog to reduce icon class repetition in html (2) Update simple dialog options to use new Translation interface and update comp to properly process placeholders again * SG-878 - Reverting all simple dialog changes as, per discussion with Oscar, going to use composition and go with configurable-simple-dialog comp for use in the dialog service * SG-878 - Testing latest simple dialog changes * SG-878 - Update simple-dialog-options * SG-878 - (1) People & collections component now use dialogService.openSimpleDialog vs custom org upgrade dialog comp (2) Rename configurable-simple-dialog to simple-configurable-dialog for better folder placement * SG-878 - Update formatting of Simple dialog options js doc comments * SG-878 - Remove test code * SG-878 -Remove org upgrade dialog component as it has been replaced with dialog service openSimpleDialog method call * SG-878 - Move models to be near where they are used which is in the simple-configurable-dialog folder. * SG-878 - Refactor icon classes into simple getter per Oscar's suggestions * SG-878 - Refactor Translation placeholderValues to be just placeholders * SG-878 - Refactor Simple Dialog Options to remove isLocalized as it doesn't buy us that much to have it. We can just check if a passed in value is a string or a Translation object to determine if we need to translate it. * SG-878 - Dialog Svc - remove backdrop classes from openSimpleDialog method as standard open method applies them * SG-878 - (1) Refactor simple configurable dialog to use comp properties instead of re-using option props (2) Reduce html complexity (3) Create translate func for code simplification (4) Remove isTranslation type guard as simple object check is sufficient * SG-668 - Refactoring collections & people comps use of dialog service openSimpleDialog to condense options per PR feedback * SG-878 - SimpleConfigDialog - (1) Footer classes were missing so btns were not spaced out properly (2) cancel btn text fixed to reference component property * SG-878 - First pass at creating a storybook example for the new openSimpleDialog method on the dialogService. * SG-878 - SimpleConfigurableDialog storybook - now displays callout with dialog results for better example * SG-878 - SimpleConfigurableDialog - use text-main tailwind class for h2s so that text is colored properly on black background * SG-878 - SimpleConfigurableDialog - Remove unstyled buttons and colored text and replace with plain secondary buttons to fix visibility issues on dark background. * Update libs/components/src/dialog/simple-configurable-dialog/models/simple-dialog-type.enum.ts SG-878 - Remove early commentary about use of simple-dialog-type enum Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.html SG-878 - SimpleConfigurableDialog html - consolidate title html to 1 line Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigurableDialog comp ts - remove unnecessary comment. Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigDialog comp - remove unnecessary comment Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * SG-668 / SG-878 - Migrate Free Org Upgrade Flows logic from deprecated collections component to vault component * SG-878 - Refactor the free org upgrade dialog to leverage separate methods to improve code and decrease cyclomatic complexity Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
2023-01-24 22:38:14 +01:00
/**
* Opens a simple dialog.
*
* You should probably use `openSimpleDialog` instead, unless you need to programmatically close the dialog.
*
Feature/SG-878 - Add open simple dialog method on dialog service (#4425) * SG-878 - First draft - Dialog service now has backwards compatible method for opening a configurable simple dialog. * SG-878 - People comp - test cases for simple dialog method - more testing required * SG-878 - Much more simple dialog work - investigating different approaches to see what will work best. Lots of WIP on this one. Includes first draft but working solution for solving placeholder support for non-localized strings. * SG-878 - (1) Broke out enums and types into separate files for better single responsibility (2) Allow null cancelButtonText for single accept button support * SG-878 - Configurable simple dialog - removed separate comp approach as it is a maint problem to have simple dialog implemented in two places. * SG-878 - Added js doc comments for dialog service openSimpleDialog method * SG-878 - Don't export ConfigurableSimpleDialogComp as only dialogService should use it * SG-878 - (1) Refactor configurable simple dialog to reduce icon class repetition in html (2) Update simple dialog options to use new Translation interface and update comp to properly process placeholders again * SG-878 - Reverting all simple dialog changes as, per discussion with Oscar, going to use composition and go with configurable-simple-dialog comp for use in the dialog service * SG-878 - Testing latest simple dialog changes * SG-878 - Update simple-dialog-options * SG-878 - (1) People & collections component now use dialogService.openSimpleDialog vs custom org upgrade dialog comp (2) Rename configurable-simple-dialog to simple-configurable-dialog for better folder placement * SG-878 - Update formatting of Simple dialog options js doc comments * SG-878 - Remove test code * SG-878 -Remove org upgrade dialog component as it has been replaced with dialog service openSimpleDialog method call * SG-878 - Move models to be near where they are used which is in the simple-configurable-dialog folder. * SG-878 - Refactor icon classes into simple getter per Oscar's suggestions * SG-878 - Refactor Translation placeholderValues to be just placeholders * SG-878 - Refactor Simple Dialog Options to remove isLocalized as it doesn't buy us that much to have it. We can just check if a passed in value is a string or a Translation object to determine if we need to translate it. * SG-878 - Dialog Svc - remove backdrop classes from openSimpleDialog method as standard open method applies them * SG-878 - (1) Refactor simple configurable dialog to use comp properties instead of re-using option props (2) Reduce html complexity (3) Create translate func for code simplification (4) Remove isTranslation type guard as simple object check is sufficient * SG-668 - Refactoring collections & people comps use of dialog service openSimpleDialog to condense options per PR feedback * SG-878 - SimpleConfigDialog - (1) Footer classes were missing so btns were not spaced out properly (2) cancel btn text fixed to reference component property * SG-878 - First pass at creating a storybook example for the new openSimpleDialog method on the dialogService. * SG-878 - SimpleConfigurableDialog storybook - now displays callout with dialog results for better example * SG-878 - SimpleConfigurableDialog - use text-main tailwind class for h2s so that text is colored properly on black background * SG-878 - SimpleConfigurableDialog - Remove unstyled buttons and colored text and replace with plain secondary buttons to fix visibility issues on dark background. * Update libs/components/src/dialog/simple-configurable-dialog/models/simple-dialog-type.enum.ts SG-878 - Remove early commentary about use of simple-dialog-type enum Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.html SG-878 - SimpleConfigurableDialog html - consolidate title html to 1 line Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigurableDialog comp ts - remove unnecessary comment. Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigDialog comp - remove unnecessary comment Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * SG-668 / SG-878 - Migrate Free Org Upgrade Flows logic from deprecated collections component to vault component * SG-878 - Refactor the free org upgrade dialog to leverage separate methods to improve code and decrease cyclomatic complexity Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
2023-01-24 22:38:14 +01:00
* @param {SimpleDialogOptions} simpleDialogOptions - An object containing options for the dialog.
* @returns `DialogRef` - The reference to the opened dialog.
* Contains a closed observable which can be subscribed to for determining which button
* a user pressed
Feature/SG-878 - Add open simple dialog method on dialog service (#4425) * SG-878 - First draft - Dialog service now has backwards compatible method for opening a configurable simple dialog. * SG-878 - People comp - test cases for simple dialog method - more testing required * SG-878 - Much more simple dialog work - investigating different approaches to see what will work best. Lots of WIP on this one. Includes first draft but working solution for solving placeholder support for non-localized strings. * SG-878 - (1) Broke out enums and types into separate files for better single responsibility (2) Allow null cancelButtonText for single accept button support * SG-878 - Configurable simple dialog - removed separate comp approach as it is a maint problem to have simple dialog implemented in two places. * SG-878 - Added js doc comments for dialog service openSimpleDialog method * SG-878 - Don't export ConfigurableSimpleDialogComp as only dialogService should use it * SG-878 - (1) Refactor configurable simple dialog to reduce icon class repetition in html (2) Update simple dialog options to use new Translation interface and update comp to properly process placeholders again * SG-878 - Reverting all simple dialog changes as, per discussion with Oscar, going to use composition and go with configurable-simple-dialog comp for use in the dialog service * SG-878 - Testing latest simple dialog changes * SG-878 - Update simple-dialog-options * SG-878 - (1) People & collections component now use dialogService.openSimpleDialog vs custom org upgrade dialog comp (2) Rename configurable-simple-dialog to simple-configurable-dialog for better folder placement * SG-878 - Update formatting of Simple dialog options js doc comments * SG-878 - Remove test code * SG-878 -Remove org upgrade dialog component as it has been replaced with dialog service openSimpleDialog method call * SG-878 - Move models to be near where they are used which is in the simple-configurable-dialog folder. * SG-878 - Refactor icon classes into simple getter per Oscar's suggestions * SG-878 - Refactor Translation placeholderValues to be just placeholders * SG-878 - Refactor Simple Dialog Options to remove isLocalized as it doesn't buy us that much to have it. We can just check if a passed in value is a string or a Translation object to determine if we need to translate it. * SG-878 - Dialog Svc - remove backdrop classes from openSimpleDialog method as standard open method applies them * SG-878 - (1) Refactor simple configurable dialog to use comp properties instead of re-using option props (2) Reduce html complexity (3) Create translate func for code simplification (4) Remove isTranslation type guard as simple object check is sufficient * SG-668 - Refactoring collections & people comps use of dialog service openSimpleDialog to condense options per PR feedback * SG-878 - SimpleConfigDialog - (1) Footer classes were missing so btns were not spaced out properly (2) cancel btn text fixed to reference component property * SG-878 - First pass at creating a storybook example for the new openSimpleDialog method on the dialogService. * SG-878 - SimpleConfigurableDialog storybook - now displays callout with dialog results for better example * SG-878 - SimpleConfigurableDialog - use text-main tailwind class for h2s so that text is colored properly on black background * SG-878 - SimpleConfigurableDialog - Remove unstyled buttons and colored text and replace with plain secondary buttons to fix visibility issues on dark background. * Update libs/components/src/dialog/simple-configurable-dialog/models/simple-dialog-type.enum.ts SG-878 - Remove early commentary about use of simple-dialog-type enum Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.html SG-878 - SimpleConfigurableDialog html - consolidate title html to 1 line Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigurableDialog comp ts - remove unnecessary comment. Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigDialog comp - remove unnecessary comment Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * SG-668 / SG-878 - Migrate Free Org Upgrade Flows logic from deprecated collections component to vault component * SG-878 - Refactor the free org upgrade dialog to leverage separate methods to improve code and decrease cyclomatic complexity Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
2023-01-24 22:38:14 +01:00
*/
openSimpleDialogRef(simpleDialogOptions: SimpleDialogOptions): DialogRef<boolean> {
return this.open<boolean, SimpleDialogOptions>(SimpleConfigurableDialogComponent, {
Feature/SG-878 - Add open simple dialog method on dialog service (#4425) * SG-878 - First draft - Dialog service now has backwards compatible method for opening a configurable simple dialog. * SG-878 - People comp - test cases for simple dialog method - more testing required * SG-878 - Much more simple dialog work - investigating different approaches to see what will work best. Lots of WIP on this one. Includes first draft but working solution for solving placeholder support for non-localized strings. * SG-878 - (1) Broke out enums and types into separate files for better single responsibility (2) Allow null cancelButtonText for single accept button support * SG-878 - Configurable simple dialog - removed separate comp approach as it is a maint problem to have simple dialog implemented in two places. * SG-878 - Added js doc comments for dialog service openSimpleDialog method * SG-878 - Don't export ConfigurableSimpleDialogComp as only dialogService should use it * SG-878 - (1) Refactor configurable simple dialog to reduce icon class repetition in html (2) Update simple dialog options to use new Translation interface and update comp to properly process placeholders again * SG-878 - Reverting all simple dialog changes as, per discussion with Oscar, going to use composition and go with configurable-simple-dialog comp for use in the dialog service * SG-878 - Testing latest simple dialog changes * SG-878 - Update simple-dialog-options * SG-878 - (1) People & collections component now use dialogService.openSimpleDialog vs custom org upgrade dialog comp (2) Rename configurable-simple-dialog to simple-configurable-dialog for better folder placement * SG-878 - Update formatting of Simple dialog options js doc comments * SG-878 - Remove test code * SG-878 -Remove org upgrade dialog component as it has been replaced with dialog service openSimpleDialog method call * SG-878 - Move models to be near where they are used which is in the simple-configurable-dialog folder. * SG-878 - Refactor icon classes into simple getter per Oscar's suggestions * SG-878 - Refactor Translation placeholderValues to be just placeholders * SG-878 - Refactor Simple Dialog Options to remove isLocalized as it doesn't buy us that much to have it. We can just check if a passed in value is a string or a Translation object to determine if we need to translate it. * SG-878 - Dialog Svc - remove backdrop classes from openSimpleDialog method as standard open method applies them * SG-878 - (1) Refactor simple configurable dialog to use comp properties instead of re-using option props (2) Reduce html complexity (3) Create translate func for code simplification (4) Remove isTranslation type guard as simple object check is sufficient * SG-668 - Refactoring collections & people comps use of dialog service openSimpleDialog to condense options per PR feedback * SG-878 - SimpleConfigDialog - (1) Footer classes were missing so btns were not spaced out properly (2) cancel btn text fixed to reference component property * SG-878 - First pass at creating a storybook example for the new openSimpleDialog method on the dialogService. * SG-878 - SimpleConfigurableDialog storybook - now displays callout with dialog results for better example * SG-878 - SimpleConfigurableDialog - use text-main tailwind class for h2s so that text is colored properly on black background * SG-878 - SimpleConfigurableDialog - Remove unstyled buttons and colored text and replace with plain secondary buttons to fix visibility issues on dark background. * Update libs/components/src/dialog/simple-configurable-dialog/models/simple-dialog-type.enum.ts SG-878 - Remove early commentary about use of simple-dialog-type enum Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.html SG-878 - SimpleConfigurableDialog html - consolidate title html to 1 line Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigurableDialog comp ts - remove unnecessary comment. Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts SG-878 - SimpleConfigDialog storybook fixes Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update libs/components/src/dialog/simple-configurable-dialog/simple-configurable-dialog.component.ts SG-878 - SimpleConfigDialog comp - remove unnecessary comment Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * SG-668 / SG-878 - Migrate Free Org Upgrade Flows logic from deprecated collections component to vault component * SG-878 - Refactor the free org upgrade dialog to leverage separate methods to improve code and decrease cyclomatic complexity Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
2023-01-24 22:38:14 +01:00
data: simpleDialogOptions,
disableClose: simpleDialogOptions.disableClose,
});
}
protected translate(translation: string | Translation, defaultKey?: string): string {
if (translation == null && defaultKey == null) {
return null;
}
if (translation == null) {
return this.i18nService.t(defaultKey);
}
// Translation interface use implies we must localize.
if (typeof translation === "object") {
return this.i18nService.t(translation.key, ...(translation.placeholders ?? []));
}
return translation;
}
2022-08-05 17:45:36 +02:00
}