Skip to content
Snippets Groups Projects
Unverified Commit 73731294 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Remove color-related settings migration for 0.45 (#23909)

parent 2193304d
No related merge requests found
(ns metabase-enterprise.public-settings-test
(:require [clojure.test :refer :all]
[metabase.public-settings :as public-settings]
[metabase.public-settings.premium-features-test :as premium-features-test]
[metabase.test.fixtures :as fixtures]
[metabase.test.util :as tu]))
......@@ -15,54 +14,3 @@
(public-settings/enable-password-login! false)
(is (= false
(public-settings/enable-password-login)))))
(deftest application-colors-adds-correct-keys
(testing "application-colors getter"
(premium-features-test/with-premium-features #{:whitelabel}
(tu/with-temporary-setting-values [application-colors {:brand "#f00"
:accent1 "#0f0"
:accent7 "#00f"}
application-colors-migrated false]
(testing "sets `accent0` to value `brand`, `summarize` to value `accent1`, and `filter` to `accent7`"
(is (= {:brand "#f00"
:accent0 "#f00"
:accent1 "#0f0"
:summarize "#0f0"
:accent7 "#00f"
:filter "#00f"}
(public-settings/application-colors)))
(testing "and sets `application-colors-migrated` to `true`"
(is (public-settings/application-colors-migrated)))))
(tu/with-temporary-setting-values [application-colors {:brand "#f00"
:accent1 "#0f0"
:accent7 "#00f"}
application-colors-migrated true]
(testing "returns the colors as-is if `application-colors-migrated` is `true`"
(is (= {:brand "#f00"
:accent1 "#0f0"
:accent7 "#00f"}
(public-settings/application-colors)))
(testing "and sets `application-colors-migrated` to `true`"
(is (public-settings/application-colors-migrated)))))
(tu/with-temporary-setting-values [application-colors-migrated false]
(testing "does not set `brand`, `accent1`, or `accent7` if they are not already part of the input"
(public-settings/application-colors! {:accent0 "#f00"
:summarize "#0f0"
:filter "#00f"})
(is (= #{:accent0 :summarize :filter}
(set (keys (public-settings/application-colors)))))))
(tu/with-temporary-setting-values [application-colors-migrated false]
(testing "respects given values if `accent0`, `summarize`, and `filter` keys are part of the input"
(public-settings/application-colors! {:brand "#f00"
:accent0 "#fa0a0a"
:accent1 "#0f0"
:summarize "#0afa0a"
:accent7 "#00f"
:filter "#0a0afa"})
(is (= {:brand "#f00"
:accent0 "#fa0a0a"
:accent1 "#0f0"
:summarize "#0afa0a"
:accent7 "#00f"
:filter "#0a0afa"}
(public-settings/application-colors))))))))
......@@ -47,8 +47,8 @@ export interface Settings {
"show-homepage-data": boolean;
"show-homepage-xrays": boolean;
"show-homepage-pin-message": boolean;
"show-lighthouse-illustration": boolean | null;
"show-metabot": boolean | null;
"show-lighthouse-illustration": boolean;
"show-metabot": boolean;
"slack-token": string | undefined;
"slack-token-valid?": boolean;
"slack-app-token": string | undefined;
......
......@@ -3,8 +3,7 @@ import AuthLayout from "../../components/AuthLayout";
import { State } from "metabase-types/store";
const mapStateToProps = (state: State) => ({
showIllustration:
state.settings.values["show-lighthouse-illustration"] ?? true,
showIllustration: state.settings.values["show-lighthouse-illustration"],
});
export default connect(mapStateToProps)(AuthLayout);
......@@ -5,7 +5,7 @@ import HomeGreeting from "../../components/HomeGreeting";
const mapStateToProps = (state: State) => ({
user: getUser(state),
showLogo: state.settings.values["show-metabot"] ?? true,
showLogo: state.settings.values["show-metabot"],
});
export default connect(mapStateToProps)(HomeGreeting);
......@@ -3,8 +3,7 @@ import { State } from "metabase-types/store";
import HomeLayout from "../../components/HomeLayout";
const mapStateToProps = (state: State) => ({
showIllustration:
state.settings.values["show-lighthouse-illustration"] ?? true,
showIllustration: state.settings.values["show-lighthouse-illustration"],
});
export default connect(mapStateToProps)(HomeLayout);
......@@ -289,13 +289,6 @@
:type :keyword
:default :doing-science)
(defsetting application-colors-migrated
"Stores whether the `application-colors` setting has been migrated to 0.44 expectations"
:visibility :internal
:type :boolean
:enabled? premium-features/enable-whitelabeling?
:default false)
(defsetting application-colors
(deferred-tru
(str "These are the primary colors used in charts and throughout Metabase. "
......@@ -303,19 +296,7 @@
:visibility :public
:type :json
:enabled? premium-features/enable-whitelabeling?
:default {}
:getter (fn []
(let [current-colors (setting/get-value-of-type :json :application-colors)]
(if (application-colors-migrated)
current-colors
(let [{:keys [accent0 brand summarize accent1 filter accent7]} current-colors
new-colors (cond-> current-colors
(and brand (not accent0)) (assoc :accent0 brand)
(and accent1 (not summarize)) (assoc :summarize accent1)
(and accent7 (not filter)) (assoc :filter accent7))]
(setting/set-value-of-type! :json :application-colors new-colors)
(application-colors-migrated! true)
new-colors)))))
:default {})
(defsetting application-font
(deferred-tru "This will replace “Lato” as the font family.")
......@@ -359,35 +340,19 @@
:enabled? premium-features/enable-whitelabeling?
:default "app/assets/img/favicon.ico")
(defn has-custom-branding?
"Whether this instance has custom colors or logo set."
[]
(or (not-empty (application-colors))
(not= (application-logo-url) "app/assets/img/logo.svg")))
(defsetting show-metabot
(deferred-tru "Enables Metabot character on the home page")
:visibility :public
:type :boolean
:enabled? premium-features/enable-whitelabeling?
:getter (fn []
(if-some [value (setting/get-value-of-type :boolean :show-metabot)]
value
(let [new-value (not (has-custom-branding?))]
(setting/set-value-of-type! :boolean :show-metabot new-value)
new-value))))
:default true)
(defsetting show-lighthouse-illustration
(deferred-tru "Display the lighthouse illustration on the home and login pages.")
:visibility :public
:type :boolean
:enabled? premium-features/enable-whitelabeling?
:getter (fn []
(if-some [value (setting/get-value-of-type :boolean :show-lighthouse-illustration)]
value
(let [new-value (not (has-custom-branding?))]
(setting/set-value-of-type! :boolean :show-lighthouse-illustration new-value)
new-value))))
:default true)
(defsetting enable-password-login
(deferred-tru "Allow logging in by email and password.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment