From c642d99dbfb5b9820b9fec56d353a7feeaef2bb0 Mon Sep 17 00:00:00 2001
From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Date: Wed, 9 Oct 2024 09:47:57 +0200
Subject: [PATCH 1/3] fix: the system information button should be visible to
 anyone

---
 .../components/backoffice-header-logo.element.ts           | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/apps/backoffice/components/backoffice-header-logo.element.ts b/src/apps/backoffice/components/backoffice-header-logo.element.ts
index 3dd588cc84..e23427254c 100644
--- a/src/apps/backoffice/components/backoffice-header-logo.element.ts
+++ b/src/apps/backoffice/components/backoffice-header-logo.element.ts
@@ -73,12 +73,7 @@ export class UmbBackofficeHeaderLogoElement extends UmbLitElement {
 
 						<a href="https://umbraco.com" target="_blank" rel="noopener">Umbraco.com</a>
 
-						${this._isUserAdmin
-							? html`<uui-button
-									@click=${this.#openSystemInformation}
-									look="secondary"
-									label="System information"></uui-button>`
-							: ''}
+						<uui-button @click=${this.#openSystemInformation} look="secondary" label="System information"></uui-button>
 					</div>
 				</umb-popover-layout>
 			</uui-popover-container>

From 91bf00f031509ce62adc235095e46764b7c7afd0 Mon Sep 17 00:00:00 2001
From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Date: Wed, 9 Oct 2024 09:54:24 +0200
Subject: [PATCH 2/3] chore: fix sonarcloud issues and optimise contexts

---
 .../sysinfo/components/sysinfo.element.ts     | 24 ++++++++-----------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/packages/sysinfo/components/sysinfo.element.ts b/src/packages/sysinfo/components/sysinfo.element.ts
index 63dfb31984..4d2faef779 100644
--- a/src/packages/sysinfo/components/sysinfo.element.ts
+++ b/src/packages/sysinfo/components/sysinfo.element.ts
@@ -21,23 +21,17 @@ export class UmbSysinfoElement extends UmbModalBaseElement {
 	@state()
 	private _buttonState?: UUIButtonState;
 
-	#serverKeyValues: Array<ServerKeyValue> = [];
-	#sysinfoRepository = new UmbSysinfoRepository(this);
-	#notificationContext?: typeof UMB_NOTIFICATION_CONTEXT.TYPE;
-
-	constructor() {
-		super();
-
-		this.consumeContext(UMB_NOTIFICATION_CONTEXT, (context) => {
-			this.#notificationContext = context;
-		});
+	readonly #serverKeyValues: Array<ServerKeyValue> = [];
+	readonly #sysinfoRepository = new UmbSysinfoRepository(this);
 
+	override connectedCallback(): void {
+		super.connectedCallback();
 		this.#populate();
 	}
 
 	async #populate() {
 		this._loading = true;
-		this.#serverKeyValues = [];
+		this.#serverKeyValues.length = 0;
 
 		const [serverTroubleshooting, serverInformation] = await Promise.all([
 			this.#sysinfoRepository.requestTroubleShooting(),
@@ -45,7 +39,7 @@ export class UmbSysinfoElement extends UmbModalBaseElement {
 		]);
 
 		if (serverTroubleshooting) {
-			this.#serverKeyValues = serverTroubleshooting.items;
+			this.#serverKeyValues.push(...serverTroubleshooting.items);
 		}
 
 		if (serverInformation) {
@@ -100,6 +94,8 @@ export class UmbSysinfoElement extends UmbModalBaseElement {
 	}
 
 	async #copyToClipboard() {
+		const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT);
+
 		try {
 			this._buttonState = 'waiting';
 			const text = `Umbraco system information
@@ -109,7 +105,7 @@ ${this._systemInformation}`;
 			await navigator.clipboard.writeText(textAsCode);
 
 			setTimeout(() => {
-				this.#notificationContext?.peek('positive', {
+				notificationContext?.peek('positive', {
 					data: {
 						headline: 'System information',
 						message: this.localize.term('speechBubbles_copySuccessMessage'),
@@ -119,7 +115,7 @@ ${this._systemInformation}`;
 			}, 250);
 		} catch {
 			this._buttonState = 'failed';
-			this.#notificationContext?.peek('danger', {
+			notificationContext?.peek('danger', {
 				data: {
 					headline: 'System information',
 					message: this.localize.term('speechBubbles_cannotCopyInformation'),

From e044c024750c563b78fe0fd1074e1b85afde3099 Mon Sep 17 00:00:00 2001
From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Date: Wed, 9 Oct 2024 10:01:43 +0200
Subject: [PATCH 3/3] feat: add information about the current user

---
 .../sysinfo/components/sysinfo.element.ts      | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/packages/sysinfo/components/sysinfo.element.ts b/src/packages/sysinfo/components/sysinfo.element.ts
index 4d2faef779..1cd7ccc38b 100644
--- a/src/packages/sysinfo/components/sysinfo.element.ts
+++ b/src/packages/sysinfo/components/sysinfo.element.ts
@@ -4,6 +4,7 @@ import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
 import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
 import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification';
 import type { UUIButtonState } from '@umbraco-cms/backoffice/external/uui';
+import { UmbCurrentUserRepository } from '@umbraco-cms/backoffice/current-user';
 
 type ServerKeyValue = {
 	name: string;
@@ -23,6 +24,7 @@ export class UmbSysinfoElement extends UmbModalBaseElement {
 
 	readonly #serverKeyValues: Array<ServerKeyValue> = [];
 	readonly #sysinfoRepository = new UmbSysinfoRepository(this);
+	readonly #currentUserRepository = new UmbCurrentUserRepository(this);
 
 	override connectedCallback(): void {
 		super.connectedCallback();
@@ -53,6 +55,22 @@ export class UmbSysinfoElement extends UmbModalBaseElement {
 		this.#serverKeyValues.push({ name: 'Browser language', data: navigator.language });
 		this.#serverKeyValues.push({ name: 'Browser location', data: location.href });
 
+		// User information
+		const { data: currentUser } = await this.#currentUserRepository.requestCurrentUser();
+		if (currentUser) {
+			this.#serverKeyValues.push({ name: 'User is admin', data: currentUser.isAdmin ? 'Yes' : 'No' });
+			this.#serverKeyValues.push({ name: 'User sections', data: currentUser.allowedSections.join(', ') });
+			this.#serverKeyValues.push({ name: 'User culture', data: currentUser.languageIsoCode });
+			this.#serverKeyValues.push({
+				name: 'User languages',
+				data: currentUser.hasAccessToAllLanguages ? 'All' : currentUser.languages.join(', '),
+			});
+			this.#serverKeyValues.push({
+				name: 'User document start nodes',
+				data: currentUser.documentStartNodeUniques.length ? currentUser.documentStartNodeUniques.join(', ') : 'None',
+			});
+		}
+
 		this._systemInformation = this.#renderServerKeyValues();
 		this._loading = false;
 	}