-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94a5a6d
commit 094ae4a
Showing
16 changed files
with
727 additions
and
341 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: 'Alpha Build' | |
|
||
on: | ||
push: | ||
branches: [v490/docker-change] | ||
branches: [v490/release2] | ||
|
||
jobs: | ||
build: | ||
|
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 |
---|---|---|
|
@@ -7,21 +7,31 @@ import queryString from 'query-string'; | |
import RunDetails from './RunDetails'; | ||
import useIsBrowser from '@docusaurus/useIsBrowser'; | ||
import Toggle from 'react-toggle'; | ||
import usePersistedState from './usePersistedState'; | ||
|
||
function getRandomPassword() { | ||
return randomWords(4).join('-'); | ||
} | ||
|
||
export default function Editor() { | ||
const isBrowser = useIsBrowser(); | ||
const [dbPassword, setDbPassword] = useState(getRandomPassword()); | ||
const [pgPassword, setPgPassword] = useState(getRandomPassword()); | ||
const [sessionSecret, setSessionSecret] = useState(getRandomPassword()); | ||
const [licence, setLicence] = useState('demo'); | ||
const [email, setEmail] = useState('[email protected]'); | ||
const [port, setPort] = useState('80'); | ||
const [pgPort, setPgPort] = useState('81'); | ||
const [isArm, setIsArm] = useState(false); | ||
const [dbPassword, setDbPassword] = usePersistedState( | ||
'db-password', | ||
getRandomPassword() | ||
); | ||
const [pgPassword, setPgPassword] = usePersistedState( | ||
'pg-password', | ||
getRandomPassword() | ||
); | ||
const [sessionSecret, setSessionSecret] = usePersistedState( | ||
'session-secret', | ||
getRandomPassword() | ||
); | ||
const [licence, setLicence] = usePersistedState('licence-key', 'demo'); | ||
const [email, setEmail] = usePersistedState('email', '[email protected]'); | ||
const [port, setPort] = usePersistedState('port', '80'); | ||
const [pgPort, setPgPort] = usePersistedState('pg-port', '81'); | ||
const [isArm, setIsArm] = usePersistedState('is-arm', false); | ||
|
||
useEffect(() => { | ||
if (isBrowser) { | ||
|
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,59 @@ | ||
import useIsBrowser from '@docusaurus/useIsBrowser'; | ||
import { useState, Dispatch, SetStateAction, useEffect } from 'react'; | ||
|
||
type UsePersistedStateValue<T> = [T, Dispatch<SetStateAction<T>>]; | ||
|
||
function getFromLocalStorage<T>( | ||
key: string, | ||
defaultValue: T, | ||
browser: boolean | ||
) { | ||
if (!browser) { | ||
return defaultValue; | ||
} | ||
const current = localStorage.getItem('retrospected-docs-' + key); | ||
if (current) { | ||
return JSON.parse(current) as T; | ||
} | ||
return defaultValue; | ||
} | ||
|
||
function storeInLocalStorage<T>(key: string, value: T, browser: boolean) { | ||
if (!browser) { | ||
return; | ||
} | ||
const json = JSON.stringify(value); | ||
localStorage.setItem('retrospected-docs-' + key, json); | ||
} | ||
|
||
/** | ||
* Similar to useState, except it persists the data to local storage, and retrieves it automatically when | ||
* mounted. Use it as you would use useState. | ||
* @param key Unique key, used to persist the data in local-storage | ||
* @param defaultValue Default value, of type T | ||
*/ | ||
function usePersistedState<T>( | ||
key: string, | ||
defaultValue: T | ||
): UsePersistedStateValue<T> { | ||
const isBrowser = useIsBrowser(); | ||
const [state, setState] = useState<T>( | ||
getFromLocalStorage(key, defaultValue, isBrowser) | ||
); | ||
|
||
useEffect(() => { | ||
if (isBrowser) { | ||
const storedDefault = getFromLocalStorage(key, defaultValue, isBrowser); | ||
setState(storedDefault); | ||
} | ||
}, [isBrowser]); | ||
|
||
useEffect(() => { | ||
storeInLocalStorage(key, state, isBrowser); | ||
}, [state, key]); | ||
|
||
return [state, setState]; | ||
} | ||
|
||
/** @component */ | ||
export default usePersistedState; |
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
Oops, something went wrong.