Skip to content
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
14 changes: 6 additions & 8 deletions ui/components/ImageAutomation/ImageAutomationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import styled from "styled-components";
import { Kind } from "../../lib/api/core/types.pb";
import EventsTable from "../EventsTable";
import Flex from "../Flex";
import InfoList, { InfoField } from "../InfoList";
import PageStatus from "../PageStatus";
import Spacer from "../Spacer";
import HeaderRows, { RowItem } from "../Policies/Utils/HeaderRows";
import SubRouterTabs, { RouterTab } from "../SubRouterTabs";
import SyncActions from "../SyncActions";
import YamlView from "../YamlView";
Expand All @@ -15,7 +14,7 @@ interface Props {
data: any;
kind: Kind;
rootPath: string;
infoFields: InfoField[];
infoFields: RowItem[];
children?: any;
}

Expand All @@ -30,7 +29,7 @@ const ImageAutomationDetails = ({
const { name, namespace, clusterName, suspended, conditions } = data;

return (
<Flex wide tall column className={className}>
<Flex wide tall column className={className} gap="4">
<PageStatus conditions={conditions} suspended={suspended} />
{kind !== Kind.ImagePolicy && (
<SyncActions
Expand All @@ -45,11 +44,10 @@ const ImageAutomationDetails = ({

<SubRouterTabs rootPath={`${rootPath}/details`}>
<RouterTab name="Details" path={`${rootPath}/details`}>
<>
<InfoList items={infoFields} />
<Spacer margin="xs" />
<Flex column gap="4">
<HeaderRows items={infoFields} />
{children}
</>
</Flex>
</RouterTab>
<RouterTab name="Events" path={`${rootPath}/events`}>
<EventsTable
Expand Down
31 changes: 23 additions & 8 deletions ui/components/ImageAutomation/policies/ImagePolicyDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useGetObject } from "../../../hooks/objects";
import { Kind } from "../../../lib/api/core/types.pb";
import { ImagePolicy } from "../../../lib/objects";
import { V2Routes } from "../../../lib/types";
import ClusterDashboardLink from "../../ClusterDashboardLink";
import Metadata from "../../Metadata";
import Page from "../../Page";
import ImageAutomationDetails from "../ImageAutomationDetails";
Expand Down Expand Up @@ -33,6 +34,7 @@ function ImagePolicyDetails({
);
const { isFlagEnabled } = useFeatureFlags();
const rootPath = V2Routes.ImagePolicyDetails;

return (
<Page
error={error}
Expand All @@ -48,14 +50,27 @@ function ImagePolicyDetails({
data={data}
kind={Kind.ImagePolicy}
infoFields={[
["Kind", Kind.ImagePolicy],
["Namespace", data?.namespace],
isFlagEnabled("WEAVE_GITOPS_FEATURE_CLUSTER") && [
"Cluster",
clusterName,
],
["Image Policy", data?.imagePolicy?.type || ""],
["Order/Range", data?.imagePolicy?.value],
{
rowkey: "Kind",
value: Kind.ImagePolicy,
},
{
rowkey: "Namespace",
value: data?.namespace,
},
{
rowkey: "Cluster",
children: <ClusterDashboardLink clusterName={clusterName} />,
visible: isFlagEnabled("WEAVE_GITOPS_FEATURE_CLUSTER"),
},
{
rowkey: "Image Policy",
value: data?.imagePolicy?.type,
},
{
rowkey: "Order/Range",
value: data?.imagePolicy?.value,
},
]}
rootPath={rootPath}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Kind } from "../../../lib/api/core/types.pb";
import { ImageRepository } from "../../../lib/objects";
import { V2Routes } from "../../../lib/types";
import Button from "../../Button";
import ClusterDashboardLink from "../../ClusterDashboardLink";
import Interval from "../../Interval";
import Link from "../../Link";
import Page from "../../Page";
Expand Down Expand Up @@ -35,6 +36,7 @@ function ImageAutomationRepoDetails({
);
const { isFlagEnabled } = useFeatureFlags();
const rootPath = V2Routes.ImageAutomationRepositoryDetails;

return (
<Page
error={error}
Expand All @@ -50,20 +52,35 @@ function ImageAutomationRepoDetails({
data={data}
kind={Kind.ImageRepository}
infoFields={[
["Kind", Kind.ImageRepository],
["Namespace", data.namespace],
isFlagEnabled("WEAVE_GITOPS_FEATURE_CLUSTER") && [
"Cluster",
clusterName,
],
[
"Image",
<Link newTab={true} to={data.obj?.spec?.image}>
{data.obj?.spec?.image}
</Link>,
],
["Interval", <Interval interval={data.interval} />],
["Tag Count", data.tagCount],
{
rowkey: "Kind",
value: Kind.ImageRepository,
},
{
rowkey: "Namespace",
value: data.namespace,
},
{
rowkey: "Cluster",
children: <ClusterDashboardLink clusterName={clusterName} />,
visible: isFlagEnabled("WEAVE_GITOPS_FEATURE_CLUSTER"),
},
{
rowkey: "Image",
children: (
<Link newTab={true} to={data.obj?.spec?.image}>
{data.obj?.spec?.image}
</Link>
),
},
{
rowkey: "Interval",
value: <Interval interval={data.interval} />,
},
{
rowkey: "Tag Count",
value: data.tagCount,
},
]}
rootPath={rootPath}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { useGetObject } from "../../../hooks/objects";
import { Kind } from "../../../lib/api/core/types.pb";
import { ImageUpdateAutomation } from "../../../lib/objects";
import { V2Routes } from "../../../lib/types";
import { InfoField } from "../../InfoList";
import ClusterDashboardLink from "../../ClusterDashboardLink";
import Metadata from "../../Metadata";
import Page from "../../Page";
import { RowItem } from "../../Policies/Utils/HeaderRows";
import SourceLink from "../../SourceLink";
import ImageAutomationDetails from "../ImageAutomationDetails";

Expand All @@ -20,7 +21,7 @@ type Props = {
function getInfoList(
data: ImageUpdateAutomation,
clusterName: string
): InfoField[] {
): RowItem[] {
const {
kind,
spec: { update, git },
Expand All @@ -30,19 +31,49 @@ function getInfoList(
const { isFlagEnabled } = useFeatureFlags();

return [
["Kind", kind],
["Namespace", data.namespace],
isFlagEnabled("WEAVE_GITOPS_FEATURE_CLUSTER") && ["Cluster", clusterName],
[
"Source",
<SourceLink sourceRef={data.sourceRef} clusterName={clusterName} />,
],
["Update Path", path],
["Checkout Branch", checkout?.ref?.branch],
["Push Branch", push?.branch],
["Author Name", commit.author?.name],
["Author Email", commit.author?.email],
["Commit Template", <code> {commit.messageTemplate}</code>],
{
rowkey: "Kind",
value: kind,
},
{
rowkey: "Namespace",
value: data.namespace,
},
{
rowkey: "Cluster",
children: <ClusterDashboardLink clusterName={clusterName} />,
visible: isFlagEnabled("WEAVE_GITOPS_FEATURE_CLUSTER"),
},
{
rowkey: "Source",
children: (
<SourceLink sourceRef={data.sourceRef} clusterName={clusterName} />
),
},
{
rowkey: "Update Path",
value: path,
},
{
rowkey: "Checkout Branch",
value: checkout?.ref?.branch,
},
{
rowkey: "Push Branch",
value: push?.branch,
},
{
rowkey: "Author Name",
value: commit.author?.name,
},
{
rowkey: "Author Email",
value: commit.author?.email,
},
{
rowkey: "Commit Template",
children: <code> {commit.messageTemplate}</code>,
},
];
}

Expand Down
12 changes: 6 additions & 6 deletions ui/components/Policies/Utils/HeaderRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ interface Props {
const HeaderRows = ({ items }: Props) => {
return (
<Flex column gap="8">
{items.map((h) => {
return (
h.visible !== false && (
{items
.filter((h) => h.visible !== false)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace this line with .filter((h) => h.visible)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there is another line like that in HeaderRows.test.tsx:

if (h.visible !== false) {

which can be replaced with

if (h.visible) {

Optional. but since you are working on these files anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all the items contains visible:true so that we deal with it as a default value for items to be visible:true

for example:

{
    rowkey: "Policy Name",
    value: "Controller ServiceAccount Tokens Automount",
  },
  {
    rowkey: "Application",
    value: "flux-system/external-secrets",
  },
  {
    rowkey: "Violation Time",
    value: "15 minutes ago",
  },
  {
    rowkey: "Category",
    value: " weave.categories.access-control",
    visible: false,
  },

here we want only to filter over what's not false to save extra checks & make visible required

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for the explanation.

.map((h) => {
return (
<Flex
alignItems="center"
center
Expand All @@ -51,9 +52,8 @@ const HeaderRows = ({ items }: Props) => {
</Text>
)}
</Flex>
)
);
})}
);
})}
</Flex>
);
};
Expand Down