-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #809 from alexstotsky/add-ttl-selection
(feature) Auth token TTL customization
- Loading branch information
Showing
10 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { useCallback, useMemo } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
|
||
import { setAuthTokenTTL } from 'state/auth/actions' | ||
import { getAuthTokenTTL } from 'state/auth/selectors' | ||
|
||
import Select from 'ui/Select' | ||
|
||
const getItems = (t) => [ | ||
{ value: 86400, label: t('auth.ttlSelect.1day') }, | ||
{ value: 172800, label: t('auth.ttlSelect.2days') }, | ||
{ value: 259200, label: t('auth.ttlSelect.3days') }, | ||
{ value: 345600, label: t('auth.ttlSelect.4days') }, | ||
{ value: 432000, label: t('auth.ttlSelect.5days') }, | ||
{ value: 518400, label: t('auth.ttlSelect.6days') }, | ||
{ value: 604800, label: t('auth.ttlSelect.7days') }, | ||
] | ||
|
||
const ExportTypeSelector = () => { | ||
const { t } = useTranslation() | ||
const dispatch = useDispatch() | ||
const authTokenTTL = useSelector(getAuthTokenTTL) | ||
const items = useMemo(() => getItems(t), [t]) | ||
|
||
const handleChange = useCallback((value) => { | ||
dispatch(setAuthTokenTTL(value)) | ||
}, [dispatch]) | ||
|
||
return ( | ||
<Select | ||
items={items} | ||
value={authTokenTTL} | ||
onChange={handleChange} | ||
/> | ||
) | ||
} | ||
|
||
export default ExportTypeSelector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './TokenTTLSelector' |