Workspace view navigation context (#19255)
* todos * navigation context * replace raw manifests with view context * Array State has method * rename to hint and much more * Notes for later * correcting one word * more notes * update JS Docs * update tests for getHasOne * fix context api usage * update code for v.16 * correct test * export UMB_WORKSPACE_VIEW_CONTEXT * minor corrections * rename to _hintMap * refactor part 1 * update version number in comment * clear method for array states * declare hint import map * mega refactor * final corrections for working POC * clean up path logic * implement scaffold * propagation and inheritance from view to workspace * separate types from classes * refactor to view context * rename editor navigation context to editor context * propagate removals * clean up notes * Hints for Content Tabs * use const path * handle gone parent * added comments on something to be looked at * hints context types * contentTypeMergedContainers * lint fixes * public contentTypeMergedContainers * refactor property structure helper class * a few notes for Presets * set variant ID instead of parsing it to the constructor * do not inject root to the path * adjust structure manager logic * UmbPropertyTypeContainerMergedModel type update * correct mergedContainersOfParentIdAndType * fix lint errors * fix missing import * Update src/Umbraco.Web.UI.Client/src/packages/core/hint/context/hints.controller.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-validation-to-hints.manager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-validation-to-hints.manager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# Workspace View Badge Example
|
||||
|
||||
This example demonstrates the essence of the Workspace View Navigation Context. And how to append a Status that will be displayed as a badge on the Workspace Views Tab Navigation.
|
||||
@@ -0,0 +1,84 @@
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { css, html, customElement, LitElement } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
|
||||
import { UMB_WORKSPACE_VIEW_CONTEXT } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document';
|
||||
|
||||
@customElement('example-hint-workspace-view')
|
||||
export class ExampleHintWorkspaceView extends UmbElementMixin(LitElement) {
|
||||
//
|
||||
|
||||
async onClick() {
|
||||
/*
|
||||
const context = await this.getContext(UMB_WORKSPACE_VIEW_NAVIGATION_CONTEXT);
|
||||
if (!context) {
|
||||
throw new Error('Could not find the context');
|
||||
}
|
||||
const view = await context.getViewContext('example.workspaceView.hint');
|
||||
*/
|
||||
|
||||
/*
|
||||
const view = await this.getContext(UMB_WORKSPACE_VIEW_CONTEXT);
|
||||
if (!view) {
|
||||
throw new Error('Could not find the view');
|
||||
}
|
||||
|
||||
if (view.hints.has('exampleHintFromToggleAction')) {
|
||||
view.hints.removeOne('exampleHintFromToggleAction');
|
||||
} else {
|
||||
view.hints.addOne({
|
||||
unique: 'exampleHintFromToggleAction',
|
||||
text: 'Hi',
|
||||
color: 'invalid',
|
||||
weight: 100,
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
const workspace = await this.getContext(UMB_DOCUMENT_WORKSPACE_CONTEXT);
|
||||
if (!workspace) {
|
||||
throw new Error('Could not find the workspace');
|
||||
}
|
||||
|
||||
if (workspace.hints.has('exampleHintFromToggleAction')) {
|
||||
workspace.hints.removeOne('exampleHintFromToggleAction');
|
||||
} else {
|
||||
workspace.hints.addOne({
|
||||
unique: 'exampleHintFromToggleAction',
|
||||
path: ['Umb.WorkspaceView.Document.Edit', 'root'],
|
||||
text: 'Hi',
|
||||
color: 'invalid',
|
||||
weight: 100,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
override render() {
|
||||
return html`
|
||||
<uui-box class="uui-text">
|
||||
<h1 class="uui-h2" style="margin-top: var(--uui-size-layout-1);">See the hint on this views tab</h1>
|
||||
<p>This is toggle on/off via this button:</p>
|
||||
<uui-button type="button" @click=${this.onClick} look="primary" color="positive">Toggle hint</uui-button>
|
||||
</uui-box>
|
||||
`;
|
||||
}
|
||||
|
||||
static override styles = [
|
||||
UmbTextStyles,
|
||||
css`
|
||||
:host {
|
||||
display: block;
|
||||
padding: var(--uui-size-layout-1);
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
export { ExampleHintWorkspaceView as element };
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'example-hint-workspace-view': ExampleHintWorkspaceView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { UMB_WORKSPACE_CONDITION_ALIAS } from '@umbraco-cms/backoffice/workspace';
|
||||
|
||||
export const manifests: Array<UmbExtensionManifest> = [
|
||||
{
|
||||
type: 'workspaceView',
|
||||
name: 'Example Badge Workspace View',
|
||||
alias: 'example.workspaceView.hint',
|
||||
element: () => import('./hint-workspace-view.js'),
|
||||
weight: 900,
|
||||
meta: {
|
||||
label: 'View with badge',
|
||||
pathname: 'badge',
|
||||
icon: 'icon-lab',
|
||||
},
|
||||
conditions: [
|
||||
{
|
||||
alias: UMB_WORKSPACE_CONDITION_ALIAS,
|
||||
match: 'Umb.Workspace.Document',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user