-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: normalization checks (#16707)
* refactor(checks): action types * feat: ive done too much * fix: tsc errors * fix: jest tests * chore: change <resourceName>Status to activeStatus * refactor: getResourceAtID
- Loading branch information
Showing
42 changed files
with
992 additions
and
738 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Types | ||
import {RemoteDataState, Label, CheckEntities} from 'src/types' | ||
import {NormalizedSchema} from 'normalizr' | ||
|
||
export type Action = | ||
| ReturnType<typeof setChecks> | ||
| ReturnType<typeof setCheck> | ||
| ReturnType<typeof removeCheck> | ||
| ReturnType<typeof addLabelToCheck> | ||
| ReturnType<typeof removeLabelFromCheck> | ||
|
||
export const SET_CHECKS = 'SET_CHECKS' | ||
export const SET_CHECK = 'SET_CHECK' | ||
export const REMOVE_CHECK = 'REMOVE_CHECK' | ||
export const ADD_LABEL_TO_CHECK = 'ADD_LABEL_TO_CHECK' | ||
export const REMOVE_LABEL_FROM_CHECK = 'REMOVE_LABEL_FROM_CHECK' | ||
|
||
type ChecksSchema<R extends string | string[]> = NormalizedSchema< | ||
CheckEntities, | ||
R | ||
> | ||
|
||
export const setChecks = ( | ||
status: RemoteDataState, | ||
schema?: ChecksSchema<string[]> | ||
) => | ||
({ | ||
type: SET_CHECKS, | ||
status, | ||
schema, | ||
} as const) | ||
|
||
export const setCheck = ( | ||
id: string, | ||
status: RemoteDataState, | ||
schema?: ChecksSchema<string> | ||
) => | ||
({ | ||
type: SET_CHECK, | ||
id, | ||
status, | ||
schema, | ||
} as const) | ||
|
||
export const removeCheck = (id: string) => | ||
({ | ||
type: REMOVE_CHECK, | ||
id, | ||
} as const) | ||
|
||
export const addLabelToCheck = (checkID: string, label: Label) => | ||
({ | ||
type: ADD_LABEL_TO_CHECK, | ||
checkID, | ||
label, | ||
} as const) | ||
|
||
export const removeLabelFromCheck = (checkID: string, labelID: string) => | ||
({ | ||
type: REMOVE_LABEL_FROM_CHECK, | ||
checkID, | ||
labelID, | ||
} as const) |
Oops, something went wrong.