-
Notifications
You must be signed in to change notification settings - Fork 167
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
logic for deprecated images #1872
logic for deprecated images #1872
Conversation
UX contextThis bug fixes the edge case where a user has a already created workbench, but the image tag or the entire image is removed from ODH. an example would be that an admin deleted a custom notebook image but a workbench was using it. @kywalker-rh @xianli123 See screenshots for how it would look in the row. For edit, the image selector appears as empty and you are required to select a new image. @kaedward In the issue you signed off on the wording |
Looks good to me, thanks for updating it @Gkrumbach07! |
ab9f5b5
to
89f1a1f
Compare
I found an issue that's not caused by your PR, but it will affect the result of your PR so you may want to update it as well here. |
89f1a1f
to
8e9f02c
Compare
I saw this in testing so i used an or operator here to prevent the text from only showing const imageDisplayName =
notebookImage?.imageName ||
obj.notebook.metadata.annotations['opendatahub.io/image-display-name'] ||
'Unknown'; However that doesn't fix the case where deprecated will show even if it is not because tag software is undefined. I updated how tag software is fetched based on your comment and adjusted how deprecated is calculated |
Needs a rebase |
8e9f02c
to
9e17a8a
Compare
9e17a8a
to
c2552f6
Compare
frontend/src/pages/projects/screens/detail/notebooks/NotebookTableRow.tsx
Outdated
Show resolved
Hide resolved
398ee66
to
784fb70
Compare
frontend/src/__tests__/integration/pages/projects/ProjectDetails.spec.ts
Outdated
Show resolved
Hide resolved
784fb70
to
046f699
Compare
Update
These changes came from conversations in an other issue that is merging with this one context on the merge: #1520 (comment) Updated Images (OUTDATED) |
@Gkrumbach07 Thanks for invloving me. I left some comments in the issue #1520 , please refer to my comments. |
4b6b423
to
e0da178
Compare
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.
Overall it's working as expected. Just left some small comments as well as the question above. Otherwise it looks good!
frontend/src/__tests__/integration/pages/projects/ProjectDetails.spec.ts
Outdated
Show resolved
Hide resolved
frontend/src/pages/projects/screens/detail/notebooks/useNotebookImageData.ts
Outdated
Show resolved
Hide resolved
frontend/src/pages/projects/screens/detail/notebooks/useNotebookImageData.ts
Outdated
Show resolved
Hide resolved
I think that's a great idea... good catch @DaoDaoNoCode ! |
84d0ed1
to
926d69b
Compare
@DaoDaoNoCode everything should be addressed |
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.
/lgtm
@christianvogt this PR is ready for your final review |
): [imageStreams: ImageStreamKind[], loaded: boolean, loadError: Error | undefined] => { | ||
const [imageStreams, setImageStreams] = React.useState<ImageStreamKind[]>([]); | ||
const [loaded, setLoaded] = React.useState(false); | ||
const [loadError, setLoadError] = React.useState<Error | undefined>(undefined); | ||
|
||
React.useEffect(() => { | ||
if (namespace) { | ||
getNotebookImageStreams(namespace) | ||
getNotebookImageStreams(namespace, includeDisabled) |
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.
If an error occurs when includeDisabled
changes and we have previously loaded data, setImageStreams
will remain the old value as the catch
clause does not reset the data. Also I don't think we should be setting loaded
to true
if we have an error. The typical pattern here sets loaded
to true
when data is available. Loaded state should be unaffected by error state.
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.
previous logic set loaded to true regardless of the outcome. This was so we can have a state where the api is settled or not. and then error and data represent the outcome. If we only set loaded to true on success, then loaded has not value because we no longer can use it to determine if we are loading or not.
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 can however set the state back to an empty array to stop previous loaded data from lingering on error
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.
actually i am just going to switch this over to useFetchState if i can so it uses that common logic
if (!loaded) { | ||
return [null, false]; | ||
if (loadError) { | ||
return [null, true, loadError]; |
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 think loaded should be set to true
here because this pattern would suggests that data is available.
return [null, true, loadError]; | |
return [null, false, loadError]; |
if (!notebook || !loaded) { | ||
return [null, false, undefined]; | ||
} | ||
|
||
if (!loaded) { | ||
return [null, false]; | ||
if (loadError) { | ||
return [null, true, loadError]; |
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 think you should handle error state before loaded state or combine all together if you allow error state to occur when loaded is false.
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.
now handling like this
if (!loaded || !notebook) {
return [null, false, loadError];
}
return [null, false, undefined]; | ||
} | ||
if (loadError) { | ||
return [null, true, loadError]; |
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.
Similar comment elsewhere:
return [null, true, loadError]; | |
return [null, false, loadError]; |
if (!notebook || !loaded) { | ||
return [null, false, undefined]; | ||
} | ||
if (loadError) { | ||
return [null, true, loadError]; |
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.
Should handle error state before loaded state. But likely can combine all together if you allow error state to occur when loaded is false
.
| [notebookImage: null, loaded: false, loadError: undefined] | ||
| [notebookImage: null, loaded: true, loadError: Error] | ||
| [notebookImage: NotebookImage, loaded: true, loadError: undefined] => { |
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.
The typical pattern suggests that loaded=true
implies data is available, but error state is not related to loaded state. In more generic cases, error can be present while data is available if an error occurred on an update.
| [notebookImage: null, loaded: false, loadError: undefined] | |
| [notebookImage: null, loaded: true, loadError: Error] | |
| [notebookImage: NotebookImage, loaded: true, loadError: undefined] => { | |
| [notebookImage: null, loaded: false, loadError: Error | undefined] | |
| [notebookImage: NotebookImage, loaded: true, loadError: undefined] => { |
| [data: null, loaded: false, loadError: undefined] | ||
| [data: null, loaded: true, loadError: Error] |
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 see that this traces down to useImageSteams
which sets loaded
to true
along with an error. So the logic around this tyoe would work but I believe the pattern is to typically return an error with any value of loaded
. useFetchState
can return a subsequent error on refresh while loaded
was previously set to true.
| [data: null, loaded: false, loadError: undefined] | |
| [data: null, loaded: true, loadError: Error] | |
| [data: null, loaded: false, loadError: Error | undefined] |
926d69b
to
fac5edb
Compare
@christianvogt i switched the logic around to use useFetchState and have loaded = true to mean there is always some data defined |
latest changes to use |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt, DaoDaoNoCode The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
logic for deprecated images added tests fix annotations made annotations land labels optional supported disabled wording unknown state will not use a label Updated tests, updated UI fix tests small fixes added deleted disabled loaded always signifies data exists moved popover
fac5edb
to
cd79472
Compare
New changes are detected. LGTM label has been removed. |
closes: #1370
Description
Added a new annotation to workbenches called
opendatahub.io/image-display-name
which stores the display name of the selected image. this gets used when displaying the image on the notebook table if the image itself could not be found. if it is not found it will also include the wording(deprecated)
.When you got to edit this workbench with a deprecated image. the image will be unselected and require you to select a new one
How Has This Been Tested?
opendatahub.io/image-display-name
) from the notebook resource, and notice that the image becomesunknown
on the table rowTest Impact
I added tests to check the use cases of unknown and deprecated. In doing this i felt the need to implement a few helpers for mocks. namely a
opts: RecursivePartial<k8sKindType>
and then lodash _.merge the base mock with the opts. this gives you the option for fine grained control without having to make a large amount of of options to feed in.Request review criteria:
Self checklist (all need to be checked):
If you have UI changes:
After the PR is posted & before it merges:
main