All checks were successful
Build and Push App Image / build-and-push (push) Successful in 50s
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import { defineStore } from "pinia";
|
|
import { computed, ref } from "vue";
|
|
import apiClient from "../services/apiClient";
|
|
|
|
const DEFAULT_FLAGS = {
|
|
registration_enabled: true,
|
|
provider_login_enabled: true,
|
|
public_sharing_enabled: true,
|
|
file_explorer_enabled: false,
|
|
};
|
|
|
|
export const useSettingsStore = defineStore("settings", () => {
|
|
const featureFlags = ref({ ...DEFAULT_FLAGS });
|
|
const flagsLoaded = ref(false);
|
|
|
|
const registrationEnabled = computed(() => !!featureFlags.value.registration_enabled);
|
|
const providerLoginEnabled = computed(() => !!featureFlags.value.provider_login_enabled);
|
|
const publicSharingEnabled = computed(() => !!featureFlags.value.public_sharing_enabled);
|
|
const fileExplorerEnabled = computed(() => !!featureFlags.value.file_explorer_enabled);
|
|
|
|
const loadFeatureFlags = async (force = false) => {
|
|
if (flagsLoaded.value && !force) {
|
|
return featureFlags.value;
|
|
}
|
|
|
|
try {
|
|
const response = await apiClient.get("/api/v1/settings/feature-flags");
|
|
featureFlags.value = {
|
|
...DEFAULT_FLAGS,
|
|
...response.data,
|
|
};
|
|
flagsLoaded.value = true;
|
|
} catch {
|
|
featureFlags.value = { ...DEFAULT_FLAGS };
|
|
flagsLoaded.value = true;
|
|
}
|
|
|
|
return featureFlags.value;
|
|
};
|
|
|
|
return {
|
|
featureFlags,
|
|
flagsLoaded,
|
|
registrationEnabled,
|
|
providerLoginEnabled,
|
|
publicSharingEnabled,
|
|
fileExplorerEnabled,
|
|
loadFeatureFlags,
|
|
};
|
|
});
|