-
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 [WIP]
Signed-off-by: olga-union <[email protected]>
- Loading branch information
1 parent
5732fc1
commit 35ee452
Showing
10 changed files
with
115 additions
and
100 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
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
43 changes: 43 additions & 0 deletions
43
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,43 @@ | ||
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; | ||
} | ||
|
||
/** | ||
* Allows to filter executions by Current User Id | ||
*/ | ||
export function useOnlyMyExecutionsFilterState( | ||
isFilterDisabled?: boolean, | ||
initialState?: boolean, | ||
): OnlyMyExecutionsFilterState { | ||
const profile = useUserProfile(); | ||
const userId = profile.value?.subject ? profile.value.subject : ''; | ||
const [onlyMyExecutionsValue, setOnlyMyExecutionsValue] = useState<boolean>( | ||
initialState ?? 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, | ||
}; | ||
} |
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