-
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.
fix(frontend): correct randomize store data persisting
- Loading branch information
1 parent
df9ae1e
commit c41cbac
Showing
4 changed files
with
67 additions
and
61 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
apps/frontend/src/widgets/SettingsPanel/Toolbar/ToolbarRandomizeMenu/__tests__/store.test.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
45 changes: 45 additions & 0 deletions
45
apps/frontend/src/widgets/SettingsPanel/Toolbar/ToolbarRandomizeMenu/constants.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 +1,46 @@ | ||
import type { Setting } from './types' | ||
|
||
export const MAX_OPERATIONS = 6 | ||
|
||
export const defaultSettings: Setting[] = [ | ||
{ | ||
label: 'flip', | ||
checked: true | ||
}, | ||
{ | ||
label: 'flop', | ||
checked: false | ||
}, | ||
{ | ||
label: 'grayscale', | ||
checked: false | ||
}, | ||
{ | ||
label: 'negate', | ||
checked: false | ||
}, | ||
{ | ||
label: 'blur', | ||
checked: true | ||
}, | ||
{ | ||
label: 'rotate', | ||
checked: true | ||
}, | ||
{ | ||
label: 'modulate', | ||
checked: false | ||
}, | ||
{ | ||
label: 'gamma', | ||
checked: true | ||
}, | ||
{ | ||
label: 'tint', | ||
checked: false | ||
}, | ||
{ | ||
label: 'normalise', | ||
checked: false | ||
} | ||
] as const |
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
16 changes: 16 additions & 0 deletions
16
apps/frontend/src/widgets/SettingsPanel/Toolbar/ToolbarRandomizeMenu/utility.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { array, boolean, object, string } from 'yup' | ||
|
||
import { defaultSettings } from './constants' | ||
|
||
export const isSettingsValid = (settings: unknown): boolean => { | ||
const optionSchema = object({ | ||
label: string() | ||
.oneOf(defaultSettings.map(s => s.label)) | ||
.defined() | ||
.required(), | ||
checked: boolean().defined().required() | ||
}) | ||
const settingsSchema = array(optionSchema).length(defaultSettings.length).defined().required() | ||
|
||
return settingsSchema.isValidSync(settings) | ||
} |