You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/06/19 18:57:49 UTC
[GitHub] [incubator-superset] betodealmeida commented on a change in pull
request #7418: Tagging frontend
betodealmeida commented on a change in pull request #7418: Tagging frontend
URL: https://github.com/apache/incubator-superset/pull/7418#discussion_r295468151
##########
File path: superset/assets/src/welcome/Welcome.jsx
##########
@@ -31,38 +37,94 @@ const propTypes = {
export default class Welcome extends React.PureComponent {
constructor(props) {
super(props);
+
+ const defaultTab = isFeatureEnabled(FeatureFlag.TAGGING_SYSTEM)
+ ? 'tags'
+ : 'favorites';
+ const parsedUrl = new URI(window.location);
+ const key = parsedUrl.fragment() || defaultTab;
+ const searchParams = parsedUrl.search(true);
+ const dashboardSearch = searchParams.search || '';
+ const tagSearch = searchParams.tags || 'owner:{{ current_user_id() }}';
this.state = {
- search: '',
+ key,
+ dashboardSearch,
+ tagSearch,
+ tagSuggestions: STANDARD_TAGS,
};
- this.onSearchChange = this.onSearchChange.bind(this);
+
+ this.handleSelect = this.handleSelect.bind(this);
+ this.onDashboardSearchChange = this.onDashboardSearchChange.bind(this);
+ this.onTagSearchChange = this.onTagSearchChange.bind(this);
+ }
+ componentDidMount() {
+ fetchSuggestions({ includeTypes: false }, (suggestions) => {
+ const tagSuggestions = [
+ ...STANDARD_TAGS,
+ ...suggestions.map(tag => tag.name),
+ ];
+ this.setState({ tagSuggestions });
+ });
+ }
+ onDashboardSearchChange(event) {
+ const dashboardSearch = event.target.value;
+ this.setState({ dashboardSearch }, () => this.updateURL('search', dashboardSearch));
}
- onSearchChange(event) {
- this.setState({ search: event.target.value });
+ onTagSearchChange(tags) {
+ const tagSearch = tags.join(',');
+ this.setState({ tagSearch }, () => this.updateURL('tags', tagSearch));
+ }
+ updateURL(key, value) {
+ const parsedUrl = new URI(window.location);
+ parsedUrl.search(data => ({ ...data, [key]: value }));
+ window.history.pushState({ value }, value, parsedUrl.href());
+ }
+ handleSelect(key) {
+ // store selected tab in URL
+ window.history.pushState({ tab: key }, key, `#${key}`);
Review comment:
This is so we can deep link to a particular tag search when the user clicks a tag (though this could be done encoding the info on the path), and also so that the user can share search results for a tag.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org