williaster 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_r207976715
##########
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);
Review comment:
object spread is preferred over concat.
----------------------------------------------------------------
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]