feat: show a button in the backoffice logo area if a new version is available
This commit is contained in:
@@ -10,6 +10,7 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type { UmbExtensionManifestInitializer } from '@umbraco-cms/backoffice/extension-api';
|
||||
import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';
|
||||
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
|
||||
import { UmbSysinfoRepository } from '@umbraco-cms/backoffice/sysinfo';
|
||||
|
||||
export class UmbBackofficeContext extends UmbContextBase<UmbBackofficeContext> {
|
||||
#activeSectionAlias = new UmbStringState(undefined);
|
||||
@@ -76,6 +77,12 @@ export class UmbBackofficeContext extends UmbContextBase<UmbBackofficeContext> {
|
||||
public setActiveSectionAlias(alias: string) {
|
||||
this.#activeSectionAlias.setValue(alias);
|
||||
}
|
||||
|
||||
public async serverUpgradeCheck(): Promise<boolean> {
|
||||
const repository = new UmbSysinfoRepository(this);
|
||||
const check = await repository.serverUpgradeCheck();
|
||||
return !!check;
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_BACKOFFICE_CONTEXT = new UmbContextToken<UmbBackofficeContext>('UmbBackofficeContext');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isCurrentUserAnAdmin } from '@umbraco-cms/backoffice/current-user';
|
||||
import { UMB_BACKOFFICE_CONTEXT } from '../backoffice.context.js';
|
||||
import { isCurrentUserAnAdmin } from '@umbraco-cms/backoffice/current-user';
|
||||
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
@@ -14,6 +14,11 @@ export class UmbBackofficeHeaderLogoElement extends UmbLitElement {
|
||||
@state()
|
||||
private _isUserAdmin = false;
|
||||
|
||||
@state()
|
||||
private _serverUpgradeCheck = false;
|
||||
|
||||
#backofficeContext?: typeof UMB_BACKOFFICE_CONTEXT.TYPE;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -26,6 +31,8 @@ export class UmbBackofficeHeaderLogoElement extends UmbLitElement {
|
||||
},
|
||||
'_observeVersion',
|
||||
);
|
||||
|
||||
this.#backofficeContext = context;
|
||||
});
|
||||
|
||||
this.#isAdmin();
|
||||
@@ -33,6 +40,10 @@ export class UmbBackofficeHeaderLogoElement extends UmbLitElement {
|
||||
|
||||
async #isAdmin() {
|
||||
this._isUserAdmin = await isCurrentUserAnAdmin(this);
|
||||
|
||||
if (this._isUserAdmin) {
|
||||
this._serverUpgradeCheck = this.#backofficeContext ? await this.#backofficeContext.serverUpgradeCheck() : false;
|
||||
}
|
||||
}
|
||||
|
||||
override render() {
|
||||
@@ -50,6 +61,9 @@ export class UmbBackofficeHeaderLogoElement extends UmbLitElement {
|
||||
height="82"
|
||||
loading="lazy" />
|
||||
<span>${this._version}</span>
|
||||
|
||||
${this._serverUpgradeCheck ? html`<uui-button color="danger" label="Upgrade available"></uui-button>` : ''}
|
||||
|
||||
<a href="https://umbraco.com" target="_blank" rel="noopener">Umbraco.com</a>
|
||||
|
||||
${this._isUserAdmin
|
||||
|
||||
Reference in New Issue
Block a user