* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
import { PopupPlacement, Tags } from 'design-system';
import * as React from 'react';
import { setIssueTags } from '../../../api/issues';
+import withComponentContext from '../../../app/components/componentContext/withComponentContext';
import { translate } from '../../../helpers/l10n';
+import { ComponentContextShape } from '../../../types/component';
import { Issue } from '../../../types/types';
import Tooltip from '../../controls/Tooltip';
import { updateIssue } from '../actions';
import IssueTagsPopup from '../popups/IssueTagsPopup';
-interface Props {
+interface Props extends ComponentContextShape {
canSetTags: boolean;
issue: Pick<Issue, 'key' | 'tags'>;
onChange: (issue: Issue) => void;
- togglePopup: (popup: string, show?: boolean) => void;
open?: boolean;
+ togglePopup: (popup: string, show?: boolean) => void;
}
-export default class IssueTags extends React.PureComponent<Props> {
- toggleSetTags = (open?: boolean) => {
+export class IssueTags extends React.PureComponent<Props> {
+ toggleSetTags = (open = false) => {
this.props.togglePopup('edit-tags', open);
};
setTags = (tags: string[]) => {
const { issue } = this.props;
const newIssue = { ...issue, tags };
+
updateIssue(
this.props.onChange,
setIssueTags({ issue: issue.key, tags: tags.join(',') }),
};
render() {
- const { issue, open } = this.props;
+ const { component, issue, open } = this.props;
const { tags = [] } = issue;
return (
<Tags
- allowUpdate={this.props.canSetTags}
+ allowUpdate={this.props.canSetTags && !component?.needIssueSync}
ariaTagsListLabel={translate('issue.tags')}
className="js-issue-edit-tags"
emptyText={translate('issue.no_tag')}
menuId="issue-tags-menu"
+ onClose={this.handleClose}
+ open={open}
overlay={<IssueTagsPopup selectedTags={tags} setTags={this.setTags} />}
popupPlacement={PopupPlacement.Bottom}
tags={tags}
tagsToDisplay={2}
tooltip={Tooltip}
- open={open}
- onClose={this.handleClose}
/>
);
}
}
+
+export default withComponentContext(IssueTags);