diff --git a/frontend/src/App/State/SettingsAppState.ts b/frontend/src/App/State/SettingsAppState.ts index c5b974610..8511b5e2b 100644 --- a/frontend/src/App/State/SettingsAppState.ts +++ b/frontend/src/App/State/SettingsAppState.ts @@ -9,6 +9,7 @@ import Indexer from 'typings/Indexer'; import MetadataProfile from 'typings/MetadataProfile'; import Notification from 'typings/Notification'; import QualityProfile from 'typings/QualityProfile'; +import RootFolder from 'typings/RootFolder'; import { UiSettings } from 'typings/UiSettings'; export interface DownloadClientAppState @@ -38,6 +39,11 @@ export interface MetadataProfilesAppState extends AppSectionState, AppSectionSchemaState {} +export interface RootFolderAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + export type UiSettingsAppState = AppSectionState; interface SettingsAppState { @@ -47,6 +53,7 @@ interface SettingsAppState { metadataProfiles: MetadataProfilesAppState; notifications: NotificationAppState; qualityProfiles: QualityProfilesAppState; + rootFolders: RootFolderAppState; uiSettings: UiSettingsAppState; } diff --git a/frontend/src/Components/Form/RootFolderSelectInputConnector.js b/frontend/src/Components/Form/RootFolderSelectInputConnector.js index a7912a7f5..dcc2b88a6 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputConnector.js +++ b/frontend/src/Components/Form/RootFolderSelectInputConnector.js @@ -2,13 +2,14 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector'; import RootFolderSelectInput from './RootFolderSelectInput'; const ADD_NEW_KEY = 'addNew'; function createMapStateToProps() { return createSelector( - (state) => state.settings.rootFolders, + createRootFoldersSelector(), (state, { value }) => value, (state, { includeMissingValue }) => includeMissingValue, (state, { includeNoChange }) => includeNoChange, diff --git a/frontend/src/Settings/MediaManagement/RootFolder/RootFoldersConnector.js b/frontend/src/Settings/MediaManagement/RootFolder/RootFoldersConnector.js index ae180a54e..e1e8807bb 100644 --- a/frontend/src/Settings/MediaManagement/RootFolder/RootFoldersConnector.js +++ b/frontend/src/Settings/MediaManagement/RootFolder/RootFoldersConnector.js @@ -3,13 +3,12 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { deleteRootFolder, fetchRootFolders } from 'Store/Actions/settingsActions'; -import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; -import sortByName from 'Utilities/Array/sortByName'; +import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector'; import RootFolders from './RootFolders'; function createMapStateToProps() { return createSelector( - createSortedSectionSelector('settings.rootFolders', sortByName), + createRootFoldersSelector(), (state) => state.settings.qualityProfiles, (state) => state.settings.metadataProfiles, (rootFolders, quality, metadata) => { diff --git a/frontend/src/Store/Selectors/createRootFoldersSelector.ts b/frontend/src/Store/Selectors/createRootFoldersSelector.ts new file mode 100644 index 000000000..a016d7665 --- /dev/null +++ b/frontend/src/Store/Selectors/createRootFoldersSelector.ts @@ -0,0 +1,11 @@ +import { createSelector } from 'reselect'; +import { RootFolderAppState } from 'App/State/SettingsAppState'; +import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; +import sortByName from 'Utilities/Array/sortByName'; + +export default function createRootFoldersSelector() { + return createSelector( + createSortedSectionSelector('settings.rootFolders', sortByName), + (rootFolders: RootFolderAppState) => rootFolders + ); +} diff --git a/frontend/src/typings/RootFolder.ts b/frontend/src/typings/RootFolder.ts new file mode 100644 index 000000000..83c509423 --- /dev/null +++ b/frontend/src/typings/RootFolder.ts @@ -0,0 +1,12 @@ +import ModelBase from 'App/ModelBase'; + +interface RootFolder extends ModelBase { + id: number; + name: string; + path: string; + accessible: boolean; + freeSpace?: number; + unmappedFolders: object[]; +} + +export default RootFolder;