From 3ce7fb36d488b6263b65173cbf31634bb6e95ea5 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Mon, 3 Oct 2022 13:34:05 +0200 Subject: [PATCH] remove create service Signed-off-by: Marko Simon --- .../components/Service/ServiceNewModal.tsx | 136 ------------------ .../components/ServicesPage/ServicesPage.tsx | 25 +--- .../components/ServicesPage/ServicesTable.tsx | 36 +++-- 3 files changed, 18 insertions(+), 179 deletions(-) delete mode 100644 plugins/ilert/src/components/Service/ServiceNewModal.tsx diff --git a/plugins/ilert/src/components/Service/ServiceNewModal.tsx b/plugins/ilert/src/components/Service/ServiceNewModal.tsx deleted file mode 100644 index 64823eaf46..0000000000 --- a/plugins/ilert/src/components/Service/ServiceNewModal.tsx +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2021 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 { alertApiRef, useApi } from '@backstage/core-plugin-api'; -import Button from '@material-ui/core/Button'; -import Dialog from '@material-ui/core/Dialog'; -import DialogActions from '@material-ui/core/DialogActions'; -import DialogContent from '@material-ui/core/DialogContent'; -import DialogTitle from '@material-ui/core/DialogTitle'; -import { makeStyles } from '@material-ui/core/styles'; -import TextField from '@material-ui/core/TextField'; -import React from 'react'; -import { ilertApiRef } from '../../api'; -import { useNewService } from '../../hooks/useNewService'; - -const useStyles = makeStyles(() => ({ - container: { - display: 'flex', - flexWrap: 'wrap', - }, - formControl: { - minWidth: 120, - width: '100%', - }, - option: { - fontSize: 15, - '& > span': { - marginRight: 10, - fontSize: 18, - }, - }, - optionWrapper: { - display: 'flex', - width: '100%', - }, - sourceImage: { - height: 22, - paddingRight: 4, - }, -})); - -export const ServiceNewModal = ({ - isModalOpened, - setIsModalOpened, - refetchServices, -}: { - isModalOpened: boolean; - setIsModalOpened: (open: boolean) => void; - refetchServices: () => void; -}) => { - const [{ name, isLoading }, { setName, setIsLoading }] = useNewService(); - const ilertApi = useApi(ilertApiRef); - const alertApi = useApi(alertApiRef); - const classes = useStyles(); - - const handleClose = () => { - setIsModalOpened(false); - }; - - const handleCreate = () => { - setIsLoading(true); - setTimeout(async () => { - try { - await ilertApi.createService({ - name, - }); - alertApi.post({ message: 'Service created.' }); - refetchServices(); - } catch (err) { - alertApi.post({ message: err, severity: 'error' }); - } - setIsModalOpened(false); - }, 250); - }; - - const canCreate = !!name; - - return ( - - 'New alert' - - {/* - - Please describe the problem you want to report. Be as descriptive as - possible. Your signed in user and a reference to the current page - will automatically be amended to the alarm so that the receiver can - reach out to you if necessary. - - */} - { - setName(event.target.value); - }} - /> - - - - - - - ); -}; diff --git a/plugins/ilert/src/components/ServicesPage/ServicesPage.tsx b/plugins/ilert/src/components/ServicesPage/ServicesPage.tsx index 73b2d92f3c..e3afd4cc1a 100644 --- a/plugins/ilert/src/components/ServicesPage/ServicesPage.tsx +++ b/plugins/ilert/src/components/ServicesPage/ServicesPage.tsx @@ -20,26 +20,17 @@ import { SupportButton, } from '@backstage/core-components'; import { AuthenticationError } from '@backstage/errors'; -import Button from '@material-ui/core/Button'; -import AddIcon from '@material-ui/icons/Add'; import React from 'react'; import { useServices } from '../../hooks/useServices'; import { MissingAuthorizationHeaderError } from '../Errors'; -import { ServiceNewModal } from '../Service/ServiceNewModal'; import { ServicesTable } from './ServicesTable'; export const ServicesPage = () => { const [ { tableState, services, isLoading, error }, - { onChangePage, onChangeRowsPerPage, refetchServices, setIsLoading }, + { onChangePage, onChangeRowsPerPage, setIsLoading }, ] = useServices(true); - const [isModalOpened, setIsModalOpened] = React.useState(false); - - const handleCreateNewServiceClick = () => { - setIsModalOpened(true); - }; - if (error) { if (error instanceof AuthenticationError) { return ( @@ -59,20 +50,6 @@ export const ServicesPage = () => { return ( - - This helps you to bring iLert into your developer portal. diff --git a/plugins/ilert/src/components/ServicesPage/ServicesTable.tsx b/plugins/ilert/src/components/ServicesPage/ServicesTable.tsx index bfb20acd71..4ed1d581ae 100644 --- a/plugins/ilert/src/components/ServicesPage/ServicesTable.tsx +++ b/plugins/ilert/src/components/ServicesPage/ServicesTable.tsx @@ -16,12 +16,11 @@ import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; import React from 'react'; -import { ilertApiRef, TableState } from '../../api'; +import { TableState } from '../../api'; import { Service } from '../../types'; import { StatusChip } from './StatusChip'; import { Table, TableColumn } from '@backstage/core-components'; -import { useApi } from '@backstage/core-plugin-api'; import { ServiceActionsMenu } from '../Service/ServiceActionsMenu'; import { ServiceLink } from '../Service/ServiceLink'; @@ -49,25 +48,24 @@ export const ServicesTable = ({ onChangeRowsPerPage: (pageSize: number) => void; compact?: boolean; }) => { - const ilertApi = useApi(ilertApiRef); const classes = useStyles(); - const xsColumnStyle = { - width: '5%', - maxWidth: '5%', - }; + // const xsColumnStyle = { + // width: '5%', + // maxWidth: '5%', + // }; const smColumnStyle = { width: '10%', maxWidth: '10%', }; - const mdColumnStyle = { - width: '15%', - maxWidth: '15%', - }; - const lgColumnStyle = { - width: '20%', - maxWidth: '20%', - }; + // const mdColumnStyle = { + // width: '15%', + // maxWidth: '15%', + // }; + // const lgColumnStyle = { + // width: '20%', + // maxWidth: '20%', + // }; const xlColumnStyle = { width: '30%', maxWidth: '30%', @@ -91,8 +89,8 @@ export const ServicesTable = ({ const statusColumn: TableColumn = { title: 'Status', field: 'status', - cellStyle: xsColumnStyle, - headerStyle: xsColumnStyle, + cellStyle: smColumnStyle, + headerStyle: smColumnStyle, render: rowData => , }; const uptimeColumn: TableColumn = { @@ -109,8 +107,8 @@ export const ServicesTable = ({ const actionsColumn: TableColumn = { title: '', field: '', - cellStyle: xsColumnStyle, - headerStyle: xsColumnStyle, + cellStyle: smColumnStyle, + headerStyle: smColumnStyle, render: rowData => , };