mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-29 16:31:33 +00:00
TagsSearch: tweaks to allow re-use beyond tags
- Allow 'followed' and 'unfollowed' list to be overridden via props. - Allow labels to be overridden via props. - Add ability to disable "Suggestions"
This commit is contained in:
parent
1008724761
commit
b2c2096da5
2 changed files with 35 additions and 27 deletions
|
@ -4,9 +4,9 @@ import { doToggleTagFollowDesktop, doAddTag, doDeleteTag } from 'redux/actions/t
|
||||||
import { selectUser } from 'redux/selectors/user';
|
import { selectUser } from 'redux/selectors/user';
|
||||||
import DiscoveryFirstRun from './view';
|
import DiscoveryFirstRun from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = (state, props) => ({
|
||||||
unfollowedTags: selectUnfollowedTags(state),
|
unfollowedTags: props.unfollowedTags || selectUnfollowedTags(state),
|
||||||
followedTags: selectFollowedTags(state),
|
followedTags: props.followedTags || selectFollowedTags(state),
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,14 @@ type Props = {
|
||||||
doToggleTagFollowDesktop: (string) => void,
|
doToggleTagFollowDesktop: (string) => void,
|
||||||
doAddTag: (string) => void,
|
doAddTag: (string) => void,
|
||||||
onSelect?: (Tag) => void,
|
onSelect?: (Tag) => void,
|
||||||
|
hideSuggestions?: boolean,
|
||||||
suggestMature?: boolean,
|
suggestMature?: boolean,
|
||||||
disableAutoFocus?: boolean,
|
disableAutoFocus?: boolean,
|
||||||
onRemove: (Tag) => void,
|
onRemove: (Tag) => void,
|
||||||
placeholder?: string,
|
placeholder?: string,
|
||||||
label?: string,
|
label?: string,
|
||||||
|
labelAddNew?: string,
|
||||||
|
labelSuggestions?: string,
|
||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
limitSelect?: number,
|
limitSelect?: number,
|
||||||
limitShow?: number,
|
limitShow?: number,
|
||||||
|
@ -44,10 +47,13 @@ export default function TagsSearch(props: Props) {
|
||||||
doAddTag,
|
doAddTag,
|
||||||
onSelect,
|
onSelect,
|
||||||
onRemove,
|
onRemove,
|
||||||
|
hideSuggestions,
|
||||||
suggestMature,
|
suggestMature,
|
||||||
disableAutoFocus,
|
disableAutoFocus,
|
||||||
placeholder,
|
placeholder,
|
||||||
label,
|
label,
|
||||||
|
labelAddNew,
|
||||||
|
labelSuggestions,
|
||||||
disabled,
|
disabled,
|
||||||
limitSelect = TAG_FOLLOW_MAX,
|
limitSelect = TAG_FOLLOW_MAX,
|
||||||
limitShow = 5,
|
limitShow = 5,
|
||||||
|
@ -189,10 +195,11 @@ export default function TagsSearch(props: Props) {
|
||||||
type="text"
|
type="text"
|
||||||
value={newTag}
|
value={newTag}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
label={__('Add Tags')}
|
label={labelAddNew || __('Add Tags')}
|
||||||
/>
|
/>
|
||||||
|
{!hideSuggestions && (
|
||||||
<section>
|
<section>
|
||||||
<label>{newTag.length ? __('Matching') : __('Known Tags')}</label>
|
<label>{labelSuggestions || (newTag.length ? __('Matching') : __('Known Tags'))}</label>
|
||||||
<ul className="tags">
|
<ul className="tags">
|
||||||
{Boolean(newTag.length) && !suggestedTags.includes(newTag) && (
|
{Boolean(newTag.length) && !suggestedTags.includes(newTag) && (
|
||||||
<Tag
|
<Tag
|
||||||
|
@ -214,6 +221,7 @@ export default function TagsSearch(props: Props) {
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
)}
|
||||||
</fieldset-section>
|
</fieldset-section>
|
||||||
{experimentalFeature &&
|
{experimentalFeature &&
|
||||||
onSelect && ( // onSelect ensures this does not appear on TagFollow
|
onSelect && ( // onSelect ensures this does not appear on TagFollow
|
||||||
|
|
Loading…
Add table
Reference in a new issue