Files
directus/app/src/stores/settings.ts
Rijk van Zanten 6a3eb823c3 Update base theme of the App (#11952)
* Add migration to remove default value from project_color

* Upgrade the default theme

* Do a pass over the header buttons

* Do another pass over --warning uses

* Little things

* Tweak smoke

* Use updated map

* Use dark system elements in dark mode

* Remove outdated files, update toasts

* Use correct delete button style for role

* Use primary for created point

* Tweak spacing in revisions section

* Use primary for sidebar sections

* Various color tweaks and changes

* Update base color palette

* Update "css reset" code

* Remove splashscreens, add default favicon

* Add primary highlight to datamodel page

* dark mode color update

* fix sign out hover color

* Does this help?!

* This fixes some loading issues

Fixes https://github.com/directus/directus/issues/10707

* Calculate default pretty background?

* Fix public view with logo

* Fix responsiveness of login page

* adjust notification group width to be equal

* Do an absolute pointless task that doesn't do anything

It was suggested that it could fix the stylelint error in tests, but alas

* Remove stylelint

Doesn't seem to play nice with script setup and other changes

Co-authored-by: Ben Haynes <ben@rngr.org>
2022-03-04 18:53:39 -05:00

49 lines
1.2 KiB
TypeScript

import api from '@/api';
import { i18n } from '@/lang';
import { notify } from '@/utils/notify';
import { unexpectedError } from '@/utils/unexpected-error';
import { merge } from 'lodash';
import { defineStore } from 'pinia';
import { Settings } from '@directus/shared/types';
import { useUserStore } from './user';
export const useSettingsStore = defineStore({
id: 'settingsStore',
state: () => ({
settings: null as null | Settings,
}),
actions: {
async hydrate() {
const userStore = useUserStore();
if (!userStore.currentUser || 'share' in userStore.currentUser) return;
const response = await api.get(`/settings`);
this.settings = response.data.data;
},
async dehydrate() {
this.$reset();
},
async updateSettings(updates: { [key: string]: any }) {
const settingsCopy = { ...(this.settings as Settings) };
const newSettings = merge({}, this.settings, updates);
this.settings = newSettings;
try {
const response = await api.patch(`/settings`, updates);
this.settings = response.data.data;
notify({
title: i18n.global.t('settings_update_success'),
});
} catch (err: any) {
this.settings = settingsCopy;
unexpectedError(err);
}
},
},
});