From 15436b33c3a6eb884ab46f69b4da420d7b861279 Mon Sep 17 00:00:00 2001 From: YanJin Date: Mon, 7 Dec 2020 14:51:33 +0100 Subject: [PATCH 01/19] ui/styles: Remove the breadcrumb in Create New Volume page We KILL breadcrumb! Refs: #2964 --- ui/src/containers/CreateVolume.js | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/ui/src/containers/CreateVolume.js b/ui/src/containers/CreateVolume.js index 0863a9be04..35621ef323 100644 --- a/ui/src/containers/CreateVolume.js +++ b/ui/src/containers/CreateVolume.js @@ -5,7 +5,7 @@ import { Formik, Form } from 'formik'; import * as yup from 'yup'; import styled from 'styled-components'; import Loader from '../components/Loader'; -import { Input, Button, Breadcrumb, Banner, Tooltip } from '@scality/core-ui'; +import { Input, Button, Banner, Tooltip, Checkbox } from '@scality/core-ui'; import isEmpty from 'lodash.isempty'; import { fetchStorageClassAction, @@ -18,11 +18,6 @@ import { fontWeight, } from '@scality/core-ui/dist/style/theme'; import { SPARSE_LOOP_DEVICE, RAW_BLOCK_DEVICE } from '../constants'; -import { - BreadcrumbContainer, - BreadcrumbLabel, - StyledLink, -} from '../components/BreadcrumbStyle'; import { sizeUnits, useQuery } from '../services/utils'; import { intl } from '../translations/IntlGlobalProvider'; @@ -159,7 +154,7 @@ const CreateVolume = (props) => { const nodes = useSelector((state) => state.app.nodes.list); const storageClass = useSelector((state) => state.app.volumes.storageClass); - const theme = useSelector((state) => state.config.theme); + const api = useSelector((state) => state.config.api); useEffect(() => { @@ -252,23 +247,7 @@ const CreateVolume = (props) => { ) : ( - - - {intl.translate('platform')} - , - - {intl.translate('volumes')} - , - - {intl.translate('create_new_volume')} - , - ]} - /> - - + Create New Volume {isStorageClassExist ? null : ( Date: Tue, 8 Dec 2020 11:26:26 +0100 Subject: [PATCH 02/19] ui/volumes: Set up the form of batch volume creation Refs: #2964 --- ui/src/containers/CreateVolume.js | 171 ++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) diff --git a/ui/src/containers/CreateVolume.js b/ui/src/containers/CreateVolume.js index 35621ef323..36280b3977 100644 --- a/ui/src/containers/CreateVolume.js +++ b/ui/src/containers/CreateVolume.js @@ -146,6 +146,48 @@ const DocumentationIcon = styled.div` } `; +const TitlePage = styled.div` + color: ${(props) => props.theme.brand.textPrimary}; + font-size: 24px; + padding-left: 40px; +`; + +const CheckboxContainer = styled.div` + padding: ${padding.base} 0 0 ${padding.small}; + .text { + font-size: ${fontSize.base}; + } +`; + +const InputNumberComponentStyle = styled.input` + width: 60px; + height: 25px; + border: solid 1px ${(props) => props.theme.brand.border}; + border-radius: 4px; + background-color: ${(props) => props.theme.brand.primary}; + color: ${(props) => props.theme.brand.textPrimary}; +`; + +const MultiCreationFormContainer = styled.div` + padding-left: ${padding.base}; + display: flex; + flex-direction: column; + color: ${(props) => props.theme.brand.textPrimary}; + font-size: ${fontSize.base}; +`; + +const SingleVolumeContainer = styled.div` + display: flex; + align-items: flex-start; + padding-top: ${padding.base}; +`; + +const SingleVolumeForm = styled.div` + display: flex; + flex-direction: column; + padding-left: ${padding.base}; +`; + const CreateVolume = (props) => { const dispatch = useDispatch(); const history = useHistory(); @@ -194,6 +236,17 @@ const CreateVolume = (props) => { selectedUnit: sizeUnits[3].value, sizeInput: '', labels: {}, + multiVolumeCreation: false, + // When the multi-volume creation mode is active, the default number is 1. + numberOfVolumes: 1, + // MultiVolumes should be the array of objects. + // For example: + // [ + // { name: "volume01'", devicePath: '/dev/sdb' }, + // { name: "volume02'", devicePath: '/dev/sdc' }, + // ... + // ]; + multiVolumes: [], }; const volumeNameRegex = /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/; @@ -348,6 +401,74 @@ const CreateVolume = (props) => { }; }); + const multiVolumeInputs = []; + for (let i = 0; i < values.numberOfVolumes; i++) { + multiVolumeInputs.push( + +
+ {i + 1}- +
+ + { + console.log('e', e); + }} + /> + {values.type === RAW_BLOCK_DEVICE ? ( + + ) : ( + + + + + intl.translate('no_results') + } + name="selectedUnit" + onChange={handleSelectChange('selectedUnit')} + value={getSelectedObjectItem( + optionsSizeUnits, + values?.selectedUnit, + )} + error={ + touched.selectedUnit && errors.selectedUnit + } + onBlur={handleOnBlur} + /> + + + )} + +
, + ); + } + return (
@@ -497,7 +618,57 @@ const CreateVolume = (props) => { onBlur={handleOnBlur} /> )} + + + + + {values.multiVolumeCreation === true && ( + + +
+ + Number of volume to create + + {/* TODO: Generalize the number input component to core-ui. */} + +
+
+ Name the Volumes and provide the Device paths. You may + use the defaults or override them. +
+ {multiVolumeInputs} +
+ } +
+ )}