diff --git a/frontend/src/Components/Form/DeviceInputConnector.js b/frontend/src/Components/Form/DeviceInputConnector.js
index d53372b35..43e313826 100644
--- a/frontend/src/Components/Form/DeviceInputConnector.js
+++ b/frontend/src/Components/Form/DeviceInputConnector.js
@@ -2,13 +2,13 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
-import { fetchDevices, clearDevices } from 'Store/Actions/deviceActions';
+import { fetchOptions, clearOptions } from 'Store/Actions/providerOptionActions';
import DeviceInput from './DeviceInput';
function createMapStateToProps() {
return createSelector(
(state, { value }) => value,
- (state) => state.devices,
+ (state) => state.providerOptions,
(value, devices) => {
return {
@@ -37,8 +37,8 @@ function createMapStateToProps() {
}
const mapDispatchToProps = {
- dispatchFetchDevices: fetchDevices,
- dispatchClearDevices: clearDevices
+ dispatchFetchOptions: fetchOptions,
+ dispatchClearOptions: clearOptions
};
class DeviceInputConnector extends Component {
@@ -51,7 +51,7 @@ class DeviceInputConnector extends Component {
}
componentWillUnmount = () => {
- // this.props.dispatchClearDevices();
+ this.props.dispatchClearOptions();
}
//
@@ -61,10 +61,14 @@ class DeviceInputConnector extends Component {
const {
provider,
providerData,
- dispatchFetchDevices
+ dispatchFetchOptions
} = this.props;
- dispatchFetchDevices({ provider, providerData });
+ dispatchFetchOptions({
+ action: 'getDevices',
+ provider,
+ providerData
+ });
}
//
@@ -92,8 +96,8 @@ DeviceInputConnector.propTypes = {
providerData: PropTypes.object.isRequired,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
- dispatchFetchDevices: PropTypes.func.isRequired,
- dispatchClearDevices: PropTypes.func.isRequired
+ dispatchFetchOptions: PropTypes.func.isRequired,
+ dispatchClearOptions: PropTypes.func.isRequired
};
export default connect(createMapStateToProps, mapDispatchToProps)(DeviceInputConnector);
diff --git a/frontend/src/Components/Form/ProviderFieldFormGroup.js b/frontend/src/Components/Form/ProviderFieldFormGroup.js
index e2961df13..d52afb4db 100644
--- a/frontend/src/Components/Form/ProviderFieldFormGroup.js
+++ b/frontend/src/Components/Form/ProviderFieldFormGroup.js
@@ -20,7 +20,7 @@ function getType(type) {
return inputTypes.NUMBER;
case 'path':
return inputTypes.PATH;
- case 'filepath':
+ case 'filePath':
return inputTypes.PATH;
case 'select':
return inputTypes.SELECT;
@@ -60,6 +60,7 @@ function ProviderFieldFormGroup(props) {
value,
type,
advanced,
+ hidden,
pending,
errors,
warnings,
@@ -68,6 +69,13 @@ function ProviderFieldFormGroup(props) {
...otherProps
} = props;
+ if (
+ hidden === 'hidden' ||
+ (hidden === 'hiddenIfNotSet' && !value)
+ ) {
+ return null;
+ }
+
return (
@@ -108,6 +116,7 @@ ProviderFieldFormGroup.propTypes = {
value: PropTypes.any,
type: PropTypes.string.isRequired,
advanced: PropTypes.bool.isRequired,
+ hidden: PropTypes.string,
pending: PropTypes.bool.isRequired,
errors: PropTypes.arrayOf(PropTypes.object).isRequired,
warnings: PropTypes.arrayOf(PropTypes.object).isRequired,
diff --git a/frontend/src/Store/Actions/index.js b/frontend/src/Store/Actions/index.js
index 4e367fc89..8e04a20cf 100644
--- a/frontend/src/Store/Actions/index.js
+++ b/frontend/src/Store/Actions/index.js
@@ -1,10 +1,9 @@
import * as addArtist from './addArtistActions';
import * as app from './appActions';
import * as blacklist from './blacklistActions';
+import * as calendar from './calendarActions';
import * as captcha from './captchaActions';
import * as customFilters from './customFilterActions';
-import * as devices from './deviceActions';
-import * as calendar from './calendarActions';
import * as commands from './commandActions';
import * as albums from './albumActions';
import * as trackFiles from './trackFileActions';
@@ -16,6 +15,7 @@ import * as oAuth from './oAuthActions';
import * as organizePreview from './organizePreviewActions';
import * as retagPreview from './retagPreviewActions';
import * as paths from './pathActions';
+import * as providerOptions from './providerOptionActions';
import * as queue from './queueActions';
import * as releases from './releaseActions';
import * as rootFolders from './rootFolderActions';
@@ -38,7 +38,6 @@ export default [
calendar,
commands,
customFilters,
- devices,
albums,
trackFiles,
albumHistory,
@@ -49,6 +48,7 @@ export default [
organizePreview,
retagPreview,
paths,
+ providerOptions,
queue,
releases,
rootFolders,
diff --git a/frontend/src/Store/Actions/deviceActions.js b/frontend/src/Store/Actions/providerOptionActions.js
similarity index 68%
rename from frontend/src/Store/Actions/deviceActions.js
rename to frontend/src/Store/Actions/providerOptionActions.js
index 089d49bf3..c8d05e7e1 100644
--- a/frontend/src/Store/Actions/deviceActions.js
+++ b/frontend/src/Store/Actions/providerOptionActions.js
@@ -8,7 +8,7 @@ import { set } from './baseActions';
//
// Variables
-export const section = 'devices';
+export const section = 'providerOptions';
//
// State
@@ -23,32 +23,27 @@ export const defaultState = {
//
// Actions Types
-export const FETCH_DEVICES = 'devices/fetchDevices';
-export const CLEAR_DEVICES = 'devices/clearDevices';
+export const FETCH_OPTIONS = 'devices/fetchOptions';
+export const CLEAR_OPTIONS = 'devices/clearOptions';
//
// Action Creators
-export const fetchDevices = createThunk(FETCH_DEVICES);
-export const clearDevices = createAction(CLEAR_DEVICES);
+export const fetchOptions = createThunk(FETCH_OPTIONS);
+export const clearOptions = createAction(CLEAR_OPTIONS);
//
// Action Handlers
export const actionHandlers = handleThunks({
- [FETCH_DEVICES]: function(getState, payload, dispatch) {
- const actionPayload = {
- action: 'getDevices',
- ...payload
- };
-
+ [FETCH_OPTIONS]: function(getState, payload, dispatch) {
dispatch(set({
section,
isFetching: true
}));
- const promise = requestAction(actionPayload);
+ const promise = requestAction(payload);
promise.done((data) => {
dispatch(set({
@@ -56,7 +51,7 @@ export const actionHandlers = handleThunks({
isFetching: false,
isPopulated: true,
error: null,
- items: data.devices || []
+ items: data.options || []
}));
});
@@ -76,7 +71,7 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({
- [CLEAR_DEVICES]: function(state) {
+ [CLEAR_OPTIONS]: function(state) {
return updateSectionState(state, section, defaultState);
}
diff --git a/src/Lidarr.Http/ClientSchema/Field.cs b/src/Lidarr.Http/ClientSchema/Field.cs
index 6aafc89b1..e9363c1f1 100644
--- a/src/Lidarr.Http/ClientSchema/Field.cs
+++ b/src/Lidarr.Http/ClientSchema/Field.cs
@@ -15,10 +15,11 @@ namespace Lidarr.Http.ClientSchema
public bool Advanced { get; set; }
public List SelectOptions { get; set; }
public string Section { get; set; }
+ public string Hidden { get; set; }
public Field Clone()
{
- return (Field) MemberwiseClone();
+ return (Field)MemberwiseClone();
}
}
}
diff --git a/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs b/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs
index 15b9cc54e..771d5635c 100644
--- a/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs
+++ b/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs
@@ -20,14 +20,14 @@ namespace Lidarr.Http.ClientSchema
var mappings = GetFieldMappings(model.GetType());
- var result = new List(mappings.Length);
+ var result = new List(mappings.Length);
foreach (var mapping in mappings)
{
var field = mapping.Field.Clone();
field.Value = mapping.GetterFunc(model);
- result.Add(field);
+ result.Add(field);
}
return result.OrderBy(r => r.Order).ToList();
@@ -45,7 +45,7 @@ namespace Lidarr.Http.ClientSchema
{
var field = fields.Find(f => f.Name == mapping.Field.Name);
- mapping.SetterFunc(target, field.Value);
+ mapping.SetterFunc(target, field.Value);
}
return target;
@@ -54,9 +54,10 @@ namespace Lidarr.Http.ClientSchema
public static T ReadFromSchema(List fields)
{
- return (T) ReadFromSchema(fields, typeof(T));
+ return (T)ReadFromSchema(fields, typeof(T));
}
+
// Ideally this function should begin a System.Linq.Expression expression tree since it's faster.
// But it's probably not needed till performance issues pop up.
public static FieldMapping[] GetFieldMappings(Type type)
@@ -74,11 +75,12 @@ namespace Lidarr.Http.ClientSchema
result[i].Field.Order = i;
}
- _mappings[type] = result;
+ _mappings[type] = result;
}
return result;
}
}
+
private static FieldMapping[] GetFieldMapping(Type type, string prefix, Func