Skip to content
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

Merged
merged 3 commits into from Dec 5, 2020

Conversation

jerolimov
Copy link
Member

@jerolimov jerolimov commented Dec 2, 2020

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 save booksmarks and favoriteKey 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:
Peek 2020-12-02 14-20

Unit test coverage report:
Untouched

Test setup:
Open developer perspective and bookmark / unbookmark / favorite namespaces and applications.

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Dec 2, 2020
@openshift-ci-robot openshift-ci-robot added the component/shared Related to console-shared label Dec 2, 2020
@jerolimov jerolimov force-pushed the odc-5111-dropdown branch 3 times, most recently from 8583c5b to 21f9a9a Compare December 2, 2020 13:46
@jerolimov
Copy link
Member Author

/cc @invincibleJai
/assign @christianvogt

Comment on lines 79 to 144
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);
}
}
Copy link
Contributor

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.

Copy link
Member Author

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) ?? {}}
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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

Comment on lines 541 to 545
const [favoriteKey, setFavoriteKey] = useUserSettingsCompatibility(
storageKey,
storageKey,
null,
// TODO: enable sync when sync PR is merged
Copy link
Contributor

@sahil143 sahil143 Dec 2, 2020

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.

Copy link
Contributor

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?

Copy link
Contributor

@christianvogt christianvogt left a 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.

Comment on lines 541 to 543
const [favoriteKey, setFavoriteKey] = useUserSettingsCompatibility(
storageKey,
storageKey,
Copy link
Contributor

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

Copy link
Member Author

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,
Copy link
Contributor

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'

Copy link
Member Author

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,
{},
Copy link
Contributor

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?

Copy link
Member Author

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.

@jerolimov jerolimov force-pushed the odc-5111-dropdown branch 2 times, most recently from 953c576 to 1908a22 Compare December 3, 2020 14:57
@jerolimov
Copy link
Member Author

Unable to clear the favorite item. After page refresh, it comes back. The config map does not update.

Fixed this. This sets now null instead of undefined to clear the .favorite entry.

Undefined is currently not supported, let add support for undefined after FF?

@sahil143 @christianvogt Can you take a new look? Thanks

@jerolimov
Copy link
Member Author

jerolimov commented Dec 3, 2020

Need to fix one test, working on this already.

@invincibleJai
Copy link
Member

Verified the changes , works as expected. Need some work tests looks like

@jerolimov
Copy link
Member Author

/retest

1 similar comment
@jerolimov
Copy link
Member Author

/retest

@jerolimov
Copy link
Member Author

/retest

@christianvogt
Copy link
Contributor

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 4, 2020
@nemesis09
Copy link
Contributor

/retest

@debsmita1
Copy link
Contributor

tested this locally, works fine
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2020
@jerolimov
Copy link
Member Author

/retest

1 similar comment
@jerolimov
Copy link
Member Author

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@jerolimov
Copy link
Member Author

/retest

@jerolimov
Copy link
Member Author

Integration tests found an issue. Working on that.
/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 4, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2020
@jerolimov
Copy link
Member Author

/unhold
The previous version of this PR has a bug that the simple Dropdown in Admin > Workloads > Pods or Developer > Search was empty. This is fixed now. I restored the line ... in dropdown.jsx Dropdown_ constructor.

    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:

Simple:
Peek 2020-12-04 18-44

Search:
Peek 2020-12-04 18-45

Project and apps:
Peek 2020-12-04 18-452

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 4, 2020
@jerolimov
Copy link
Member Author

/retest

2 similar comments
@jerolimov
Copy link
Member Author

/retest

@jerolimov
Copy link
Member Author

/retest

@@ -562,13 +562,26 @@ export const Dropdown = (props) => {
[setBookmarks],
);

// FIXME: Remove this after latest namespace wasn't fetched from localStorage anymore.
Copy link
Contributor

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?

Copy link
Contributor

@sahil143 sahil143 Dec 4, 2020

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.

@andrewballantyne
Copy link
Contributor

/lgtm
/hold

Putting a hold on this since it has a dependency

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 4, 2020
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jerolimov
Copy link
Member Author

/retest

@andrewballantyne
Copy link
Contributor

/hold cancel

Removing hold based on discussion with @jerolimov -- we'll log a ticket to address removing the FIXME

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 4, 2020
@andrewballantyne
Copy link
Contributor

/retest

Operator degraded issue -- don't think it's related, this task passed already.

@openshift-merge-robot openshift-merge-robot merged commit caee4d0 into openshift:master Dec 5, 2020
@spadgett spadgett added this to the v4.7 milestone Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet