-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make number of deploy runs fetched configurable
- Loading branch information
1 parent
885c927
commit 9623250
Showing
11 changed files
with
148 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { mapValues } from 'lodash-es' | ||
import { atom, selector } from 'recoil' | ||
import { AppSettings, appSettingsSchema } from './schemas' | ||
|
||
export const defaultAppSettings: AppSettings = { | ||
deployTimeoutSecs: 60, | ||
refreshIntervalSecs: 60, | ||
workflowRuns: 100, | ||
} | ||
|
||
export const appSettingsDescription: Record<keyof AppSettings, string> = { | ||
deployTimeoutSecs: 'Deploy timeout (seconds)', | ||
refreshIntervalSecs: 'Status refresh interval (seconds)', | ||
workflowRuns: 'Number of deploy runs to fetch (max 100)', | ||
} | ||
|
||
export const appSettingsState = atom({ | ||
default: defaultAppSettings, | ||
key: 'appSettings', | ||
effects: [ | ||
({ onSet, setSelf }) => { | ||
const storedJson = localStorage.getItem('appSettings') | ||
if (storedJson) { | ||
try { | ||
const appSettings = appSettingsSchema.parse(JSON.parse(storedJson)) | ||
setSelf(appSettings) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
} | ||
onSet((newValue) => { | ||
localStorage.setItem('appSettings', JSON.stringify(newValue)) | ||
}) | ||
}, | ||
], | ||
}) | ||
|
||
export const appSettings = mapValues(defaultAppSettings, (_, key) => | ||
selector({ | ||
key, | ||
get: ({ get }) => | ||
get(appSettingsState)[key as keyof typeof defaultAppSettings], | ||
set: ({ set, get }, newValue) => | ||
set(appSettingsState, { | ||
...get(appSettingsState), | ||
[key]: newValue, | ||
}), | ||
}) | ||
) |
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,9 @@ | ||
import { z } from 'zod' | ||
|
||
export const appSettingsSchema = z.object({ | ||
deployTimeoutSecs: z.number(), | ||
refreshIntervalSecs: z.number(), | ||
workflowRuns: z.number(), | ||
}) | ||
|
||
export interface AppSettings extends z.infer<typeof appSettingsSchema> {} |
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,3 @@ | ||
export function keysOf<T extends {}>(x: T): (keyof T)[] { | ||
return Object.keys(x) as (keyof T)[] | ||
} |
Oops, something went wrong.