SetTagsModal: switch to tag selector

This commit is contained in:
Jesse Chan
2020-10-05 00:48:34 +08:00
parent 095d280c78
commit ce1f98e548
3 changed files with 9 additions and 8 deletions
@@ -11,7 +11,7 @@ import TorrentFilterStore from '../../../stores/TorrentFilterStore';
interface TagSelectProps {
id?: string;
label?: React.ReactNode;
defaultValue?: string;
defaultValue?: TorrentProperties['tags'];
placeholder?: string;
}
@@ -53,9 +53,11 @@ export default class TagSelect extends Component<TagSelectProps, TagSelectStates
constructor(props: TagSelectProps) {
super(props);
const {defaultValue} = this.props;
this.state = {
isOpen: false,
selectedTags: [],
selectedTags: defaultValue != null ? defaultValue : [],
};
}
@@ -281,7 +281,7 @@ class DownloadRulesTab extends React.Component<DownloadRulesTabProps, DownloadRu
id: 'feeds.apply.tags',
})}
placeholder={this.props.intl.formatMessage(MESSAGES.tags)}
defaultValue={rule.tags.join()}
defaultValue={rule.tags}
/>
</FormRow>
<FormRow>
@@ -1,8 +1,9 @@
import {injectIntl, WrappedComponentProps} from 'react-intl';
import React from 'react';
import {Form, FormRow, Textbox} from '../../../ui';
import {Form, FormRow} from '../../../ui';
import Modal from '../Modal';
import TagSelect from '../../general/form-elements/TagSelect';
import TorrentActions from '../../../actions/TorrentActions';
import TorrentStore from '../../../stores/TorrentStore';
@@ -56,8 +57,6 @@ class SetTagsModal extends React.Component<WrappedComponentProps, SetTagsModalSt
}
getContent() {
const tagsValue = TorrentStore.getSelectedTorrentsTags()[0].join(', ');
return (
<div className="modal__content inverse">
<Form
@@ -65,8 +64,8 @@ class SetTagsModal extends React.Component<WrappedComponentProps, SetTagsModalSt
this.formRef = ref;
}}>
<FormRow>
<Textbox
defaultValue={tagsValue}
<TagSelect
defaultValue={TorrentStore.getSelectedTorrentsTags()[0]}
id="tags"
placeholder={this.props.intl.formatMessage({
id: 'torrents.set.tags.enter.tags',