mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: App Sync Profiles
This commit is contained in:
97
frontend/src/Store/Actions/Settings/appProfiles.js
Normal file
97
frontend/src/Store/Actions/Settings/appProfiles.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import createFetchHandler from 'Store/Actions/Creators/createFetchHandler';
|
||||
import createFetchSchemaHandler from 'Store/Actions/Creators/createFetchSchemaHandler';
|
||||
import createRemoveItemHandler from 'Store/Actions/Creators/createRemoveItemHandler';
|
||||
import createSaveProviderHandler from 'Store/Actions/Creators/createSaveProviderHandler';
|
||||
import createSetSettingValueReducer from 'Store/Actions/Creators/Reducers/createSetSettingValueReducer';
|
||||
import { createThunk } from 'Store/thunks';
|
||||
import getSectionState from 'Utilities/State/getSectionState';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
|
||||
//
|
||||
// Variables
|
||||
|
||||
const section = 'settings.appProfiles';
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const FETCH_APP_PROFILES = 'settings/appProfiles/fetchAppProfiles';
|
||||
export const FETCH_APP_PROFILE_SCHEMA = 'settings/appProfiles/fetchAppProfileSchema';
|
||||
export const SAVE_APP_PROFILE = 'settings/appProfiles/saveAppProfile';
|
||||
export const DELETE_APP_PROFILE = 'settings/appProfiles/deleteAppProfile';
|
||||
export const SET_APP_PROFILE_VALUE = 'settings/appProfiles/setAppProfileValue';
|
||||
export const CLONE_APP_PROFILE = 'settings/appProfiles/cloneAppProfile';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchAppProfiles = createThunk(FETCH_APP_PROFILES);
|
||||
export const fetchAppProfileSchema = createThunk(FETCH_APP_PROFILE_SCHEMA);
|
||||
export const saveAppProfile = createThunk(SAVE_APP_PROFILE);
|
||||
export const deleteAppProfile = createThunk(DELETE_APP_PROFILE);
|
||||
|
||||
export const setAppProfileValue = createAction(SET_APP_PROFILE_VALUE, (payload) => {
|
||||
return {
|
||||
section,
|
||||
...payload
|
||||
};
|
||||
});
|
||||
|
||||
export const cloneAppProfile = createAction(CLONE_APP_PROFILE);
|
||||
|
||||
//
|
||||
// Details
|
||||
|
||||
export default {
|
||||
|
||||
//
|
||||
// State
|
||||
|
||||
defaultState: {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
isSchemaFetching: false,
|
||||
isSchemaPopulated: false,
|
||||
schemaError: null,
|
||||
schema: {},
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
items: [],
|
||||
pendingChanges: {}
|
||||
},
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
actionHandlers: {
|
||||
[FETCH_APP_PROFILES]: createFetchHandler(section, '/appprofile'),
|
||||
[FETCH_APP_PROFILE_SCHEMA]: createFetchSchemaHandler(section, '/appprofile/schema'),
|
||||
[SAVE_APP_PROFILE]: createSaveProviderHandler(section, '/appprofile'),
|
||||
[DELETE_APP_PROFILE]: createRemoveItemHandler(section, '/appprofile')
|
||||
},
|
||||
|
||||
//
|
||||
// Reducers
|
||||
|
||||
reducers: {
|
||||
[SET_APP_PROFILE_VALUE]: createSetSettingValueReducer(section),
|
||||
|
||||
[CLONE_APP_PROFILE]: function(state, { payload }) {
|
||||
const id = payload.id;
|
||||
const newState = getSectionState(state, section);
|
||||
const item = newState.items.find((i) => i.id === id);
|
||||
const pendingChanges = { ...item, id: 0 };
|
||||
delete pendingChanges.id;
|
||||
|
||||
pendingChanges.name = `${pendingChanges.name} - Copy`;
|
||||
newState.pendingChanges = pendingChanges;
|
||||
|
||||
return updateSectionState(state, section, newState);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
@@ -74,6 +74,12 @@ export const defaultState = {
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'appProfileId',
|
||||
label: translate('AppProfile'),
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'added',
|
||||
label: translate('Added'),
|
||||
@@ -138,6 +144,12 @@ export const defaultState = {
|
||||
type: filterBuilderTypes.EXACT,
|
||||
valueType: filterBuilderValueTypes.PROTOCOL
|
||||
},
|
||||
{
|
||||
name: 'appProfileId',
|
||||
label: translate('AppProfile'),
|
||||
type: filterBuilderTypes.EXACT,
|
||||
valueType: filterBuilderValueTypes.APP_PROFILE
|
||||
},
|
||||
{
|
||||
name: 'tags',
|
||||
label: translate('Tags'),
|
||||
|
@@ -2,6 +2,7 @@ import { createAction } from 'redux-actions';
|
||||
import { handleThunks } from 'Store/thunks';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import applications from './Settings/applications';
|
||||
import appProfiles from './Settings/appProfiles';
|
||||
import development from './Settings/development';
|
||||
import downloadClients from './Settings/downloadClients';
|
||||
import general from './Settings/general';
|
||||
@@ -16,6 +17,7 @@ export * from './Settings/indexerCategories';
|
||||
export * from './Settings/languages';
|
||||
export * from './Settings/notifications';
|
||||
export * from './Settings/applications';
|
||||
export * from './Settings/appProfiles';
|
||||
export * from './Settings/development';
|
||||
export * from './Settings/ui';
|
||||
|
||||
@@ -36,6 +38,7 @@ export const defaultState = {
|
||||
languages: languages.defaultState,
|
||||
notifications: notifications.defaultState,
|
||||
applications: applications.defaultState,
|
||||
appProfiles: appProfiles.defaultState,
|
||||
development: development.defaultState,
|
||||
ui: ui.defaultState
|
||||
};
|
||||
@@ -64,6 +67,7 @@ export const actionHandlers = handleThunks({
|
||||
...languages.actionHandlers,
|
||||
...notifications.actionHandlers,
|
||||
...applications.actionHandlers,
|
||||
...appProfiles.actionHandlers,
|
||||
...development.actionHandlers,
|
||||
...ui.actionHandlers
|
||||
});
|
||||
@@ -83,6 +87,7 @@ export const reducers = createHandleActions({
|
||||
...languages.reducers,
|
||||
...notifications.reducers,
|
||||
...applications.reducers,
|
||||
...appProfiles.reducers,
|
||||
...development.reducers,
|
||||
...ui.reducers
|
||||
|
||||
|
Reference in New Issue
Block a user