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

Include the Categories filter even if the result is empty #1649

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ describe("filter operators", () => {
.dive()
.text(),
).toMatch("No Operator found");
expect(wrapper.find(".horizontal-column")).toExist();
});

it("filters by category", () => {
Expand Down
71 changes: 39 additions & 32 deletions dashboard/src/components/OperatorList/OperatorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ class OperatorList extends React.Component<IOperatorListProps, IOperatorListStat
}
return true;
});
if (filteredOperators.length === 0) {
return <p>No Operator found</p>;
}
filteredOperators.forEach(operator => {
if (csvNames.some(csvName => csvName === getDefaultChannel(operator.status).currentCSV)) {
installedOperators.push(operator);
Expand Down Expand Up @@ -249,34 +246,28 @@ class OperatorList extends React.Component<IOperatorListProps, IOperatorListStat
</div>
<div className="col-10">
<div className="padding-l-normal">
{installedOperators.length > 0 && (
<>
<h3>Installed</h3>
<CardGrid>
{installedOperators.map(operator => {
return (
<InfoCard
key={operator.metadata.name}
link={app.operators.view(this.props.namespace, operator.metadata.name)}
title={operator.metadata.name}
icon={api.operators.operatorIcon(
this.props.namespace,
operator.metadata.name,
)}
info={`v${operator.status.channels[0].currentCSVDesc.version}`}
tag1Content={
operator.status.channels[0].currentCSVDesc.annotations.categories
}
tag2Content={operator.status.provider.name}
/>
);
})}
</CardGrid>
</>
{filteredOperators.length === 0 ? (
<p>No Operator found</p>
) : (
this.renderCardGrid(installedOperators, availableOperators)
)}
<h3>Available Operators</h3>
</div>
</div>
</div>
);
}

private renderCardGrid(
installedOperators: IPackageManifest[],
availableOperators: IPackageManifest[],
) {
return (
<>
{installedOperators.length > 0 && (
<>
<h3>Installed</h3>
<CardGrid>
{availableOperators.map(operator => {
{installedOperators.map(operator => {
return (
<InfoCard
key={operator.metadata.name}
Expand All @@ -290,9 +281,25 @@ class OperatorList extends React.Component<IOperatorListProps, IOperatorListStat
);
})}
</CardGrid>
</div>
</div>
</div>
</>
)}
<h3>Available Operators</h3>
<CardGrid>
{availableOperators.map(operator => {
return (
<InfoCard
key={operator.metadata.name}
link={app.operators.view(this.props.namespace, operator.metadata.name)}
title={operator.metadata.name}
icon={api.operators.operatorIcon(this.props.namespace, operator.metadata.name)}
info={`v${operator.status.channels[0].currentCSVDesc.version}`}
tag1Content={operator.status.channels[0].currentCSVDesc.annotations.categories}
tag2Content={operator.status.provider.name}
/>
);
})}
</CardGrid>
</>
);
}

Expand Down