Skip to content
Snippets Groups Projects
Unverified Commit 321c6c29 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Differentiate `UserSettings` type from the rest of the `Settings` (#39456)

parent 398ff345
Branches
Tags
No related merge requests found
......@@ -190,7 +190,7 @@ export interface OpenAiModel {
export type HelpLinkSetting = "metabase" | "hidden" | "custom";
export interface Settings {
interface InstanceSettings {
"active-users-count"?: number;
"admin-email": string;
"anon-tracking-enabled": boolean;
......@@ -205,8 +205,6 @@ export interface Settings {
"custom-homepage": boolean;
"custom-homepage-dashboard": number | null;
"deprecation-notice-version"?: string;
"dismissed-browse-models-banner"?: boolean;
"dismissed-custom-dashboard-toast"?: boolean;
"ee-openai-api-key"?: string;
"email-configured?": boolean;
"embedding-app-origin": string;
......@@ -285,9 +283,16 @@ export interface Settings {
"user-visibility": string | null;
"last-acknowledged-version": string | null;
"show-static-embed-terms": boolean | null;
}
export interface UserSettings {
"dismissed-browse-models-banner"?: boolean;
"dismissed-custom-dashboard-toast"?: boolean;
"last-used-native-database-id"?: number | null;
}
export type Settings = InstanceSettings & UserSettings;
export type SettingKey = keyof Settings;
export type SettingValue = Settings[SettingKey];
......@@ -3,6 +3,7 @@ import { createAsyncThunk, createReducer } from "@reduxjs/toolkit";
import { createThunkAction } from "metabase/lib/redux";
import MetabaseSettings from "metabase/lib/settings";
import { SessionApi, SettingsApi } from "metabase/services";
import type { UserSettings } from "metabase-types/api";
export const REFRESH_SITE_SETTINGS = "metabase/settings/REFRESH_SITE_SETTINGS";
......@@ -37,7 +38,10 @@ export const settings = createReducer(
export const UPDATE_USER_SETTING = "metabase/settings/UPDATE_USER_SETTING";
export const updateUserSetting = createThunkAction(
UPDATE_USER_SETTING,
function (setting) {
function <K extends keyof UserSettings>(setting: {
key: K;
value: UserSettings[K];
}) {
return async function (dispatch) {
try {
await SettingsApi.put(setting);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment