-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Add filters to Browse models #38560
Add filters to Browse models #38560
Conversation
d19a4ee
to
eea3b38
Compare
d144f2e
to
f6e8547
Compare
88b11e0
to
0bfe280
Compare
Codenotify: Notifying subscribers in CODENOTIFY files for diff a2d799f...8fd30a6.
|
|
b744b3f
to
bccc6a8
Compare
d67ccf7
to
8c8ccf8
Compare
8c8ccf8
to
ed47524
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.
- I think this branch needs a rebase, it has some divergent changes from what I saw in Browse models: Set default tab #38291
- we need to extract the enterprise specific logic and components from the OSS codebase. We do this by putting some placeholders in the OSS codebase that the the enterprise code can hook into.
src/metabase/public_settings.clj
Outdated
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 can go away now that we're storing in localStorage, right?
@@ -149,6 +149,7 @@ export const createMockSettings = ( | |||
"custom-homepage-dashboard": null, | |||
"help-link": "metabase", | |||
"help-link-custom-destination": "", | |||
"default-browse-tab": 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.
we don't need this now that we're storing this in localStorage, right?
@@ -203,6 +203,7 @@ export interface Settings { | |||
"custom-formatting": FormattingSettings; | |||
"custom-homepage": boolean; | |||
"custom-homepage-dashboard": number | null; | |||
"default-browse-tab": string | 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.
we don't need this now that we're storing this in localStorage, right?
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.
Remnant of some rebasing chaos, now resolved
const [onlyShowVerifiedModels, setOnlyShowVerifiedModels] = useState( | ||
localStorage.getItem("onlyShowVerifiedModelsInBrowseData") !== "false", | ||
); | ||
|
||
const changeOnlyShowVerifiedModels = (newValue: boolean) => { | ||
localStorage.setItem( | ||
"onlyShowVerifiedModelsInBrowseData", | ||
newValue ? "true" : "false", | ||
); | ||
setOnlyShowVerifiedModels(newValue); | ||
}; |
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.
we can't have this enterprise-only logic in an OSS component
// If no children specified, use the tab id to determine what to show inside the tab | ||
if (!children) { | ||
if (tab === "models") { | ||
children = ( | ||
<BrowseModels | ||
modelsResult={modelsResult} | ||
onlyShowVerifiedModels={onlyShowVerifiedModels} | ||
/> | ||
); | ||
} | ||
if (tab === "databases") { | ||
children = <BrowseDatabases databasesResult={databasesResult} />; | ||
} | ||
} |
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 logic changed in another branch that merged recently, right? IIRC you extracted it to a component.
return ( | ||
<BrowseAppRoot data-testid="browse-app"> | ||
<BrowseContainer> | ||
<BrowseDataHeader> | ||
<BrowseSectionContainer> | ||
<Flex maw="1014px" m="0 auto" w="100%" align="center"> |
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 we avoid this pixel measure? maybe 64rem (1024px) ?
<Flex maw="1014px" m="0 auto" w="100%" align="center"> | |
<Flex maw="1014px" m="0 auto" w="100%" align="center"> |
<Switch | ||
ml="auto" | ||
size="sm" | ||
labelPosition="left" | ||
checked={onlyShowVerifiedModels} | ||
label={<strong>{t`Only show verified models`}</strong>} | ||
onChange={e => { | ||
changeOnlyShowVerifiedModels(e.target.checked); | ||
}} |
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 switch component can't be in the OSS codebase, we need to import a component from a plugin like ExtraModelsFilters
or something. check out what @npfitz did in a similar case here:
return ( | ||
<BrowseModels | ||
modelsResult={modelsResult} | ||
onlyShowVerifiedModels={onlyShowVerifiedModels} |
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.
instead of passing down an enterprise-specifc property like this, I would maybe make state a generic filterProperties
or something like that.
const modelsFiltered = onlyShowVerifiedModels | ||
? models.filter( | ||
(model: SearchResult) => model.moderated_status === "verified", | ||
) | ||
: models; | ||
const modelsWithoutInstanceAnalyticsCollection = modelsFiltered.filter( | ||
(model: SearchResult) => !isInstanceAnalyticsCollection(model.collection), | ||
); | ||
|
||
const groupsOfModels = groupModels( | ||
modelsWithoutInstanceAnalyticsCollection, | ||
localeCode, |
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 logic must be in the enterprise folder
This PR adds filters to Browse models