1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00

feat(templates): allow managing git based templates [EE-2600] (#7855)

Co-authored-by: itsconquest <william.conquest@portainer.io>
Co-authored-by: oscarzhou <oscar.zhou@portainer.io>
Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com>
This commit is contained in:
Oscar Zhou 2023-04-04 12:44:42 +12:00 committed by GitHub
parent 30a2bb0495
commit c650868fe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 944 additions and 101 deletions

View file

@ -46,6 +46,13 @@ class KubernetesDeployController {
template: null,
baseWebhookUrl: baseStackWebhookUrl(),
webhookId: createWebhookId(),
templateLoadFailed: false,
isEditorReadOnly: false,
};
this.currentUser = {
isAdmin: false,
id: null,
};
this.formValues = {
@ -95,7 +102,7 @@ class KubernetesDeployController {
const metadata = {
type: buildLabel(this.state.BuildMethod),
format: formatLabel(this.state.DeployType),
role: roleLabel(this.Authentication.isAdmin()),
role: roleLabel(this.currentUser.isAdmin),
'automatic-updates': automaticUpdatesLabel(this.formValues.RepositoryAutomaticUpdates, this.formValues.RepositoryMechanism),
};
@ -183,9 +190,15 @@ class KubernetesDeployController {
this.state.template = template;
try {
const fileContent = await this.CustomTemplateService.customTemplateFile(templateId);
this.state.templateContent = fileContent;
this.onChangeFileContent(fileContent);
try {
this.state.templateContent = await this.CustomTemplateService.customTemplateFile(templateId, template.GitConfig !== null);
this.onChangeFileContent(this.state.templateContent);
this.state.isEditorReadOnly = true;
} catch (err) {
this.state.templateLoadFailed = true;
throw err;
}
if (template.Variables && template.Variables.length > 0) {
const variables = Object.fromEntries(template.Variables.map((variable) => [variable.name, '']));
@ -318,6 +331,9 @@ class KubernetesDeployController {
$onInit() {
return this.$async(async () => {
this.currentUser.isAdmin = this.Authentication.isAdmin();
this.currentUser.id = this.Authentication.getUserDetails().ID;
this.formValues.namespace_toggle = false;
await this.getNamespaces();