2023-01-26 03:03:44 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
|
|
|
|
import { EnvironmentType } from '@/react/portainer/environments/types';
|
|
|
|
|
|
|
|
import { EditorType } from './types';
|
|
|
|
|
2023-01-30 21:03:21 +00:00
|
|
|
export function getValidEditorTypes(
|
|
|
|
endpointTypes: EnvironmentType[],
|
|
|
|
allowKubeToSelectCompose?: boolean
|
|
|
|
) {
|
2023-01-26 03:03:44 +00:00
|
|
|
const right: Partial<Record<EnvironmentType, EditorType[]>> = {
|
|
|
|
[EnvironmentType.EdgeAgentOnDocker]: [EditorType.Compose],
|
2023-01-30 21:03:21 +00:00
|
|
|
[EnvironmentType.EdgeAgentOnKubernetes]: allowKubeToSelectCompose
|
|
|
|
? [EditorType.Kubernetes, EditorType.Compose]
|
|
|
|
: [EditorType.Kubernetes],
|
2023-01-26 03:03:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return endpointTypes.length
|
|
|
|
? _.intersection(...endpointTypes.map((type) => right[type]))
|
|
|
|
: [EditorType.Compose, EditorType.Kubernetes];
|
|
|
|
}
|