Skip to content

Add new pipelines UI with promotion information #3510

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

Merged
merged 16 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 15 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/weaveworks/weave-gitops v0.34.1-0.20231012154759-d858858e0f9b
github.com/weaveworks/weave-gitops v0.34.1-0.20231016201857-ff77b2fbe912
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.2
github.com/weaveworks/weave-gitops-enterprise/common v0.0.0
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1268,8 +1268,8 @@ github.com/weaveworks/templates-controller v0.2.0 h1:7pWLCoHasLyk1qgDH6N9XVgozZv
github.com/weaveworks/templates-controller v0.2.0/go.mod h1:qO/4Eeqas5kjLCacboFKcisszFMjCjIUMxhtqxYlMUw=
github.com/weaveworks/tf-controller/api v0.0.0-20230416092146-4a7dfa5b6cc4 h1:+IkLtnXzCkhJzojbadPd+UxwaTa6K/Eb2grY6LcYfeo=
github.com/weaveworks/tf-controller/api v0.0.0-20230416092146-4a7dfa5b6cc4/go.mod h1:LUBkwqS7FHz/QTNuYzvWj6svehhh1djnV0Gj3OTc87E=
github.com/weaveworks/weave-gitops v0.34.1-0.20231012154759-d858858e0f9b h1:JnajzrfWR6qCmlbUoIbI+BX2doMthNj8WMPkh99vndQ=
github.com/weaveworks/weave-gitops v0.34.1-0.20231012154759-d858858e0f9b/go.mod h1:+8Ud/ZraL0mQWLoC14yaVdiIsmXvKqMWA2ANb97du5I=
github.com/weaveworks/weave-gitops v0.34.1-0.20231016201857-ff77b2fbe912 h1:UH2WnIjSwd5aG8E+66A/wRegBmmDiMKU+0Nj+3YOsYg=
github.com/weaveworks/weave-gitops v0.34.1-0.20231016201857-ff77b2fbe912/go.mod h1:+8Ud/ZraL0mQWLoC14yaVdiIsmXvKqMWA2ANb97du5I=
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.2 h1:7jeiQehqmI4ds6YIq8TW1Vqhlb6V7G2BVRJ8VM3r99I=
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.2/go.mod h1:6PMYg+VtSNePnP7EXyNG+/hNRNZ3r0mQtolIZU4s/J0=
github.com/xanzy/go-gitlab v0.83.0 h1:37p0MpTPNbsTMKX/JnmJtY8Ch1sFiJzVF342+RvZEGw=
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@types/styled-components": "^5.1.9",
"@types/urijs": "^1.19.19",
"@weaveworks/progressive-delivery": "0.0.0-rc13",
"@weaveworks/weave-gitops": "npm:@weaveworks/[email protected]2-gd858858e",
"@weaveworks/weave-gitops": "npm:@weaveworks/[email protected]8-gff77b2fb",
"babel-jest": "^27.4.2",
"babel-plugin-named-asset-import": "^0.3.8",
"babel-preset-react-app": "^10.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ exports[`Applications index test snapshots loading 1`] = `
}

.c10.MuiIconButton-root:hover {
background-color: #fff;
background-color: #ffffff;
color: #009CCC;
}

Expand All @@ -225,7 +225,7 @@ exports[`Applications index test snapshots loading 1`] = `
}

.c15 {
background-color: #fff;
background-color: #ffffff;
border-radius: 10px;
box-sizing: border-box;
margin: 0 auto;
Expand Down Expand Up @@ -979,7 +979,7 @@ exports[`Applications index test snapshots success 1`] = `
.c33 {
position: absolute;
overflow: hidden;
background: #fff;
background: #ffffff;
height: 0px;
-webkit-transition-property: height;
transition-property: height;
Expand Down Expand Up @@ -1189,7 +1189,7 @@ exports[`Applications index test snapshots success 1`] = `
}

.c10.MuiIconButton-root:hover {
background-color: #fff;
background-color: #ffffff;
color: #009CCC;
}

Expand All @@ -1213,7 +1213,7 @@ exports[`Applications index test snapshots success 1`] = `
}

.c15 {
background-color: #fff;
background-color: #ffffff;
border-radius: 10px;
box-sizing: border-box;
margin: 0 auto;
Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/Clusters/ClusterDashboardLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatURL } from '@weaveworks/weave-gitops';
import { Text, formatURL } from '@weaveworks/weave-gitops';
import { Link } from 'react-router-dom';
import { Routes } from '../../utils/nav';

Expand Down Expand Up @@ -37,5 +37,9 @@ export function ClusterDashboardLink({
namespace,
}: Props): JSX.Element {
const clsUrl = formatClusterDashboardUrl({ clusterName, namespace });
return <>{clsUrl ? <Link to={clsUrl}>{clusterName}</Link> : clusterName}</>;
return clsUrl ? (
<Link to={clsUrl}>{clusterName}</Link>
) : (
<Text>{clusterName}</Text>
);
}
21 changes: 15 additions & 6 deletions ui/src/components/Pipelines/PipelineDetails/PromotePipeline.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import ShowChartIcon from '@material-ui/icons/ShowChart';
import { Button, Flex } from '@weaveworks/weave-gitops';
import React from 'react';
import styled from 'styled-components';
import { ApprovePromotionRequest } from '../../../api/pipelines/pipelines.pb';

import { useApprove } from '../../../hooks/pipelines';

const PromotionButton = styled(Button)`
&.MuiButton-root {
background: ${props => props.theme.colors.white};
border-radius: 16px;
&.MuiButton-outlined {
border-color: ${props => props.theme.colors.neutral20};
}
&.Mui-disabled {
color: ${props => props.theme.colors.neutral20};
}
}
`;

const PromotePipeline = ({
className,
req,
Expand All @@ -18,15 +29,13 @@ const PromotePipeline = ({
const approve = useApprove();
return (
<Flex column gap="8" className={className}>
<Button
startIcon={<ShowChartIcon />}
<PromotionButton
onClick={() => approve.mutateAsync(req)}
disabled={approve.isLoading || !promoteVersion}
loading={approve.isLoading}
>
Approve Promotion
</Button>
{/** Add PR link here when backend changes get made */}
</PromotionButton>
</Flex>
);
};
Expand Down
48 changes: 48 additions & 0 deletions ui/src/components/Pipelines/PipelineDetails/PromotionInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Flex, Text, computeReady } from '@weaveworks/weave-gitops';
import styled from 'styled-components';
import { PipelineTargetStatus } from '../../../api/pipelines/types.pb';
import { EnvironmentCard } from './styles';

type Props = {
className?: string;
targets: PipelineTargetStatus[];
};

const PromotionInfoContainer = styled(EnvironmentCard)`
background: ${props => props.theme.colors.neutralGray};
border: 1px solid ${props => props.theme.colors.neutral40};
border-style: dashed;
`;

const gatherTargetStatus = (targets: PipelineTargetStatus[]) => {
if (!targets.length) return 'No targets found.';
const reduced = targets.reduce(
(obj, target) => {
let ready = true;
target.workloads?.forEach(workload => {
if (computeReady(workload.conditions || []) !== 'Ready') ready = false;
});
if (ready) obj.true += 1;
else obj.false += 1;
return obj;
},
{ true: 0, false: 0 },
);
return `${reduced['true']} out of ${targets.length} targets have successfully updated.`;
};

function PromotionInfo({ className, targets }: Props) {
return (
<PromotionInfoContainer className={className}>
<Flex center align wide tall wrap>
<Text color="neutral40">{gatherTargetStatus(targets)}</Text>
</Flex>
</PromotionInfoContainer>
);
}

export default styled(PromotionInfo).attrs({ className: PromotionInfo.name })`
${Text} {
text-align: center;
}
`;
89 changes: 89 additions & 0 deletions ui/src/components/Pipelines/PipelineDetails/Target.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import {
Flex,
Icon,
IconType,
KubeStatusIndicator,
Link,
Text,
V2Routes,
computeReady,
formatURL,
} from '@weaveworks/weave-gitops';
import _ from 'lodash';
import styled from 'styled-components';
import { PipelineTargetStatus } from '../../../api/pipelines/types.pb';
import { useListConfigContext } from '../../../contexts/ListConfig';
import { ClusterDashboardLink } from '../../Clusters/ClusterDashboardLink';
import { EnvironmentCard } from './styles';

type Props = {
className?: string;
target: PipelineTargetStatus;
background: number;
};

function Target({ className, target, background }: Props) {
const configResponse = useListConfigContext();
const clusterName = target.clusterRef?.name
? `${target.clusterRef?.namespace || 'default'}/${target.clusterRef?.name}`
: configResponse?.data?.managementClusterName || null;

return (
<EnvironmentCard
className={className}
background={background}
column
gap="8"
>
<Flex column>
<Flex gap="4" align>
<Icon type={IconType.ClustersIcon} size="medium" color="black" />
<Text>Cluster:</Text>
</Flex>
<ClusterDashboardLink clusterName={clusterName} />
</Flex>
{_.map(target.workloads, (workload, index) => {
const { lastAppliedRevision, version } = workload;
return (
<Flex key={index} column gap="8">
<Flex column>
<Text size="medium">Namespace/Name</Text>
<Flex gap="4" align>
<KubeStatusIndicator
noText
conditions={workload?.conditions || []}
/>
<Link
to={formatURL(V2Routes.HelmRelease, {
name: workload.name,
namespace: target.namespace,
clusterName: clusterName,
})}
>
{target.namespace} / {workload.name}
</Link>
</Flex>
</Flex>
<Text
bold
size="small"
color={
computeReady(workload?.conditions || []) === 'Ready'
? 'successOriginal'
: 'alertOriginal'
}
>
LAST APPLIED VERSION:{' '}
{lastAppliedRevision ? 'v' + lastAppliedRevision : '-'}
</Text>
<Text size="small">
SPECIFIED VERSION: {version ? 'v' + version : '-'}
</Text>
</Flex>
);
})}
</EnvironmentCard>
);
}

export default styled(Target).attrs({ className: Target.name })``;
50 changes: 0 additions & 50 deletions ui/src/components/Pipelines/PipelineDetails/WorkloadStatus.tsx

This file was deleted.

Loading