Quellcode durchsuchen

Fix mapping screens and embedded required layouts

Fixes storage and network mapping screen layout issues when using long
instances name.

Fixes embedded required field symbol layout (embedded fields are the
ones rendered inside properties table for object type fields).
Sergiu Miclea vor 6 Jahren
Ursprung
Commit
ff1cb81687

+ 3 - 3
src/components/atoms/TextInput/TextInput.jsx

@@ -30,7 +30,7 @@ const Required = styled.div`
   position: absolute;
   position: absolute;
   width: 8px;
   width: 8px;
   height: 8px;
   height: 8px;
-  right: -16px;
+  right: ${props => props.right}px;
   top: 12px;
   top: 12px;
   background: url('${requiredImage}') center no-repeat;
   background: url('${requiredImage}') center no-repeat;
 `
 `
@@ -107,7 +107,7 @@ type Props = {
   disabledLoading?: boolean,
   disabledLoading?: boolean,
 }
 }
 const TextInput = (props: Props) => {
 const TextInput = (props: Props) => {
-  const { _ref, value, onChange, showClose, onCloseClick, disabled, disabledLoading } = props
+  const { _ref, value, onChange, showClose, onCloseClick, disabled, disabledLoading, embedded } = props
   let actualDisabled = disabled || disabledLoading
   let actualDisabled = disabled || disabledLoading
   let input
   let input
   return (
   return (
@@ -121,7 +121,7 @@ const TextInput = (props: Props) => {
         {...props}
         {...props}
         disabled={actualDisabled}
         disabled={actualDisabled}
       />
       />
-      {props.required ? <Required /> : null}
+      {props.required ? <Required right={embedded ? -24 : -16} /> : null}
       <Close
       <Close
         data-test-id="textInput-close"
         data-test-id="textInput-close"
         show={showClose && value !== '' && value !== undefined}
         show={showClose && value !== '' && value !== undefined}

+ 2 - 2
src/components/molecules/AutocompleteDropdown/AutocompleteDropdown.jsx

@@ -49,7 +49,7 @@ const Required = styled.div`
   position: absolute;
   position: absolute;
   width: 8px;
   width: 8px;
   height: 8px;
   height: 8px;
-  right: -16px;
+  right: ${props => props.right}px;
   top: 12px;
   top: 12px;
   background: url('${requiredImage}') center no-repeat;
   background: url('${requiredImage}') center no-repeat;
 `
 `
@@ -455,7 +455,7 @@ class AutocompleteDropdown extends React.Component<Props, State> {
           disabledLoading={this.props.disabledLoading}
           disabledLoading={this.props.disabledLoading}
           embedded={this.props.embedded}
           embedded={this.props.embedded}
         />
         />
-        {this.props.required ? <Required /> : null}
+        {this.props.required ? <Required right={this.props.embedded ? -24 : -16} /> : null}
         {this.renderList()}
         {this.renderList()}
       </Wrapper>
       </Wrapper>
     )
     )

+ 5 - 0
src/components/molecules/AutocompleteDropdown/story.jsx

