Skip to content

Commit

Permalink
Bug 1866114: Don't store OpenAPI definitions in localStorage
Browse files Browse the repository at this point in the history
The document is too large, so we hit browser limits for localStorage.
This can break Safari. Since the API server supports ETags for the
OpenAPI document, rely on browser caching instead.
  • Loading branch information
spadgett authored and yaacov committed Aug 9, 2020
1 parent c084c58 commit a4d11d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type K8sResourceSelectProps = {
title?: string;
validation?: ValidationObject;
filter?: (obj: K8sResourceKind) => boolean;
getResourceLabel?: (resource: K8sResourceKind) => string;
};

export const K8sResourceSelectRow: React.FC<K8sResourceSelectProps> = ({
Expand All @@ -36,6 +37,7 @@ export const K8sResourceSelectRow: React.FC<K8sResourceSelectProps> = ({
title,
validation,
filter,
getResourceLabel,
}) => {
const isLoading = !isLoaded(data);
const loadError = getLoadError(data, model);
Expand Down Expand Up @@ -84,7 +86,11 @@ export const K8sResourceSelectRow: React.FC<K8sResourceSelectProps> = ({
)}
{ignoreCaseSort(loadedData, ['metadata', 'name']).map((entity) => {
const selectName = getName(entity);
return <FormSelectOption key={selectName} value={selectName} label={selectName} />;
const label = getResourceLabel && getResourceLabel(entity);

return (
<FormSelectOption key={selectName} value={selectName} label={label || selectName} />
);
})}
</FormSelect>
</FormRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
PersistentVolumeClaimModel,
StorageClassModel,
} from '@console/internal/models';
import { getName } from '@console/shared/src';
import { getName, getAnnotations } from '@console/shared/src';
import { getLoadedData, isLoaded, prefixedID, resolveDataVolumeName } from '../../../utils';
import { validateDisk } from '../../../utils/validations/vm';
import { isValidationError } from '../../../utils/validations/common';
Expand Down Expand Up @@ -47,6 +47,7 @@ import { DiskWrapper } from '../../../k8s/wrapper/vm/disk-wrapper';
import { DataVolumeWrapper } from '../../../k8s/wrapper/vm/data-volume-wrapper';
import { VolumeWrapper } from '../../../k8s/wrapper/vm/volume-wrapper';
import { AccessMode, DiskBus, DiskType, VolumeMode } from '../../../constants/vm/storage';
import { DEFAULT_SC_ANNOTATION } from '../../../constants/sc';
import { getPvcStorageSize } from '../../../selectors/pvc/selectors';
import { K8sResourceSelectRow } from '../../form/k8s-resource-select-row';
import { SizeUnitFormRow } from '../../form/size-unit-form-row';
Expand Down Expand Up @@ -548,6 +549,11 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => {
model={StorageClassModel}
hasPlaceholder
onChange={(sc) => onStorageClassNameChanged(sc || '')}
getResourceLabel={(sc) =>
getAnnotations(sc, {})[DEFAULT_SC_ANNOTATION] === 'true'
? `${getName(sc)} (default)`
: getName(sc)
}
/>
)}
{isPlainDataVolume && (
Expand Down

0 comments on commit a4d11d8

Please sign in to comment.