mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 23:07:26 +03:00
Updated tags list, allowing to click on a tag to show the list filtered by that tag
This commit is contained in:
parent
680d80d753
commit
2650027c40
5 changed files with 38 additions and 19 deletions
|
@ -44,16 +44,19 @@ export class SearchBar extends React.Component {
|
||||||
<h4 className="search-bar__selected-tag mt-2">
|
<h4 className="search-bar__selected-tag mt-2">
|
||||||
<FontAwesomeIcon icon={tagsIcon} className="search-bar__tags-icon" />
|
<FontAwesomeIcon icon={tagsIcon} className="search-bar__tags-icon" />
|
||||||
|
|
||||||
{selectedTags.map(tag => <Tag
|
{selectedTags.map(tag => (
|
||||||
text={tag}
|
<Tag
|
||||||
clearable
|
key={tag}
|
||||||
onClose={() => listShortUrls(
|
text={tag}
|
||||||
{
|
clearable
|
||||||
...shortUrlsListParams,
|
onClose={() => listShortUrls(
|
||||||
tags: selectedTags.filter(selectedTag => selectedTag !== tag)
|
{
|
||||||
}
|
...shortUrlsListParams,
|
||||||
)}
|
tags: selectedTags.filter(selectedTag => selectedTag !== tag)
|
||||||
/>)}
|
}
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</h4>
|
</h4>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from
|
||||||
import { ShortUrlsRow } from './helpers/ShortUrlsRow'
|
import { ShortUrlsRow } from './helpers/ShortUrlsRow'
|
||||||
import { listShortUrls } from './reducers/shortUrlsList'
|
import { listShortUrls } from './reducers/shortUrlsList'
|
||||||
import './ShortUrlsList.scss'
|
import './ShortUrlsList.scss'
|
||||||
|
import qs from 'qs';
|
||||||
|
|
||||||
const SORTABLE_FIELDS = {
|
const SORTABLE_FIELDS = {
|
||||||
dateCreated: 'Created at',
|
dateCreated: 'Created at',
|
||||||
|
@ -64,8 +65,10 @@ export class ShortUrlsList extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { match: { params } } = this.props;
|
const { match: { params }, location } = this.props;
|
||||||
this.refreshList({ page: params.page });
|
const query = qs.parse(location.search, { ignoreQueryPrefix: true });
|
||||||
|
|
||||||
|
this.refreshList({ page: params.page, tags: query.tag ? [query.tag] : [] });
|
||||||
}
|
}
|
||||||
|
|
||||||
renderShortUrls() {
|
renderShortUrls() {
|
||||||
|
|
|
@ -15,9 +15,13 @@ export class ShortUrlsRow extends React.Component {
|
||||||
|
|
||||||
const { refreshList, shortUrlsListParams } = this.props;
|
const { refreshList, shortUrlsListParams } = this.props;
|
||||||
const selectedTags = shortUrlsListParams.tags || [];
|
const selectedTags = shortUrlsListParams.tags || [];
|
||||||
return tags.map(
|
return tags.map(tag => (
|
||||||
tag => <Tag key={tag} text={tag} onClick={() => refreshList({tags: [ ...selectedTags, tag ] })} />
|
<Tag
|
||||||
);
|
key={tag}
|
||||||
|
text={tag}
|
||||||
|
onClick={() => refreshList({ tags: [ ...selectedTags, tag ] })}
|
||||||
|
/>
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ColorGenerator, { colorGeneratorType } from '../utils/ColorGenerator';
|
import ColorGenerator, { colorGeneratorType } from '../utils/ColorGenerator';
|
||||||
import './TagCard.scss';
|
import './TagCard.scss';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
tag: PropTypes.string,
|
tag: PropTypes.string,
|
||||||
|
@ -20,7 +21,7 @@ export default class TagCard extends React.Component {
|
||||||
state = { isDeleteModalOpen: false, isEditModalOpen: false };
|
state = { isDeleteModalOpen: false, isEditModalOpen: false };
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { tag, colorGenerator } = this.props;
|
const { tag, colorGenerator, currentServerId } = this.props;
|
||||||
const toggleDelete = () =>
|
const toggleDelete = () =>
|
||||||
this.setState({ isDeleteModalOpen: !this.state.isDeleteModalOpen });
|
this.setState({ isDeleteModalOpen: !this.state.isDeleteModalOpen });
|
||||||
|
|
||||||
|
@ -41,7 +42,9 @@ export default class TagCard extends React.Component {
|
||||||
style={{backgroundColor: colorGenerator.getColorForKey(tag)}}
|
style={{backgroundColor: colorGenerator.getColorForKey(tag)}}
|
||||||
className="tag-card__tag-bullet"
|
className="tag-card__tag-bullet"
|
||||||
/>
|
/>
|
||||||
{tag}
|
<Link to={`/server/${currentServerId}/list-short-urls/1?tag=${tag}`}>
|
||||||
|
{tag}
|
||||||
|
</Link>
|
||||||
</h5>
|
</h5>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ export class TagsList extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderContent() {
|
renderContent() {
|
||||||
const { tagsList } = this.props;
|
const { tagsList, match } = this.props;
|
||||||
if (tagsList.loading) {
|
if (tagsList.loading) {
|
||||||
return <MuttedMessage marginSize={0}>Loading...</MuttedMessage>
|
return <MuttedMessage marginSize={0}>Loading...</MuttedMessage>
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,13 @@ export class TagsList extends React.Component {
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{tagsGroups.map((group, index) => (
|
{tagsGroups.map((group, index) => (
|
||||||
<div key={index} className="col-md-6 col-xl-3">
|
<div key={index} className="col-md-6 col-xl-3">
|
||||||
{group.map(tag => <TagCard tag={tag} key={tag}/>)}
|
{group.map(tag => (
|
||||||
|
<TagCard
|
||||||
|
key={tag}
|
||||||
|
tag={tag}
|
||||||
|
currentServerId={match.params.serverId}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
Loading…
Reference in a new issue