From 52ae2a6e1b972c0f4c8c6a724d91fb868d259f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Fri, 22 Nov 2024 11:37:20 +0100 Subject: [PATCH 1/8] improve gui for pipeline job creation --- src/components/create-job-form/index.tsx | 80 ++++++++++++++----- .../pipeline-form-apply-config.tsx | 10 +-- .../pipeline-form-build-branches.tsx | 57 +++++++------ .../create-job-form/pipeline-form-deploy.tsx | 22 ++--- .../create-job-form/pipeline-form-promote.tsx | 26 +++--- .../use-get-application-branches.ts | 31 ++----- src/components/environments-summary/index.tsx | 65 +++++++-------- .../link/apply-config-pipeline-link.tsx | 26 ++++++ .../link/radix-config-file-link.tsx | 24 ++++++ src/components/page-configuration/index.tsx | 23 +----- .../page-create-application/index.tsx | 17 +--- 11 files changed, 203 insertions(+), 178 deletions(-) create mode 100644 src/components/link/apply-config-pipeline-link.tsx create mode 100644 src/components/link/radix-config-file-link.tsx diff --git a/src/components/create-job-form/index.tsx b/src/components/create-job-form/index.tsx index 7a1626d66..e720c727a 100644 --- a/src/components/create-job-form/index.tsx +++ b/src/components/create-job-form/index.tsx @@ -3,17 +3,23 @@ import * as PropTypes from 'prop-types'; import { type ComponentProps, type FunctionComponent, - type PropsWithChildren, - useState, + useCallback, + useMemo, } from 'react'; -import { PipelineFormPromote } from './pipeline-form-promote'; - -import './style.css'; import { useSearchParams } from 'react-router-dom'; +import { pollingInterval } from '../../store/defaults'; +import { + type Application, + useGetApplicationQuery, +} from '../../store/radix-api'; import { PipelineFormApplyConfig } from './pipeline-form-apply-config'; import { PipelineFormBuildBranches } from './pipeline-form-build-branches'; import { PipelineFormDeploy } from './pipeline-form-deploy'; +import { PipelineFormPromote } from './pipeline-form-promote'; +import { useGetApplicationBranches } from './use-get-application-branches'; +import './style.css'; +import AsyncResource from '../async-resource/async-resource'; export interface CreateJobFormProps { appName: string; @@ -25,11 +31,11 @@ type SupportedPipelineNames = | ComponentProps['pipelineName'] | ComponentProps['pipelineName']; -export type FormProp = PropsWithChildren<{ - appName: string; +export type FormProp = { + application: Application; onSuccess: (jobName: string) => void; pipelineName: string; -}>; +}; const Pipelines = { build: PipelineFormBuildBranches, @@ -39,28 +45,53 @@ const Pipelines = { 'apply-config': PipelineFormApplyConfig, } satisfies Record>; +const pipelineSearchParam = 'pipeline'; + export default function CreateJobForm({ appName, onSuccess, }: CreateJobFormProps) { - const [searchParams] = useSearchParams(); - const [pipeline, setPipeline] = useState(() => { - const urlPipeline = searchParams.get('pipeline'); + const { data: application, ...appState } = useGetApplicationQuery( + { appName }, + { pollingInterval } + ); + + const hasEnvironments = useMemo( + () => application?.environments?.length > 0, + [application] + ); + const buildBranches = useGetApplicationBranches(application); + const hasBuildBranches = useMemo( + () => Object.keys(buildBranches).length > 0, + [buildBranches] + ); + const [searchParams, setSearchParams] = useSearchParams(); + const setPipelineType = useCallback( + (pipeline: string) => { + setSearchParams((prev) => { + prev.set(pipelineSearchParam, pipeline); + return prev; + }); + }, + [setSearchParams] + ); + const pipeline = useMemo(() => { + const urlPipeline = searchParams.get(pipelineSearchParam); if (Object.keys(Pipelines).includes(urlPipeline)) { - return urlPipeline as SupportedPipelineNames; + return urlPipeline; } - return 'build-deploy'; - }); + return !hasEnvironments + ? 'apply-config' + : hasBuildBranches + ? 'build-deploy' + : ''; + }, [searchParams, hasEnvironments, hasBuildBranches]); const PipelineForm = Pipelines[pipeline]; return ( - + setPipeline(e.target.value as SupportedPipelineNames)} + onChange={(e) => setPipelineType(e.target.value)} > ))} - + {PipelineForm && ( + + )} + ); } CreateJobForm.propTypes = { diff --git a/src/components/create-job-form/pipeline-form-apply-config.tsx b/src/components/create-job-form/pipeline-form-apply-config.tsx index 4dcbbd45b..04f427778 100644 --- a/src/components/create-job-form/pipeline-form-apply-config.tsx +++ b/src/components/create-job-form/pipeline-form-apply-config.tsx @@ -12,19 +12,16 @@ import { Alert } from '../alert'; import { handlePromiseWithToast } from '../global-top-nav/styled-toaster'; import type { FormProp } from './index'; -export function PipelineFormApplyConfig({ - children, - appName, - onSuccess, -}: FormProp) { +export function PipelineFormApplyConfig({ application, onSuccess }: FormProp) { const [trigger, state] = useTriggerPipelineApplyConfigMutation(); const [deployExternalDNS, setDeployExternalDNS] = useState(false); + const handleSubmit = handlePromiseWithToast( async (e: FormEvent) => { e.preventDefault(); const response = await trigger({ - appName, + appName: application.name, pipelineParametersApplyConfig: { deployExternalDNS: deployExternalDNS, }, @@ -37,7 +34,6 @@ export function PipelineFormApplyConfig({
- {children} -
+
- {children} - Build (but do not deploy) a git branch + {isBuildDeployPipeline ? ( + <>Build and deploy a git branch + ) : ( + <>Build (but do not deploy) a git branch + )} Git branch to build - - + + {Object.keys(branches ?? {}).map((branch, i) => (
)} - {pipelineName === 'build-deploy' && - branch && - !isAnyValidRegex(branch) && ( - - )} + {isBuildDeployPipeline && branch && !isAnyValidRegex(branch) && ( + + )}
- {state.isLoading && ( + {createJobState.isLoading && (
Creating…
)} - {state.isError && ( + {createJobState.isError && ( - Failed to create job. {getFetchErrorMessage(state.error)} + Failed to create job. {getFetchErrorMessage(createJobState.error)} )}
diff --git a/src/components/create-job-form/pipeline-form-deploy.tsx b/src/components/create-job-form/pipeline-form-deploy.tsx index 397b5e85d..5ebcdb977 100644 --- a/src/components/create-job-form/pipeline-form-deploy.tsx +++ b/src/components/create-job-form/pipeline-form-deploy.tsx @@ -5,31 +5,22 @@ import { Typography, } from '@equinor/eds-core-react'; import { type FormEvent, useState } from 'react'; -import { pollingInterval } from '../../store/defaults'; -import { - useGetEnvironmentSummaryQuery, - useTriggerPipelineDeployMutation, -} from '../../store/radix-api'; +import { useTriggerPipelineDeployMutation } from '../../store/radix-api'; import { getFetchErrorMessage } from '../../store/utils'; import { Alert } from '../alert'; import { handlePromiseWithToast } from '../global-top-nav/styled-toaster'; import type { FormProp } from './index'; -export function PipelineFormDeploy({ children, appName, onSuccess }: FormProp) { +export function PipelineFormDeploy({ application, onSuccess }: FormProp) { const [trigger, state] = useTriggerPipelineDeployMutation(); - const { data: environments } = useGetEnvironmentSummaryQuery( - { appName }, - { pollingInterval } - ); const [toEnvironment, setToEnvironment] = useState(''); - const handleSubmit = handlePromiseWithToast( async (e: FormEvent) => { e.preventDefault(); const response = await trigger({ - appName, + appName: application.name, pipelineParametersDeploy: { toEnvironment, }, @@ -45,7 +36,6 @@ export function PipelineFormDeploy({ children, appName, onSuccess }: FormProp) {
- {children} setToEnvironment(e.target.value)} value={toEnvironment} > - - {environments?.map(({ name }, i) => ( + + {application.environments?.map(({ name }, i) => ( diff --git a/src/components/create-job-form/pipeline-form-promote.tsx b/src/components/create-job-form/pipeline-form-promote.tsx index 1bd65479d..c4051b9a5 100644 --- a/src/components/create-job-form/pipeline-form-promote.tsx +++ b/src/components/create-job-form/pipeline-form-promote.tsx @@ -11,7 +11,6 @@ import { pollingInterval } from '../../store/defaults'; import { type DeploymentSummary, useGetDeploymentsQuery, - useGetEnvironmentSummaryQuery, useTriggerPipelinePromoteMutation, } from '../../store/radix-api'; import { formatDateTime } from '../../utils/datetime'; @@ -23,19 +22,11 @@ import { Alert } from '../alert'; import { handlePromiseWithToast } from '../global-top-nav/styled-toaster'; import type { FormProp } from './index'; -export function PipelineFormPromote({ - children, - appName, - onSuccess, -}: FormProp) { +export function PipelineFormPromote({ application, onSuccess }: FormProp) { const [searchParams] = useSearchParams(); const [trigger, state] = useTriggerPipelinePromoteMutation(); const { data: deployments } = useGetDeploymentsQuery( - { appName }, - { pollingInterval } - ); - const { data: environments } = useGetEnvironmentSummaryQuery( - { appName }, + { appName: application.name }, { pollingInterval } ); const [toEnvironment, setToEnvironment] = useState(''); @@ -53,7 +44,7 @@ export function PipelineFormPromote({ e.preventDefault(); const response = await trigger({ - appName, + appName: application.name, pipelineParametersPromote: { toEnvironment, deploymentName, @@ -81,7 +72,6 @@ export function PipelineFormPromote({
- {children} - + {Object.keys(groupedDeployments).map((key, i) => ( {groupedDeployments[key].map((x, j) => ( @@ -158,8 +150,10 @@ export function PipelineFormPromote({ onChange={(e) => setToEnvironment(e.target.value)} value={toEnvironment} > - - {environments?.map(({ name, activeDeployment }, i) => ( + + {application.environments?.map(({ name, activeDeployment }, i) => ( - Config file{' '} - - {getRadixConfigFullName(registration.radixConfigFullName)} - + Config file Now you can run the{' '} - + apply-config pipeline job - {' '} + to apply radixconfig.yaml, or go to{' '} Date: Fri, 22 Nov 2024 13:00:25 +0100 Subject: [PATCH 2/8] prevent screen "flickering" when fetching data when current fetch has failed --- src/components/async-resource/async-resource.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/async-resource/async-resource.tsx b/src/components/async-resource/async-resource.tsx index 7489b8244..39547eed8 100644 --- a/src/components/async-resource/async-resource.tsx +++ b/src/components/async-resource/async-resource.tsx @@ -35,8 +35,9 @@ export default function AsyncResource({ } if ( - asyncState.isError && - !nonErrorCodes?.includes(getFetchErrorCode(asyncState.error)) + asyncState.isError || + (asyncState.error && + !nonErrorCodes?.includes(getFetchErrorCode(asyncState.error))) ) { const { code, message } = getFetchErrorData(asyncState.error); From 6b60ff482d1dbc311c3dce68acd10a6c0f3203d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Fri, 22 Nov 2024 15:12:06 +0100 Subject: [PATCH 3/8] hide pipeline inputs when radixconfig is not applied, and show information about what to do with it --- src/components/alert/dev.tsx | 12 +- .../async-resource/async-resource.tsx | 4 +- src/components/create-job-form/index.tsx | 11 +- .../missing-radix-config-alert.tsx | 28 +++ .../pipeline-form-build-branches.tsx | 192 ++++++++++-------- .../create-job-form/pipeline-form-deploy.tsx | 90 ++++---- .../create-job-form/pipeline-form-promote.tsx | 176 ++++++++-------- 7 files changed, 282 insertions(+), 231 deletions(-) create mode 100644 src/components/create-job-form/missing-radix-config-alert.tsx diff --git a/src/components/alert/dev.tsx b/src/components/alert/dev.tsx index c33a1adb7..30e7725df 100644 --- a/src/components/alert/dev.tsx +++ b/src/components/alert/dev.tsx @@ -55,9 +55,7 @@ const testData: Array = [ ), () => ( - - That didn't work 😞 - + That didn't work 😞
The error message was error_msg
@@ -72,9 +70,7 @@ const testData: Array = [ ), () => ( - - That didn't work 😞 - + That didn't work 😞
Error subscribing to resource some resource with parameter{' '} some parameter @@ -118,9 +114,7 @@ const testData: Array = [ ), () => ( - - That didn't work 😞 - + That didn't work 😞
Error subscribing to resource some_resource with parameters{' '} some_parameter, some_other_parameter,{' '} diff --git a/src/components/async-resource/async-resource.tsx b/src/components/async-resource/async-resource.tsx index 39547eed8..9f47455d3 100644 --- a/src/components/async-resource/async-resource.tsx +++ b/src/components/async-resource/async-resource.tsx @@ -46,9 +46,7 @@ export default function AsyncResource({ content={errorContent} defaultContent={ - - That didn't work 😞 - + That didn't work 😞
Error message: diff --git a/src/components/create-job-form/index.tsx b/src/components/create-job-form/index.tsx index e720c727a..d49e4f70e 100644 --- a/src/components/create-job-form/index.tsx +++ b/src/components/create-job-form/index.tsx @@ -55,16 +55,9 @@ export default function CreateJobForm({ { appName }, { pollingInterval } ); - - const hasEnvironments = useMemo( - () => application?.environments?.length > 0, - [application] - ); + const hasEnvironments = application?.environments?.length; const buildBranches = useGetApplicationBranches(application); - const hasBuildBranches = useMemo( - () => Object.keys(buildBranches).length > 0, - [buildBranches] - ); + const hasBuildBranches = Object.keys(buildBranches).length > 0; const [searchParams, setSearchParams] = useSearchParams(); const setPipelineType = useCallback( (pipeline: string) => { diff --git a/src/components/create-job-form/missing-radix-config-alert.tsx b/src/components/create-job-form/missing-radix-config-alert.tsx new file mode 100644 index 000000000..3f5f32ea6 --- /dev/null +++ b/src/components/create-job-form/missing-radix-config-alert.tsx @@ -0,0 +1,28 @@ +import { Icon, Typography } from '@equinor/eds-core-react'; +import { info_circle } from '@equinor/eds-icons'; +import type { Application } from '../../store/radix-api'; +import { Alert } from '../alert'; +import { NewApplyConfigPipelineLink } from '../link/apply-config-pipeline-link'; +import { RadixConfigFileLink } from '../link/radix-config-file-link'; + +type Props = { application: Application }; + +export const MissingRadixConfigAlert = ({ application }: Props) => ( + + +
+ + The {' '} + file must be read by Radix before using this pipeline job. + + + Please run{' '} + + apply-config + {' '} + to read {' '} + from the application's GitHub repository. + +
+
+); diff --git a/src/components/create-job-form/pipeline-form-build-branches.tsx b/src/components/create-job-form/pipeline-form-build-branches.tsx index 8368bb9dd..ceacae98d 100644 --- a/src/components/create-job-form/pipeline-form-build-branches.tsx +++ b/src/components/create-job-form/pipeline-form-build-branches.tsx @@ -1,10 +1,12 @@ import { Button, CircularProgress, + Icon, NativeSelect, TextField, Typography, } from '@equinor/eds-core-react'; +import { info_circle } from '@equinor/eds-icons'; import { type ChangeEvent, type FormEvent, useState } from 'react'; import { useTriggerPipelineBuildDeployMutation, @@ -14,6 +16,7 @@ import { getFetchErrorMessage } from '../../store/utils'; import { Alert } from '../alert'; import { handlePromiseWithToast } from '../global-top-nav/styled-toaster'; import type { FormProp } from './index'; +import { MissingRadixConfigAlert } from './missing-radix-config-alert'; import { TargetEnvs } from './target-envs'; import { useGetApplicationBranches } from './use-get-application-branches'; @@ -22,6 +25,7 @@ export function PipelineFormBuildBranches({ application, pipelineName, }: FormProp) { + const hasEnvironments = application?.environments?.length > 0; const isBuildDeployPipeline = pipelineName === 'build-deploy'; const [triggerBuild, buildState] = useTriggerPipelineBuildMutation(); const [triggerBuildDeploy, buildDeployState] = @@ -32,6 +36,7 @@ export function PipelineFormBuildBranches({ const [branchFullName, setBranchFullName] = useState(''); const [toEnvironment, setToEnvironment] = useState(''); const branches = useGetApplicationBranches(application); + const hasBranches = Object.keys(branches).length > 0; const [filteredBranches, setFilteredBranches] = useState([]); const handleOnTextChange = ({ @@ -96,98 +101,119 @@ export function PipelineFormBuildBranches({ disabled={createJobState.isLoading} className="grid grid--gap-medium" > -
- - {isBuildDeployPipeline ? ( - <>Build and deploy a git branch - ) : ( - <>Build (but do not deploy) a git branch - )} - - - Git branch to build - - - - {Object.keys(branches ?? {}).map((branch, i) => ( -
+ ) : ( + <> + {!hasEnvironments ? ( + + ) : ( + <> + {!hasBranches && ( + + +
+ + No environments are configured to be built by Radix. + +
+
+ )} + + )} + + )}
{createJobState.isLoading && ( diff --git a/src/components/create-job-form/pipeline-form-deploy.tsx b/src/components/create-job-form/pipeline-form-deploy.tsx index 5ebcdb977..ced4c862d 100644 --- a/src/components/create-job-form/pipeline-form-deploy.tsx +++ b/src/components/create-job-form/pipeline-form-deploy.tsx @@ -11,8 +11,10 @@ import { getFetchErrorMessage } from '../../store/utils'; import { Alert } from '../alert'; import { handlePromiseWithToast } from '../global-top-nav/styled-toaster'; import type { FormProp } from './index'; +import { MissingRadixConfigAlert } from './missing-radix-config-alert'; export function PipelineFormDeploy({ application, onSuccess }: FormProp) { + const hasEnvironments = application?.environments?.length > 0; const [trigger, state] = useTriggerPipelineDeployMutation(); const [toEnvironment, setToEnvironment] = useState(''); const handleSubmit = handlePromiseWithToast( @@ -35,57 +37,61 @@ export function PipelineFormDeploy({ application, onSuccess }: FormProp) { return (
-
- - Deploy an application - + {hasEnvironments ? (
- Environment + Deploy an application - setToEnvironment(e.target.value)} - value={toEnvironment} - > - - {application.environments?.map(({ name }, i) => ( -
-
- {state.isLoading && ( -
- Creating… -
- )} - {state.isError && ( - - Failed to create job. {getFetchErrorMessage(state.error)} - - )} + ) : ( + + )} +
+ {state.isLoading && (
- + Creating…
+ )} + {state.isError && ( + + Failed to create job. {getFetchErrorMessage(state.error)} + + )} +
+
diff --git a/src/components/create-job-form/pipeline-form-promote.tsx b/src/components/create-job-form/pipeline-form-promote.tsx index c4051b9a5..7193853ab 100644 --- a/src/components/create-job-form/pipeline-form-promote.tsx +++ b/src/components/create-job-form/pipeline-form-promote.tsx @@ -21,8 +21,10 @@ import { getFetchErrorMessage } from '../../store/utils'; import { Alert } from '../alert'; import { handlePromiseWithToast } from '../global-top-nav/styled-toaster'; import type { FormProp } from './index'; +import { MissingRadixConfigAlert } from './missing-radix-config-alert'; export function PipelineFormPromote({ application, onSuccess }: FormProp) { + const hasEnvironments = application?.environments?.length > 0; const [searchParams] = useSearchParams(); const [trigger, state] = useTriggerPipelinePromoteMutation(); const { data: deployments } = useGetDeploymentsQuery( @@ -71,101 +73,105 @@ export function PipelineFormPromote({ application, onSuccess }: FormProp) { return (
-
- - Promote an existing deployment to an environment - - - Deployment to promote - - setDeploymentName(e.target.value)} - name="deploymentName" - value={deploymentName} - > - - {Object.keys(groupedDeployments).map((key, i) => ( - - {groupedDeployments[key].map((x, j) => ( - - ))} - - ))} - - - {selectedDeployment && ( + {hasEnvironments ? ( +
- Active {selectedDeployment.activeTo ? 'from' : 'since'}{' '} - {' '} - {selectedDeployment.activeTo && ( - <> - to {' '} - - )} - on environment {selectedDeployment.environment} + Promote an existing deployment to an environment - )} -
+ + Deployment to promote + + setDeploymentName(e.target.value)} + name="deploymentName" + value={deploymentName} + > + + {Object.keys(groupedDeployments).map((key, i) => ( + + {groupedDeployments[key].map((x, j) => ( + + ))} + + ))} + -
- - Target environment - - setToEnvironment(e.target.value)} - value={toEnvironment} - > - - {application.environments?.map(({ name, activeDeployment }, i) => ( -
+ {application.environments?.map( + ({ name, activeDeployment }, i) => ( + + ) + )} + +
+ ) : ( + + )}
{state.isLoading && (
From 18ff6ba03146c6a965607483ba42da87e5afbf9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Mon, 25 Nov 2024 10:01:13 +0100 Subject: [PATCH 4/8] make links in environment card wrap --- .../environments-summary/environment-card.tsx | 31 ++++++++----------- .../environment-ingress.tsx | 24 +++++++------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/components/environments-summary/environment-card.tsx b/src/components/environments-summary/environment-card.tsx index 22e4f5692..6128c4f6a 100644 --- a/src/components/environments-summary/environment-card.tsx +++ b/src/components/environments-summary/environment-card.tsx @@ -53,11 +53,8 @@ const DeploymentDetails: FunctionComponent<{ deployment: Readonly; }> = ({ appName, deployment }) => !deployment ? ( - - + + No active deployment ) : ( @@ -67,15 +64,13 @@ const DeploymentDetails: FunctionComponent<{ link token={{ textDecoration: 'none' }} > - - - - deployment{' '} - - () - + + + deployment{' '} + + () - + ); @@ -161,11 +156,11 @@ export const EnvironmentCard: FunctionComponent = ({ ? { header: <>, body: ( - - + + No link available ), diff --git a/src/components/environments-summary/environment-ingress.tsx b/src/components/environments-summary/environment-ingress.tsx index 5250cbcb3..b6fe384e3 100644 --- a/src/components/environments-summary/environment-ingress.tsx +++ b/src/components/environments-summary/environment-ingress.tsx @@ -34,8 +34,8 @@ const ComponentDetails: FunctionComponent<{ icon: IconData; component: Readonly; }> = ({ icon, component }) => ( - - + <> + {component.name} - + ); export const EnvironmentIngress: FunctionComponent = ({ @@ -82,21 +82,19 @@ export const EnvironmentIngress: FunctionComponent = ({ )) ) : ( - - - - No link available - - + + + No link available + )} {comps.passive .filter(({ status }) => status === 'Outdated') From 6a41e00775553a6c179bf13f5a9cec13f4c172bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Mon, 25 Nov 2024 12:26:39 +0100 Subject: [PATCH 5/8] environment info when no radixconfig --- src/components/app-overview/index.tsx | 18 ++-- src/components/component/dns-aliases.tsx | 20 ++-- .../missing-radix-config-alert.tsx | 9 +- src/components/environments-summary/index.tsx | 34 ++++--- src/components/jobs-list/index.tsx | 91 ++++++++++--------- 5 files changed, 84 insertions(+), 88 deletions(-) diff --git a/src/components/app-overview/index.tsx b/src/components/app-overview/index.tsx index e045612e3..5e776cb1a 100644 --- a/src/components/app-overview/index.tsx +++ b/src/components/app-overview/index.tsx @@ -69,18 +69,14 @@ export function AppOverview({ appName }: { appName: string }) { title={'DNS external aliases'} /> )} - {environments?.length > 0 && ( + Environments - )} - - - {jobs?.length > 0 && ( - Latest pipeline jobs - )} + + diff --git a/src/components/component/dns-aliases.tsx b/src/components/component/dns-aliases.tsx index f9ebf0d10..cfddf7ab3 100644 --- a/src/components/component/dns-aliases.tsx +++ b/src/components/component/dns-aliases.tsx @@ -17,10 +17,10 @@ export const DNSAliases: FunctionComponent = ({ title, }) => ( <> - {dnsAliases?.length > 0 && - (dnsAliases.length == 1 ? ( -
- {title} + {dnsAliases?.length > 0 && ( +
+ {title} + {dnsAliases.length == 1 ? ( = ({ environmentName={dnsAliases[0].environmentName} /> -
- ) : ( - <> - - {title} - + ) : ( @@ -60,7 +55,8 @@ export const DNSAliases: FunctionComponent = ({ - - ))} + )} +
+ )} ); diff --git a/src/components/create-job-form/missing-radix-config-alert.tsx b/src/components/create-job-form/missing-radix-config-alert.tsx index 3f5f32ea6..3fcf7868c 100644 --- a/src/components/create-job-form/missing-radix-config-alert.tsx +++ b/src/components/create-job-form/missing-radix-config-alert.tsx @@ -10,19 +10,18 @@ type Props = { application: Application }; export const MissingRadixConfigAlert = ({ application }: Props) => ( -
+ The {' '} file must be read by Radix before using this pipeline job. - Please run{' '} + Run the{' '} apply-config {' '} - to read {' '} - from the application's GitHub repository. + pipeline job to read the file from the application's GitHub repository. -
+
); diff --git a/src/components/environments-summary/index.tsx b/src/components/environments-summary/index.tsx index d6d4242b9..1e36890cc 100644 --- a/src/components/environments-summary/index.tsx +++ b/src/components/environments-summary/index.tsx @@ -1,14 +1,9 @@ import { Typography } from '@equinor/eds-core-react'; import * as PropTypes from 'prop-types'; import type { FunctionComponent } from 'react'; - -import { EnvironmentCard } from './environment-card'; - -import { externalUrls } from '../../externalUrls'; import type { EnvironmentSummary } from '../../store/radix-api'; - import { NewApplyConfigPipelineLink } from '../link/apply-config-pipeline-link'; -import { ExternalLink } from '../link/external-link'; +import { EnvironmentCard } from './environment-card'; import './style.css'; export interface EnvironmentsSummaryProps { @@ -21,27 +16,30 @@ export const EnvironmentsSummary: FunctionComponent< EnvironmentsSummaryProps > = ({ appName, envs, repository }) => { return ( -
+ <> {envs?.length > 0 ? ( - envs.map((env, i) => ( - - )) +
+ {envs.map((env, i) => ( + + ))} +
) : ( - - No enironments. + + + The radixconfig.yaml file must be read by Radix in order to show + information about environments. + - Please run the{' '} + Run the{' '} apply-config {' '} - pipeline job to apply{' '} - - radixconfig.yaml - + pipeline job to read the file from the application's GitHub + repository. )} -
+ ); }; diff --git a/src/components/jobs-list/index.tsx b/src/components/jobs-list/index.tsx index 508c7d935..eb9ecf076 100644 --- a/src/components/jobs-list/index.tsx +++ b/src/components/jobs-list/index.tsx @@ -55,48 +55,55 @@ export const JobsList: FunctionComponent = ({ ); }, [dateSort, envSort, jobs, limit, pipelineSort]); - return sortedData.length > 0 ? ( -
- - - - ID - setDateSort(getNewSortDir(dateSort))} - > - Date/Time - - - setEnvSort(getNewSortDir(envSort, true))} - > - Environment - - - Status - setPipelineSort(getNewSortDir(pipelineSort, true))} - > - Pipeline - - - - - - {sortedData.map((x) => ( - - ))} - -
-
- ) : ( - <> - No pipeline jobs yet - Push to GitHub to trigger a job - + return ( + + Latest pipeline jobs + {sortedData.length > 0 ? ( +
+ + + + ID + setDateSort(getNewSortDir(dateSort))} + > + Date/Time + + + setEnvSort(getNewSortDir(envSort, true))} + > + Environment + + + Status + + setPipelineSort(getNewSortDir(pipelineSort, true)) + } + > + Pipeline + + + + + + {sortedData.map((x) => ( + + ))} + +
+
+ ) : ( + + No pipeline jobs yet + Push to GitHub to trigger a job + + )} +
); }; From 0b2a870099dde70b2594b4a4e03e6956507e9f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Mon, 25 Nov 2024 12:29:16 +0100 Subject: [PATCH 6/8] show info alert when no environments --- src/components/environments-summary/index.tsx | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/components/environments-summary/index.tsx b/src/components/environments-summary/index.tsx index 1e36890cc..4988142f9 100644 --- a/src/components/environments-summary/index.tsx +++ b/src/components/environments-summary/index.tsx @@ -1,10 +1,12 @@ -import { Typography } from '@equinor/eds-core-react'; +import { Icon, Typography } from '@equinor/eds-core-react'; import * as PropTypes from 'prop-types'; import type { FunctionComponent } from 'react'; import type { EnvironmentSummary } from '../../store/radix-api'; import { NewApplyConfigPipelineLink } from '../link/apply-config-pipeline-link'; import { EnvironmentCard } from './environment-card'; import './style.css'; +import { info_circle } from '@equinor/eds-icons'; +import { Alert } from '../alert'; export interface EnvironmentsSummaryProps { appName: string; @@ -24,20 +26,23 @@ export const EnvironmentsSummary: FunctionComponent< ))}
) : ( - - - The radixconfig.yaml file must be read by Radix in order to show - information about environments. - - - Run the{' '} - - apply-config - {' '} - pipeline job to read the file from the application's GitHub - repository. - - + + + + + The radixconfig.yaml file must be read by Radix in order to show + information about environments. + + + Run the{' '} + + apply-config + {' '} + pipeline job to read the file from the application's GitHub + repository. + + + )} ); From 9cb91a7145f80ba7c85fc8ac0e2bc4b72333ffee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Mon, 25 Nov 2024 13:09:55 +0100 Subject: [PATCH 7/8] show info box on empty environments --- src/components/app-overview/index.tsx | 15 +----- src/components/environments-summary/dev.tsx | 4 +- src/components/environments-summary/index.tsx | 46 +++++++++---------- src/components/page-environments/index.tsx | 7 +-- 4 files changed, 27 insertions(+), 45 deletions(-) diff --git a/src/components/app-overview/index.tsx b/src/components/app-overview/index.tsx index 5e776cb1a..af6977b22 100644 --- a/src/components/app-overview/index.tsx +++ b/src/components/app-overview/index.tsx @@ -26,14 +26,7 @@ export function AppOverview({ appName }: { appName: string }) { { skip: !appName, pollingInterval } ); - const { - appAlias, - dnsAliases, - dnsExternalAliases, - environments, - jobs, - registration, - } = application ?? {}; + const { appAlias, dnsAliases, dnsExternalAliases, jobs } = application ?? {}; return (
@@ -71,11 +64,7 @@ export function AppOverview({ appName }: { appName: string }) { )} Environments - + {application && } diff --git a/src/components/environments-summary/dev.tsx b/src/components/environments-summary/dev.tsx index eec12be9e..b3facfa8e 100644 --- a/src/components/environments-summary/dev.tsx +++ b/src/components/environments-summary/dev.tsx @@ -80,7 +80,9 @@ export default ( > {testData.map((x, i) => (
- + {i !== testData.length - 1 && }
))} diff --git a/src/components/environments-summary/index.tsx b/src/components/environments-summary/index.tsx index 4988142f9..56e233509 100644 --- a/src/components/environments-summary/index.tsx +++ b/src/components/environments-summary/index.tsx @@ -1,28 +1,30 @@ import { Icon, Typography } from '@equinor/eds-core-react'; -import * as PropTypes from 'prop-types'; -import type { FunctionComponent } from 'react'; -import type { EnvironmentSummary } from '../../store/radix-api'; +import type { Application } from '../../store/radix-api'; import { NewApplyConfigPipelineLink } from '../link/apply-config-pipeline-link'; import { EnvironmentCard } from './environment-card'; import './style.css'; import { info_circle } from '@equinor/eds-icons'; import { Alert } from '../alert'; +import { RadixConfigFileLink } from '../link/radix-config-file-link'; -export interface EnvironmentsSummaryProps { - appName: string; - envs?: Readonly>; - repository?: string; -} +export type EnvironmentsSummaryProps = { + application: Application; +}; -export const EnvironmentsSummary: FunctionComponent< - EnvironmentsSummaryProps -> = ({ appName, envs, repository }) => { +export const EnvironmentsSummary = ({ + application, +}: EnvironmentsSummaryProps) => { return ( <> - {envs?.length > 0 ? ( + {application.environments?.length > 0 ? (
- {envs.map((env, i) => ( - + {application.environments?.map((env, i) => ( + ))}
) : ( @@ -30,12 +32,14 @@ export const EnvironmentsSummary: FunctionComponent< - The radixconfig.yaml file must be read by Radix in order to show - information about environments. + The{' '} + {' '} + file must be read by Radix in order to show information about + environments. Run the{' '} - + apply-config {' '} pipeline job to read the file from the application's GitHub @@ -47,11 +51,3 @@ export const EnvironmentsSummary: FunctionComponent< ); }; - -EnvironmentsSummary.propTypes = { - appName: PropTypes.string.isRequired, - envs: PropTypes.arrayOf( - PropTypes.object as PropTypes.Validator - ), - repository: PropTypes.string, -}; diff --git a/src/components/page-environments/index.tsx b/src/components/page-environments/index.tsx index e5cf7c131..71f33e1cc 100644 --- a/src/components/page-environments/index.tsx +++ b/src/components/page-environments/index.tsx @@ -16,7 +16,6 @@ export function PageEnvironments({ appName }: Props) { { appName }, { skip: !appName, pollingInterval } ); - const { environments, registration } = application ?? {}; return ( <> @@ -29,11 +28,7 @@ export function PageEnvironments({ appName }: Props) { /> - + {application && } ); From d44ce14cd07584bd0eb83e6137a0238a0ce0d9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Mon, 25 Nov 2024 13:11:43 +0100 Subject: [PATCH 8/8] hide "please select" from pipeline job type drop down --- src/components/create-job-form/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/create-job-form/index.tsx b/src/components/create-job-form/index.tsx index d49e4f70e..07fd13c5a 100644 --- a/src/components/create-job-form/index.tsx +++ b/src/components/create-job-form/index.tsx @@ -98,7 +98,7 @@ export default function CreateJobForm({ value={pipeline} onChange={(e) => setPipelineType(e.target.value)} > - {Object.keys(Pipelines).map((pipeline) => (