diff --git a/plugins/octopus-deploy/dev/index.tsx b/plugins/octopus-deploy/dev/index.tsx index 503cbe6d12..d3d6cb3215 100644 --- a/plugins/octopus-deploy/dev/index.tsx +++ b/plugins/octopus-deploy/dev/index.tsx @@ -1,12 +1,28 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React from 'react'; import { createDevApp } from '@backstage/dev-utils'; -import { octopusDeployPlugin, OctopusDeployPage } from '../src/plugin'; +import { octopusDeployPlugin } from '../src/plugin'; +import { EntityPageOctopusDeploy } from '../src/components/EntityPageOctopusDeploy'; createDevApp() .registerPlugin(octopusDeployPlugin) .addPage({ - element: , + element: , title: 'Root Page', - path: '/octopus-deploy' + path: '/octopus-deploy', }) .render(); diff --git a/plugins/octopus-deploy/src/components/ReleaseTable/ReleaseTable.tsx b/plugins/octopus-deploy/src/components/ReleaseTable/ReleaseTable.tsx index 21322057d3..be2a68a687 100644 --- a/plugins/octopus-deploy/src/components/ReleaseTable/ReleaseTable.tsx +++ b/plugins/octopus-deploy/src/components/ReleaseTable/ReleaseTable.tsx @@ -1,123 +1,154 @@ -import { Box, Typography } from "@material-ui/core"; -import { - OctopusEnvironment, - OctopusReleaseProgression -} from '../../api'; +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Box, Typography } from '@material-ui/core'; +import { OctopusEnvironment, OctopusReleaseProgression } from '../../api'; import React from 'react'; -import { ResponseErrorPanel, StatusAborted, StatusError, StatusOK, StatusPending, StatusRunning, StatusWarning, Table, TableColumn } from "@backstage/core-components"; +import { + ResponseErrorPanel, + StatusAborted, + StatusError, + StatusOK, + StatusPending, + StatusRunning, + StatusWarning, + Table, + TableColumn, +} from '@backstage/core-components'; type ReleaseTableProps = { - environments?: OctopusEnvironment[]; - releases?: OctopusReleaseProgression[]; - loading: boolean; - error?: Error + environments?: OctopusEnvironment[]; + releases?: OctopusReleaseProgression[]; + loading: boolean; + error?: Error; }; export const getDeploymentStatusComponent = (state: string | undefined) => { - switch (state) { - case "Success": - return ( - - Success - - ); - case "Queued": - return ( - - Queued - - ); - case "Executing": - return ( - - Executing - - ); - case "Failed": - return ( - - Failed - - ); - case "Cancelling": - return ( - - Cancelling - - ); - case "Canceled": - return ( - - Canceled - - ); - case "TimedOut": - return ( - - Timed Out - - ); - default: - return ( - - Unknown - - ); - } -} - -export const ReleaseTable = ({environments, releases, loading, error}: ReleaseTableProps) => { - if (error) { - return ( -
- -
- ); - } - - const columns: TableColumn[] = [ - { - title: 'Version', - field: 'Release.Version', - highlight: false, - width: 'auto' - }, - ...environments?.map(env => ({ - title: env.Name, - width: 'auto', - render: (row: Partial) => { - const deploymentsForEnvironment = row.Deployments[env.Id]; - if (deploymentsForEnvironment) { - return ( - - - {getDeploymentStatusComponent(deploymentsForEnvironment[0].State)} - - - ) - } - } - //field: `Deployments.${env.Id}[0].State` // TODO: We'll probably need to deal with multi-tenant deployments here - })) ?? [] - ] + switch (state) { + case 'Success': + return ( + + Success + + ); + case 'Queued': + return ( + + Queued + + ); + case 'Executing': + return ( + + Executing + + ); + case 'Failed': + return ( + + Failed + + ); + case 'Cancelling': + return ( + + Cancelling + + ); + case 'Canceled': + return ( + + Canceled + + ); + case 'TimedOut': + return ( + + Timed Out + + ); + default: + return ( + + Unknown + + ); + } +}; +export const ReleaseTable = ({ + environments, + releases, + loading, + error, +}: ReleaseTableProps) => { + if (error) { return ( - - Octopus Deploy - Releases ({releases ? releases.length : 0}) - - } - data={releases ?? []} - /> - ) -} \ No newline at end of file +
+ +
+ ); + } + + const columns: TableColumn[] = [ + { + title: 'Version', + field: 'Release.Version', + highlight: false, + width: 'auto', + }, + ...(environments?.map(env => ({ + title: env.Name, + width: 'auto', + render: (row: Partial) => { + const deploymentsForEnvironment = row.Deployments + ? row.Deployments[env.Id] + : null; + if (deploymentsForEnvironment) { + return ( + + + {getDeploymentStatusComponent( + deploymentsForEnvironment[0].State, + )} + + + ); + } + return ; + }, + })) ?? []), + ]; + + return ( +
+ Octopus Deploy - Releases ({releases ? releases.length : 0}) + + } + data={releases ?? []} + /> + ); +};