New: App Sync Profiles

This commit is contained in:
Qstick
2021-05-18 00:17:04 -04:00
parent 29c4849bef
commit f64f8e915f
51 changed files with 1509 additions and 19 deletions

View File

@@ -0,0 +1,28 @@
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import FilterBuilderRowValue from './FilterBuilderRowValue';
function createMapStateToProps() {
return createSelector(
(state) => state.settings.appProfiles,
(appProfiles) => {
const tagList = appProfiles.items.map((appProfile) => {
const {
id,
name
} = appProfile;
return {
id,
name
};
});
return {
tagList
};
}
);
}
export default connect(createMapStateToProps)(FilterBuilderRowValue);

View File

@@ -3,6 +3,7 @@ import React, { Component } from 'react';
import SelectInput from 'Components/Form/SelectInput';
import IconButton from 'Components/Link/IconButton';
import { filterBuilderTypes, filterBuilderValueTypes, icons } from 'Helpers/Props';
import AppProfileFilterBuilderRowValueConnector from './AppProfileFilterBuilderRowValueConnector';
import BoolFilterBuilderRowValue from './BoolFilterBuilderRowValue';
import DateFilterBuilderRowValue from './DateFilterBuilderRowValue';
import FilterBuilderRowValueConnector from './FilterBuilderRowValueConnector';
@@ -47,6 +48,9 @@ function getRowValueConnector(selectedFilterBuilderProp) {
const valueType = selectedFilterBuilderProp.valueType;
switch (valueType) {
case filterBuilderValueTypes.APP_PROFILE:
return AppProfileFilterBuilderRowValueConnector;
case filterBuilderValueTypes.BOOL:
return BoolFilterBuilderRowValue;

View File

@@ -0,0 +1,99 @@
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import sortByName from 'Utilities/Array/sortByName';
import SelectInput from './SelectInput';
function createMapStateToProps() {
return createSelector(
createSortedSectionSelector('settings.appProfiles', sortByName),
(state, { includeNoChange }) => includeNoChange,
(state, { includeMixed }) => includeMixed,
(appProfiles, includeNoChange, includeMixed) => {
const values = _.map(appProfiles.items, (appProfile) => {
return {
key: appProfile.id,
value: appProfile.name
};
});
if (includeNoChange) {
values.unshift({
key: 'noChange',
value: 'No Change',
disabled: true
});
}
if (includeMixed) {
values.unshift({
key: 'mixed',
value: '(Mixed)',
disabled: true
});
}
return {
values
};
}
);
}
class AppProfileSelectInputConnector extends Component {
//
// Lifecycle
componentDidMount() {
const {
name,
value,
values
} = this.props;
if (!value || !values.some((v) => v.key === value) ) {
const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key)));
if (firstValue) {
this.onChange({ name, value: firstValue.key });
}
}
}
//
// Listeners
onChange = ({ name, value }) => {
this.props.onChange({ name, value: parseInt(value) });
}
//
// Render
render() {
return (
<SelectInput
{...this.props}
onChange={this.onChange}
/>
);
}
}
AppProfileSelectInputConnector.propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
values: PropTypes.arrayOf(PropTypes.object).isRequired,
includeNoChange: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired
};
AppProfileSelectInputConnector.defaultProps = {
includeNoChange: false
};
export default connect(createMapStateToProps)(AppProfileSelectInputConnector);

View File

@@ -3,6 +3,7 @@ import React from 'react';
import Link from 'Components/Link/Link';
import { inputTypes } from 'Helpers/Props';
import translate from 'Utilities/String/translate';
import AppProfileSelectInputConnector from './AppProfileSelectInputConnector';
import AutoCompleteInput from './AutoCompleteInput';
import AvailabilitySelectInput from './AvailabilitySelectInput';
import CaptchaInputConnector from './CaptchaInputConnector';
@@ -29,6 +30,9 @@ import styles from './FormInputGroup.css';
function getComponent(type) {
switch (type) {
case inputTypes.APP_PROFILE_SELECT:
return AppProfileSelectInputConnector;
case inputTypes.AUTO_COMPLETE:
return AutoCompleteInput;

View File

@@ -7,7 +7,7 @@ import { saveDimensions, setIsSidebarVisible } from 'Store/Actions/appActions';
import { fetchCustomFilters } from 'Store/Actions/customFilterActions';
import { fetchIndexers } from 'Store/Actions/indexerActions';
import { fetchIndexerStatus } from 'Store/Actions/indexerStatusActions';
import { fetchGeneralSettings, fetchIndexerCategories, fetchLanguages, fetchUISettings } from 'Store/Actions/settingsActions';
import { fetchAppProfiles, fetchGeneralSettings, fetchIndexerCategories, fetchLanguages, fetchUISettings } from 'Store/Actions/settingsActions';
import { fetchStatus } from 'Store/Actions/systemActions';
import { fetchTags } from 'Store/Actions/tagActions';
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
@@ -49,6 +49,7 @@ const selectIsPopulated = createSelector(
(state) => state.settings.ui.isPopulated,
(state) => state.settings.general.isPopulated,
(state) => state.settings.languages.isPopulated,
(state) => state.settings.appProfiles.isPopulated,
(state) => state.indexers.isPopulated,
(state) => state.indexerStatus.isPopulated,
(state) => state.settings.indexerCategories.isPopulated,
@@ -59,6 +60,7 @@ const selectIsPopulated = createSelector(
uiSettingsIsPopulated,
generalSettingsIsPopulated,
languagesIsPopulated,
appProfilesIsPopulated,
indexersIsPopulated,
indexerStatusIsPopulated,
indexerCategoriesIsPopulated,
@@ -70,6 +72,7 @@ const selectIsPopulated = createSelector(
uiSettingsIsPopulated &&
generalSettingsIsPopulated &&
languagesIsPopulated &&
appProfilesIsPopulated &&
indexersIsPopulated &&
indexerStatusIsPopulated &&
indexerCategoriesIsPopulated &&
@@ -84,6 +87,7 @@ const selectErrors = createSelector(
(state) => state.settings.ui.error,
(state) => state.settings.general.error,
(state) => state.settings.languages.error,
(state) => state.settings.appProfiles.error,
(state) => state.indexers.error,
(state) => state.indexerStatus.error,
(state) => state.settings.indexerCategories.error,
@@ -94,6 +98,7 @@ const selectErrors = createSelector(
uiSettingsError,
generalSettingsError,
languagesError,
appProfilesError,
indexersError,
indexerStatusError,
indexerCategoriesError,
@@ -105,6 +110,7 @@ const selectErrors = createSelector(
uiSettingsError ||
generalSettingsError ||
languagesError ||
appProfilesError ||
indexersError ||
indexerStatusError ||
indexerCategoriesError ||
@@ -118,6 +124,7 @@ const selectErrors = createSelector(
uiSettingsError,
generalSettingsError,
languagesError,
appProfilesError,
indexersError,
indexerStatusError,
indexerCategoriesError,
@@ -174,6 +181,9 @@ function createMapDispatchToProps(dispatch, props) {
dispatchFetchUISettings() {
dispatch(fetchUISettings());
},
dispatchFetchAppProfiles() {
dispatch(fetchAppProfiles());
},
dispatchFetchGeneralSettings() {
dispatch(fetchGeneralSettings());
},
@@ -207,6 +217,7 @@ class PageConnector extends Component {
this.props.dispatchFetchCustomFilters();
this.props.dispatchFetchTags();
this.props.dispatchFetchLanguages();
this.props.dispatchFetchAppProfiles();
this.props.dispatchFetchIndexers();
this.props.dispatchFetchIndexerStatus();
this.props.dispatchFetchIndexerCategories();
@@ -232,6 +243,7 @@ class PageConnector extends Component {
hasError,
dispatchFetchTags,
dispatchFetchLanguages,
dispatchFetchAppProfiles,
dispatchFetchIndexers,
dispatchFetchIndexerStatus,
dispatchFetchIndexerCategories,
@@ -272,6 +284,7 @@ PageConnector.propTypes = {
dispatchFetchCustomFilters: PropTypes.func.isRequired,
dispatchFetchTags: PropTypes.func.isRequired,
dispatchFetchLanguages: PropTypes.func.isRequired,
dispatchFetchAppProfiles: PropTypes.func.isRequired,
dispatchFetchIndexers: PropTypes.func.isRequired,
dispatchFetchIndexerStatus: PropTypes.func.isRequired,
dispatchFetchIndexerCategories: PropTypes.func.isRequired,