UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

47 lines (46 loc) 3.24 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /* * Copyright 2025 The Kubernetes 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 { InlineIcon } from '@iconify/react'; import Button from '@mui/material/Button'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; import CardHeader from '@mui/material/CardHeader'; import Grid from '@mui/material/Grid'; import Typography from '@mui/material/Typography'; import { useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; import { createRouteURL } from '../../../lib/router'; import { useTypedSelector } from '../../../redux/reducers/reducers'; import { PageGrid } from '../../common/Resource'; import SectionBox from '../../common/SectionBox'; function AddClusterProvider({ title, icon, description, url }) { const history = useHistory(); const { t } = useTranslation(['translation']); const Icon = icon; const avatar = _jsx(Icon, { width: 24, height: 24 }); return (_jsxs(Card, { variant: "outlined", children: [_jsx(CardHeader, { title: title, avatar: avatar }), _jsxs(CardContent, { children: [_jsx(Typography, { children: description }), _jsx(Button, { variant: "contained", onClick: () => history.push(url), sx: { mt: 2 }, children: t('translation|Add') })] })] })); } export default function AddCluster(props) { const { open } = props; const { t } = useTranslation(['translation']); const history = useHistory(); const addClusterProviders = useTypedSelector(state => state.clusterProvider.clusterProviders); if (!open) { return null; } return (_jsx(PageGrid, { children: _jsx(SectionBox, { backLink: true, title: t('translation|Add Cluster'), py: 2, mt: [4, 0, 0], children: _jsxs(Grid, { container: true, justifyContent: "flex-start", alignItems: "stretch", spacing: 4, children: [_jsx(Grid, { item: true, xs: 12, children: _jsx(Typography, { children: t('Proceed to select your preferred method for cluster creation and addition') }) }), _jsx(Grid, { item: true, xs: 12, children: _jsx(Card, { variant: "outlined", children: _jsx(CardContent, { children: _jsx(Button, { onClick: () => history.push(createRouteURL('loadKubeConfig')), startIcon: _jsx(InlineIcon, { icon: "mdi:plus-box-outline" }), children: t('translation|Load from KubeConfig') }) }) }) }), addClusterProviders.length > 0 && (_jsx(Grid, { item: true, xs: 12, children: _jsx(Typography, { variant: "h4", children: t('translation|Providers') }) })), addClusterProviders.length > 0 && (_jsx(Grid, { item: true, xs: 12, children: addClusterProviders.map(addClusterProviderInfo => (_jsx(AddClusterProvider, { ...addClusterProviderInfo }))) }))] }) }) })); }