mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
PM-10069 - Refactor unauthExtensionRefreshSwap to be available in non-extension clients and rename. (#10518)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { Type, inject } from "@angular/core";
|
||||
import { Route, Routes } from "@angular/router";
|
||||
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
|
||||
import { componentRouteSwap } from "../../utils/component-route-swap";
|
||||
|
||||
/**
|
||||
* Helper function to swap between two components based on the UnauthenticatedExtensionUIRefresh feature flag.
|
||||
* We need this because the auth teams's authenticated UI will be refreshed as part of the MVP but the
|
||||
* unauthenticated UIs will not necessarily make the cut.
|
||||
* Note: Even though this is primarily an extension refresh initiative, this will be used across clients
|
||||
* as we are consolidating the unauthenticated UIs into single libs/auth components which affects all clients.
|
||||
* @param defaultComponent - The current non-refreshed component to render.
|
||||
* @param refreshedComponent - The new refreshed component to render.
|
||||
* @param options - The shared route options to apply to both components.
|
||||
*/
|
||||
export function unauthUiRefreshSwap(
|
||||
defaultComponent: Type<any>,
|
||||
refreshedComponent: Type<any>,
|
||||
options: Route,
|
||||
): Routes {
|
||||
return componentRouteSwap(
|
||||
defaultComponent,
|
||||
refreshedComponent,
|
||||
async () => {
|
||||
const configService = inject(ConfigService);
|
||||
return configService.getFeatureFlag(FeatureFlag.UnauthenticatedExtensionUIRefresh);
|
||||
},
|
||||
options,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user