Skip to content

Commit

Permalink
Merge pull request #1619 from bipuladh/ibm-flash
Browse files Browse the repository at this point in the history
Adds support for new volume modes in IBM flashsystem
  • Loading branch information
openshift-merge-bot[bot] authored Oct 9, 2024
2 parents 5bdfa87 + 74a0345 commit 27fb46e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
6 changes: 6 additions & 0 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"Status": "Status",
"Storage Client": "Storage Client",
"Overview": "Overview",
"Thick": "Thick",
"Thin": "Thin",
"Compressed": "Compressed",
"Deduplicated": "Deduplicated",
"Deduplicated thin": "Deduplicated thin",
"Deduplicated compressed": "Deduplicated compressed",
"IP address": "IP address",
"Rest API IP address of IBM FlashSystem.": "Rest API IP address of IBM FlashSystem.",
"Username": "Username",
Expand Down
35 changes: 30 additions & 5 deletions packages/ibm/system-connection-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { getAPIVersionForModel, isValidIP } from '@odf/shared/utils';
import { k8sGet } from '@openshift-console/dynamic-plugin-sdk';
import { Select, SelectOption } from '@patternfly/react-core/deprecated';
import { TFunction } from 'i18next';
import * as _ from 'lodash-es';
import * as Yup from 'yup';
import {
FormGroup,
Expand All @@ -34,7 +36,26 @@ import {
getFlashSystemSecretName,
} from './utils';

const VOLUME_MODES = ['thick', 'thin'];
const VOLUME_MODES_VALUES = [
'thick',
'thin',
'compressed',
'deduplicated',
'dedup_thin',
'dedup_compressed',
];

const VOLUME_MODES_TEXT = (t: TFunction) => [
t('Thick'),
t('Thin'),
t('Compressed'),
t('Deduplicated'),
t('Deduplicated thin'),
t('Deduplicated compressed'),
];

const volumeModeObject = (t: TFunction) =>
_.zipObject(VOLUME_MODES_TEXT(t), VOLUME_MODES_VALUES);

export const FlashSystemConnectionDetails: React.FC<
ExternalComponentProps<FlashSystemState>
Expand All @@ -45,9 +66,13 @@ export const FlashSystemConnectionDetails: React.FC<

const onToggle = () => setIsOpen(!isOpen);

const volumeMapper = volumeModeObject(t);
const inverseVolumeMapper = _.invert(volumeMapper);

const onModeSelect = (event, value) => {
event.preventDefault();
setFormState('volmode', value);
const volumeMode = volumeMapper[value];
setFormState('volmode', volumeMode);
setIsOpen(!isOpen);
};

Expand Down Expand Up @@ -160,13 +185,13 @@ export const FlashSystemConnectionDetails: React.FC<
<Select
onSelect={onModeSelect}
id="volume-mode-input"
selections={formState.volmode}
selections={inverseVolumeMapper[formState.volmode]}
onToggle={onToggle}
isOpen={isOpen}
isDisabled={false}
placeholderText={VOLUME_MODES[0]}
placeholderText={Object.keys(volumeMapper)[0]}
>
{VOLUME_MODES.map((mode) => (
{Object.keys(volumeMapper).map((mode) => (
<SelectOption key={mode} value={mode} />
))}
</Select>
Expand Down

0 comments on commit 27fb46e

Please sign in to comment.