Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster restructure #250

Merged
merged 8 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/clusterDetails/clusterDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { InstallationType } from '../../types/redux';
import ClusterDetails from '.';

const cluster: ClusterInfo = {
id: 'mock',
clusterName: 'kuberfirst-mgmt2',
type: ClusterType.MANAGEMENT,
cloudProvider: InstallationType.AWS,
Expand Down
36 changes: 33 additions & 3 deletions components/clusterDetails/clusterDetails.styled.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
import styled from 'styled-components';
import { styled as muiStyled, typographyClasses } from '@mui/material';
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';

import ColumnComponent from '../column';
import RowComponent from '../row';
import Typography from '../typography';
import { EXCLUSIVE_PLUM, VOLCANIC_SAND } from '../../constants/colors';
import NextLink from '../nextLink';
import {
CHEFS_HAT,
DR_WHITE,
EXCLUSIVE_PLUM,
TRUE_BLUE,
VOLCANIC_SAND,
} from '../../constants/colors';

export const Content = styled.div`
display: flex;
flex-direction: column;
gap: 32px;
margin-top: 24px;
`;

export const Column = styled(ColumnComponent)`
export const StatusContainer = styled(RowComponent)`
gap: 8px;
padding: 16px;
background-color: ${DR_WHITE};
border: 1px solid ${CHEFS_HAT};
border-radius: 4px;
`;

export const ColumnInfo = styled(ColumnComponent)`
gap: 8px;
justify-content: space-between;
`;

export const Row = styled(RowComponent)`
export const InfoIcon = styled(InfoOutlinedIcon)`
color: ${TRUE_BLUE};
height: 20px;
width: 20px;
`;

export const Link = styled(NextLink)`
display: inline-flex;
a {
color: ${TRUE_BLUE};
}
`;

export const RowInfo = styled(RowComponent)`
gap: 156px;
`;

Expand Down
152 changes: 95 additions & 57 deletions components/clusterDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@ import React, { ComponentPropsWithoutRef, FunctionComponent } from 'react';
import moment from 'moment';

import { ClusterInfo } from '../clusterTable/clusterTable';
import Typography from '../../components/typography';
import Row from '../../components/row';
import Column from '../../components/column';
import { ClusterStatus, ClusterType } from '../../types/provision';

import { Content, Column, Row, StyledLabel, StyledValue } from './clusterDetails.styled';
import {
Content,
ColumnInfo,
RowInfo,
StyledLabel,
StyledValue,
InfoIcon,
Link,
StatusContainer,
} from './clusterDetails.styled';

export interface ClusterDetailsProps extends ComponentPropsWithoutRef<'div'> {
cluster: ClusterInfo;
}

const ClusterDetails: FunctionComponent<ClusterDetailsProps> = ({ cluster, ...rest }) => {
const ClusterDetails: FunctionComponent<ClusterDetailsProps> = ({ cluster }) => {
const {
adminEmail,
cloudProvider,
Expand All @@ -20,69 +33,94 @@ const ClusterDetails: FunctionComponent<ClusterDetailsProps> = ({ cluster, ...re
gitUser,
nodes,
instanceSize,
status,
type,
} = cluster;
return (
<Content {...rest}>
{/* Top Row */}
<Row>
<>
<StatusContainer>
<Row>
<InfoIcon />
</Row>
<Column>
<StyledLabel variant="labelLarge">Cluster domain name</StyledLabel>
<StyledValue variant="body2">{domainName}</StyledValue>
{status === ClusterStatus.PROVISIONING || type === ClusterType.DRAFT ? (
<>
<Typography variant="body2">
The cluster has been registered and will be synced
</Typography>
<Typography variant="body2">
Provisioning details: <Link href="">Link</Link>
</Typography>
</>
) : (
<Typography>
Cluster details: <Link href="">Link</Link>{' '}
</Typography>
)}
</Column>
<Column>
<StyledLabel variant="labelLarge">Alerts email</StyledLabel>
<StyledValue variant="body2">{adminEmail}</StyledValue>
</Column>
</Row>
</StatusContainer>
<Content>
{/* Top Row */}
<RowInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Cluster domain name</StyledLabel>
<StyledValue variant="body2">{domainName}</StyledValue>
</ColumnInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Alerts email</StyledLabel>
<StyledValue variant="body2">{adminEmail}</StyledValue>
</ColumnInfo>
</RowInfo>

{/* Second Row */}
<Row>
<Column>
<StyledLabel variant="labelLarge">Created</StyledLabel>
<StyledValue variant="body2">
{moment(new Date(creationDate as string)).format('DD MMM YYYY, HH:mm:ss')}
</StyledValue>
</Column>
<Column>
<StyledLabel variant="labelLarge">Created by</StyledLabel>
<StyledValue variant="body2">{gitUser}</StyledValue>
</Column>
</Row>
{/* Second Row */}
<RowInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Created</StyledLabel>
<StyledValue variant="body2">
{moment(new Date(creationDate as string)).format('DD MMM YYYY, HH:mm:ss')}
</StyledValue>
</ColumnInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Created by</StyledLabel>
<StyledValue variant="body2">{gitUser}</StyledValue>
</ColumnInfo>
</RowInfo>

{/* Third Row */}
<Row>
<Column>
<StyledLabel variant="labelLarge">GIT provider</StyledLabel>
<StyledValue variant="body2">{gitProvider}</StyledValue>
</Column>
<Column>
<StyledLabel variant="labelLarge">Cloud provider</StyledLabel>
<StyledValue variant="body2">{cloudProvider}</StyledValue>
</Column>
</Row>
{/* Third Row */}
<RowInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">GIT provider</StyledLabel>
<StyledValue variant="body2">{gitProvider}</StyledValue>
</ColumnInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Cloud provider</StyledLabel>
<StyledValue variant="body2">{cloudProvider}</StyledValue>
</ColumnInfo>
</RowInfo>

{/* Fourth Row */}
<Row>
<Column>
<StyledLabel variant="labelLarge">Cloud region</StyledLabel>
<StyledValue variant="body2">{cloudRegion}</StyledValue>
</Column>
<Column>
<StyledLabel variant="labelLarge">Number of nodes</StyledLabel>
<StyledValue variant="body2">{nodes}</StyledValue>
</Column>
</Row>
{/* Fourth Row */}
<RowInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Cloud region</StyledLabel>
<StyledValue variant="body2">{cloudRegion}</StyledValue>
</ColumnInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Number of nodes</StyledLabel>
<StyledValue variant="body2">{nodes}</StyledValue>
</ColumnInfo>
</RowInfo>

{/* Fifth Row */}
<Row>
<Column>
<StyledLabel variant="labelLarge">Instance size</StyledLabel>
<StyledValue variant="body2" style={{ width: '100%' }}>
{instanceSize}
</StyledValue>
</Column>
</Row>
</Content>
{/* Fifth Row */}
<RowInfo>
<ColumnInfo>
<StyledLabel variant="labelLarge">Instance size</StyledLabel>
<StyledValue variant="body2" style={{ width: '100%' }}>
{instanceSize}
</StyledValue>
</ColumnInfo>
</RowInfo>
</Content>
</>
);
};

Expand Down
78 changes: 4 additions & 74 deletions components/clusterTable/clusterTable.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,93 +1,23 @@
import { Meta, StoryObj } from '@storybook/react';

import { ClusterStatus, ClusterType } from '../../types/provision';
import { InstallationType } from '../../types/redux';
import { noop } from '../../utils/noop';
import { sortClustersByType } from '../../utils/sortClusterByType';
import { mapClusterFromRaw } from '../../utils/mapClustersFromRaw';
import { mockClusterResponse } from '../../tests/mocks/mockClusterResponse';

import { ClusterTable, ClusterInfo } from './clusterTable';
import { ClusterTable } from './clusterTable';

const clusters: ClusterInfo[] = [
{
clusterName: 'kuberfirst-mgmt',
type: ClusterType.MANAGEMENT,
cloudProvider: InstallationType.AWS,
cloudRegion: 'ap-southeast-1',
creationDate: '05 Apr 2023, 12:24:56',
gitUser: 'Eleanor Carroll',
status: ClusterStatus.PROVISIONED,
adminEmail: 'admin@mycompany.com',
gitProvider: 'Github',
domainName: 'yourdomain.com',
nodes: 2,
},
{
clusterName: 'kuberfirst-worker-1',
type: ClusterType.WORKLOAD,
cloudProvider: InstallationType.CIVO,
cloudRegion: 'ap-southeast-1',
nodes: 2,
creationDate: '05 Apr 2023, 12:24:56',
gitUser: 'Eleanor Carroll',
status: ClusterStatus.ERROR,
adminEmail: 'admin@mycompany.com',
gitProvider: 'Github',
domainName: 'yourdomain.com',
},
{
clusterName: 'kuberfirst-worker-2',
type: ClusterType.WORKLOAD,
cloudProvider: InstallationType.DIGITAL_OCEAN,
cloudRegion: 'ap-southeast-1',
nodes: 2,
creationDate: '05 Apr 2023, 12:24:56',
gitUser: 'Eleanor Carroll',
status: ClusterStatus.DELETING,
adminEmail: 'admin@mycompany.com',
gitProvider: 'Github',
domainName: 'yourdomain.com',
},
{
clusterName: 'kuberfirst-worker-3',
type: ClusterType.WORKLOAD,
cloudProvider: InstallationType.DIGITAL_OCEAN,
cloudRegion: 'ap-southeast-1',
nodes: 2,
creationDate: '05 Apr 2023, 12:24:56',
gitUser: 'Eleanor Carroll',
status: ClusterStatus.PROVISIONED,
adminEmail: 'admin@mycompany.com',
gitProvider: 'Github',
domainName: 'yourdomain.com',
},
{
clusterName: 'kuberfirst-worker-4',
type: ClusterType.WORKLOAD,
cloudProvider: InstallationType.VULTR,
cloudRegion: 'ap-southeast-1',
nodes: 2,
creationDate: '05 Apr 2023, 12:24:56',
gitUser: 'Eleanor Carroll',
status: ClusterStatus.PROVISIONED,
adminEmail: 'admin@mycompany.com',
gitProvider: 'Github',
domainName: 'yourdomain.com',
},
];
const managementCluster = mapClusterFromRaw(mockClusterResponse);

const meta: Meta<typeof ClusterTable> = {
component: ClusterTable,
};

export default meta;

const { managementCluster, workloadClusters } = sortClustersByType(clusters);

export const Default: StoryObj<typeof ClusterTable> = {
args: {
onMenuOpenClose: noop,
onDeleteCluster: noop,
managementCluster,
workloadClusters,
},
};
Loading