mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
fix(app): various persisted folder fixes [EE-6235] (#10963)
Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
7a04d1d4ea
commit
95474b7dc5
9 changed files with 84 additions and 78 deletions
|
@ -16,7 +16,7 @@ import { ApplicationFormValues } from '../../types';
|
|||
import { ExistingVolume, PersistedFolderFormValue } from './types';
|
||||
|
||||
type Props = {
|
||||
initialValues: PersistedFolderFormValue[];
|
||||
initialValues?: PersistedFolderFormValue[];
|
||||
item: PersistedFolderFormValue;
|
||||
onChange: (value: PersistedFolderFormValue) => void;
|
||||
error: ItemError<PersistedFolderFormValue>;
|
||||
|
@ -220,7 +220,6 @@ export function PersistedFolderItem({
|
|||
function isToggleVolumeTypeVisible() {
|
||||
return (
|
||||
!(isEdit && isExistingPersistedFolder()) && // if it's not an edit of an existing persisted folder
|
||||
applicationValues.ApplicationType !== 'StatefulSet' && // and if it's not a statefulset
|
||||
applicationValues.Containers.length <= 1 // and if there is only one container);
|
||||
);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,10 @@ export function PersistedFoldersFormSection({
|
|||
value={values}
|
||||
onChange={onChange}
|
||||
errors={errors}
|
||||
isDeleteButtonHidden={isDeleteButtonHidden()}
|
||||
isDeleteButtonHidden={
|
||||
isEdit && applicationValues.ApplicationType === 'StatefulSet'
|
||||
}
|
||||
canUndoDelete={isEdit}
|
||||
deleteButtonDataCy="k8sAppCreate-persistentFolderRemoveButton"
|
||||
addButtonDataCy="k8sAppCreate-persistentFolderAddButton"
|
||||
disabled={storageClasses.length === 0}
|
||||
|
@ -77,33 +80,20 @@ export function PersistedFoldersFormSection({
|
|||
initialValues={initialValues}
|
||||
/>
|
||||
)}
|
||||
itemBuilder={() => {
|
||||
const newVolumeClaimName = `${applicationValues.Name}-${uuidv4()}`;
|
||||
return {
|
||||
persistentVolumeClaimName:
|
||||
availableVolumes[0]?.PersistentVolumeClaim.Name ||
|
||||
newVolumeClaimName,
|
||||
containerPath: '',
|
||||
size: '',
|
||||
sizeUnit: 'GB',
|
||||
storageClass: storageClasses[0],
|
||||
useNewVolume: true,
|
||||
existingVolume: undefined,
|
||||
needsDeletion: false,
|
||||
};
|
||||
}}
|
||||
itemBuilder={() => ({
|
||||
persistentVolumeClaimName: getNewPVCName(applicationValues.Name),
|
||||
containerPath: '',
|
||||
size: '',
|
||||
sizeUnit: 'GB',
|
||||
storageClass: storageClasses[0],
|
||||
useNewVolume: true,
|
||||
existingVolume: undefined,
|
||||
needsDeletion: false,
|
||||
})}
|
||||
addLabel="Add persisted folder"
|
||||
canUndoDelete={isEdit}
|
||||
/>
|
||||
</FormSection>
|
||||
);
|
||||
|
||||
function isDeleteButtonHidden() {
|
||||
return (
|
||||
(isEdit && applicationValues.ApplicationType === 'StatefulSet') ||
|
||||
applicationValues.Containers.length >= 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function usePVCOptions(existingPVCs: ExistingVolume[]): Option<string>[] {
|
||||
|
@ -123,3 +113,10 @@ function getAddButtonError(storageClasses: StorageClass[]) {
|
|||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function getNewPVCName(applicationName: string) {
|
||||
const name = `${applicationName}-${uuidv4()}`;
|
||||
// limit it to 63 characters to avoid exceeding the limit for the volume name
|
||||
const nameLimited = name.length > 63 ? name.substring(0, 63) : name;
|
||||
return nameLimited;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue