mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-16 04:23:47 +00:00
Created filtering by tag feature
This commit is contained in:
@@ -2,6 +2,7 @@ import searchIcon from '@fortawesome/fontawesome-free-solid/faSearch';
|
||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import Tag from '../utils/Tag';
|
||||
import { listShortUrls } from './reducers/shortUrlsList';
|
||||
import './SearchBar.scss';
|
||||
import { pick } from 'ramda';
|
||||
@@ -14,22 +15,41 @@ export class SearchBar extends React.Component {
|
||||
timer = null;
|
||||
|
||||
render() {
|
||||
const { listShortUrls, shortUrlsListParams } = this.props;
|
||||
const selectedTag = shortUrlsListParams.tags ? shortUrlsListParams.tags[0] : '';
|
||||
|
||||
return (
|
||||
<div className="search-bar">
|
||||
<input type="text"
|
||||
className="form-control form-control-lg search-bar__input"
|
||||
placeholder="Search..."
|
||||
onChange={e => this.searchTermChanged(e.target.value)}
|
||||
value={this.state.searchTerm}
|
||||
/>
|
||||
<FontAwesomeIcon icon={searchIcon} className="search-bar__icon" />
|
||||
<div className="close search-bar__close"
|
||||
hidden={! this.state.showClearBtn}
|
||||
onClick={() => this.searchTermChanged('')}
|
||||
id="search-bar__close"
|
||||
>
|
||||
×
|
||||
<div class="serach-bar-container">
|
||||
<div className="search-bar">
|
||||
<input
|
||||
type="text"
|
||||
className="form-control form-control-lg search-bar__input"
|
||||
placeholder="Search..."
|
||||
onChange={e => this.searchTermChanged(e.target.value)}
|
||||
value={this.state.searchTerm}
|
||||
/>
|
||||
<FontAwesomeIcon icon={searchIcon} className="search-bar__icon" />
|
||||
<div
|
||||
className="close search-bar__close"
|
||||
hidden={! this.state.showClearBtn}
|
||||
onClick={() => this.searchTermChanged('')}
|
||||
id="search-bar__close"
|
||||
>
|
||||
×
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{selectedTag && (
|
||||
<h4 className="search-bar__selected-tag mt-2">
|
||||
<small>Filtering by tag:</small>
|
||||
|
||||
<Tag
|
||||
text={selectedTag}
|
||||
clearable
|
||||
onClose={() => listShortUrls({ ...shortUrlsListParams, tags: undefined })}
|
||||
/>
|
||||
</h4>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user