Added option to open links in the same tab for apps/bookamrs/search separately

This commit is contained in:
unknown 2021-06-25 11:24:29 +02:00
parent 0c3a27febd
commit c03f302fa6
7 changed files with 50 additions and 13 deletions

View file

@ -1 +1 @@
REACT_APP_VERSION=1.5.1
REACT_APP_VERSION=1.5.2

View file

@ -16,7 +16,7 @@ const AppCard = (props: ComponentProps): JSX.Element => {
return (
<a
href={redirectUrl}
target={searchConfig('openSameTab', false) ? '' : '_blank'}
target={searchConfig('appsSameTab', false) ? '' : '_blank'}
rel='noreferrer'
className={classes.AppCard}
>

View file

@ -19,7 +19,7 @@ const BookmarkCard = (props: ComponentProps): JSX.Element => {
return (
<a
href={redirectUrl}
target={searchConfig('openSameTab', false) ? '' : '_blank'}
target={searchConfig('bookmarksSameTab', false) ? '' : '_blank'}
rel='noreferrer'
key={`bookmark-${bookmark.id}`}>
{bookmark.icon && (

View file

@ -36,7 +36,9 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
hideCategories: 0,
hideSearch: 0,
useOrdering: 'createdAt',
openSameTab: 0
appsSameTab: 0,
bookmarksSameTab: 0,
searchSameTab: 0
})
// Get config
@ -50,7 +52,9 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
hideCategories: searchConfig('hideCategories', 0),
hideSearch: searchConfig('hideSearch', 0),
useOrdering: searchConfig('useOrdering', 'createdAt'),
openSameTab: searchConfig('openSameTab', 0)
appsSameTab: searchConfig('appsSameTab', 0),
bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
searchSameTab: searchConfig('searchSameTab', 0)
})
}, [props.loading]);
@ -139,18 +143,41 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
</select>
</InputGroup>
<InputGroup>
<label htmlFor='openSameTab'>Open all links in the same tab</label>
<label htmlFor='searchSameTab'>Open search results in the same tab</label>
<select
id='openSameTab'
name='openSameTab'
value={formData.openSameTab}
id='searchSameTab'
name='searchSameTab'
value={formData.searchSameTab}
onChange={(e) => inputChangeHandler(e, true)}
>
<option value={1}>True</option>
<option value={0}>False</option>
</select>
</InputGroup>
<InputGroup>
<label htmlFor='appsSameTab'>Open applications in the same tab</label>
<select
id='appsSameTab'
name='appsSameTab'
value={formData.appsSameTab}
onChange={(e) => inputChangeHandler(e, true)}
>
<option value={1}>True</option>
<option value={0}>False</option>
</select>
</InputGroup>
<InputGroup>
<label htmlFor='bookmarksSameTab'>Open bookmarks in the same tab</label>
<select
id='bookmarksSameTab'
name='bookmarksSameTab'
value={formData.bookmarksSameTab}
onChange={(e) => inputChangeHandler(e, true)}
>
<option value={1}>True</option>
<option value={0}>False</option>
</select>
</InputGroup>
{/* MODULES OPTIONS */}
<h2 className={classes.SettingsSection}>Modules</h2>
<InputGroup>

View file

@ -14,5 +14,7 @@ export interface SettingsForm {
hideCategories: number;
hideSearch: number;
useOrdering: string;
openSameTab: number;
appsSameTab: number;
bookmarksSameTab: number;
searchSameTab: number;
}

View file

@ -11,7 +11,7 @@ export const searchParser = (searchQuery: string): boolean => {
const query = queries.find((q: Query) => q.prefix === prefix);
if (query) {
const sameTab = searchConfig('openSameTab', false);
const sameTab = searchConfig('searchSameTab', false);
if (sameTab) {
document.location.replace(`${query.template}${search}`);

View file

@ -37,7 +37,15 @@
"value": "createdAt"
},
{
"key": "openSameTab",
"key": "appsSameTab",
"value": false
},
{
"key": "bookmarksSameTab",
"value": false
},
{
"key": "searchSameTab",
"value": false
},
{