Skip to content

Commit

Permalink
Pipelines View is missing any reference to the source git repository … (
Browse files Browse the repository at this point in the history
#3688)

* Pipelines View is missing any reference to the source git repository or Pull Requests
  • Loading branch information
TheGostKasper authored Dec 11, 2023
1 parent aa8c216 commit ecadc65
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 114 deletions.

This file was deleted.

64 changes: 33 additions & 31 deletions ui/src/components/Pipelines/PipelineDetails/Workloads.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { Flex, Link, Text } from '@weaveworks/weave-gitops';
import _ from 'lodash';
import styled from 'styled-components';
import { Pipeline, Promotion } from '../../../api/pipelines/types.pb';
import { Pipeline, Strategy } from '../../../api/pipelines/types.pb';
import PromotePipeline from './PromotePipeline';
import PromotionInfo from './PromotionInfo';
import { EnvironmentCard } from './styles';
import Target from './Target';

const getStrategy = (promo?: Promotion) => {
if (!promo) return '-';
if (!promo.manual) return 'Automated';

const nonNullStrat = _.map(promo.strategy, (value, key) => {
if (value !== null) return key;
});
return _.startCase(nonNullStrat[0] || '-');
const getEnvStrategy = (strategy?: Strategy) => {
if (strategy?.pullRequest) {
return {
strategy: 'Pull Request',
...strategy?.pullRequest,
};
}
if (strategy?.notification) {
return {
strategy: 'Notification',
};
}
return {
strategy: '-',
};
};

const EnvironmentContainer = styled(Flex)`
Expand Down Expand Up @@ -44,11 +50,7 @@ function Workloads({
const status = targetsStatuses[env.name!].targetsStatuses || [];
const promoteVersion =
targetsStatuses[env.name!].waitingStatus?.revision || '';
const strategy = env.promotion
? getStrategy(env.promotion)
: getStrategy(pipeline.promotion);
const { branch = '-', url = '-' } =
env.promotion?.strategy?.pullRequest || {};
const envStrategy = getEnvStrategy(env.promotion?.strategy);

return (
<EnvironmentContainer key={index} tall column gap="16">
Expand All @@ -63,34 +65,34 @@ function Workloads({
</Flex>
<Flex gap="8" wide start>
<Text bold>Strategy:</Text>
<Text> {strategy}</Text>
<Text> {envStrategy.strategy}</Text>
</Flex>
</Flex>
<PromotionContainer column gap="12" wide>
{strategy === 'Pull Request' && (
{envStrategy.strategy === 'Pull Request' && (
<Flex column gap="8" wide start>
<Flex gap="8" wide start>
<Text bold>Branch:</Text>
<Text> {branch}</Text>
<Text> {envStrategy.branch}</Text>
</Flex>
<Flex gap="8" wide start>
<Text bold>URL:</Text>
<Link to={url}>{url}</Link>
<Link to={envStrategy.url}>{envStrategy.url}</Link>
</Flex>
</Flex>
)}
{strategy !== 'Automated' &&
index < environments.length - 1 && (
<PromotePipeline
req={{
name: pipeline.name,
env: env.name,
namespace: pipeline.namespace,
revision: promoteVersion,
}}
promoteVersion={promoteVersion || ''}
/>
)}

{env.promotion?.manual && index < environments.length - 1 && (
<PromotePipeline
req={{
name: pipeline.name,
env: env.name,
namespace: pipeline.namespace,
revision: promoteVersion,
}}
promoteVersion={promoteVersion || ''}
/>
)}
</PromotionContainer>
</EnvironmentCard>
{status.map((target, indx) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,30 +286,6 @@ describe('PipelineDetails', () => {
}
});

describe('renders promotion strategy', () => {
it('pull request', async () => {
const params = res.pipeline;
api.GetPipelineReturns = res;
core.GetObjectReturns = { object: {} };

await act(async () => {
const c = wrap(
<PipelineDetails
name={params?.name || ''}
namespace={params?.namespace || ''}
/>,
);
render(c);
});
expect(screen.getByText('Pull Request')).toBeInTheDocument();
expect(
screen.getByText('https://gitlab.com/weaveworks/cool-project'),
).toBeInTheDocument();
expect(screen.getByText('main')).toBeInTheDocument();
expect(screen.getByText('Secret Ref')).toBeInTheDocument();
expect(screen.getByText('Notification')).toBeInTheDocument();
});
});
it('handles visibility of promotion button', async () => {
const params = res.pipeline;
const manual: Pipeline = {
Expand Down
33 changes: 18 additions & 15 deletions ui/src/components/Pipelines/PipelineDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ListError } from '@weaveworks/progressive-delivery/api/prog/types.pb';
import {
Flex,
RouterTab,
SubRouterTabs,
YamlView,
Expand Down Expand Up @@ -49,21 +50,23 @@ const PipelineDetails = ({ name, namespace }: Props) => {
<NotificationsWrapper
errors={mappedErrors(data?.errors || [], namespace)}
>
<SubRouterTabs rootPath={`${path}/status`}>
<RouterTab name="Status" path={`${path}/status`}>
<Workloads pipeline={data?.pipeline || ({} as Pipeline)} />
</RouterTab>
<RouterTab name="Yaml" path={`${path}/yaml`}>
<YamlView
yaml={data?.pipeline?.yaml || ''}
header={createYamlCommand(
'Pipeline',
data?.pipeline?.name,
data?.pipeline?.namespace,
)}
/>
</RouterTab>
</SubRouterTabs>
<Flex column gap="16" wide>
<SubRouterTabs rootPath={`${path}/status`}>
<RouterTab name="Status" path={`${path}/status`}>
<Workloads pipeline={data?.pipeline || ({} as Pipeline)} />
</RouterTab>
<RouterTab name="Yaml" path={`${path}/yaml`}>
<YamlView
yaml={data?.pipeline?.yaml || ''}
header={createYamlCommand(
'Pipeline',
data?.pipeline?.name,
data?.pipeline?.namespace,
)}
/>
</RouterTab>
</SubRouterTabs>
</Flex>
</NotificationsWrapper>
</Page>
);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/contexts/Pipelines/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const useGetPipeline = (req: GetPipelineRequest, enabled?: boolean) => {
[PIPELINES_KEY, req.namespace, req.name],
() => pipelinsService.GetPipeline(req),
{
refetchInterval: 5000,
refetchInterval: 50000,
retry: false,
onError,
enabled,
Expand Down

0 comments on commit ecadc65

Please sign in to comment.