mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Refactor Episode section naming to Album in UI
This commit is contained in:
parent
0e7a22dc95
commit
b1a016289c
66 changed files with 372 additions and 372 deletions
|
@ -6,7 +6,7 @@ import { sortDirections } from 'Helpers/Props';
|
|||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
||||
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
|
||||
import episodeEntities from 'Album/episodeEntities';
|
||||
import albumEntities from 'Album/albumEntities';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import { updateItem } from './baseActions';
|
||||
|
@ -14,7 +14,7 @@ import { updateItem } from './baseActions';
|
|||
//
|
||||
// Variables
|
||||
|
||||
export const section = 'episodes';
|
||||
export const section = 'albums';
|
||||
|
||||
//
|
||||
// State
|
||||
|
@ -74,47 +74,47 @@ export const defaultState = {
|
|||
};
|
||||
|
||||
export const persistState = [
|
||||
'episodes.columns'
|
||||
'albums.columns'
|
||||
];
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const FETCH_EPISODES = 'episodes/fetchEpisodes';
|
||||
export const SET_EPISODES_SORT = 'episodes/setEpisodesSort';
|
||||
export const SET_EPISODES_TABLE_OPTION = 'episodes/setEpisodesTableOption';
|
||||
export const CLEAR_EPISODES = 'episodes/clearEpisodes';
|
||||
export const TOGGLE_EPISODE_MONITORED = 'episodes/toggleEpisodeMonitored';
|
||||
export const TOGGLE_EPISODES_MONITORED = 'episodes/toggleEpisodesMonitored';
|
||||
export const FETCH_ALBUMS = 'albums/fetchAlbums';
|
||||
export const SET_ALBUMS_SORT = 'albums/setAlbumsSort';
|
||||
export const SET_ALBUMS_TABLE_OPTION = 'albums/setAlbumsTableOption';
|
||||
export const CLEAR_ALBUMS = 'albums/clearAlbums';
|
||||
export const TOGGLE_ALBUM_MONITORED = 'albums/toggleAlbumMonitored';
|
||||
export const TOGGLE_ALBUMS_MONITORED = 'albums/toggleAlbumsMonitored';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchEpisodes = createThunk(FETCH_EPISODES);
|
||||
export const setEpisodesSort = createAction(SET_EPISODES_SORT);
|
||||
export const setEpisodesTableOption = createAction(SET_EPISODES_TABLE_OPTION);
|
||||
export const clearEpisodes = createAction(CLEAR_EPISODES);
|
||||
export const toggleEpisodeMonitored = createThunk(TOGGLE_EPISODE_MONITORED);
|
||||
export const toggleEpisodesMonitored = createThunk(TOGGLE_EPISODES_MONITORED);
|
||||
export const fetchAlbums = createThunk(FETCH_ALBUMS);
|
||||
export const setAlbumsSort = createAction(SET_ALBUMS_SORT);
|
||||
export const setAlbumsTableOption = createAction(SET_ALBUMS_TABLE_OPTION);
|
||||
export const clearAlbums = createAction(CLEAR_ALBUMS);
|
||||
export const toggleAlbumMonitored = createThunk(TOGGLE_ALBUM_MONITORED);
|
||||
export const toggleAlbumsMonitored = createThunk(TOGGLE_ALBUMS_MONITORED);
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
export const actionHandlers = handleThunks({
|
||||
[FETCH_EPISODES]: createFetchHandler(section, '/album'),
|
||||
[FETCH_ALBUMS]: createFetchHandler(section, '/album'),
|
||||
|
||||
[TOGGLE_EPISODE_MONITORED]: function(getState, payload, dispatch) {
|
||||
[TOGGLE_ALBUM_MONITORED]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
albumId,
|
||||
episodeEntity = episodeEntities.EPISODES,
|
||||
albumEntity = albumEntities.ALBUMS,
|
||||
monitored
|
||||
} = payload;
|
||||
|
||||
const episodeSection = _.last(episodeEntity.split('.'));
|
||||
const albumSection = _.last(albumEntity.split('.'));
|
||||
|
||||
dispatch(updateItem({
|
||||
id: albumId,
|
||||
section: episodeSection,
|
||||
section: albumSection,
|
||||
isSaving: true
|
||||
}));
|
||||
|
||||
|
@ -128,7 +128,7 @@ export const actionHandlers = handleThunks({
|
|||
promise.done((data) => {
|
||||
dispatch(updateItem({
|
||||
id: albumId,
|
||||
section: episodeSection,
|
||||
section: albumSection,
|
||||
isSaving: false,
|
||||
monitored
|
||||
}));
|
||||
|
@ -137,26 +137,26 @@ export const actionHandlers = handleThunks({
|
|||
promise.fail((xhr) => {
|
||||
dispatch(updateItem({
|
||||
id: albumId,
|
||||
section: episodeSection,
|
||||
section: albumSection,
|
||||
isSaving: false
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
[TOGGLE_EPISODES_MONITORED]: function(getState, payload, dispatch) {
|
||||
[TOGGLE_ALBUMS_MONITORED]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
albumIds,
|
||||
episodeEntity = episodeEntities.EPISODES,
|
||||
albumEntity = albumEntities.ALBUMS,
|
||||
monitored
|
||||
} = payload;
|
||||
|
||||
const episodeSection = _.last(episodeEntity.split('.'));
|
||||
const albumSection = _.last(albumEntity.split('.'));
|
||||
|
||||
dispatch(batchActions(
|
||||
albumIds.map((albumId) => {
|
||||
return updateItem({
|
||||
id: albumId,
|
||||
section: episodeSection,
|
||||
section: albumSection,
|
||||
isSaving: true
|
||||
});
|
||||
})
|
||||
|
@ -174,7 +174,7 @@ export const actionHandlers = handleThunks({
|
|||
albumIds.map((albumId) => {
|
||||
return updateItem({
|
||||
id: albumId,
|
||||
section: episodeSection,
|
||||
section: albumSection,
|
||||
isSaving: false,
|
||||
monitored
|
||||
});
|
||||
|
@ -187,7 +187,7 @@ export const actionHandlers = handleThunks({
|
|||
albumIds.map((albumId) => {
|
||||
return updateItem({
|
||||
id: albumId,
|
||||
section: episodeSection,
|
||||
section: albumSection,
|
||||
isSaving: false
|
||||
});
|
||||
})
|
||||
|
@ -201,9 +201,9 @@ export const actionHandlers = handleThunks({
|
|||
|
||||
export const reducers = createHandleActions({
|
||||
|
||||
[SET_EPISODES_TABLE_OPTION]: createSetTableOptionReducer(section),
|
||||
[SET_ALBUMS_TABLE_OPTION]: createSetTableOptionReducer(section),
|
||||
|
||||
[CLEAR_EPISODES]: (state) => {
|
||||
[CLEAR_ALBUMS]: (state) => {
|
||||
return Object.assign({}, state, {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
|
@ -212,6 +212,6 @@ export const reducers = createHandleActions({
|
|||
});
|
||||
},
|
||||
|
||||
[SET_EPISODES_SORT]: createSetClientSideCollectionSortReducer(section)
|
||||
[SET_ALBUMS_SORT]: createSetClientSideCollectionSortReducer(section)
|
||||
|
||||
}, defaultState, section);
|
|
@ -175,7 +175,7 @@ export const actionHandlers = handleThunks({
|
|||
});
|
||||
|
||||
promise.done((data) => {
|
||||
const episodes = _.filter(getState().episodes.items, { artistId: id, seasonNumber });
|
||||
const albums = _.filter(getState().albums.items, { artistId: id, seasonNumber });
|
||||
|
||||
dispatch(batchActions([
|
||||
updateItem({
|
||||
|
@ -184,10 +184,10 @@ export const actionHandlers = handleThunks({
|
|||
...data
|
||||
}),
|
||||
|
||||
...episodes.map((episode) => {
|
||||
...albums.map((album) => {
|
||||
return updateItem({
|
||||
id: episode.id,
|
||||
section: 'episodes',
|
||||
id: album.id,
|
||||
section: 'albums',
|
||||
monitored
|
||||
});
|
||||
})
|
||||
|
|
|
@ -42,7 +42,7 @@ export const defaultState = {
|
|||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'episodeTitle',
|
||||
name: 'albumTitle',
|
||||
label: 'Album Title',
|
||||
isVisible: true
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as blacklist from './blacklistActions';
|
|||
import * as captcha from './captchaActions';
|
||||
import * as calendar from './calendarActions';
|
||||
import * as commands from './commandActions';
|
||||
import * as episodes from './episodeActions';
|
||||
import * as albums from './albumActions';
|
||||
import * as trackFiles from './trackFileActions';
|
||||
import * as albumHistory from './albumHistoryActions';
|
||||
import * as history from './historyActions';
|
||||
|
@ -34,7 +34,7 @@ export default [
|
|||
captcha,
|
||||
calendar,
|
||||
commands,
|
||||
episodes,
|
||||
albums,
|
||||
trackFiles,
|
||||
albumHistory,
|
||||
history,
|
||||
|
|
|
@ -64,7 +64,7 @@ export const defaultState = {
|
|||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'episodeTitle',
|
||||
name: 'albumTitle',
|
||||
label: 'Album Title',
|
||||
isVisible: true
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@ import $ from 'jquery';
|
|||
import { createAction } from 'redux-actions';
|
||||
import { batchActions } from 'redux-batched-actions';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import episodeEntities from 'Album/episodeEntities';
|
||||
import albumEntities from 'Album/albumEntities';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import createRemoveItemHandler from './Creators/createRemoveItemHandler';
|
||||
|
@ -60,20 +60,20 @@ export const actionHandlers = handleThunks({
|
|||
[DELETE_TRACK_FILE]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
id: trackFileId,
|
||||
episodeEntity = episodeEntities.EPISODES
|
||||
albumEntity = albumEntities.ALBUMS
|
||||
} = payload;
|
||||
|
||||
const episodeSection = _.last(episodeEntity.split('.'));
|
||||
const albumSection = _.last(albumEntity.split('.'));
|
||||
const deletePromise = deleteTrackFileHelper(getState, payload, dispatch);
|
||||
|
||||
deletePromise.done(() => {
|
||||
const episodes = getState().episodes.items;
|
||||
const tracksWithRemovedFiles = _.filter(episodes, { trackFileId });
|
||||
const albums = getState().albums.items;
|
||||
const tracksWithRemovedFiles = _.filter(albums, { trackFileId });
|
||||
|
||||
dispatch(batchActions([
|
||||
...tracksWithRemovedFiles.map((track) => {
|
||||
return updateItem({
|
||||
section: episodeSection,
|
||||
section: albumSection,
|
||||
...track,
|
||||
trackFileId: 0,
|
||||
hasFile: false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue