Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class UmbAuthContext extends UmbContextBase {
return {
base: config.baseUrl,
credentials: config.credentials,
token: this.getLatestToken,
token: () => this.getLatestToken(),
};
}

Expand Down
10 changes: 5 additions & 5 deletions templates/UmbracoExtension/Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"generate-client": "node scripts/generate-openapi.js https://localhost:44339/umbraco/swagger/umbracoextension/swagger.json"
},
"devDependencies": {
"@hey-api/client-fetch": "^0.8.3",
"@hey-api/openapi-ts": "^0.64.10",
"@hey-api/client-fetch": "^0.10.0",
"@hey-api/openapi-ts": "^0.66.7",
"@umbraco-cms/backoffice": "^UMBRACO_VERSION_FROM_TEMPLATE",
"chalk": "^5.4.1",
"cross-env": "^7.0.3",
"node-fetch": "^3.3.2",
"typescript": "^5.8.2",
"vite": "^6.2.0"
"typescript": "^5.8.3",
"vite": "^6.3.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@ import {
} from "@umbraco-cms/backoffice/external/lit";
import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api";
import { UUIButtonElement } from "@umbraco-cms/backoffice/external/uui";
import {
UMB_NOTIFICATION_CONTEXT,
UmbNotificationContext,
} from "@umbraco-cms/backoffice/notification";
import {
UMB_CURRENT_USER_CONTEXT,
UmbCurrentUserModel,
} from "@umbraco-cms/backoffice/current-user";
import { UMB_NOTIFICATION_CONTEXT } from "@umbraco-cms/backoffice/notification";
import { UMB_CURRENT_USER_CONTEXT } from "@umbraco-cms/backoffice/current-user";
import { UmbracoExtensionService, UserModel } from "../api/index.js";

@customElement("example-dashboard")
export class ExampleDashboardElement extends UmbElementMixin(LitElement) {
@state()
private _yourName: string | undefined = "Press the button!";
private _yourName?: string = "Press the button!";

@state()
private _timeFromMrWolf: Date | undefined;
private _timeFromMrWolf?: Date;

@state()
private _serverUserData: UserModel | undefined = undefined;
private _serverUserData?: UserModel;

@state()
private _contextCurrentUser: UmbCurrentUserModel | undefined = undefined;
private _contextCurrentUser?: typeof UMB_CURRENT_USER_CONTEXT.TYPE;

#notificationContext?: typeof UMB_NOTIFICATION_CONTEXT.TYPE;

constructor() {
super();
Expand All @@ -42,14 +38,16 @@ export class ExampleDashboardElement extends UmbElementMixin(LitElement) {
// When we have the current user context
// We can observe properties from it, such as the current user or perhaps just individual properties
// When the currentUser object changes we will get notified and can reset the @state properrty
this.observe(currentUserContext.currentUser, (currentUser) => {
this._contextCurrentUser = currentUser;
});
this.observe(
currentUserContext.currentUser,
(currentUser) => {
this._contextCurrentUser = currentUser;
},
"_contextCurrentUser"
);
});
}

#notificationContext: UmbNotificationContext | undefined = undefined;

#onClickWhoAmI = async (ev: Event) => {
const buttonElement = ev.target as UUIButtonElement;
buttonElement.state = "waiting";
Expand Down
10 changes: 5 additions & 5 deletions templates/UmbracoExtension/Client/src/entrypoints/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
UmbEntryPointOnInit,
UmbEntryPointOnUnload,
} from "@umbraco-cms/backoffice/extension-api";
Expand All @@ -15,12 +15,12 @@ export const onInit: UmbEntryPointOnInit = (_host, _extensionRegistry) => {
// Do the OAuth token handshake stuff
_host.consumeContext(UMB_AUTH_CONTEXT, async (authContext) => {
// Get the token info from Umbraco
const config = authContext.getOpenApiConfiguration();
const config = authContext?.getOpenApiConfiguration();

client.setConfig({
auth: config.token,
baseUrl: config.base,
credentials: config.credentials,
auth: config?.token ?? undefined,
baseUrl: config?.base ?? "",
credentials: config?.credentials ?? "same-origin",
});
});
//#endif
Expand Down
Loading