From dbf4b0926ec5f17cc6139da7d30079aac9f93062 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 25 Dec 2021 10:49:12 +0100 Subject: [PATCH] Added Settings suffix to all settings sub-components --- ...pdates.tsx => RealTimeUpdatesSettings.tsx} | 4 +- ...ation.tsx => ShortUrlCreationSettings.tsx} | 8 ++-- ...UrlsList.tsx => ShortUrlsListSettings.tsx} | 8 ++-- src/settings/{Tags.tsx => TagsSettings.tsx} | 6 +-- ...erface.scss => UserInterfaceSettings.scss} | 0 ...nterface.tsx => UserInterfaceSettings.tsx} | 4 +- .../{Visits.tsx => VisitsSettings.tsx} | 6 +-- src/settings/services/provideServices.ts | 44 +++++++++---------- ...t.tsx => RealTimeUpdatesSettings.test.tsx} | 13 +++--- ....tsx => ShortUrlCreationSettings.test.tsx} | 14 +++--- ...est.tsx => ShortUrlsListSettings.test.tsx} | 14 +++--- .../{Tags.test.tsx => TagsSettings.test.tsx} | 10 ++--- ...est.tsx => UserInterfaceSettings.test.tsx} | 6 +-- ...isits.test.tsx => VisitsSettings.test.tsx} | 6 +-- 14 files changed, 76 insertions(+), 67 deletions(-) rename src/settings/{RealTimeUpdates.tsx => RealTimeUpdatesSettings.tsx} (96%) rename src/settings/{ShortUrlCreation.tsx => ShortUrlCreationSettings.tsx} (88%) rename src/settings/{ShortUrlsList.tsx => ShortUrlsListSettings.tsx} (75%) rename src/settings/{Tags.tsx => TagsSettings.tsx} (83%) rename src/settings/{UserInterface.scss => UserInterfaceSettings.scss} (100%) rename src/settings/{UserInterface.tsx => UserInterfaceSettings.tsx} (88%) rename src/settings/{Visits.tsx => VisitsSettings.tsx} (72%) rename test/settings/{RealTimeUpdates.test.tsx => RealTimeUpdatesSettings.test.tsx} (91%) rename test/settings/{ShortUrlCreation.test.tsx => ShortUrlCreationSettings.test.tsx} (89%) rename test/settings/{ShortUrlsList.test.tsx => ShortUrlsListSettings.test.tsx} (76%) rename test/settings/{Tags.test.tsx => TagsSettings.test.tsx} (87%) rename test/settings/{UserInterface.test.tsx => UserInterfaceSettings.test.tsx} (87%) rename test/settings/{Visits.test.tsx => VisitsSettings.test.tsx} (90%) diff --git a/src/settings/RealTimeUpdates.tsx b/src/settings/RealTimeUpdatesSettings.tsx similarity index 96% rename from src/settings/RealTimeUpdates.tsx rename to src/settings/RealTimeUpdatesSettings.tsx index 243a7d0c..8081b26f 100644 --- a/src/settings/RealTimeUpdates.tsx +++ b/src/settings/RealTimeUpdatesSettings.tsx @@ -12,7 +12,7 @@ interface RealTimeUpdatesProps { const intervalValue = (interval?: number) => !interval ? '' : `${interval}`; -const RealTimeUpdates = ( +const RealTimeUpdatesSettings = ( { settings: { realTimeUpdates }, toggleRealTimeUpdates, setRealTimeUpdatesInterval }: RealTimeUpdatesProps, ) => ( @@ -50,4 +50,4 @@ const RealTimeUpdates = ( ); -export default RealTimeUpdates; +export default RealTimeUpdatesSettings; diff --git a/src/settings/ShortUrlCreation.tsx b/src/settings/ShortUrlCreationSettings.tsx similarity index 88% rename from src/settings/ShortUrlCreation.tsx rename to src/settings/ShortUrlCreationSettings.tsx index 53814d71..5c3a1ebb 100644 --- a/src/settings/ShortUrlCreation.tsx +++ b/src/settings/ShortUrlCreationSettings.tsx @@ -3,11 +3,11 @@ import { DropdownItem, FormGroup } from 'reactstrap'; import { SimpleCard } from '../utils/SimpleCard'; import ToggleSwitch from '../utils/ToggleSwitch'; import { DropdownBtn } from '../utils/DropdownBtn'; -import { Settings, ShortUrlCreationSettings, TagFilteringMode } from './reducers/settings'; +import { Settings, ShortUrlCreationSettings as ShortUrlsSettings, TagFilteringMode } from './reducers/settings'; interface ShortUrlCreationProps { settings: Settings; - setShortUrlCreationSettings: (settings: ShortUrlCreationSettings) => void; + setShortUrlCreationSettings: (settings: ShortUrlsSettings) => void; } const tagFilteringModeText = (tagFilteringMode: TagFilteringMode | undefined): string => @@ -17,8 +17,8 @@ const tagFilteringModeHint = (tagFilteringMode: TagFilteringMode | undefined): R ? <>The list of suggested tags will contain those including provided input. : <>The list of suggested tags will contain those starting with provided input.; -export const ShortUrlCreation: FC = ({ settings, setShortUrlCreationSettings }) => { - const shortUrlCreation: ShortUrlCreationSettings = settings.shortUrlCreation ?? { validateUrls: false }; +export const ShortUrlCreationSettings: FC = ({ settings, setShortUrlCreationSettings }) => { + const shortUrlCreation: ShortUrlsSettings = settings.shortUrlCreation ?? { validateUrls: false }; const changeTagsFilteringMode = (tagFilteringMode: TagFilteringMode) => () => setShortUrlCreationSettings( { ...shortUrlCreation ?? { validateUrls: false }, tagFilteringMode }, ); diff --git a/src/settings/ShortUrlsList.tsx b/src/settings/ShortUrlsListSettings.tsx similarity index 75% rename from src/settings/ShortUrlsList.tsx rename to src/settings/ShortUrlsListSettings.tsx index 11dcb687..01ed2547 100644 --- a/src/settings/ShortUrlsList.tsx +++ b/src/settings/ShortUrlsListSettings.tsx @@ -3,14 +3,16 @@ import { FormGroup } from 'reactstrap'; import { OrderingDropdown } from '../utils/OrderingDropdown'; import { SHORT_URLS_ORDERABLE_FIELDS } from '../short-urls/data'; import { SimpleCard } from '../utils/SimpleCard'; -import { DEFAULT_SHORT_URLS_ORDERING, Settings, ShortUrlsListSettings } from './reducers/settings'; +import { DEFAULT_SHORT_URLS_ORDERING, Settings, ShortUrlsListSettings as ShortUrlsSettings } from './reducers/settings'; interface ShortUrlsListProps { settings: Settings; - setShortUrlsListSettings: (settings: ShortUrlsListSettings) => void; + setShortUrlsListSettings: (settings: ShortUrlsSettings) => void; } -export const ShortUrlsList: FC = ({ settings: { shortUrlsList }, setShortUrlsListSettings }) => ( +export const ShortUrlsListSettings: FC = ( + { settings: { shortUrlsList }, setShortUrlsListSettings }, +) => ( diff --git a/src/settings/Tags.tsx b/src/settings/TagsSettings.tsx similarity index 83% rename from src/settings/Tags.tsx rename to src/settings/TagsSettings.tsx index 85103215..7359fb2f 100644 --- a/src/settings/Tags.tsx +++ b/src/settings/TagsSettings.tsx @@ -5,14 +5,14 @@ import { TagsModeDropdown } from '../tags/TagsModeDropdown'; import { capitalize } from '../utils/utils'; import { OrderingDropdown } from '../utils/OrderingDropdown'; import { TAGS_ORDERABLE_FIELDS } from '../tags/data/TagsListChildrenProps'; -import { Settings, TagsSettings } from './reducers/settings'; +import { Settings, TagsSettings as TagsSettingsOptions } from './reducers/settings'; interface TagsProps { settings: Settings; - setTagsSettings: (settings: TagsSettings) => void; + setTagsSettings: (settings: TagsSettingsOptions) => void; } -export const Tags: FC = ({ settings: { tags }, setTagsSettings }) => ( +export const TagsSettings: FC = ({ settings: { tags }, setTagsSettings }) => ( diff --git a/src/settings/UserInterface.scss b/src/settings/UserInterfaceSettings.scss similarity index 100% rename from src/settings/UserInterface.scss rename to src/settings/UserInterfaceSettings.scss diff --git a/src/settings/UserInterface.tsx b/src/settings/UserInterfaceSettings.tsx similarity index 88% rename from src/settings/UserInterface.tsx rename to src/settings/UserInterfaceSettings.tsx index e2d74a5d..cca9e11b 100644 --- a/src/settings/UserInterface.tsx +++ b/src/settings/UserInterfaceSettings.tsx @@ -6,14 +6,14 @@ import { SimpleCard } from '../utils/SimpleCard'; import ToggleSwitch from '../utils/ToggleSwitch'; import { changeThemeInMarkup, Theme } from '../utils/theme'; import { Settings, UiSettings } from './reducers/settings'; -import './UserInterface.scss'; +import './UserInterfaceSettings.scss'; interface UserInterfaceProps { settings: Settings; setUiSettings: (settings: UiSettings) => void; } -export const UserInterface: FC = ({ settings: { ui }, setUiSettings }) => ( +export const UserInterfaceSettings: FC = ({ settings: { ui }, setUiSettings }) => ( diff --git a/src/settings/Visits.tsx b/src/settings/VisitsSettings.tsx similarity index 72% rename from src/settings/Visits.tsx rename to src/settings/VisitsSettings.tsx index a64a9641..3bb58e88 100644 --- a/src/settings/Visits.tsx +++ b/src/settings/VisitsSettings.tsx @@ -2,14 +2,14 @@ import { FormGroup } from 'reactstrap'; import { FC } from 'react'; import { SimpleCard } from '../utils/SimpleCard'; import { DateIntervalSelector } from '../utils/dates/DateIntervalSelector'; -import { Settings, VisitsSettings } from './reducers/settings'; +import { Settings, VisitsSettings as VisitsSettingsConfig } from './reducers/settings'; interface VisitsProps { settings: Settings; - setVisitsSettings: (settings: VisitsSettings) => void; + setVisitsSettings: (settings: VisitsSettingsConfig) => void; } -export const Visits: FC = ({ settings, setVisitsSettings }) => ( +export const VisitsSettings: FC = ({ settings, setVisitsSettings }) => ( diff --git a/src/settings/services/provideServices.ts b/src/settings/services/provideServices.ts index c54d37aa..d60ad3d7 100644 --- a/src/settings/services/provideServices.ts +++ b/src/settings/services/provideServices.ts @@ -1,5 +1,5 @@ import Bottle from 'bottlejs'; -import RealTimeUpdates from '../RealTimeUpdates'; +import RealTimeUpdatesSettings from '../RealTimeUpdatesSettings'; import Settings from '../Settings'; import { setRealTimeUpdatesInterval, @@ -12,46 +12,46 @@ import { } from '../reducers/settings'; import { ConnectDecorator } from '../../container/types'; import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer'; -import { ShortUrlCreation } from '../ShortUrlCreation'; -import { UserInterface } from '../UserInterface'; -import { Visits } from '../Visits'; -import { Tags } from '../Tags'; -import { ShortUrlsList } from '../ShortUrlsList'; +import { ShortUrlCreationSettings } from '../ShortUrlCreationSettings'; +import { UserInterfaceSettings } from '../UserInterfaceSettings'; +import { VisitsSettings } from '../VisitsSettings'; +import { TagsSettings } from '../TagsSettings'; +import { ShortUrlsListSettings } from '../ShortUrlsListSettings'; const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory( 'Settings', Settings, - 'RealTimeUpdates', - 'ShortUrlCreation', + 'RealTimeUpdatesSettings', + 'ShortUrlCreationSettings', 'ShortUrlsListSettings', - 'UserInterface', - 'Visits', - 'Tags', + 'UserInterfaceSettings', + 'VisitsSettings', + 'TagsSettings', ); bottle.decorator('Settings', withoutSelectedServer); bottle.decorator('Settings', connect(null, [ 'resetSelectedServer' ])); - bottle.serviceFactory('RealTimeUpdates', () => RealTimeUpdates); + bottle.serviceFactory('RealTimeUpdatesSettings', () => RealTimeUpdatesSettings); bottle.decorator( - 'RealTimeUpdates', + 'RealTimeUpdatesSettings', connect([ 'settings' ], [ 'toggleRealTimeUpdates', 'setRealTimeUpdatesInterval' ]), ); - bottle.serviceFactory('ShortUrlCreation', () => ShortUrlCreation); - bottle.decorator('ShortUrlCreation', connect([ 'settings' ], [ 'setShortUrlCreationSettings' ])); + bottle.serviceFactory('ShortUrlCreationSettings', () => ShortUrlCreationSettings); + bottle.decorator('ShortUrlCreationSettings', connect([ 'settings' ], [ 'setShortUrlCreationSettings' ])); - bottle.serviceFactory('UserInterface', () => UserInterface); - bottle.decorator('UserInterface', connect([ 'settings' ], [ 'setUiSettings' ])); + bottle.serviceFactory('UserInterfaceSettings', () => UserInterfaceSettings); + bottle.decorator('UserInterfaceSettings', connect([ 'settings' ], [ 'setUiSettings' ])); - bottle.serviceFactory('Visits', () => Visits); - bottle.decorator('Visits', connect([ 'settings' ], [ 'setVisitsSettings' ])); + bottle.serviceFactory('VisitsSettings', () => VisitsSettings); + bottle.decorator('VisitsSettings', connect([ 'settings' ], [ 'setVisitsSettings' ])); - bottle.serviceFactory('Tags', () => Tags); - bottle.decorator('Tags', connect([ 'settings' ], [ 'setTagsSettings' ])); + bottle.serviceFactory('TagsSettings', () => TagsSettings); + bottle.decorator('TagsSettings', connect([ 'settings' ], [ 'setTagsSettings' ])); - bottle.serviceFactory('ShortUrlsListSettings', () => ShortUrlsList); + bottle.serviceFactory('ShortUrlsListSettings', () => ShortUrlsListSettings); bottle.decorator('ShortUrlsListSettings', connect([ 'settings' ], [ 'setShortUrlsListSettings' ])); // Actions diff --git a/test/settings/RealTimeUpdates.test.tsx b/test/settings/RealTimeUpdatesSettings.test.tsx similarity index 91% rename from test/settings/RealTimeUpdates.test.tsx rename to test/settings/RealTimeUpdatesSettings.test.tsx index f8dd3cfe..17ea87f4 100644 --- a/test/settings/RealTimeUpdates.test.tsx +++ b/test/settings/RealTimeUpdatesSettings.test.tsx @@ -1,19 +1,22 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { Mock } from 'ts-mockery'; import { Input } from 'reactstrap'; -import { RealTimeUpdatesSettings, Settings } from '../../src/settings/reducers/settings'; -import RealTimeUpdates from '../../src/settings/RealTimeUpdates'; +import { + RealTimeUpdatesSettings as RealTimeUpdatesSettingsOptions, + Settings, +} from '../../src/settings/reducers/settings'; +import RealTimeUpdatesSettings from '../../src/settings/RealTimeUpdatesSettings'; import ToggleSwitch from '../../src/utils/ToggleSwitch'; -describe('', () => { +describe('', () => { const toggleRealTimeUpdates = jest.fn(); const setRealTimeUpdatesInterval = jest.fn(); let wrapper: ShallowWrapper; - const createWrapper = (realTimeUpdates: Partial = {}) => { + const createWrapper = (realTimeUpdates: Partial = {}) => { const settings = Mock.of({ realTimeUpdates }); wrapper = shallow( - ', () => { +describe('', () => { let wrapper: ShallowWrapper; const setShortUrlCreationSettings = jest.fn(); - const createWrapper = (shortUrlCreation?: ShortUrlCreationSettings) => { + const createWrapper = (shortUrlCreation?: ShortUrlsSettings) => { wrapper = shallow( - ({ shortUrlCreation })} setShortUrlCreationSettings={setShortUrlCreationSettings} />, @@ -68,9 +68,9 @@ describe('', () => { }); it.each([ - [ { tagFilteringMode: 'includes' } as ShortUrlCreationSettings, 'Suggest tags including input', 'including' ], + [ { tagFilteringMode: 'includes' } as ShortUrlsSettings, 'Suggest tags including input', 'including' ], [ - { tagFilteringMode: 'startsWith' } as ShortUrlCreationSettings, + { tagFilteringMode: 'startsWith' } as ShortUrlsSettings, 'Suggest tags starting with input', 'starting with', ], diff --git a/test/settings/ShortUrlsList.test.tsx b/test/settings/ShortUrlsListSettings.test.tsx similarity index 76% rename from test/settings/ShortUrlsList.test.tsx rename to test/settings/ShortUrlsListSettings.test.tsx index 89d999ca..f8ca25e7 100644 --- a/test/settings/ShortUrlsList.test.tsx +++ b/test/settings/ShortUrlsListSettings.test.tsx @@ -1,16 +1,20 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { Mock } from 'ts-mockery'; -import { DEFAULT_SHORT_URLS_ORDERING, Settings, ShortUrlsListSettings } from '../../src/settings/reducers/settings'; -import { ShortUrlsList } from '../../src/settings/ShortUrlsList'; +import { + DEFAULT_SHORT_URLS_ORDERING, + Settings, + ShortUrlsListSettings as ShortUrlsSettings, +} from '../../src/settings/reducers/settings'; +import { ShortUrlsListSettings } from '../../src/settings/ShortUrlsListSettings'; import { OrderingDropdown } from '../../src/utils/OrderingDropdown'; import { ShortUrlsOrder } from '../../src/short-urls/data'; -describe('', () => { +describe('', () => { let wrapper: ShallowWrapper; const setSettings = jest.fn(); - const createWrapper = (shortUrlsList?: ShortUrlsListSettings) => { + const createWrapper = (shortUrlsList?: ShortUrlsSettings) => { wrapper = shallow( - ({ shortUrlsList })} setShortUrlsListSettings={setSettings} />, + ({ shortUrlsList })} setShortUrlsListSettings={setSettings} />, ); return wrapper; diff --git a/test/settings/Tags.test.tsx b/test/settings/TagsSettings.test.tsx similarity index 87% rename from test/settings/Tags.test.tsx rename to test/settings/TagsSettings.test.tsx index a99bd1a4..d6ae737b 100644 --- a/test/settings/Tags.test.tsx +++ b/test/settings/TagsSettings.test.tsx @@ -1,17 +1,17 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { Mock } from 'ts-mockery'; import { FormGroup } from 'reactstrap'; -import { Settings, TagsMode, TagsSettings } from '../../src/settings/reducers/settings'; +import { Settings, TagsMode, TagsSettings as TagsSettingsOptions } from '../../src/settings/reducers/settings'; import { TagsModeDropdown } from '../../src/tags/TagsModeDropdown'; -import { Tags } from '../../src/settings/Tags'; +import { TagsSettings } from '../../src/settings/TagsSettings'; import { OrderingDropdown } from '../../src/utils/OrderingDropdown'; import { TagsOrder } from '../../src/tags/data/TagsListChildrenProps'; -describe('', () => { +describe('', () => { let wrapper: ShallowWrapper; const setTagsSettings = jest.fn(); - const createWrapper = (tags?: TagsSettings) => { - wrapper = shallow(({ tags })} setTagsSettings={setTagsSettings} />); + const createWrapper = (tags?: TagsSettingsOptions) => { + wrapper = shallow(({ tags })} setTagsSettings={setTagsSettings} />); return wrapper; }; diff --git a/test/settings/UserInterface.test.tsx b/test/settings/UserInterfaceSettings.test.tsx similarity index 87% rename from test/settings/UserInterface.test.tsx rename to test/settings/UserInterfaceSettings.test.tsx index 55abf685..03391cee 100644 --- a/test/settings/UserInterface.test.tsx +++ b/test/settings/UserInterfaceSettings.test.tsx @@ -3,15 +3,15 @@ import { Mock } from 'ts-mockery'; import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Settings, UiSettings } from '../../src/settings/reducers/settings'; -import { UserInterface } from '../../src/settings/UserInterface'; +import { UserInterfaceSettings } from '../../src/settings/UserInterfaceSettings'; import ToggleSwitch from '../../src/utils/ToggleSwitch'; import { Theme } from '../../src/utils/theme'; -describe('', () => { +describe('', () => { let wrapper: ShallowWrapper; const setUiSettings = jest.fn(); const createWrapper = (ui?: UiSettings) => { - wrapper = shallow(({ ui })} setUiSettings={setUiSettings} />); + wrapper = shallow(({ ui })} setUiSettings={setUiSettings} />); return wrapper; }; diff --git a/test/settings/Visits.test.tsx b/test/settings/VisitsSettings.test.tsx similarity index 90% rename from test/settings/Visits.test.tsx rename to test/settings/VisitsSettings.test.tsx index 89a73546..243fe3b6 100644 --- a/test/settings/Visits.test.tsx +++ b/test/settings/VisitsSettings.test.tsx @@ -1,15 +1,15 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { Mock } from 'ts-mockery'; import { Settings } from '../../src/settings/reducers/settings'; -import { Visits } from '../../src/settings/Visits'; +import { VisitsSettings } from '../../src/settings/VisitsSettings'; import { SimpleCard } from '../../src/utils/SimpleCard'; import { DateIntervalSelector } from '../../src/utils/dates/DateIntervalSelector'; -describe('', () => { +describe('', () => { let wrapper: ShallowWrapper; const setVisitsSettings = jest.fn(); const createWrapper = (settings: Partial = {}) => { - wrapper = shallow((settings)} setVisitsSettings={setVisitsSettings} />); + wrapper = shallow((settings)} setVisitsSettings={setVisitsSettings} />); return wrapper; };