Skip to content

Commit

Permalink
remove kind from asterisk wildcard conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
joshri committed Sep 14, 2022
1 parent f5fc0f7 commit 709251e
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions ui/components/AlertsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ type Props = {
rows?: Alert[];
};

const makeEventSourceLink = (obj: CrossNamespaceObjectRef) => {
export const makeEventSourceLink = (obj: CrossNamespaceObjectRef) => {
const url =
obj.kind === Kind.Kustomization || obj.kind === Kind.HelmRelease
? V2Routes.Automations
: V2Routes.Sources;
let filters = "";
if (obj.name !== "*") filters += `name${filterSeparator}${obj.name}_`;
if (obj.kind !== "*") filters += `type${filterSeparator}${obj.kind}_`;
if (obj.namespace !== "*")
filters += `namespace${filterSeparator}${obj.namespace}_`;
if (filters) return url + `?${qs.stringify({ filters: filters })}`;
Expand Down Expand Up @@ -67,15 +66,24 @@ function AlertsTable({ className, rows = [] }: Props) {
value: (a) => {
return (
<ul className="event-sources">
{a?.eventSources?.map((obj: CrossNamespaceObjectRef, index) => (
<Link
className="event-sources"
key={index}
to={makeEventSourceLink(obj)}
>
{obj.kind}: {obj.namespace}/{obj.name}
</Link>
))}
{a?.eventSources?.map((obj: CrossNamespaceObjectRef, index) => {
if (obj.name && obj.namespace && obj.kind)
return (
<Link
className="event-sources"
key={index}
to={makeEventSourceLink(obj)}
>
{obj.kind}: {obj.namespace}/{obj.name}
</Link>
);
else
return (
<li className="event-sources" key={index}>
{obj.kind}: {obj.namespace}/{obj.name}
</li>
);
})}
</ul>
);
},
Expand Down Expand Up @@ -120,7 +128,7 @@ export default styled(AlertsTable).attrs({ className: AlertsTable.name })`
padding-left: ${(props) => props.theme.spacing.small};
}
}
${Link} {
${Link}, li {
&.event-sources {
display: block;
}
Expand Down

0 comments on commit 709251e

Please sign in to comment.