Skip to content

Commit

Permalink
add plus between tags to clarify how they are used getredash#4628
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkovar committed Jul 1, 2020
1 parent 8f4ac95 commit 6c8fdbf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions client/app/assets/less/redash/tags-control.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
display: inline-block;
}

.tag-separator {
margin: 4px 3px 0 0;
}

&.disabled {
opacity: 0.4;
}
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/NoTaggedObjectsFound.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function NoTaggedObjectsFound({ objectType, tags }) {
return (
<BigMessage icon="fa-tags">
No {objectType} found tagged with&nbsp;
<TagsControl className="inline-tags-control" tags={Array.from(tags)} />.
<TagsControl className="inline-tags-control" tags={Array.from(tags)} tagSeparator={'+'} />.
</BigMessage>
);
}
Expand Down
13 changes: 9 additions & 4 deletions client/app/components/tags-control/TagsControl.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { map, trim } from "lodash";
import { flatMap, map, trim } from "lodash";
import React from "react";
import PropTypes from "prop-types";
import Tooltip from "antd/lib/tooltip";
Expand All @@ -12,6 +12,7 @@ export class TagsControl extends React.Component {
onEdit: PropTypes.func,
className: PropTypes.string,
tagsExtra: PropTypes.node,
tagSeparator: PropTypes.node,
children: PropTypes.node,
};

Expand All @@ -22,6 +23,7 @@ export class TagsControl extends React.Component {
onEdit: () => {},
className: "",
tagsExtra: null,
tagSeparator: null,
children: null,
};

Expand Down Expand Up @@ -52,11 +54,14 @@ export class TagsControl extends React.Component {
return (
<div className={"tags-control " + this.props.className} data-test="TagsControl">
{this.props.children}
{map(this.props.tags, tag => (
{flatMap(this.props.tags, (tag, i) => [
<span className="label label-tag" key={tag} title={tag} data-test="TagLabel">
{tag}
</span>
))}
</span>,
this.props.tagSeparator && i < this.props.tags.length - 1 && (
<span className="tag-separator">{this.props.tagSeparator}</span>
),
])}
{this.props.canEdit && this.renderEditButton()}
{this.props.tagsExtra}
</div>
Expand Down

0 comments on commit 6c8fdbf

Please sign in to comment.