mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 12:25:22 +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:
parent
30a2bb0495
commit
c650868fe9
32 changed files with 944 additions and 101 deletions
|
@ -105,6 +105,16 @@
|
|||
></custom-templates-variables-field>
|
||||
</div>
|
||||
|
||||
<span ng-if="ctrl.state.BuildMethod === ctrl.BuildMethods.CUSTOM_TEMPLATE && ctrl.state.templateId && ctrl.state.templateLoadFailed">
|
||||
<p class="small vertical-center text-danger mb-5" ng-if="ctrl.currentUser.isAdmin || ctrl.currentUser.id === ctrl.state.template.CreatedByUserId">
|
||||
<pr-icon icon="'alert-triangle'" mode="'danger'" size="'md'" feather="true"></pr-icon>Custom template could not be loaded, please
|
||||
<a ui-sref="kubernetes.templates.custom.edit({id: ctrl.state.templateId})">click here</a> for configuration.</p
|
||||
>
|
||||
<p class="small vertical-center text-danger mb-5" ng-if="!(ctrl.currentUser.isAdmin || ctrl.currentUser.id === ctrl.state.template.CreatedByUserId)">
|
||||
<pr-icon icon="'alert-triangle'" mode="'danger'" size="'md'" feather="true"></pr-icon>Custom template could not be loaded, please contact your administrator.</p
|
||||
>
|
||||
</span>
|
||||
|
||||
<!-- editor -->
|
||||
<div class="mt-4">
|
||||
<web-editor-form
|
||||
|
@ -115,6 +125,7 @@
|
|||
ng-required="true"
|
||||
yml="true"
|
||||
placeholder="Define or paste the content of your manifest file here"
|
||||
read-only="ctrl.state.isEditorReadOnly"
|
||||
>
|
||||
<editor-description>
|
||||
<p class="vertical-center">
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue