-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 'Only Mine' toggle for execution tasks list #335
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
35ee452
feat: 'Only Mine' toggle for execution tasks list [WIP]
816f1ec
feat: add test, react-hooks lib, refine code, update storybook
olga-union 092af20
feat: update test
olga-union f4d9244
feat: fix broken test
olga-union f94baef
Merge branch 'master' of https://github.com/flyteorg/flyteconsole int…
olga-union 1f18996
feat: add ExecutionFilters tests
olga-union 93ddad0
feat: bump test coverage
olga-union 4f7b941
feat: more ExecutionFilters tests
olga-union a475b22
feat: 'Only Mine' toggle for execution tasks list [WIP]
c36dad6
feat: add test, react-hooks lib, refine code, update storybook
olga-union 5d0d85f
feat: update test
olga-union 18db906
feat: fix broken test
olga-union 732ff30
feat: added RawOutputDataConfig in ExecutionSpec #patch (#329)
pingsutw f842d2d
chore(release): Release 0.46.0 [skip ci]
flyte-bot 6c80922
feat: add ExecutionFilters tests
olga-union 1a17593
feat: bump test coverage
olga-union 597ca67
feat: more ExecutionFilters tests
olga-union a414f4c
feat: trigger build
olga-union 028bf22
Merge branch 'olga-union/add-only-my-executions-filter' of https://gi…
olga-union File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
35 changes: 35 additions & 0 deletions
35
src/components/Executions/filters/test/useOnlyMyExecutionsFilterState.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { loadedFetchable } from 'components/hooks/__mocks__/fetchableData'; | ||
import { useUserProfile } from 'components/hooks/useUserProfile'; | ||
import { useOnlyMyExecutionsFilterState } from 'components/Executions/filters/useOnlyMyExecutionsFilterState'; | ||
import { UserProfile } from 'models/Common/types'; | ||
import { FetchableData } from 'components/hooks/types'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
|
||
jest.mock('components/hooks/useUserProfile'); | ||
|
||
describe('useOnlyMyExecutionsFilterState', () => { | ||
const mockUseRemoteLiteralMap = useUserProfile as jest.Mock<FetchableData<UserProfile | null>>; | ||
mockUseRemoteLiteralMap.mockReturnValue(loadedFetchable(null, jest.fn())); | ||
|
||
describe.each` | ||
isFilterDisabled | initialValue | expected | ||
${undefined} | ${undefined} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} | ||
${false} | ${undefined} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} | ||
${true} | ${undefined} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} | ||
${undefined} | ${false} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} | ||
${undefined} | ${true} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: true }} | ||
${false} | ${false} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} | ||
${false} | ${true} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: true }} | ||
${true} | ${false} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} | ||
${true} | ${true} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: true }} | ||
`('for each case', ({ isFilterDisabled, initialValue, expected }) => { | ||
it(`should return ${JSON.stringify( | ||
expected, | ||
)} when called with isFilterDisabled = ${isFilterDisabled} and initialValue = ${initialValue}`, () => { | ||
const { result } = renderHook(() => | ||
useOnlyMyExecutionsFilterState({ isFilterDisabled, initialValue }), | ||
); | ||
expect(result.current).toEqual(expect.objectContaining(expected)); | ||
}); | ||
}); | ||
}); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially wrote this up as individual tests, but thought this may be a good use case to digest them as a table. I have the original code handy, so wouldn't be a problem to revert, if it's just my taste :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any particular taste, but curious how it will look like if one of them fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anrusina only failed cases will show up, like in this screenshot, test case title is customized on line 26, and I just stringified
expected
to show value instead of [Object Object]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