-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Export helper for hosting external ui extensions
- Loading branch information
1 parent
99073c9
commit 3d08460
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/admin-ui/src/lib/core/src/shared/components/extension-host/host-external-frame.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Route } from '@angular/router'; | ||
|
||
import { ExtensionHostConfig, ExtensionHostOptions } from './extension-host-config'; | ||
import { ExtensionHostComponent } from './extension-host.component'; | ||
|
||
export interface ExternalFrameOptions extends ExtensionHostOptions { | ||
path: string; | ||
breadcrumbLabel: string; | ||
} | ||
|
||
/** | ||
* This function is used to conveniently configure a UI extension route to | ||
* host an external URL from the Admin UI using the {@link ExtensionHostComponent} | ||
* | ||
* @example | ||
* ```TypeScript | ||
* \@NgModule({ | ||
* imports: [ | ||
* RouterModule.forChild([ | ||
* hostExternalFrame({ | ||
* path: '', | ||
* breadcrumbLabel: 'Vue.js App', | ||
* extensionUrl: './assets/vue-app/index.html', | ||
* openInNewTab: false, | ||
* }), | ||
* ]), | ||
* ], | ||
* }) | ||
export class VueUiExtensionModule {} | ||
* ``` | ||
*/ | ||
export function hostExternalFrame(options: ExternalFrameOptions): Route { | ||
const pathMatch = options.path === '' ? 'full' : 'prefix'; | ||
return { | ||
path: options.path, | ||
pathMatch, | ||
component: ExtensionHostComponent, | ||
data: { | ||
breadcrumb: [ | ||
{ | ||
label: options.breadcrumbLabel, | ||
link: ['./'], | ||
}, | ||
], | ||
extensionHostConfig: new ExtensionHostConfig(options), | ||
}, | ||
}; | ||
} |