-
Notifications
You must be signed in to change notification settings - Fork 16.1k
A tagging system for dashboards, charts and queries #5524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
0637a9b
WIP
betodealmeida 90be846
Merge branch 'master' of github.com:apache/incubator-superset into ta…
betodealmeida 3eb8d80
Missing update
betodealmeida b72066d
Refactor tag component
betodealmeida 01e0616
Decouple tag component from app
betodealmeida 0bc67f6
Working on hooks
betodealmeida ab8a039
Ready for review
betodealmeida 9516c9e
Minor adjustments
betodealmeida a64878e
Small fixes
betodealmeida 806e363
Fixing lint and addressing issues
betodealmeida 7f8df3f
Fix import order
betodealmeida caaeff1
Add polyfills
betodealmeida 4c2ddd5
Fix polyfills
betodealmeida a5e9e3e
Fix pylint, javascript and mysql
betodealmeida ea3fc3b
Fix pylint and mysql
betodealmeida dd3e6cc
Fix javascript lint
betodealmeida cace713
Fix another unit test
betodealmeida fedd2d2
Fix javascript tests
betodealmeida b2ea51e
Fix for MySQL
betodealmeida c5fc98f
Tag search
betodealmeida 0e1442c
Address comments
betodealmeida 9e0531c
Fix conflict
betodealmeida dd27890
Merge branch 'master' into tagging_system
betodealmeida 3f04ff8
Fix liny
betodealmeida c281d28
Merge branch 'tagging_system' of github.com:lyft/incubator-superset i…
betodealmeida 3d67e87
Update constants.js
1d17894
Fix conflict
betodealmeida c3f4052
Merge branch 'tagging_system' of github.com:lyft/incubator-superset i…
betodealmeida b54cf15
Merge heads, remove dep
betodealmeida 72a5193
Move CSRF token to function
betodealmeida 69e74ff
Remove dep
betodealmeida 3acb018
Working on comments
betodealmeida 95daf30
Fix merge
betodealmeida ca4e555
Small fixes
betodealmeida dc2055f
Fix CSS
betodealmeida 50c8fbf
Fix unit test
betodealmeida 980cba3
Fix merge conflict
betodealmeida 9b6c1f9
Use uri.js, fix SQL Lab redirect
betodealmeida b708540
Migration script heads
betodealmeida 04e3478
Default tag search to owned content
betodealmeida 533a9c8
Simplify tag options
betodealmeida 358bddc
Rebase and fix conflict
betodealmeida e35d053
Remove ObjectTags input
betodealmeida a0df8d5
Merge heads in alembic
betodealmeida 05319ef
Fix unit test
betodealmeida 234e309
Merge
betodealmeida File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| /** | ||
| * <div class="react-tags"> | ||
| * <div class="react-tags__selected"> | ||
| * <button class="react-tags__selected-tag"> | ||
| * <span class="react-tags__selected-tag-name" /> | ||
| * </button> | ||
| * </div> | ||
| * <div class="react-tags__search"> | ||
| * <div class="react-tags__search-input"> | ||
| * <input /> | ||
| * <div /> | ||
| * </div> | ||
| * <div class="react-tags__suggestions"> | ||
| * <ul> | ||
| * <li class="is-active"> | ||
| * <mark /> | ||
| * </li> | ||
| * <li class="is-disabled"> | ||
| * <mark /> | ||
| * </li> | ||
| * </ul> | ||
| * </div> | ||
| * </div> | ||
| */ | ||
| .react-tags { | ||
| position: relative; | ||
| display: inline-block; | ||
| padding: 1px 0 0 1px; | ||
| margin: 0 10px; | ||
| border: 1px solid #F5F5F5; | ||
| border-radius: 1px; | ||
|
|
||
| /* shared font styles */ | ||
| font-size: 12px; | ||
| line-height: 1.2; | ||
|
|
||
| /* clicking anywhere will focus the input */ | ||
| cursor: text; | ||
| } | ||
|
|
||
| .react-tags-rw { | ||
| display: inline-block; | ||
| margin: 0 10px; | ||
| font-size: 12px; | ||
| line-height: 1.2; | ||
| } | ||
|
|
||
| .react-tags.is-focused { | ||
| border-color: #F0F0F0; | ||
| } | ||
|
|
||
| .react-tags__selected { | ||
| display: inline; | ||
| } | ||
|
|
||
| .react-tags__selected-tag { | ||
| display: inline-block; | ||
| box-sizing: border-box; | ||
| margin: 0; | ||
| padding: 6px 8px; | ||
| border: 1px solid #F5F5F5; | ||
| border-radius: 2px; | ||
| background: #F1F1F1; | ||
|
|
||
| /* match the font styles */ | ||
| font-size: inherit; | ||
| line-height: inherit; | ||
| } | ||
|
|
||
| .react-tags__selected-tag:after { | ||
| content: '\2715'; | ||
| color: #AAA; | ||
| margin-left: 8px; | ||
| } | ||
|
|
||
| .react-tags__selected-tag:hover, | ||
| .react-tags__selected-tag:focus { | ||
| border-color: #B1B1B1; | ||
| } | ||
|
|
||
| .react-tags__search { | ||
| display: inline-block; | ||
|
|
||
| /* match tag layout */ | ||
| padding: 7px 2px; | ||
| margin-bottom: 0; | ||
|
|
||
| /* prevent autoresize overflowing the container */ | ||
| max-width: 100%; | ||
| } | ||
|
|
||
| @media screen and (min-width: 30em) { | ||
|
|
||
| .react-tags__search { | ||
| /* this will become the offsetParent for suggestions */ | ||
| position: relative; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| .react-tags__search input { | ||
| /* prevent autoresize overflowing the container */ | ||
| max-width: 100%; | ||
|
|
||
| /* remove styles and layout from this element */ | ||
| margin: 0; | ||
| margin-left: 2px; | ||
| padding: 0; | ||
| border: 0; | ||
| outline: none; | ||
|
|
||
| /* match the font styles */ | ||
| font-size: inherit; | ||
| line-height: inherit; | ||
| } | ||
|
|
||
| .react-tags__search input::-ms-clear { | ||
| display: none; | ||
| } | ||
|
|
||
| .react-tags__suggestions { | ||
| position: absolute; | ||
| top: 100%; | ||
| left: 0; | ||
| width: 100%; | ||
| z-index: 9999; | ||
| } | ||
|
|
||
| @media screen and (min-width: 30em) { | ||
|
|
||
| .react-tags__suggestions { | ||
| width: 240px; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| .react-tags__suggestions ul { | ||
| margin: 4px -1px; | ||
| padding: 0; | ||
| list-style: none; | ||
| background: white; | ||
| border: 1px solid #D1D1D1; | ||
| border-radius: 2px; | ||
| box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); | ||
| } | ||
|
|
||
| .react-tags__suggestions li { | ||
| border-bottom: 1px solid #ddd; | ||
| padding: 6px 8px; | ||
| } | ||
|
|
||
| .react-tags__suggestions li mark { | ||
| text-decoration: underline; | ||
| background: none; | ||
| font-weight: 600; | ||
| } | ||
|
|
||
| .react-tags__suggestions li:hover { | ||
| cursor: pointer; | ||
| background: #eee; | ||
| } | ||
|
|
||
| .react-tags__suggestions li.is-active { | ||
| background: #b7cfe0; | ||
| } | ||
|
|
||
| .react-tags__suggestions li.is-disabled { | ||
| opacity: 0.5; | ||
| cursor: auto; | ||
| } | ||
|
|
||
| .react-tags span.label { | ||
| margin-left: 5px; | ||
| padding: 0.3em 0.6em 0.3em; | ||
| } | ||
|
|
||
| .react-tags a.deco-none { | ||
| color: inherit; | ||
| text-decoration:none; | ||
| } | ||
|
|
||
| .react-tags-rw span.label { | ||
| margin-left: 5px; | ||
| } | ||
|
|
||
| .react-tags-rw a.deco-none { | ||
| color: inherit; | ||
| text-decoration:none; | ||
| } | ||
|
|
||
| .react-tags span.glyphicon { | ||
| cursor: pointer; | ||
| margin-left: 3px; | ||
| top: 2px; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| 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: [], | ||
| }; | ||
|
|
||
| this.handleDelete = this.handleDelete.bind(this); | ||
| this.handleAddition = this.handleAddition.bind(this); | ||
| } | ||
|
|
||
| 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 = [...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; | ||
| return ( | ||
| <ReactTags | ||
| {...rest} | ||
| tags={this.state.tags} | ||
| suggestions={this.state.suggestions} | ||
| handleDelete={this.handleDelete} | ||
| handleAddition={this.handleAddition} | ||
| allowNew | ||
| placeHolder={t('Add new tag')} | ||
| tagComponent={Tag} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| renderReadOnlyTags() { | ||
| return ( | ||
| <div className="react-tags-rw"> | ||
| {this.state.tags.map(tag => ( | ||
| <Label bsStyle="info"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs a |
||
| <a | ||
| href={`/superset/welcome?tags=${tag.name}#tags`} | ||
| className="deco-none" | ||
| > | ||
| {tag.name} | ||
| </a> | ||
| </Label> | ||
| ))} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| render() { | ||
| if (this.props.editable) { | ||
| return this.renderEditableTags(); | ||
| } | ||
| return this.renderReadOnlyTags(); | ||
| } | ||
| } | ||
|
|
||
| ObjectTags.propTypes = propTypes; | ||
| ObjectTags.defaultProps = defaultProps; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would ❤️ approval from @williaster and/or @graceguo-supercat on this import as a preferred method to eventually replace jQuery in the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we should definitely be using fetch over jquery 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was not jquery vs fetch, but npm's
fetchpackage vswhatwg-fetchwhich are different things. I have no opposition with either but should make a conscious decision.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see,
whatwg-fetchhas 2.7M weekly downloads whereasfetchhas12k, so I'd prob say the former?