@@ -60,6 +60,7 @@ type State = {
 }
 }
 type Props = {
 type Props = {
   items: { value: string, label: string }[],
   items: { value: string, label: string }[],
+  required?: boolean,
 }
 }
 class Wrapper extends React.Component<Props, State> {
 class Wrapper extends React.Component<Props, State> {
   state = {
   state = {
@@ -72,6 +73,7 @@ class Wrapper extends React.Component<Props, State> {
         items={this.props.items}
         items={this.props.items}
         selectedItem={this.state.selectedItem}
         selectedItem={this.state.selectedItem}
         onChange={selectedItem => { this.setState({ selectedItem }) }}
         onChange={selectedItem => { this.setState({ selectedItem }) }}
+        required={this.props.required}
         onInputChange={(value, filteredItems) => {
         onInputChange={(value, filteredItems) => {
           if (filteredItems.length === 0) {
           if (filteredItems.length === 0) {
             console.log('input value', value)
             console.log('input value', value)
@@ -89,3 +91,6 @@ storiesOf('AutocompleteDropdown', module)
   .add('short list', () => (
   .add('short list', () => (
     <Wrapper items={itemsShort} />
     <Wrapper items={itemsShort} />
   ))
   ))
+  .add('required', () => (
+    <Wrapper items={itemsShort} required />
+  ))

+ 7 - 2
src/components/molecules/Dropdown/Dropdown.jsx

@@ -45,7 +45,7 @@ const Required = styled.div`
   position: absolute;
   position: absolute;
   width: 8px;
   width: 8px;
   height: 8px;
   height: 8px;
-  right: -16px;
+  right: ${props => props.right}px;
   top: 12px;
   top: 12px;
   background: url('${requiredImage}') center no-repeat;
   background: url('${requiredImage}') center no-repeat;
   ${props => props.disabledLoading ? StyleProps.animations.disabledLoading : ''}
   ${props => props.disabledLoading ? StyleProps.animations.disabledLoading : ''}
@@ -503,7 +503,12 @@ class Dropdown extends React.Component<Props, State> {
           value={buttonValue()}
           value={buttonValue()}
           onClick={() => this.handleButtonClick()}
           onClick={() => this.handleButtonClick()}
         />
         />
-        {this.props.required ? <Required disabledLoading={this.props.disabledLoading} /> : null}
+        {this.props.required ? (
+          <Required
+            disabledLoading={this.props.disabledLoading}
+            right={this.props.embedded ? -24 : -16}
+          />
+        ) : null}
         {this.renderList()}
         {this.renderList()}
       </Wrapper>
       </Wrapper>
     )
     )

+ 4 - 0
src/components/molecules/Dropdown/story.jsx

@@ -82,6 +82,7 @@ class MultipleSelectionWrapper extends React.Component<Props, State> {
           }
           }
         }}
         }}
         items={this.props.items}
         items={this.props.items}
+        {...this.props}
       />
       />
     )
     )
   }
   }
@@ -92,6 +93,9 @@ storiesOf('Dropdown', module)
   .add('default', () => (
   .add('default', () => (
     <Wrapper />
     <Wrapper />
   ))
   ))
+  .add('required', () => (
+    <Wrapper required />
+  ))
   .add('disabled', () => (
   .add('disabled', () => (
     <Wrapper disabled />
     <Wrapper disabled />
   ))
   ))

+ 2 - 1
src/components/molecules/PropertiesTable/story.jsx

@@ -23,7 +23,8 @@ let properties = [
   { type: 'strict-boolean', name: 'prop-2', label: 'Strict Boolean' },
   { type: 'strict-boolean', name: 'prop-2', label: 'Strict Boolean' },
   { type: 'string', name: 'prop-3', label: 'String' },
   { type: 'string', name: 'prop-3', label: 'String' },
   { type: 'string', name: 'prop-3a', label: 'String', required: true },
   { type: 'string', name: 'prop-3a', label: 'String', required: true },
-  { type: 'string', enum: ['a', 'b', 'c'], name: 'prop-4', label: 'String enum' },
+  { type: 'string', enum: ['a', 'b', 'c'], name: 'prop-4', label: 'String enum', required: true },
+  { type: 'string', enum: ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a'], name: 'prop-5', label: 'String enum', required: true },
 ]
 ]
 
 
 class Wrapper extends React.Component<any, any> {
 class Wrapper extends React.Component<any, any> {

+ 2 - 0
src/components/organisms/EditReplica/EditReplica.jsx

@@ -505,6 +505,7 @@ class EditReplica extends React.Component<Props, State> {
         storageMap={this.getStorageMap(endpointStore.storageBackends)}
         storageMap={this.getStorageMap(endpointStore.storageBackends)}
         onChange={(s, t, type) => { this.handleStorageChange(s, t, type) }}
         onChange={(s, t, type) => { this.handleStorageChange(s, t, type) }}
         style={{ padding: '32px 32px 0 32px', width: 'calc(100% - 64px)' }}
         style={{ padding: '32px 32px 0 32px', width: 'calc(100% - 64px)' }}
+        titleWidth={160}
       />
       />
     )
     )
   }
   }
@@ -519,6 +520,7 @@ class EditReplica extends React.Component<Props, State> {
         onChange={(nic, network, secGroups) => { this.handleNetworkChange(nic, network, secGroups) }}
         onChange={(nic, network, secGroups) => { this.handleNetworkChange(nic, network, secGroups) }}
         selectedNetworks={this.getSelectedNetworks()}
         selectedNetworks={this.getSelectedNetworks()}
         style={{ padding: '32px 32px 0 32px', width: 'calc(100% - 64px)' }}
         style={{ padding: '32px 32px 0 32px', width: 'calc(100% - 64px)' }}
+        titleWidth={160}
       />
       />
     )
     )
   }
   }

+ 4 - 2
src/components/organisms/WizardNetworks/WizardNetworks.jsx

@@ -67,7 +67,7 @@ const NetworkImage = styled.div`
   margin-right: 16px;
   margin-right: 16px;
 `
 `
 const NetworkTitle = styled.div`
 const NetworkTitle = styled.div`
-  width: 320px;
+  width: ${props => props.width}px;
 `
 `
 const NetworkName = styled.div`
 const NetworkName = styled.div`
   font-size: 16px;
   font-size: 16px;
@@ -76,6 +76,7 @@ const NetworkSubtitle = styled.div`
   font-size: 12px;
   font-size: 12px;
   color: ${Palette.grayscale[5]};
   color: ${Palette.grayscale[5]};
   margin-top: 1px;
   margin-top: 1px;
+  word-break: break-word;
 `
 `
 const ArrowImage = styled.div`
 const ArrowImage = styled.div`
   min-width: 32px;
   min-width: 32px;
@@ -121,6 +122,7 @@ type Props = {
   selectedNetworks: ?NetworkMap[],
   selectedNetworks: ?NetworkMap[],
   onChange: (nic: NicType, network: Network, securityGroups?: SecurityGroup[]) => void,
   onChange: (nic: NicType, network: Network, securityGroups?: SecurityGroup[]) => void,
   style?: any,
   style?: any,
+  titleWidth?: number,
 }
 }
 @observer
 @observer
 class WizardNetworks extends React.Component<Props> {
 class WizardNetworks extends React.Component<Props> {
@@ -254,7 +256,7 @@ class WizardNetworks extends React.Component<Props> {
           return (
           return (
             <Nic key={nic.id} data-test-id="networkItem">
             <Nic key={nic.id} data-test-id="networkItem">
               <NetworkImage />
               <NetworkImage />
-              <NetworkTitle>
+              <NetworkTitle width={this.props.titleWidth || 320}>
                 <NetworkName data-test-id={`wNetworks-networkName-${nic.id}`}>{nic.network_name}</NetworkName>
                 <NetworkName data-test-id={`wNetworks-networkName-${nic.id}`}>{nic.network_name}</NetworkName>
                 {connectedTo.length ? (
                 {connectedTo.length ? (
                   <NetworkSubtitle data-test-id={`wNetworks-connectedTo-${nic.id}`}>
                   <NetworkSubtitle data-test-id={`wNetworks-connectedTo-${nic.id}`}>

+ 4 - 2
src/components/organisms/WizardStorage/WizardStorage.jsx

@@ -79,7 +79,7 @@ const StorageImage = styled.div`
   margin-right: 16px;
   margin-right: 16px;
 `
 `
 const StorageTitle = styled.div`
 const StorageTitle = styled.div`
-  width: 320px;
+  width: ${props => props.width}px;
 `
 `
 const StorageName = styled.div`
 const StorageName = styled.div`
   font-size: 16px;
   font-size: 16px;
@@ -89,6 +89,7 @@ const StorageSubtitle = styled.div`
   font-size: 12px;
   font-size: 12px;
   color: ${Palette.grayscale[5]};
   color: ${Palette.grayscale[5]};
   margin-top: 1px;
   margin-top: 1px;
+  word-break: break-word;
 `
 `
 const ArrowImage = styled.div`
 const ArrowImage = styled.div`
   min-width: 32px;
   min-width: 32px;
@@ -147,6 +148,7 @@ export type Props = {
   storageMap: ?StorageMap[],
   storageMap: ?StorageMap[],
   onChange: (sourceStorage: Disk, targetStorage: StorageBackend, type: 'backend' | 'disk') => void,
   onChange: (sourceStorage: Disk, targetStorage: StorageBackend, type: 'backend' | 'disk') => void,
   style?: any,
   style?: any,
+  titleWidth?: number,
 }
 }
 @observer
 @observer
 class WizardStorage extends React.Component<Props> {
 class WizardStorage extends React.Component<Props> {
@@ -203,7 +205,7 @@ class WizardStorage extends React.Component<Props> {
             return (
             return (
               <StorageItem key={disk[diskFieldName]}>
               <StorageItem key={disk[diskFieldName]}>
                 <StorageImage backend={type === 'backend'} />
                 <StorageImage backend={type === 'backend'} />
-                <StorageTitle>
+                <StorageTitle width={this.props.titleWidth || 320}>
                   <StorageName
                   <StorageName
                     data-test-id={`${TEST_ID}-${type}-source`}
                     data-test-id={`${TEST_ID}-${type}-source`}
                     title={diskNameParsed[1] ? disk[diskFieldName] : null}
                     title={diskNameParsed[1] ? disk[diskFieldName] : null}