New: Sort root folders by path

Closes #4280
Closes #3956
pull/4545/head
Bogdan 11 months ago
parent dec241e6b6
commit f7418d6174

@ -9,6 +9,7 @@ import Indexer from 'typings/Indexer';
import MetadataProfile from 'typings/MetadataProfile'; import MetadataProfile from 'typings/MetadataProfile';
import Notification from 'typings/Notification'; import Notification from 'typings/Notification';
import QualityProfile from 'typings/QualityProfile'; import QualityProfile from 'typings/QualityProfile';
import RootFolder from 'typings/RootFolder';
import { UiSettings } from 'typings/UiSettings'; import { UiSettings } from 'typings/UiSettings';
export interface DownloadClientAppState export interface DownloadClientAppState
@ -38,6 +39,11 @@ export interface MetadataProfilesAppState
extends AppSectionState<MetadataProfile>, extends AppSectionState<MetadataProfile>,
AppSectionSchemaState<MetadataProfile> {} AppSectionSchemaState<MetadataProfile> {}
export interface RootFolderAppState
extends AppSectionState<RootFolder>,
AppSectionDeleteState,
AppSectionSaveState {}
export type UiSettingsAppState = AppSectionState<UiSettings>; export type UiSettingsAppState = AppSectionState<UiSettings>;
interface SettingsAppState { interface SettingsAppState {
@ -47,6 +53,7 @@ interface SettingsAppState {
metadataProfiles: MetadataProfilesAppState; metadataProfiles: MetadataProfilesAppState;
notifications: NotificationAppState; notifications: NotificationAppState;
qualityProfiles: QualityProfilesAppState; qualityProfiles: QualityProfilesAppState;
rootFolders: RootFolderAppState;
uiSettings: UiSettingsAppState; uiSettings: UiSettingsAppState;
} }

@ -2,13 +2,14 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector';
import RootFolderSelectInput from './RootFolderSelectInput'; import RootFolderSelectInput from './RootFolderSelectInput';
const ADD_NEW_KEY = 'addNew'; const ADD_NEW_KEY = 'addNew';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.settings.rootFolders, createRootFoldersSelector(),
(state, { value }) => value, (state, { value }) => value,
(state, { includeMissingValue }) => includeMissingValue, (state, { includeMissingValue }) => includeMissingValue,
(state, { includeNoChange }) => includeNoChange, (state, { includeNoChange }) => includeNoChange,

@ -3,13 +3,12 @@ import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { deleteRootFolder, fetchRootFolders } from 'Store/Actions/settingsActions'; import { deleteRootFolder, fetchRootFolders } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector';
import sortByName from 'Utilities/Array/sortByName';
import RootFolders from './RootFolders'; import RootFolders from './RootFolders';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createSortedSectionSelector('settings.rootFolders', sortByName), createRootFoldersSelector(),
(state) => state.settings.qualityProfiles, (state) => state.settings.qualityProfiles,
(state) => state.settings.metadataProfiles, (state) => state.settings.metadataProfiles,
(rootFolders, quality, metadata) => { (rootFolders, quality, metadata) => {

@ -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
);
}

@ -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;
Loading…
Cancel
Save