mistercrunch commented on a change in pull request #5524: A tagging system for
dashboards, charts and queries
URL:
https://github.com/apache/incubator-superset/pull/5524#discussion_r207066782
##########
File path: superset/assets/src/components/ObjectTags.jsx
##########
@@ -0,0 +1,122 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import ReactTags from 'react-tag-autocomplete';
+import { Glyphicon, Label } from 'react-bootstrap';
+import TooltipWrapper from './TooltipWrapper';
+
+import './ObjectTags.css';
+
+import { t } from '../locales';
+
+const propTypes = {
+ fetchTags: PropTypes.func,
+ fetchSuggestions: PropTypes.func,
+ deleteTag: PropTypes.func,
+ addTag: PropTypes.func,
+ editable: PropTypes.bool,
+ onChange: PropTypes.func,
+};
+
+const defaultProps = {
+ fetchTags: (callback) => { callback([]); },
+ fetchSuggestions: (callback) => { callback([]); },
+ deleteTag: (tag, callback) => { callback(); },
+ addTag: (tag, callback) => { callback(); },
+ editable: true,
+ onChange: () => {},
+};
+
+export default class ObjectTags extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ tags: [],
+ suggestions: [],
+ };
+ }
+
+ componentDidMount() {
+ this.props.fetchTags(tags => this.setState({ tags }));
+ this.props.fetchSuggestions(suggestions => this.setState({ suggestions }));
+ }
+
+ handleDelete(i) {
+ const tags = this.state.tags.slice(0);
+ const tag = tags.splice(i, 1)[0].name;
+ this.props.deleteTag(tag, () => this.setState({ tags }));
+ this.props.onChange(tags);
+ }
+
+ handleAddition(tag) {
+ const tags = [].concat(this.state.tags, tag);
+ this.props.addTag(tag.name, () => this.setState({ tags }));
+ this.props.onChange(tags);
+ }
+
+ renderEditableTags() {
+ const Tag = props => (
+ <Label bsStyle="info">
+ <a
+ href={`/superset/welcome?tags=${props.tag.name}#tags`}
+ className="deco-none"
+ >
+ {props.tag.name}
+ </a>
+ <TooltipWrapper
+ label="remove"
+ tooltip={t('Click to remove tag')}
+ >
+ <Glyphicon onClick={props.onDelete} glyph="remove" />
+ </TooltipWrapper>
+ </Label>
+ );
+ const {
+ fetchTags,
+ fetchSuggestions,
+ deleteTag,
+ addTag,
+ editable,
+ onChange,
+ ...rest } = this.props;
Review comment:
i see what you did here :), I'm surprised the linter isn't complaining about
unused consts though, I'm ok with this if the linter is.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]