2022-08-09 10:45:44 +02:00
|
|
|
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
|
|
|
|
|
import { css, html, LitElement } from 'lit';
|
|
|
|
|
import { customElement, property } from 'lit/decorators.js';
|
2022-12-20 15:09:34 +01:00
|
|
|
import { UmbWorkspaceMediaContext } from './workspace-media.context';
|
2022-12-23 13:32:39 +01:00
|
|
|
import type { ManifestWorkspaceAction, ManifestWorkspaceView, ManifestWorkspaceViewCollection } from '@umbraco-cms/models';
|
2022-10-20 11:11:36 +02:00
|
|
|
import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry';
|
2022-12-12 13:29:55 +01:00
|
|
|
import { UmbContextConsumerMixin, UmbContextProviderMixin } from '@umbraco-cms/context-api';
|
2022-08-09 10:45:44 +02:00
|
|
|
|
2022-12-16 09:44:50 +01:00
|
|
|
import '../shared/workspace-content/workspace-content.element';
|
2022-08-09 10:45:44 +02:00
|
|
|
|
2022-12-16 10:26:24 +01:00
|
|
|
@customElement('umb-workspace-media')
|
|
|
|
|
export class UmbWorkspaceMediaElement extends UmbContextConsumerMixin(UmbContextProviderMixin(LitElement)) {
|
2022-08-09 10:45:44 +02:00
|
|
|
static styles = [
|
|
|
|
|
UUITextStyles,
|
|
|
|
|
css`
|
|
|
|
|
:host {
|
|
|
|
|
display: block;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
];
|
|
|
|
|
|
2022-12-20 14:40:08 +01:00
|
|
|
private _entityKey!: string;
|
2022-08-09 10:45:44 +02:00
|
|
|
@property()
|
2022-12-20 14:40:08 +01:00
|
|
|
public get entityKey(): string {
|
|
|
|
|
return this._entityKey;
|
|
|
|
|
}
|
|
|
|
|
public set entityKey(value: string) {
|
|
|
|
|
this._entityKey = value;
|
|
|
|
|
this._provideWorkspace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _workspaceContext?:UmbWorkspaceMediaContext;
|
|
|
|
|
|
2022-08-09 10:45:44 +02:00
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
2022-10-20 11:11:36 +02:00
|
|
|
|
2022-12-20 14:40:08 +01:00
|
|
|
// TODO: consider if registering extensions should happen initially or else where, to enable unregister of extensions.
|
2022-12-16 10:26:24 +01:00
|
|
|
this._registerWorkspaceViews();
|
2022-10-20 11:11:36 +02:00
|
|
|
}
|
2022-12-12 13:29:55 +01:00
|
|
|
|
2022-12-20 14:40:08 +01:00
|
|
|
connectedCallback(): void {
|
|
|
|
|
super.connectedCallback();
|
|
|
|
|
// TODO: avoid this connection, our own approach on Lit-Controller could be handling this case.
|
|
|
|
|
this._workspaceContext?.connectedCallback();
|
|
|
|
|
}
|
|
|
|
|
disconnectedCallback(): void {
|
|
|
|
|
super.connectedCallback()
|
|
|
|
|
// TODO: avoid this connection, our own approach on Lit-Controller could be handling this case.
|
|
|
|
|
this._workspaceContext?.disconnectedCallback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected _provideWorkspace() {
|
2022-12-20 15:10:28 +01:00
|
|
|
if(this._entityKey) {
|
2022-12-20 14:40:08 +01:00
|
|
|
this._workspaceContext = new UmbWorkspaceMediaContext(this, this._entityKey);
|
|
|
|
|
this.provideContext('umbWorkspaceContext', this._workspaceContext);
|
|
|
|
|
}
|
2022-10-20 11:11:36 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-16 10:26:24 +01:00
|
|
|
private _registerWorkspaceViews() {
|
2022-12-23 13:32:39 +01:00
|
|
|
const dashboards: Array<ManifestWorkspaceView | ManifestWorkspaceViewCollection | ManifestWorkspaceAction> = [
|
2022-12-20 14:36:56 +01:00
|
|
|
{
|
2022-12-22 15:17:48 +01:00
|
|
|
type: 'workspaceViewCollection',
|
2022-12-20 14:36:56 +01:00
|
|
|
alias: 'Umb.WorkspaceView.Media.Collection',
|
|
|
|
|
name: 'Media Workspace Collection View',
|
|
|
|
|
weight: 300,
|
|
|
|
|
meta: {
|
|
|
|
|
workspaces: ['Umb.Workspace.Media'],
|
|
|
|
|
label: 'Media',
|
|
|
|
|
pathname: 'collection',
|
|
|
|
|
icon: 'umb:grid',
|
2022-12-22 15:17:48 +01:00
|
|
|
entityType: 'media',
|
|
|
|
|
storeAlias: 'umbMediaStore'
|
2022-12-20 14:36:56 +01:00
|
|
|
},
|
|
|
|
|
},
|
2022-10-20 11:11:36 +02:00
|
|
|
{
|
2022-12-16 09:38:17 +01:00
|
|
|
type: 'workspaceView',
|
2022-12-16 10:26:24 +01:00
|
|
|
alias: 'Umb.WorkspaceView.Media.Edit',
|
|
|
|
|
name: 'Media Workspace Edit View',
|
2022-12-16 09:47:58 +01:00
|
|
|
loader: () => import('../shared/workspace-content/views/edit/workspace-view-content-edit.element'),
|
2022-10-20 11:11:36 +02:00
|
|
|
weight: 200,
|
|
|
|
|
meta: {
|
2022-12-16 10:26:24 +01:00
|
|
|
workspaces: ['Umb.Workspace.Media'],
|
2022-10-20 11:11:36 +02:00
|
|
|
label: 'Media',
|
|
|
|
|
pathname: 'media',
|
|
|
|
|
icon: 'umb:picture',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2022-12-16 09:38:17 +01:00
|
|
|
type: 'workspaceView',
|
2022-12-16 10:26:24 +01:00
|
|
|
alias: 'Umb.WorkspaceView.Media.Info',
|
|
|
|
|
name: 'Media Workspace Info View',
|
2022-12-16 09:47:58 +01:00
|
|
|
loader: () => import('../shared/workspace-content/views/info/workspace-view-content-info.element'),
|
2022-10-20 11:11:36 +02:00
|
|
|
weight: 100,
|
|
|
|
|
meta: {
|
2022-12-16 10:26:24 +01:00
|
|
|
workspaces: ['Umb.Workspace.Media'],
|
2022-10-20 11:11:36 +02:00
|
|
|
label: 'Info',
|
|
|
|
|
pathname: 'info',
|
|
|
|
|
icon: 'info',
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-12-23 13:32:39 +01:00
|
|
|
{
|
|
|
|
|
type: 'workspaceAction',
|
|
|
|
|
alias: 'Umb.WorkspaceAction.Document.Save',
|
|
|
|
|
name: 'Save Document Workspace Action',
|
|
|
|
|
loader: () => import('../shared/actions/save/workspace-action-node-save.element'),
|
|
|
|
|
meta: {
|
|
|
|
|
workspaces: ['Umb.Workspace.Media'],
|
|
|
|
|
look: 'primary',
|
|
|
|
|
color: 'positive'
|
|
|
|
|
},
|
|
|
|
|
}
|
2022-10-20 11:11:36 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
dashboards.forEach((dashboard) => {
|
|
|
|
|
if (umbExtensionsRegistry.isRegistered(dashboard.alias)) return;
|
|
|
|
|
umbExtensionsRegistry.register(dashboard);
|
|
|
|
|
});
|
2022-08-09 10:45:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2022-12-19 22:31:01 +01:00
|
|
|
return html`<umb-workspace-content alias="Umb.Workspace.Media"></umb-workspace-content>`;
|
2022-08-09 10:45:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-16 10:26:24 +01:00
|
|
|
export default UmbWorkspaceMediaElement;
|
2022-08-09 10:45:44 +02:00
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
interface HTMLElementTagNameMap {
|
2022-12-16 10:26:24 +01:00
|
|
|
'umb-workspace-media': UmbWorkspaceMediaElement;
|
2022-08-09 10:45:44 +02:00
|
|
|
}
|
|
|
|
|
}
|