74 lines
1.9 KiB
TypeScript
Raw Normal View History

2022-07-06 11:02:36 +02:00
import { writable, readable, type Writable, type Readable } from 'svelte/store';
2022-07-06 11:02:36 +02:00
interface AppSession {
version: string | null,
2022-07-06 11:02:36 +02:00
userId: string | null,
teamId: string | null,
permission: string,
isAdmin: boolean,
whiteLabeled: boolean,
whiteLabeledDetails: {
icon: string | null,
},
tokens: {
github: string | null,
gitlab: string | null,
}
}
export const loginEmail: Writable<string | undefined> = writable()
export const appSession: Writable<AppSession> = writable({
version: null,
2022-07-06 11:02:36 +02:00
userId: null,
teamId: null,
permission: 'read',
isAdmin: false,
whiteLabeled: false,
whiteLabeledDetails: {
icon: null
},
tokens: {
github: null,
gitlab: null
}
});
export const isTraefikUsed: Writable<boolean> = writable(false);
export const disabledButton: Writable<boolean> = writable(false);
export const status: Writable<any> = writable({
application: {
isRunning: false,
isExited: false,
loading: false,
initialLoading: true
},
service: {
2022-07-21 12:43:53 +00:00
isRunning: false,
isExited: false,
2022-07-06 11:02:36 +02:00
loading: false,
2022-07-21 12:43:53 +00:00
initialLoading: true
},
2022-07-06 11:02:36 +02:00
database: {
2022-07-21 12:43:53 +00:00
isRunning: false,
isExited: false,
2022-07-06 11:02:36 +02:00
loading: false,
2022-07-21 12:43:53 +00:00
initialLoading: true
2022-07-06 11:02:36 +02:00
}
});
export const features = readable({
beta: window.localStorage.getItem('beta') === 'true',
latestVersion: window.localStorage.getItem('latestVersion')
});
export const location: Writable<null | string> = writable(null)
export const setLocation = (resource: any) => {
if (GITPOD_WORKSPACE_URL && resource.exposePort) {
const { href } = new URL(GITPOD_WORKSPACE_URL);
const newURL = href
.replace('https://', `https://${resource.exposePort}-`)
.replace(/\/$/, '');
location.set(newURL)
} else {
location.set(resource.fqdn)
}
}