improve workspace-action model
This commit is contained in:
@@ -3,7 +3,7 @@ import { css, html, LitElement } from 'lit';
|
||||
import { customElement, property } from 'lit/decorators.js';
|
||||
import { UmbWorkspaceDocumentContext } from './workspace-document.context';
|
||||
import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry';
|
||||
import type { ManifestWorkspaceView } from '@umbraco-cms/models';
|
||||
import type { ManifestWorkspaceAction, ManifestWorkspaceView } from '@umbraco-cms/models';
|
||||
import { UmbContextConsumerMixin, UmbContextProviderMixin } from '@umbraco-cms/context-api';
|
||||
import '../shared/workspace-content/workspace-content.element';
|
||||
import { UmbObserverMixin } from '@umbraco-cms/observable-api';
|
||||
@@ -61,7 +61,7 @@ export class UmbWorkspaceDocumentElement extends UmbObserverMixin(UmbContextCons
|
||||
}
|
||||
|
||||
private _registerWorkspaceViews() {
|
||||
const dashboards: Array<ManifestWorkspaceView> = [
|
||||
const dashboards: Array<ManifestWorkspaceView | ManifestWorkspaceAction> = [
|
||||
{
|
||||
type: 'workspaceView',
|
||||
alias: 'Umb.WorkspaceView.Document.Edit',
|
||||
@@ -88,6 +88,39 @@ export class UmbWorkspaceDocumentElement extends UmbObserverMixin(UmbContextCons
|
||||
icon: 'info',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'workspaceAction',
|
||||
alias: 'Umb.WorkspaceAction.Document.SaveAndPreview',
|
||||
name: 'Save Document Workspace Action',
|
||||
loader: () => import('../shared/actions/save/workspace-action-node-save.element'),
|
||||
meta: {
|
||||
workspaces: ['Umb.Workspace.Document'],
|
||||
label: 'Save and preview',
|
||||
},
|
||||
},
|
||||
{
|
||||
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.Document'],
|
||||
look: 'secondary',
|
||||
label: 'Save'
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'workspaceAction',
|
||||
alias: 'Umb.WorkspaceAction.Document.SaveAndPublish',
|
||||
name: 'Save Document Workspace Action',
|
||||
loader: () => import('../shared/actions/save/workspace-action-node-save.element'),
|
||||
meta: {
|
||||
workspaces: ['Umb.Workspace.Document'],
|
||||
label: 'Save and publish',
|
||||
look: 'primary',
|
||||
color: 'positive'
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
dashboards.forEach((dashboard) => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
|
||||
import type { UUIButtonState } from '@umbraco-ui/uui';
|
||||
import type { UmbWorkspaceNodeContext } from '../../workspace-context/workspace-node.context';
|
||||
import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
|
||||
import { ManifestWorkspaceAction } from '@umbraco-cms/models';
|
||||
|
||||
@customElement('umb-workspace-action-node-save')
|
||||
export class UmbWorkspaceActionNodeSaveElement extends UmbContextConsumerMixin(LitElement) {
|
||||
@@ -15,6 +16,8 @@ export class UmbWorkspaceActionNodeSaveElement extends UmbContextConsumerMixin(L
|
||||
|
||||
private _workspaceContext?: UmbWorkspaceNodeContext;
|
||||
|
||||
public manifest?: ManifestWorkspaceAction;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -38,9 +41,9 @@ export class UmbWorkspaceActionNodeSaveElement extends UmbContextConsumerMixin(L
|
||||
render() {
|
||||
return html`<uui-button
|
||||
@click=${this._handleSave}
|
||||
look="primary"
|
||||
color="positive"
|
||||
label="save"
|
||||
look=${this.manifest?.meta.look || 'default'}
|
||||
color=${this.manifest?.meta.color || 'default'}
|
||||
label=${this.manifest?.meta.label || 'Save'}
|
||||
.state="${this._saveButtonState}"></uui-button>`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ export class UmbWorkspaceContentElement extends UmbContextProviderMixin(
|
||||
</div>
|
||||
|
||||
<div id="footer" slot="footer">Breadcrumbs</div>
|
||||
<!-- TODO: convert document workspace actions to extensions: -->
|
||||
<!-- TODO: convert document workspace actions to extensions:
|
||||
<uui-button slot="actions" @click=${this._onSaveAndPreview} label="Save and preview"></uui-button>
|
||||
<uui-button slot="actions" @click=${this._onSave} look="secondary" label="Save"></uui-button>
|
||||
<uui-button
|
||||
@@ -198,6 +198,7 @@ export class UmbWorkspaceContentElement extends UmbContextProviderMixin(
|
||||
look="primary"
|
||||
color="positive"
|
||||
label="Save and publish"></uui-button>
|
||||
-->
|
||||
</umb-workspace-entity>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,11 @@ export class UmbWorkspaceEntity extends UmbContextConsumerMixin(UmbObserverMixin
|
||||
router-slot {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
umb-extension-slot[slot='actions'] {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { InterfaceColor, InterfaceLook } from '@umbraco-ui/uui-base/lib/types/index'
|
||||
import type { ManifestElement } from './models';
|
||||
|
||||
export interface ManifestWorkspaceAction extends ManifestElement {
|
||||
@@ -7,4 +8,7 @@ export interface ManifestWorkspaceAction extends ManifestElement {
|
||||
|
||||
export interface MetaEditorAction {
|
||||
workspaces: Array<string>;
|
||||
label: string,
|
||||
look?: InterfaceLook,
|
||||
color?: InterfaceColor,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user