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
Save dropdown bookmarks and favoriteKey in user settings #7390
Save dropdown bookmarks and favoriteKey in user settings #7390
Conversation
8583c5b
to
21f9a9a
Compare
/cc @invincibleJai |
React.useEffect(() => { | ||
if (cfData && cfLoaded && settings !== undefined) { | ||
if (keyRef.current && cfLoaded && cfData && settings !== undefined) { | ||
const value = seralizeData(settings); | ||
if (value !== cfData.data?.[key]) { | ||
if (value !== cfData.data?.[keyRef.current]) { | ||
updateConfigMap(cfData, keyRef.current, value); | ||
} | ||
} |
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.
This implementation will change with sync PR.
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.
Reverted this to don't get into a merge conflict. We need to check after both are merged it there are some settings are stored without key.
@@ -337,7 +337,7 @@ export const DropdownField: React.FC<FieldProps> = ({ | |||
key={idSchema.$id} | |||
title={t('console-shared~Select {{title}}', { title: title || schema?.title || name })} | |||
selectedKey={formData} | |||
items={items ?? {}} | |||
items={(items as 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.
Why do you need type cast here?
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.
Because items comes from const { items, title } = getUiOptions(uiSchema);
which returns items as string | string[] | array | object .... In this case this must be an object, this is was Dropdown requested before.
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.
Moved this cast to the line where getUiOptions is assigned to items
const [favoriteKey, setFavoriteKey] = useUserSettingsCompatibility( | ||
storageKey, | ||
storageKey, | ||
null, | ||
// TODO: enable sync when sync PR is merged |
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.
@jerolimov how would the returned state work here. If key is undefined and we don't want to initialize it in user settings.
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'm guessing similar to useState
?
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.
Unable to clear the favorite item. After page refresh, it comes back. The config map does not update.
const [favoriteKey, setFavoriteKey] = useUserSettingsCompatibility( | ||
storageKey, | ||
storageKey, |
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 format of the user-settings keys should be namespace.key
. eg console.foobar
I'd prefer to see a temporary prop in place for the old key and new one that adheres to the new format.
The current keys I see created are:
dropdown-storage-namespaces
dropdown-storage-namespaces-bookmarks
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.
Okay, this (old) Dropdown component has now a userSettingsPrefix
and storageKey
prop, so that the users can set both attributes for the useUserSettingsCompatibility
. I used the prefix name because the component automatically appends .favorite
and .bookmarks
.
const [favoriteKey, setFavoriteKey] = useUserSettingsCompatibility( | ||
storageKey, | ||
storageKey, | ||
null, |
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.
Prefer undefined
because this is what's being saved in the user settings:
dropdown-storage-namespaces: 'null'
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.
Removed the default so its now undefined.
const [bookmarks, setBookmarks] = useUserSettingsCompatibility( | ||
bookmarkStorageKey, | ||
bookmarkStorageKey, | ||
{}, |
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.
Can this be undefined
to start?
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.
Yeah works fine. Removed the default so its now undefined.
953c576
to
1908a22
Compare
Fixed this. This sets now null instead of undefined to clear the Undefined is currently not supported, let add support for undefined after FF? @sahil143 @christianvogt Can you take a new look? Thanks |
Need to fix one test, working on this already. |
Verified the changes , works as expected. Need some work tests looks like |
1908a22
to
a2ec078
Compare
/retest |
1 similar comment
/retest |
a2ec078
to
d9b7828
Compare
/retest |
/approve |
/retest |
tested this locally, works fine |
/retest |
1 similar comment
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
Integration tests found an issue. Working on that. |
c795994
to
b05cbe0
Compare
/unhold this.state.items = props.items; The dynamic cases of projects and apps works fine because the items was also set when the props are updated. Here are some working examples: |
/retest |
2 similar comments
/retest |
/retest |
@@ -562,13 +562,26 @@ export const Dropdown = (props) => { | |||
[setBookmarks], | |||
); | |||
|
|||
// FIXME: Remove this after latest namespace wasn't fetched from localStorage anymore. |
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.
This is a temporary solution? It's a FIXME but the text does not specify when we would fix it. Could you explain more of what the scenario is?
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 guess once my PR #7411 goes in.
/lgtm Putting a hold on this since it has a dependency |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, christianvogt, debsmita1, jerolimov 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 |
/retest |
/hold cancel Removing hold based on discussion with @jerolimov -- we'll log a ticket to address removing the FIXME |
/retest Operator degraded issue -- don't think it's related, this task passed already. |
Fixes:
https://issues.redhat.com/browse/ODC-5198
Analysis / Root cause:
As a user, I want sync my bookmarks for namespaces, applications and other dropdowns between browsers.
Solution Description:
Update Dropdown component to use
useUserSettings
hook and savebooksmarks
andfavoriteKey
in user settings.Screen shots / Gifs for design review:
From user perspective nothing has changed. This video shows the migration and update of the configmap:
Unit test coverage report:
Untouched
Test setup:
Open developer perspective and bookmark / unbookmark / favorite namespaces and applications.
Browser conformance: