mirror of
https://github.com/portainer/portainer.git
synced 2025-08-07 14:55:27 +02:00
chore(template/git): sync frontend code from ee (#11344)
This commit is contained in:
parent
73307e164b
commit
bb02c69d14
19 changed files with 77 additions and 16 deletions
|
@ -65,7 +65,7 @@ export default class GitFormAuthFieldsetController {
|
|||
);
|
||||
|
||||
this.errors = await validateForm<GitAuthModel>(
|
||||
() => gitAuthValidation(this.gitCredentials, isAuthEdit),
|
||||
() => gitAuthValidation(this.gitCredentials, isAuthEdit, false),
|
||||
value
|
||||
);
|
||||
if (this.errors && Object.keys(this.errors).length > 0) {
|
||||
|
|
|
@ -24,6 +24,8 @@ export default class GitFormController {
|
|||
|
||||
onChange?: (value: GitFormModel) => void;
|
||||
|
||||
createdFromCustomTemplateId?: number;
|
||||
|
||||
/* @ngInject */
|
||||
constructor(
|
||||
$async: <T>(fn: () => Promise<T>) => Promise<T>,
|
||||
|
@ -47,15 +49,26 @@ export default class GitFormController {
|
|||
...newValues,
|
||||
};
|
||||
this.onChange?.(value);
|
||||
await this.runGitFormValidation(value);
|
||||
|
||||
const isCreatedFromCustomTemplate =
|
||||
!!this.createdFromCustomTemplateId &&
|
||||
this.createdFromCustomTemplateId > 0;
|
||||
await this.runGitFormValidation(value, isCreatedFromCustomTemplate);
|
||||
}
|
||||
|
||||
async runGitFormValidation(value: GitFormModel) {
|
||||
async runGitFormValidation(
|
||||
value: GitFormModel,
|
||||
isCreatedFromCustomTemplate: boolean
|
||||
) {
|
||||
return this.$async(async () => {
|
||||
this.errors = {};
|
||||
this.gitForm?.$setValidity('gitForm', true, this.gitForm);
|
||||
|
||||
this.errors = await validateGitForm(this.gitCredentials, value);
|
||||
this.errors = await validateGitForm(
|
||||
this.gitCredentials,
|
||||
value,
|
||||
isCreatedFromCustomTemplate
|
||||
);
|
||||
if (this.errors && Object.keys(this.errors).length > 0) {
|
||||
this.gitForm?.$setValidity('gitForm', false, this.gitForm);
|
||||
}
|
||||
|
@ -82,6 +95,9 @@ export default class GitFormController {
|
|||
throw new Error('GitFormController: value is required');
|
||||
}
|
||||
|
||||
await this.runGitFormValidation(this.value);
|
||||
const isCreatedFromCustomTemplate =
|
||||
!!this.createdFromCustomTemplateId &&
|
||||
this.createdFromCustomTemplateId > 0;
|
||||
await this.runGitFormValidation(this.value, isCreatedFromCustomTemplate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ export const gitForm: IComponentOptions = {
|
|||
base-webhook-url="$ctrl.baseWebhookUrl"
|
||||
webhook-id="$ctrl.webhookId"
|
||||
webhooks-docs="$ctrl.webhooksDocs"
|
||||
created-from-custom-template-id="$ctrl.createdFromCustomTemplateId"
|
||||
errors="$ctrl.errors">
|
||||
</react-git-form>
|
||||
</ng-form>`,
|
||||
|
@ -32,6 +33,7 @@ export const gitForm: IComponentOptions = {
|
|||
isAuthExplanationVisible: '<',
|
||||
webhookId: '@',
|
||||
webhooksDocs: '@',
|
||||
createdFromCustomTemplateId: '<',
|
||||
},
|
||||
controller,
|
||||
};
|
||||
|
|
|
@ -28,6 +28,7 @@ export const gitFormModule = angular
|
|||
'baseWebhookUrl',
|
||||
'webhookId',
|
||||
'webhooksDocs',
|
||||
'createdFromCustomTemplateId',
|
||||
])
|
||||
)
|
||||
.component(
|
||||
|
@ -69,6 +70,7 @@ export const gitFormModule = angular
|
|||
'model',
|
||||
'onChange',
|
||||
'stackId',
|
||||
'createdFromCustomTemplateId',
|
||||
'value',
|
||||
'isUrlValid',
|
||||
])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue