-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 'Only Mine' toggle for execution tasks list (#343)
Signed-off-by: Olga Nad <[email protected]>
- Loading branch information
1 parent
1b3987a
commit 3b62b27
Showing
15 changed files
with
411 additions
and
119 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
46 changes: 0 additions & 46 deletions
46
src/components/Executions/filters/useCurrentUserOnlyFilterState.ts
This file was deleted.
Oops, something went wrong.
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
48 changes: 48 additions & 0 deletions
48
src/components/Executions/filters/useOnlyMyExecutionsFilterState.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,48 @@ | ||
import { useState } from 'react'; | ||
import { FilterOperation, FilterOperationName } from 'models/AdminEntity/types'; | ||
import { useUserProfile } from 'components/hooks/useUserProfile'; | ||
|
||
interface OnlyMyExecutionsFilterState { | ||
onlyMyExecutionsValue: boolean; | ||
isFilterDisabled: boolean; | ||
onOnlyMyExecutionsFilterChange: (newValue: boolean) => void; | ||
getFilter: () => FilterOperation | null; | ||
} | ||
|
||
interface OnlyMyExecutionsFilterStateProps { | ||
isFilterDisabled?: boolean; | ||
initialValue?: boolean; | ||
} | ||
|
||
/** | ||
* Allows to filter executions by Current User Id | ||
*/ | ||
export function useOnlyMyExecutionsFilterState({ | ||
isFilterDisabled, | ||
initialValue, | ||
}: OnlyMyExecutionsFilterStateProps): OnlyMyExecutionsFilterState { | ||
const profile = useUserProfile(); | ||
const userId = profile.value?.subject ? profile.value.subject : ''; | ||
const [onlyMyExecutionsValue, setOnlyMyExecutionsValue] = useState<boolean>( | ||
initialValue ?? false, | ||
); | ||
|
||
const getFilter = (): FilterOperation | null => { | ||
if (!onlyMyExecutionsValue) { | ||
return null; | ||
} | ||
|
||
return { | ||
key: 'user', | ||
value: userId, | ||
operation: FilterOperationName.EQ, | ||
}; | ||
}; | ||
|
||
return { | ||
onlyMyExecutionsValue, | ||
isFilterDisabled: isFilterDisabled ?? false, | ||
onOnlyMyExecutionsFilterChange: setOnlyMyExecutionsValue, | ||
getFilter, | ||
}; | ||
} |
Oops, something went wrong.