2023-02-07 03:33:57 +00:00
|
|
|
import { Box, Boxes } from 'lucide-react';
|
|
|
|
|
|
|
|
import { BoxSelector, BoxSelectorOption } from '@@/BoxSelector';
|
|
|
|
|
2024-01-05 02:42:36 +00:00
|
|
|
import { AppDataAccessPolicy } from '../types';
|
|
|
|
|
2023-02-07 03:33:57 +00:00
|
|
|
interface Props {
|
|
|
|
isEdit: boolean;
|
|
|
|
persistedFoldersUseExistingVolumes: boolean;
|
2024-01-05 02:42:36 +00:00
|
|
|
value: AppDataAccessPolicy;
|
|
|
|
onChange(value: AppDataAccessPolicy): void;
|
2023-02-07 03:33:57 +00:00
|
|
|
}
|
|
|
|
|
2024-01-02 20:46:26 +00:00
|
|
|
export function DataAccessPolicyFormSection({
|
2023-02-07 03:33:57 +00:00
|
|
|
isEdit,
|
|
|
|
persistedFoldersUseExistingVolumes,
|
|
|
|
value,
|
|
|
|
onChange,
|
|
|
|
}: Props) {
|
|
|
|
const options = getOptions(value, isEdit, persistedFoldersUseExistingVolumes);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BoxSelector
|
|
|
|
slim
|
|
|
|
options={options}
|
|
|
|
value={value}
|
|
|
|
onChange={onChange}
|
|
|
|
radioName="data_access_policy"
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getOptions(
|
2024-01-05 02:42:36 +00:00
|
|
|
value: AppDataAccessPolicy,
|
2023-02-07 03:33:57 +00:00
|
|
|
isEdit: boolean,
|
|
|
|
persistedFoldersUseExistingVolumes: boolean
|
2024-01-05 02:42:36 +00:00
|
|
|
): ReadonlyArray<BoxSelectorOption<AppDataAccessPolicy>> {
|
2023-02-07 03:33:57 +00:00
|
|
|
return [
|
|
|
|
{
|
2024-01-05 02:42:36 +00:00
|
|
|
value: 'Isolated',
|
2023-02-07 03:33:57 +00:00
|
|
|
id: 'data_access_isolated',
|
|
|
|
icon: Boxes,
|
|
|
|
iconType: 'badge',
|
|
|
|
label: 'Isolated',
|
|
|
|
description:
|
|
|
|
'Application will be deployed as a StatefulSet with each instantiating their own data',
|
|
|
|
tooltip: () =>
|
|
|
|
isEdit || persistedFoldersUseExistingVolumes
|
|
|
|
? 'Changing the data access policy is not allowed'
|
|
|
|
: '',
|
|
|
|
disabled: () =>
|
2024-01-05 02:42:36 +00:00
|
|
|
(isEdit && value !== 'Isolated') || persistedFoldersUseExistingVolumes,
|
2023-02-07 03:33:57 +00:00
|
|
|
},
|
|
|
|
{
|
2024-01-05 02:42:36 +00:00
|
|
|
value: 'Shared',
|
2023-02-07 03:33:57 +00:00
|
|
|
id: 'data_access_shared',
|
|
|
|
icon: Box,
|
|
|
|
iconType: 'badge',
|
|
|
|
label: 'Shared',
|
|
|
|
description:
|
|
|
|
'Application will be deployed as a Deployment with a shared storage access',
|
2024-01-16 19:31:22 +00:00
|
|
|
tooltip: () => {
|
|
|
|
if (persistedFoldersUseExistingVolumes) {
|
|
|
|
return 'Changing the data access policy is not allowed';
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
disabled: () => persistedFoldersUseExistingVolumes,
|
2023-02-07 03:33:57 +00:00
|
|
|
},
|
|
|
|
] as const;
|
|
|
|
}
|