diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/actions/save/workspace-action-data-type-save.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/actions/save/workspace-action-data-type-save.element.ts index 291cfc6e97..3724c14b88 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/actions/save/workspace-action-data-type-save.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/actions/save/workspace-action-data-type-save.element.ts @@ -2,11 +2,8 @@ import { css, html, LitElement } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import type { UUIButtonState } from '@umbraco-ui/uui'; -import type { UmbNotificationDefaultData } from '../../../../../core/services/notification/layouts/default'; -import type { UmbNotificationService } from '../../../../../core/services/notification'; -import { UmbDataTypeContext } from '../../data-type.context'; +import type { UmbWorkspaceDataTypeContext } from '../../workspace-data-type.context'; import { UmbContextConsumerMixin } from '@umbraco-cms/context-api'; -import { UmbDataTypeStore } from '@umbraco-cms/stores/data-type/data-type.store'; @customElement('umb-workspace-action-data-type-save') export class UmbWorkspaceActionDataTypeSaveElement extends UmbContextConsumerMixin(LitElement) { @@ -15,33 +12,26 @@ export class UmbWorkspaceActionDataTypeSaveElement extends UmbContextConsumerMix @state() private _saveButtonState?: UUIButtonState; - private _dataTypeStore?: UmbDataTypeStore; - private _dataTypeContext?: UmbDataTypeContext; - private _notificationService?: UmbNotificationService; + private _workspaceContext?: UmbWorkspaceDataTypeContext; constructor() { super(); - this.consumeAllContexts(['umbDataTypeStore', 'umbDataTypeContext', 'umbNotificationService'], (instances) => { - this._dataTypeStore = instances['umbDataTypeStore']; - this._dataTypeContext = instances['umbDataTypeContext']; - this._notificationService = instances['umbNotificationService']; - }); + this.consumeContext('umbWorkspaceContext', (instance) => { + this._workspaceContext = instance; + } + ); } private async _handleSave() { - if (!this._dataTypeStore || !this._dataTypeContext) return; + if (!this._workspaceContext) return; - try { - this._saveButtonState = 'waiting'; - const dataType = this._dataTypeContext.getData(); - await this._dataTypeStore.save([dataType]); - const data: UmbNotificationDefaultData = { message: 'Data Type Saved' }; - this._notificationService?.peek('positive', { data }); + this._saveButtonState = 'waiting'; + await this._workspaceContext.save().then(() => { this._saveButtonState = 'success'; - } catch (error) { + }).catch(() => { this._saveButtonState = 'failed'; - } + }) } render() { diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/workspace-data-type.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/workspace-data-type.context.ts index eb6a143ed4..ce33a1fb3c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/workspace-data-type.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/data-type/workspace-data-type.context.ts @@ -1,6 +1,6 @@ import { UmbWorkspaceNodeContext } from "../shared/workspace-context/workspace-node.context"; import type { UmbDataTypeStore, UmbDataTypeStoreItemType } from "@umbraco-cms/stores/data-type/data-type.store"; -import { DataTypeDetails } from "@umbraco-cms/models"; +import type { DataTypeDetails } from "@umbraco-cms/models"; const DefaultDataTypeData = ({ key: '',