Skip to content

Commit

Permalink
feat: update grouping name for subnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Topher committed Nov 27, 2023
1 parent 8d5000a commit 3928f5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/base/components/GroupSelect/GroupSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { Select } from "@canonical/react-components";
import classNames from "classnames";

type Props<T> = {
className?: string;
grouping: T | null;
groupOptions: { value: T | string; label: string }[];
name?: string;
setGrouping: (group: T | null) => void;
setHiddenGroups?: (groups: string[]) => void;
groupOptions: { value: T | string; label: string }[];
};

const GroupSelect = <T extends string>({
grouping,
setGrouping,
setHiddenGroups,
groupOptions,
name,
className,
}: Props<T>): JSX.Element => {
return (
<Select
aria-label="Group by"
className="u-no-padding--right"
className={classNames("u-no-padding--right", className)}
defaultValue={grouping ?? ""}
name="machine-groupings"
name={name || "machine-groupings"}
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
setGrouping((e.target.value as T) ?? null);
setHiddenGroups && setHiddenGroups([]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/subnets/views/SubnetsList/SubnetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ const SubnetsList = (): JSX.Element => {
subtitle={
<div className="u-flex--wrap u-flex--align-center">
<GroupSelect
className="u-no-margin--bottom"
groupOptions={subnetOptions}
grouping={groupBy as GroupByKey}
name="network-groupings"
setGrouping={setGroupBy}
/>
</div>
Expand Down

0 comments on commit 3928f5d

Please sign in to comment.