rename runtime level to server status

This commit is contained in:
Mads Rasmussen
2023-11-10 13:16:03 +01:00
parent 18f4043971
commit d18f9cab84

View File

@@ -58,7 +58,7 @@ export class UmbAppElement extends UmbLitElement {
#authContext?: typeof UMB_AUTH_CONTEXT.TYPE;
#umbIconRegistry = new UmbIconRegistry();
#uuiIconRegistry = new UUIIconRegistryEssential();
#runtimeLevel = RuntimeLevelModel.UNKNOWN;
#serverStatus = RuntimeLevelModel.UNKNOWN;
constructor() {
super();
@@ -84,11 +84,11 @@ export class UmbAppElement extends UmbLitElement {
// Try to initialise the auth flow and get the runtime status
try {
// Get the current runtime level
await this.#setInitStatus();
await this.#setServerStatus();
// If the runtime level is "install" we should clear any cached tokens
// else we should try and set the auth status
if (this.#runtimeLevel === RuntimeLevelModel.INSTALL) {
if (this.#serverStatus === RuntimeLevelModel.INSTALL) {
await this.#authContext.signOut();
} else {
await this.#setAuthStatus();
@@ -141,12 +141,12 @@ export class UmbAppElement extends UmbLitElement {
});
}
async #setInitStatus() {
async #setServerStatus() {
const { data, error } = await tryExecute(ServerResource.getServerStatus());
if (error) {
throw error;
}
this.#runtimeLevel = data?.serverStatus ?? RuntimeLevelModel.UNKNOWN;
this.#serverStatus = data?.serverStatus ?? RuntimeLevelModel.UNKNOWN;
}
async #setAuthStatus() {
@@ -165,7 +165,7 @@ export class UmbAppElement extends UmbLitElement {
}
#redirect() {
switch (this.#runtimeLevel) {
switch (this.#serverStatus) {
case RuntimeLevelModel.INSTALL:
history.replaceState(null, '', 'install');
break;
@@ -197,7 +197,7 @@ export class UmbAppElement extends UmbLitElement {
default:
// Redirect to the error page
this.#errorPage(`Unsupported runtime level: ${this.#runtimeLevel}`);
this.#errorPage(`Unsupported runtime level: ${this.#serverStatus}`);
}
}