|
|
|
@ -7,6 +7,7 @@ import StoreLinkIcon, { whichStore } from '../common/StoreLinkIcon'; |
|
|
|
|
import EditableText from '../common/EditableText'; |
|
|
|
|
import SubmitChangesButton from '../common/SubmitChangesButton'; |
|
|
|
|
import SongTable, { SongGetters } from '../tables/ResultsTable'; |
|
|
|
|
import { saveArtistChanges } from '../../lib/saveChanges'; |
|
|
|
|
var _ = require('lodash'); |
|
|
|
|
|
|
|
|
|
export type ArtistMetadata = serverApi.ArtistDetails; |
|
|
|
@ -24,6 +25,7 @@ export enum ArtistWindowStateActions { |
|
|
|
|
SetMetadata = "SetMetadata", |
|
|
|
|
SetPendingChanges = "SetPendingChanges", |
|
|
|
|
SetSongs = "SetSongs", |
|
|
|
|
Reload = "Reload", |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function ArtistWindowReducer(state: ArtistWindowState, action: any) { |
|
|
|
@ -34,6 +36,8 @@ export function ArtistWindowReducer(state: ArtistWindowState, action: any) { |
|
|
|
|
return { ...state, pendingChanges: action.value } |
|
|
|
|
case ArtistWindowStateActions.SetSongs: |
|
|
|
|
return { ...state, songsByArtist: action.value } |
|
|
|
|
case ArtistWindowStateActions.Reload: |
|
|
|
|
return { ...state, metadata: null, pendingChanges: null, songsByArtist: null } |
|
|
|
|
default: |
|
|
|
|
throw new Error("Unimplemented ArtistWindow state update.") |
|
|
|
|
} |
|
|
|
@ -164,8 +168,21 @@ export default function ArtistWindow(props: IProps) { |
|
|
|
|
</a> |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const [applying, setApplying] = useState(false); |
|
|
|
|
const maybeSubmitButton = pendingChanges && Object.keys(pendingChanges).length > 0 && |
|
|
|
|
<SubmitChangesButton /> |
|
|
|
|
<Box> |
|
|
|
|
<SubmitChangesButton onClick={() => { |
|
|
|
|
setApplying(true); |
|
|
|
|
saveArtistChanges(props.state.artistId, pendingChanges || {}) |
|
|
|
|
.then(() => { |
|
|
|
|
setApplying(false); |
|
|
|
|
props.dispatch({ |
|
|
|
|
type: ArtistWindowStateActions.Reload |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}} /> |
|
|
|
|
{applying && <CircularProgress />} |
|
|
|
|
</Box> |
|
|
|
|
|
|
|
|
|
return <Box width="100%" justifyContent="center" display="flex" flexWrap="wrap"> |
|
|
|
|
<Box |
|
|
|
|