1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

feat(edge/templates): introduce edge specific settings [EE-6276] (#10609)

This commit is contained in:
Chaim Lev-Ari 2023-11-15 14:43:18 +02:00 committed by GitHub
parent 68950fbb24
commit e43d076269
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 885 additions and 319 deletions

View file

@ -45,7 +45,7 @@ export function AuthFieldset({
label="Authentication"
labelClass="col-sm-3 col-lg-2"
name="authentication"
checked={value.RepositoryAuthentication}
checked={value.RepositoryAuthentication || false}
onChange={(value) =>
handleChange({ RepositoryAuthentication: value })
}

View file

@ -113,7 +113,7 @@ export function GitForm({
<div className="col-sm-12">
<SwitchField
label="Skip TLS Verification"
checked={value.TLSSkipVerify}
checked={value.TLSSkipVerify || false}
onChange={(value) => handleChange({ TLSSkipVerify: value })}
name="TLSSkipVerify"
tooltip="Enabling this will allow skipping TLS validation for any self-signed certificate."

View file

@ -1,9 +1,6 @@
import { useCallback } from 'react';
import {
GitFormModel,
RelativePathModel,
} from '@/react/portainer/gitops/types';
import { GitFormModel } from '@/react/portainer/gitops/types';
import { PathSelector } from '@/react/portainer/gitops/ComposePathField/PathSelector';
import { dummyGitForm } from '@/react/portainer/gitops/RelativePathFieldset/utils';
import { useValidation } from '@/react/portainer/gitops/RelativePathFieldset/useValidation';
@ -13,6 +10,8 @@ import { TextTip } from '@@/Tip/TextTip';
import { FormControl } from '@@/form-components/FormControl';
import { Input, Select } from '@@/form-components/Input';
import { RelativePathModel, getPerDevConfigsFilterType } from './types';
interface Props {
value: RelativePathModel;
gitModel?: GitFormModel;
@ -156,7 +155,9 @@ export function RelativePathFieldset({
value={value.PerDeviceConfigsMatchType}
onChange={(e) =>
innerOnChange({
PerDeviceConfigsMatchType: e.target.value,
PerDeviceConfigsMatchType: getPerDevConfigsFilterType(
e.target.value
),
})
}
options={[
@ -186,7 +187,8 @@ export function RelativePathFieldset({
value={value.PerDeviceConfigsGroupMatchType}
onChange={(e) =>
innerOnChange({
PerDeviceConfigsGroupMatchType: e.target.value,
PerDeviceConfigsGroupMatchType:
getPerDevConfigsFilterType(e.target.value),
})
}
options={[

View file

@ -0,0 +1,37 @@
export function getDefaultRelativePathModel(): RelativePathModel {
return {
SupportRelativePath: false,
FilesystemPath: '',
PerDeviceConfigsGroupMatchType: '',
PerDeviceConfigsMatchType: '',
PerDeviceConfigsPath: '',
SupportPerDeviceConfigs: false,
};
}
export interface RelativePathModel {
SupportRelativePath: boolean;
FilesystemPath: string;
SupportPerDeviceConfigs: boolean;
PerDeviceConfigsPath: string;
PerDeviceConfigsMatchType: PerDevConfigsFilterType;
PerDeviceConfigsGroupMatchType: PerDevConfigsFilterType;
}
export type PerDevConfigsFilterType = 'file' | 'dir' | '';
function isPerDevConfigsFilterType(
type: string
): type is PerDevConfigsFilterType {
return ['file', 'dir'].includes(type);
}
export function getPerDevConfigsFilterType(
type: string
): PerDevConfigsFilterType {
if (isPerDevConfigsFilterType(type)) {
return type;
}
return '';
}

View file

@ -1,6 +1,6 @@
import { boolean, object, SchemaOf, string } from 'yup';
import { boolean, mixed, object, SchemaOf, string } from 'yup';
import { RelativePathModel } from '@/react/portainer/gitops/types';
import { PerDevConfigsFilterType, RelativePathModel } from './types';
export function relativePathValidation(): SchemaOf<RelativePathModel> {
return object({
@ -18,7 +18,11 @@ export function relativePathValidation(): SchemaOf<RelativePathModel> {
then: string().required('Directory is required'),
})
.default(''),
PerDeviceConfigsMatchType: string().oneOf(['', 'file', 'dir']),
PerDeviceConfigsGroupMatchType: string().oneOf(['', 'file', 'dir']),
PerDeviceConfigsMatchType: mixed<PerDevConfigsFilterType>()
.oneOf(['', 'file', 'dir'])
.default(''),
PerDeviceConfigsGroupMatchType: mixed<PerDevConfigsFilterType>()
.oneOf(['', 'file', 'dir'])
.default(''),
});
}

View file

@ -1,4 +1,6 @@
export type AutoUpdateMechanism = 'Webhook' | 'Interval';
export { type RelativePathModel } from './RelativePathFieldset/types';
export interface AutoUpdateResponse {
/* Auto update interval */
Interval: string;
@ -37,7 +39,7 @@ export type AutoUpdateModel = {
};
export type GitCredentialsModel = {
RepositoryAuthentication: boolean;
RepositoryAuthentication?: boolean;
RepositoryUsername?: string;
RepositoryPassword?: string;
RepositoryGitCredentialID?: number;
@ -54,13 +56,12 @@ export interface GitFormModel extends GitAuthModel {
RepositoryURL: string;
RepositoryURLValid?: boolean;
ComposeFilePathInRepository: string;
RepositoryAuthentication: boolean;
RepositoryReferenceName?: string;
AdditionalFiles?: string[];
SaveCredential?: boolean;
NewCredentialName?: string;
TLSSkipVerify: boolean;
TLSSkipVerify?: boolean;
/**
* Auto update
@ -70,15 +71,6 @@ export interface GitFormModel extends GitAuthModel {
AutoUpdate?: AutoUpdateModel;
}
export interface RelativePathModel {
SupportRelativePath: boolean;
FilesystemPath?: string;
SupportPerDeviceConfigs?: boolean;
PerDeviceConfigsPath?: string;
PerDeviceConfigsMatchType?: string;
PerDeviceConfigsGroupMatchType?: string;
}
export function toGitFormModel(response?: RepoConfigResponse): GitFormModel {
if (!response) {
return {