HomeElementl

[dagit] Fix multi-repo switcher localStorage

Description

[dagit] Fix multi-repo switcher localStorage

Summary:
Repair an issue with localStorage in the multi-repo switcher.

When the localStorage value doesn't match any of the loaded repos, we fall back to the first option in the list. Unfortunately, this is causing a bug where changing the filter option will unselect the first option. This shouldn't happen, as toggling on one repo should never toggle off another. The issue here is that the list of selected keys is not in sync with the list of options.

To repair this, check the list of matching options immediately upon creating the hook state. In the case where there are no matches, choose the key for the first loaded option.

This requires that state is not determined until the workspace query is finished loading. To that end, split up the component so that the hook only runs when options have loaded.

Test Plan:
Set a bogus repo key in localStorage, reload dagit with a multi-repo workspace. Verify that the first option is selected by default, and verify that selecting other repos does not deselect the first option. Check localStorage in the console, verify that it is correct.

Repeat with empty workspace, verify that things look fine.

Reviewers: bengotow, prha, sashank, dgibson

Reviewed By: prha

Differential Revision: https://dagster.phacility.com/D7089

Details

Provenance
dishAuthored on Mar 22 2021, 2:00 PM
Reviewer
prha
Differential Revision
D7089: [dagit] Fix multi-repo switcher localStorage
Parents
R1:8a798b323f8c: Fix typos in kubernetes db migration guide
Branches
Unknown
Tags
Unknown