// External Modules import * as React from 'react'; import {connect} from 'react-redux'; import {Dispatch} from 'redux'; // Types import {ISetItem, IStorageDestinationItem} from '../../interfaces'; import {IApplicationState} from '../../store'; import {superdeskApi} from '../../apis'; // Redux Actions & Selectors import {confirmBeforeDeletingSet, editSet, previewSet} from '../../store/sets/actions'; import {getSetsGroupedByState, getSelectedSetId, getAssetsCountForSets} from '../../store/sets/selectors'; import {getStorageDestinationsById} from '../../store/storageDestinations/selectors'; // UI import {SetListGroup} from './setListGroup'; interface IProps { storageDestinations: Dictionary; previewSet(set: ISetItem): void; deleteSet(set: ISetItem): void; editSet(set: ISetItem): void; currentSetId?: string; sets: ISetArrays; counts: Dictionary; } type ISetArrays = { draft: Array; usable: Array; disabled: Array; }; const mapStateToProps = (state: IApplicationState) => ({ sets: getSetsGroupedByState(state), storageDestinations: getStorageDestinationsById(state), currentSetId: getSelectedSetId(state), counts: getAssetsCountForSets(state), }); const mapDispatchToProps = (dispatch: Dispatch) => ({ editSet: (set: ISetItem) => dispatch(editSet(set._id)), previewSet: (set: ISetItem) => dispatch(previewSet(set._id)), deleteSet: (set: ISetItem) => dispatch(confirmBeforeDeletingSet(set)), }); export class SetListPanelComponent extends React.PureComponent { render() { const {gettext} = superdeskApi.localization; if (Object.keys(this.props.storageDestinations).length === 0) { return null; } return ( ); } } export const SetListPanel = connect( mapStateToProps, mapDispatchToProps, )(SetListPanelComponent);