-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ts/notification-store
- Loading branch information
Showing
6 changed files
with
95 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { get } from "svelte/store" | ||
import { API } from "@/api" | ||
import { auth } from "@/stores/portal" | ||
import { BudiStore } from "../BudiStore" | ||
import { PublicOIDCConfig } from "@budibase/types" | ||
|
||
class OIDCStore extends BudiStore<PublicOIDCConfig> { | ||
constructor() { | ||
super({}) | ||
} | ||
|
||
async init() { | ||
const tenantId = get(auth).tenantId | ||
const configs = await API.getOIDCConfigs(tenantId) | ||
// Just use the first config for now. | ||
// We will be support multiple logins buttons later on. | ||
this.set(configs[0] || {}) | ||
} | ||
} | ||
|
||
export const oidc = new OIDCStore() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { get } from "svelte/store" | ||
import { API } from "@/api" | ||
import { auth } from "@/stores/portal" | ||
import { | ||
ConfigType, | ||
PublicSettingsInnerConfig, | ||
SettingsBrandingConfig, | ||
SettingsInnerConfig, | ||
} from "@budibase/types" | ||
import { BudiStore } from "../BudiStore" | ||
|
||
interface LocalOrganisationState { | ||
loaded: boolean | ||
} | ||
|
||
type SavedOrganisationState = SettingsInnerConfig & SettingsBrandingConfig | ||
type OrganisationState = SavedOrganisationState & | ||
PublicSettingsInnerConfig & | ||
LocalOrganisationState | ||
|
||
const DEFAULT_STATE: OrganisationState = { | ||
platformUrl: "", | ||
emailBrandingEnabled: true, | ||
testimonialsEnabled: true, | ||
platformTitle: "Budibase", | ||
company: "Budibase", | ||
google: false, | ||
googleDatasourceConfigured: false, | ||
oidc: false, | ||
oidcCallbackUrl: "", | ||
googleCallbackUrl: "", | ||
loaded: false, | ||
} | ||
|
||
class OrganisationStore extends BudiStore<OrganisationState> { | ||
constructor() { | ||
super(DEFAULT_STATE) | ||
} | ||
|
||
async init() { | ||
const tenantId = get(auth).tenantId | ||
const settingsConfigDoc = await API.getTenantConfig(tenantId) | ||
this.set({ ...DEFAULT_STATE, ...settingsConfigDoc.config, loaded: true }) | ||
} | ||
|
||
async save(changes: Partial<SavedOrganisationState>) { | ||
// Strip non persisted fields | ||
const { | ||
oidc, | ||
google, | ||
googleDatasourceConfigured, | ||
oidcCallbackUrl, | ||
googleCallbackUrl, | ||
loaded, | ||
...config | ||
} = get(this.store) | ||
|
||
// Save new config | ||
const newConfig: SavedOrganisationState = { | ||
...config, | ||
...changes, | ||
} | ||
await API.saveConfig({ | ||
type: ConfigType.SETTINGS, | ||
config: newConfig, | ||
}) | ||
await this.init() | ||
} | ||
} | ||
|
||
export const organisation = new OrganisationStore() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters