From 0bf04f5fe4c950721398c0a5b1d07534ef7b79af Mon Sep 17 00:00:00 2001 From: Maciej Bodek Date: Mon, 18 Sep 2023 11:14:48 +0200 Subject: [PATCH] Kill Settings feature --- .../providers/LocalStorageProvider/index.tsx | 30 ------ .../providers/LocalStorageProvider/types.ts | 2 - .../web-console/src/scenes/Layout/index.tsx | 5 - .../src/scenes/Notifications/index.tsx | 7 -- .../Settings/Notifications/Duration/index.tsx | 63 ----------- .../Settings/Notifications/Toggler/index.tsx | 53 --------- .../scenes/Settings/Notifications/index.tsx | 65 ----------- .../web-console/src/scenes/Settings/index.tsx | 101 ------------------ .../web-console/src/scenes/Sidebar/index.tsx | 46 -------- .../src/utils/localStorage/types.ts | 2 - 10 files changed, 374 deletions(-) delete mode 100644 packages/web-console/src/scenes/Settings/Notifications/Duration/index.tsx delete mode 100644 packages/web-console/src/scenes/Settings/Notifications/Toggler/index.tsx delete mode 100644 packages/web-console/src/scenes/Settings/Notifications/index.tsx delete mode 100644 packages/web-console/src/scenes/Settings/index.tsx diff --git a/packages/web-console/src/providers/LocalStorageProvider/index.tsx b/packages/web-console/src/providers/LocalStorageProvider/index.tsx index 206d91528..82351cd80 100644 --- a/packages/web-console/src/providers/LocalStorageProvider/index.tsx +++ b/packages/web-console/src/providers/LocalStorageProvider/index.tsx @@ -40,8 +40,6 @@ const defaultConfig: LocalConfig = { authPayload: "", editorCol: 10, editorLine: 10, - isNotificationEnabled: true, - notificationDelay: 5, editorSplitterBasis: 350, resultsSplitterBasis: 350, exampleQueriesVisited: false, @@ -51,8 +49,6 @@ type ContextProps = { authPayload: string editorCol: number editorLine: number - notificationDelay: number - isNotificationEnabled: boolean editorSplitterBasis: number resultsSplitterBasis: number updateSettings: (key: StoreKey, value: SettingsType) => void @@ -63,8 +59,6 @@ const defaultValues: ContextProps = { authPayload: "", editorCol: 1, editorLine: 1, - isNotificationEnabled: true, - notificationDelay: 5, editorSplitterBasis: 350, resultsSplitterBasis: 350, updateSettings: (key: StoreKey, value: SettingsType) => undefined, @@ -85,18 +79,6 @@ export const LocalStorageProvider = ({ const [editorLine, setEditorLine] = useState( parseInteger(getValue(StoreKey.EDITOR_LINE), defaultConfig.editorLine), ) - const [isNotificationEnabled, setIsNotificationEnabled] = useState( - parseBoolean( - getValue(StoreKey.NOTIFICATION_ENABLED), - defaultConfig.isNotificationEnabled, - ), - ) - const [notificationDelay, setNotificationDelay] = useState( - parseInteger( - getValue(StoreKey.NOTIFICATION_DELAY), - defaultConfig.notificationDelay, - ), - ) const [editorSplitterBasis, seteditorSplitterBasis] = useState( parseInteger( getValue(StoreKey.EDITOR_SPLITTER_BASIS), @@ -134,16 +116,6 @@ export const LocalStorageProvider = ({ case StoreKey.EXAMPLE_QUERIES_VISITED: setExampleQueriesVisited(value === "true") break - case StoreKey.NOTIFICATION_ENABLED: - setIsNotificationEnabled( - parseBoolean(value, defaultConfig.isNotificationEnabled), - ) - break - case StoreKey.NOTIFICATION_DELAY: - setNotificationDelay( - parseInteger(value, defaultConfig.notificationDelay), - ) - break case StoreKey.EDITOR_SPLITTER_BASIS: seteditorSplitterBasis( parseInteger(value, defaultConfig.editorSplitterBasis), @@ -163,8 +135,6 @@ export const LocalStorageProvider = ({ authPayload, editorCol, editorLine, - isNotificationEnabled, - notificationDelay, editorSplitterBasis, resultsSplitterBasis, updateSettings, diff --git a/packages/web-console/src/providers/LocalStorageProvider/types.ts b/packages/web-console/src/providers/LocalStorageProvider/types.ts index df0ae69ba..bfb600706 100644 --- a/packages/web-console/src/providers/LocalStorageProvider/types.ts +++ b/packages/web-console/src/providers/LocalStorageProvider/types.ts @@ -28,8 +28,6 @@ export type LocalConfig = { authPayload: string editorCol: number editorLine: number - notificationDelay: number - isNotificationEnabled: boolean editorSplitterBasis: number resultsSplitterBasis: number exampleQueriesVisited: boolean diff --git a/packages/web-console/src/scenes/Layout/index.tsx b/packages/web-console/src/scenes/Layout/index.tsx index b6dca99bd..4ef0cedfd 100644 --- a/packages/web-console/src/scenes/Layout/index.tsx +++ b/packages/web-console/src/scenes/Layout/index.tsx @@ -28,7 +28,6 @@ import { BusEvent } from "../../consts" import Footer from "../Footer" import Console from "../Console" import Import from "../Import" -import Settings from "../Settings" import News from "../News" import SideMenu from "../SideMenu" import { QuestProvider } from "../../providers" @@ -67,10 +66,6 @@ const Layout = () => { - - - - diff --git a/packages/web-console/src/scenes/Notifications/index.tsx b/packages/web-console/src/scenes/Notifications/index.tsx index 4d0db1591..7b4f63062 100644 --- a/packages/web-console/src/scenes/Notifications/index.tsx +++ b/packages/web-console/src/scenes/Notifications/index.tsx @@ -24,7 +24,6 @@ import React, { useCallback, - useContext, useState, useEffect, useRef, @@ -42,7 +41,6 @@ import { useScreenSize, } from "../../components" import { actions, selectors } from "../../store" -import { LocalStorageContext } from "../../providers/LocalStorageProvider" import { TerminalBox, Subtract, ArrowUpS } from "styled-icons/remix-line" import Notification from "./Notification" @@ -86,7 +84,6 @@ const ClearAllNotificationsButton = styled(SecondaryButton)` const Notifications = () => { const notifications = useSelector(selectors.query.getNotifications) - const { isNotificationEnabled } = useContext(LocalStorageContext) const { sm } = useScreenSize() const [isMinimized, setIsMinimized] = useState(true) const contentRef = useRef(null) @@ -122,10 +119,6 @@ const Notifications = () => { } }, [sm]) - if (!isNotificationEnabled) { - return <> - } - return ( diff --git a/packages/web-console/src/scenes/Settings/Notifications/Duration/index.tsx b/packages/web-console/src/scenes/Settings/Notifications/Duration/index.tsx deleted file mode 100644 index 00a6e4c5d..000000000 --- a/packages/web-console/src/scenes/Settings/Notifications/Duration/index.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ___ _ ____ ____ - * / _ \ _ _ ___ ___| |_| _ \| __ ) - * | | | | | | |/ _ \/ __| __| | | | _ \ - * | |_| | |_| | __/\__ \ |_| |_| | |_) | - * \__\_\\__,_|\___||___/\__|____/|____/ - * - * Copyright (c) 2014-2019 Appsicle - * Copyright (c) 2019-2022 QuestDB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -import React, { ChangeEvent, useCallback, useContext } from "react" -import styled from "styled-components" -import { Input, Text } from "components" -import { LocalStorageContext } from "providers/LocalStorageProvider" -import { StoreKey } from "utils/localStorage/types" - -const Wrapper = styled.div` - & > :last-child:not(:first-child) { - margin-left: 1rem; - } -` - -const Duration = () => { - const { notificationDelay, updateSettings } = useContext(LocalStorageContext) - - const handleChange = useCallback( - (e: ChangeEvent) => { - updateSettings(StoreKey.NOTIFICATION_DELAY, e.target.value) - }, - [updateSettings], - ) - - return ( - - - seconds - - ) -} - -export default Duration diff --git a/packages/web-console/src/scenes/Settings/Notifications/Toggler/index.tsx b/packages/web-console/src/scenes/Settings/Notifications/Toggler/index.tsx deleted file mode 100644 index 570344c1d..000000000 --- a/packages/web-console/src/scenes/Settings/Notifications/Toggler/index.tsx +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ___ _ ____ ____ - * / _ \ _ _ ___ ___| |_| _ \| __ ) - * | | | | | | |/ _ \/ __| __| | | | _ \ - * | |_| | |_| | __/\__ \ |_| |_| | |_) | - * \__\_\\__,_|\___||___/\__|____/|____/ - * - * Copyright (c) 2014-2019 Appsicle - * Copyright (c) 2019-2022 QuestDB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -import React, { useCallback, useContext } from "react" -import { SwitchButton } from "../../../../components" -import { LocalStorageContext } from "../../../../providers/LocalStorageProvider" -import { StoreKey } from "../../../../utils/localStorage/types" - -const Toggler = () => { - const { isNotificationEnabled, updateSettings } = - useContext(LocalStorageContext) - - const handleSelect = useCallback( - (value: string) => { - updateSettings(StoreKey.NOTIFICATION_ENABLED, value) - }, - [updateSettings], - ) - - return ( - - ) -} - -export default Toggler diff --git a/packages/web-console/src/scenes/Settings/Notifications/index.tsx b/packages/web-console/src/scenes/Settings/Notifications/index.tsx deleted file mode 100644 index 194d84080..000000000 --- a/packages/web-console/src/scenes/Settings/Notifications/index.tsx +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * ___ _ ____ ____ - * / _ \ _ _ ___ ___| |_| _ \| __ ) - * | | | | | | |/ _ \/ __| __| | | | _ \ - * | |_| | |_| | __/\__ \ |_| |_| | |_) | - * \__\_\\__,_|\___||___/\__|____/|____/ - * - * Copyright (c) 2014-2019 Appsicle - * Copyright (c) 2019-2022 QuestDB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -import React from "react" -import styled from "styled-components" -import Toggler from "./Toggler" -import { color } from "../../../utils" - -const Wrapper = styled.div` - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - width: 100%; -` - -const SettingGroup = styled.div` - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: center; - width: 100%; - padding: 2rem; - background: ${color("background")}; - - &:not(:last-child) { - border-bottom: 1px dotted ${color("selection")}; - } -` -const SettingControl = styled.div` - width: 250px; -` - -const Notifications = () => ( - - - - - - - -) - -export default Notifications diff --git a/packages/web-console/src/scenes/Settings/index.tsx b/packages/web-console/src/scenes/Settings/index.tsx deleted file mode 100644 index a89ac7ed7..000000000 --- a/packages/web-console/src/scenes/Settings/index.tsx +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * ___ _ ____ ____ - * / _ \ _ _ ___ ___| |_| _ \| __ ) - * | | | | | | |/ _ \/ __| __| | | | _ \ - * | |_| | |_| | __/\__ \ |_| |_| | |_) | - * \__\_\\__,_|\___||___/\__|____/|____/ - * - * Copyright (c) 2014-2019 Appsicle - * Copyright (c) 2019-2022 QuestDB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -import React, { useCallback, useState } from "react" -import styled from "styled-components" -import Notifications from "./Notifications" -import { PaneContent, Text, PrimaryToggleButton, Page } from "../../components" -import { Settings2 } from "styled-icons/evaicons-solid" -import { Popup } from "styled-icons/entypo" -import { color } from "../../utils" - -const Root = styled.div` - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: flex-start; - padding: 2rem; -` - -const PaneWrapper = styled.div` - display: flex; - flex-direction: column; - flex: 0; -` - -const PageInfo = styled(Text)` - margin-bottom: 2rem; -` - -const Icon = styled(Settings2)` - color: ${color("foreground")}; -` -const SettingsMenu = styled(PaneWrapper)` - width: 100%; - padding: 0 10px; -` - -const ToggleButton = styled(PrimaryToggleButton)` - height: 4rem; - padding: 0 1rem; -` -const Content = styled(PaneContent)` - color: ${color("foreground")}; - - *::selection { - background: ${color("red")}; - color: ${color("foreground")}; - } -` - -const Settings = () => { - const [selected, setSelected] = useState<"notification">("notification") - const handleNotificationClick = useCallback(() => { - setSelected("notification") - }, []) - - return ( - }> - - - On this page, you can customize your Quest DB console - - - - - - Notification Log - - - - {selected === "notification" && } - - - ) -} - -export default Settings diff --git a/packages/web-console/src/scenes/Sidebar/index.tsx b/packages/web-console/src/scenes/Sidebar/index.tsx index 807eaba52..34229a716 100644 --- a/packages/web-console/src/scenes/Sidebar/index.tsx +++ b/packages/web-console/src/scenes/Sidebar/index.tsx @@ -27,7 +27,6 @@ import { useDispatch, useSelector } from "react-redux" import styled from "styled-components" import { CodeSSlash, Notification2 } from "styled-icons/remix-line" import { Upload2 } from "styled-icons/remix-line" -import { Settings2 } from "styled-icons/evaicons-solid" import { PopperHover, PrimaryToggleButton, Tooltip } from "../../components" import { actions, selectors } from "../../store" @@ -160,51 +159,6 @@ const Sidebar = () => { - - - dispatch(actions.console.setActivePanel("settings")) - } - selected={activePanel === "settings"} - > - - - - ) : ( - - dispatch(actions.console.setActivePanel("settings")) - } - selected={activePanel === "settings"} - data-hook="navigation-settings-button" - > - - - ) - } - > - - {readOnly ? ( - <> - Settings is currently disabled. -
- To use this feature, turn read-only mode to false in - the configuration file - - ) : ( - <>Settings - )} -
-
-