-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Add "Not Found" empty state to detail workspaces (#17489)
Co-authored-by: Niels Lyngsø <[email protected]> Co-authored-by: Niels Lyngsø <[email protected]>
- Loading branch information
1 parent
7cc8f84
commit 310ccdc
Showing
29 changed files
with
270 additions
and
166 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
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
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
12 changes: 12 additions & 0 deletions
12
...Client/src/packages/core/workspace/entity-detail/entity-detail-workspace.context-token.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,12 @@ | ||
import type { UmbWorkspaceContext } from '../workspace-context.interface.js'; | ||
import type { UmbEntityDetailWorkspaceContextBase } from './entity-detail-workspace-base.js'; | ||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; | ||
|
||
export const UMB_ENTITY_DETAIL_WORKSPACE_CONTEXT = new UmbContextToken< | ||
UmbWorkspaceContext, | ||
UmbEntityDetailWorkspaceContextBase | ||
>( | ||
'UmbWorkspaceContext', | ||
undefined, | ||
(context): context is UmbEntityDetailWorkspaceContextBase => (context as any).IS_ENTITY_DETAIL_WORKSPACE_CONTEXT, | ||
); |
50 changes: 50 additions & 0 deletions
50
...ackages/core/workspace/entity-detail/global-components/entity-detail-not-found.element.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,50 @@ | ||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; | ||
import { css, html, customElement, property } from '@umbraco-cms/backoffice/external/lit'; | ||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; | ||
|
||
@customElement('umb-entity-detail-not-found') | ||
export class UmbEntityDetailNotFoundElement extends UmbLitElement { | ||
@property({ type: String, attribute: 'entity-type' }) | ||
entityType = ''; | ||
|
||
override render() { | ||
return html` | ||
<div class="uui-text"> | ||
<h4>${this.localize.term('entityDetail_notFoundTitle', this.entityType)}</h4> | ||
${this.localize.term('entityDetail_notFoundDescription', this.entityType)} | ||
</div> | ||
`; | ||
} | ||
|
||
static override styles = [ | ||
UmbTextStyles, | ||
css` | ||
:host { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
min-width: 0; | ||
} | ||
:host > div { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
} | ||
@keyframes fadeIn { | ||
100% { | ||
opacity: 100%; | ||
} | ||
} | ||
`, | ||
]; | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'umb-entity-detail-not-found': UmbEntityDetailNotFoundElement; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
.../core/workspace/entity-detail/global-components/entity-detail-workspace-editor.element.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,77 @@ | ||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; | ||
import { UMB_ENTITY_DETAIL_WORKSPACE_CONTEXT } from '../entity-detail-workspace.context-token.js'; | ||
import { css, customElement, html, ifDefined, nothing, property, state } from '@umbraco-cms/backoffice/external/lit'; | ||
|
||
@customElement('umb-entity-detail-workspace-editor') | ||
export class UmbEntityDetailWorkspaceEditorElement extends UmbLitElement { | ||
@property({ attribute: 'back-path' }) | ||
public backPath?: string; | ||
|
||
@state() | ||
private _entityType?: string; | ||
|
||
@state() | ||
private _isLoading = false; | ||
|
||
@state() | ||
private _exists = false; | ||
|
||
@state() | ||
private _isNew? = false; | ||
|
||
#context?: typeof UMB_ENTITY_DETAIL_WORKSPACE_CONTEXT.TYPE; | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.consumeContext(UMB_ENTITY_DETAIL_WORKSPACE_CONTEXT, (context) => { | ||
this.#context = context; | ||
this.observe(this.#context?.entityType, (entityType) => (this._entityType = entityType)); | ||
this.observe(this.#context?.loading.isOn, (isLoading) => (this._isLoading = isLoading)); | ||
this.observe(this.#context?.data, (data) => (this._exists = !!data)); | ||
this.observe(this.#context?.isNew, (isNew) => (this._isNew = isNew)); | ||
}); | ||
} | ||
|
||
protected override render() { | ||
return html` ${!this._exists && !this._isLoading | ||
? html`<umb-entity-detail-not-found entity-type=${ifDefined(this._entityType)}></umb-entity-detail-not-found>` | ||
: nothing} | ||
<!-- TODO: It is currently on purpose that the workspace editor is always in the DOM, even when it doesn't have data. | ||
We currently rely on the entity actions to be available to execute, and we ran into an issue when the entity got deleted; then the DOM got cleared, and the delete action couldn't complete. | ||
We need to look into loading the entity actions in the workspace context instead so we don't rely on the DOM. | ||
--> | ||
<umb-workspace-editor | ||
?loading=${this._isLoading} | ||
.backPath=${this.backPath} | ||
class="${this._exists === false ? 'hide' : ''}"> | ||
<slot name="header" slot="header"></slot> | ||
${this.#renderEntityActions()} | ||
<slot></slot> | ||
</umb-workspace-editor>`; | ||
} | ||
|
||
#renderEntityActions() { | ||
if (this._isNew) return nothing; | ||
return html`<umb-workspace-entity-action-menu slot="action-menu"></umb-workspace-entity-action-menu>`; | ||
} | ||
|
||
static override styles = [ | ||
css` | ||
umb-workspace-editor { | ||
visibility: visible; | ||
} | ||
umb-workspace-editor.hide { | ||
visibility: hidden; | ||
} | ||
`, | ||
]; | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'umb-entity-detail-workspace-editor': UmbEntityDetailWorkspaceEditorElement; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...mbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/global-components/index.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,5 @@ | ||
import './entity-detail-not-found.element.js'; | ||
import './entity-detail-workspace-editor.element.js'; | ||
|
||
export * from './entity-detail-not-found.element.js'; | ||
export * from './entity-detail-workspace-editor.element.js'; |
4 changes: 4 additions & 0 deletions
4
src/Umbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/index.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 |
---|---|---|
@@ -1 +1,5 @@ | ||
import './global-components/index.js'; | ||
|
||
export * from './entity-detail-workspace-base.js'; | ||
export * from './global-components/index.js'; | ||
export type * from './types.js'; |
17 changes: 17 additions & 0 deletions
17
src/Umbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/types.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,17 @@ | ||
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity'; | ||
|
||
export interface UmbEntityDetailWorkspaceContextArgs { | ||
entityType: string; | ||
workspaceAlias: string; | ||
detailRepositoryAlias: string; | ||
} | ||
|
||
/** | ||
* @deprecated Use UmbEntityDetailWorkspaceContextArgs instead | ||
*/ | ||
export type UmbEntityWorkspaceContextArgs = UmbEntityDetailWorkspaceContextArgs; | ||
|
||
export interface UmbEntityDetailWorkspaceContextCreateArgs<DetailModelType> { | ||
parent: UmbEntityModel; | ||
preset?: Partial<DetailModelType>; | ||
} |
Oops, something went wrong.