-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added settings page for access key and access secret
- Loading branch information
wwills2
committed
Jan 23, 2024
1 parent
615ee7b
commit 1552051
Showing
12 changed files
with
157 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Button, TextInput } from "flowbite-react"; | ||
import styled from "styled-components"; | ||
import { FormattedMessage } from "react-intl"; | ||
import {useCallback, useEffect, useRef} from "react"; | ||
import {useDispatch, useSelector} from "react-redux"; | ||
import { | ||
getAccessKey, | ||
getAccessSecret, | ||
setAccessKey, | ||
setAccessSecret | ||
} from "@/store/slices/userOptions"; | ||
|
||
const SettingsDiv = styled('div')` | ||
height: 100%; | ||
width: 100%; | ||
padding: 10px; | ||
display: flex; | ||
justify-content: center; | ||
`; | ||
|
||
interface SettingsProps { | ||
|
||
} | ||
|
||
interface AccessSettingsProps { | ||
|
||
} | ||
|
||
const AccessSettings: React.FC<AccessSettingsProps> = () => { | ||
|
||
const dispatch = useDispatch(); | ||
const accessKeyTextInput = useRef<HTMLInputElement>(null); | ||
const accessSecretTextInput = useRef<HTMLInputElement>(null); | ||
const accessKey = useSelector((state: any) => getAccessKey(state)); | ||
const accessSecret = useSelector((state: any) => getAccessSecret(state)); | ||
|
||
useEffect(() => { | ||
if (accessKeyTextInput.current && accessSecretTextInput.current) { | ||
accessKeyTextInput.current.value = accessKey; | ||
accessSecretTextInput.current.value = accessSecret; | ||
} | ||
}, [accessKeyTextInput, accessSecretTextInput, accessSecret, accessKey]); | ||
|
||
const onSave = useCallback(() => { | ||
if (accessKeyTextInput.current && accessSecretTextInput.current) { | ||
if (accessKeyTextInput.current.value != '' && accessSecretTextInput.current.value != '') { | ||
dispatch(setAccessKey(accessKeyTextInput.current.value as string)); | ||
dispatch(setAccessSecret(accessSecretTextInput.current.value as string)); | ||
} | ||
} | ||
}, [dispatch]); | ||
|
||
return ( | ||
<> | ||
<div> | ||
<div className="mb-2 block"> | ||
<FormattedMessage id="access-key"/> | ||
</div> | ||
<TextInput | ||
id="acessKey" | ||
type="text" | ||
ref={accessKeyTextInput} | ||
required/> | ||
</div> | ||
<div> | ||
<div className="mb-2 block"> | ||
<FormattedMessage id="access-secret"/> | ||
</div> | ||
<TextInput | ||
id="accessSecret" | ||
type="text" | ||
ref={accessSecretTextInput} | ||
required/> | ||
</div> | ||
<div style={{height: "20px"}}/> | ||
<Button type="submit" onClick={onSave} style={{width: "100%"}}> | ||
<FormattedMessage id="save"/> | ||
</Button> | ||
</> | ||
); | ||
} | ||
|
||
const Settings: React.FC<SettingsProps> = () => { | ||
return ( | ||
<SettingsDiv> | ||
<div style={{width: "448px"}}> | ||
<AccessSettings/> | ||
</div> | ||
</SettingsDiv> | ||
); | ||
} | ||
|
||
export {Settings}; |
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 * from './Settings'; |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './AppDefault'; | ||
export * from './Hello1'; | ||
export * from './Hello2'; | ||
export * from './Browser' | ||
export * from './Browser'; | ||
export * from './Settings'; | ||
export * from './Error'; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './userOptions.slice'; | ||
export * from './userOptions.slice'; | ||
export * from './userOptions.view'; |
4 changes: 3 additions & 1 deletion
4
src/renderer/store/slices/userOptions/userOptions.initialstate.ts
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export default { | ||
selectedTheme: 'light' | ||
selectedTheme: 'light', | ||
accessKey: '', | ||
accessSecret: '', | ||
}; |
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,7 @@ | ||
export const getAccessKey = (state) => { | ||
return state.userOptions.accessKey; | ||
} | ||
|
||
export const getAccessSecret = (state) => { | ||
return state.userOptions.accessSecret; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
|
||
"app-default": "App Default", | ||
"hello-1": "Hello 1", | ||
"hello-2": "Hello 2", | ||
"browser": "Browser" | ||
"browser": "Browser", | ||
"settings": "Settings", | ||
"access-key": "Access Key", | ||
"access-secret": "Access Secret", | ||
"save": "Save" | ||
} |