From e81588616ec27e418990a38bbc47d26d1ef64da9 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 17 Aug 2023 19:31:36 +0200 Subject: [PATCH 1/3] Update to shlink-web-component 0.2 --- package-lock.json | 14 +++++++------- package.json | 2 +- src/utils/services/LocalStorage.ts | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 51978ab4..e81735cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@json2csv/plainjs": "^7.0.1", "@reduxjs/toolkit": "^1.9.5", "@shlinkio/shlink-frontend-kit": "^0.2.0", - "@shlinkio/shlink-web-component": "^0.1.1", + "@shlinkio/shlink-web-component": "^0.2.0", "bootstrap": "5.2.3", "bottlejs": "^2.0.1", "classnames": "^2.3.2", @@ -3024,9 +3024,9 @@ } }, "node_modules/@shlinkio/shlink-web-component": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.1.1.tgz", - "integrity": "sha512-N59LT9KCLPkPvPDPdS5EVvpPg0/eQUf1QuHewVZNK3Ee3XxAqoNK5ssHTuPX/xFDvzPmROEQWxIdcuma5+6e4w==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.2.0.tgz", + "integrity": "sha512-7yOTC7VyQwcSE++7nzdfrZIpfl/1vtsyxUcz7SEh7tC1xbUzjjiUgkAJHXQ6SsAbbYWHEt64nkw2gv5m8Iyq7g==", "dependencies": { "@json2csv/plainjs": "^7.0.1", "bottlejs": "^2.0.1", @@ -12630,9 +12630,9 @@ } }, "@shlinkio/shlink-web-component": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.1.1.tgz", - "integrity": "sha512-N59LT9KCLPkPvPDPdS5EVvpPg0/eQUf1QuHewVZNK3Ee3XxAqoNK5ssHTuPX/xFDvzPmROEQWxIdcuma5+6e4w==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.2.0.tgz", + "integrity": "sha512-7yOTC7VyQwcSE++7nzdfrZIpfl/1vtsyxUcz7SEh7tC1xbUzjjiUgkAJHXQ6SsAbbYWHEt64nkw2gv5m8Iyq7g==", "requires": { "@json2csv/plainjs": "^7.0.1", "bottlejs": "^2.0.1", diff --git a/package.json b/package.json index 2eec4282..130f5627 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@json2csv/plainjs": "^7.0.1", "@reduxjs/toolkit": "^1.9.5", "@shlinkio/shlink-frontend-kit": "^0.2.0", - "@shlinkio/shlink-web-component": "^0.1.1", + "@shlinkio/shlink-web-component": "^0.2.0", "bootstrap": "5.2.3", "bottlejs": "^2.0.1", "classnames": "^2.3.2", diff --git a/src/utils/services/LocalStorage.ts b/src/utils/services/LocalStorage.ts index 9c404e07..c3278c7d 100644 --- a/src/utils/services/LocalStorage.ts +++ b/src/utils/services/LocalStorage.ts @@ -6,7 +6,6 @@ export class LocalStorage { public readonly get = (key: string): T | undefined => { const item = this.localStorage.getItem(buildPath(key)); - return item ? JSON.parse(item) as T : undefined; }; From de0b735eab3614002ea0fd4f5e9e0712af5b07e0 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 19 Aug 2023 13:12:25 +0200 Subject: [PATCH 2/3] Update shlink-web-component to v0.3.0 --- .github/dependabot.yml | 4 ++-- package-lock.json | 14 +++++++------- package.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index becad809..4afd4fd3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: schedule: interval: weekly day: saturday - time: '9:00' + time: '09:00' timezone: 'Europe/Madrid' open-pull-requests-limit: 10 - package-ecosystem: docker @@ -13,5 +13,5 @@ updates: schedule: interval: weekly day: saturday - time: '9:01' + time: '09:00' timezone: 'Europe/Madrid' diff --git a/package-lock.json b/package-lock.json index e81735cd..cb91940e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@json2csv/plainjs": "^7.0.1", "@reduxjs/toolkit": "^1.9.5", "@shlinkio/shlink-frontend-kit": "^0.2.0", - "@shlinkio/shlink-web-component": "^0.2.0", + "@shlinkio/shlink-web-component": "^0.3.0", "bootstrap": "5.2.3", "bottlejs": "^2.0.1", "classnames": "^2.3.2", @@ -3024,9 +3024,9 @@ } }, "node_modules/@shlinkio/shlink-web-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.2.0.tgz", - "integrity": "sha512-7yOTC7VyQwcSE++7nzdfrZIpfl/1vtsyxUcz7SEh7tC1xbUzjjiUgkAJHXQ6SsAbbYWHEt64nkw2gv5m8Iyq7g==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.3.0.tgz", + "integrity": "sha512-8zAcSF5j403pQrnScHBwPJpJbZDLTWxbuu9GZLJK77ZHDRQ0xYjc1iKZPAiwVWDYnr7SSHkeGq8DgrKs7n2K8Q==", "dependencies": { "@json2csv/plainjs": "^7.0.1", "bottlejs": "^2.0.1", @@ -12630,9 +12630,9 @@ } }, "@shlinkio/shlink-web-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.2.0.tgz", - "integrity": "sha512-7yOTC7VyQwcSE++7nzdfrZIpfl/1vtsyxUcz7SEh7tC1xbUzjjiUgkAJHXQ6SsAbbYWHEt64nkw2gv5m8Iyq7g==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@shlinkio/shlink-web-component/-/shlink-web-component-0.3.0.tgz", + "integrity": "sha512-8zAcSF5j403pQrnScHBwPJpJbZDLTWxbuu9GZLJK77ZHDRQ0xYjc1iKZPAiwVWDYnr7SSHkeGq8DgrKs7n2K8Q==", "requires": { "@json2csv/plainjs": "^7.0.1", "bottlejs": "^2.0.1", diff --git a/package.json b/package.json index 130f5627..3a5043e3 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@json2csv/plainjs": "^7.0.1", "@reduxjs/toolkit": "^1.9.5", "@shlinkio/shlink-frontend-kit": "^0.2.0", - "@shlinkio/shlink-web-component": "^0.2.0", + "@shlinkio/shlink-web-component": "^0.3.0", "bootstrap": "5.2.3", "bottlejs": "^2.0.1", "classnames": "^2.3.2", From b2e6e7db616a2da816b4a7dc11e7cbf8682bb877 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 19 Aug 2023 17:21:34 +0200 Subject: [PATCH 3/3] Define UiSettings which are no longer part of shlink-web-component --- .github/dependabot.yml | 4 ++++ src/app/App.tsx | 4 ++-- src/settings/UserInterfaceSettings.tsx | 4 ++-- src/settings/reducers/settings.ts | 20 ++++++++++++++------ test/settings/UserInterfaceSettings.test.tsx | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4afd4fd3..2af9e347 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,10 @@ updates: time: '09:00' timezone: 'Europe/Madrid' open-pull-requests-limit: 10 + ignore: + # Bootstrap can introduce visual breaking changes on styles + # Ignore it, since the plan is to remove it anyway + - dependency-name: 'bootstrap' - package-ecosystem: docker directory: '/' schedule: diff --git a/src/app/App.tsx b/src/app/App.tsx index 87cbb156..b27811a7 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -1,5 +1,4 @@ import { changeThemeInMarkup } from '@shlinkio/shlink-frontend-kit'; -import type { Settings } from '@shlinkio/shlink-web-component'; import classNames from 'classnames'; import type { FC } from 'react'; import { useEffect } from 'react'; @@ -7,13 +6,14 @@ import { Route, Routes, useLocation } from 'react-router-dom'; import { AppUpdateBanner } from '../common/AppUpdateBanner'; import { NotFound } from '../common/NotFound'; import type { ServersMap } from '../servers/data'; +import type { AppSettings } from '../settings/reducers/settings'; import { forceUpdate } from '../utils/helpers/sw'; import './App.scss'; interface AppProps { fetchServers: () => void; servers: ServersMap; - settings: Settings; + settings: AppSettings; resetAppUpdate: () => void; appUpdated: boolean; } diff --git a/src/settings/UserInterfaceSettings.tsx b/src/settings/UserInterfaceSettings.tsx index e34ad0f1..58f2a086 100644 --- a/src/settings/UserInterfaceSettings.tsx +++ b/src/settings/UserInterfaceSettings.tsx @@ -2,12 +2,12 @@ import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import type { Theme } from '@shlinkio/shlink-frontend-kit'; import { changeThemeInMarkup, SimpleCard, ToggleSwitch } from '@shlinkio/shlink-frontend-kit'; -import type { Settings, UiSettings } from '@shlinkio/shlink-web-component'; import type { FC } from 'react'; +import type { AppSettings, UiSettings } from './reducers/settings'; import './UserInterfaceSettings.scss'; interface UserInterfaceProps { - settings: Settings; + settings: AppSettings; setUiSettings: (settings: UiSettings) => void; } diff --git a/src/settings/reducers/settings.ts b/src/settings/reducers/settings.ts index 5962b9b7..64da272c 100644 --- a/src/settings/reducers/settings.ts +++ b/src/settings/reducers/settings.ts @@ -1,11 +1,11 @@ import type { PayloadAction, PrepareAction } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit'; +import type { Theme } from '@shlinkio/shlink-frontend-kit'; import type { Settings, ShortUrlCreationSettings, ShortUrlsListSettings, TagsSettings, - UiSettings, VisitsSettings, } from '@shlinkio/shlink-web-component'; import { mergeDeepRight } from 'ramda'; @@ -18,7 +18,15 @@ export const DEFAULT_SHORT_URLS_ORDERING: ShortUrlsOrder = { dir: 'DESC', }; -const initialState: Settings = { +export type UiSettings = { + theme: Theme; +}; + +export type AppSettings = Settings & { + ui?: UiSettings; +}; + +const initialState: AppSettings = { realTimeUpdates: { enabled: true, }, @@ -36,12 +44,12 @@ const initialState: Settings = { }, }; -type SettingsAction = PayloadAction; -type SettingsPrepareAction = PrepareAction; +type SettingsAction = PayloadAction; +type SettingsPrepareAction = PrepareAction; -const commonReducer = (state: Settings, { payload }: SettingsAction) => mergeDeepRight(state, payload); +const commonReducer = (state: AppSettings, { payload }: SettingsAction) => mergeDeepRight(state, payload); const toReducer = (prepare: SettingsPrepareAction) => ({ reducer: commonReducer, prepare }); -const toPreparedAction: SettingsPrepareAction = (payload: Settings) => ({ payload }); +const toPreparedAction: SettingsPrepareAction = (payload: AppSettings) => ({ payload }); const { reducer, actions } = createSlice({ name: 'shlink/settings', diff --git a/test/settings/UserInterfaceSettings.test.tsx b/test/settings/UserInterfaceSettings.test.tsx index 3a99a05f..b0ef7aae 100644 --- a/test/settings/UserInterfaceSettings.test.tsx +++ b/test/settings/UserInterfaceSettings.test.tsx @@ -1,7 +1,7 @@ import type { Theme } from '@shlinkio/shlink-frontend-kit'; -import type { UiSettings } from '@shlinkio/shlink-web-component'; import { screen } from '@testing-library/react'; import { fromPartial } from '@total-typescript/shoehorn'; +import type { UiSettings } from '../../src/settings/reducers/settings'; import { UserInterfaceSettings } from '../../src/settings/UserInterfaceSettings'; import { renderWithEvents } from '../__helpers__/setUpTest';