From ff5b311eee6fd6ac7607be7dcda96cf4258e7cac Mon Sep 17 00:00:00 2001
From: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com>
Date: Thu, 12 Oct 2023 11:02:09 +1300
Subject: [PATCH] fix(helm): fix helm move to advance deployments issues
[EE-5999] (#10453)
* fix helm move to adv deployments
---
app/assets/ico/helm.svg | 2 +-
app/kubernetes/__module.js | 11 -----------
.../helm-templates-list/helm-templates-list.html | 4 ----
.../helm/helm-templates/helm-templates.controller.js | 7 +++++++
.../helm/helm-templates/helm-templates.html | 2 +-
.../components/helm/helm-templates/helm-templates.js | 1 +
app/kubernetes/views/deploy/deploy.html | 10 ++++++++--
app/kubernetes/views/deploy/deployController.js | 7 ++++++-
.../access-tokens-datatable.html | 2 +-
app/portainer/react/views/index.ts | 2 +-
.../HelmRepositoryDatatable.tsx | 1 +
.../HelmRepositoryDatatableActions.tsx | 6 +++++-
.../CreateHelmRepositoriesView.tsx | 0
.../CreateHelmRespositoriesForm.tsx | 8 +++++++-
.../CreateHelmRepositoryView/index.ts | 0
.../components/CreateHelmRepositoryForm.validation.ts | 0
.../components/HelmRepositoryForm.tsx | 0
17 files changed, 39 insertions(+), 24 deletions(-)
rename app/react/portainer/account/{help-repositories => helm-repositories}/CreateHelmRepositoryView/CreateHelmRepositoriesView.tsx (100%)
rename app/react/portainer/account/{help-repositories => helm-repositories}/CreateHelmRepositoryView/CreateHelmRespositoriesForm.tsx (82%)
rename app/react/portainer/account/{help-repositories => helm-repositories}/CreateHelmRepositoryView/index.ts (100%)
rename app/react/portainer/account/{help-repositories => helm-repositories}/components/CreateHelmRepositoryForm.validation.ts (100%)
rename app/react/portainer/account/{help-repositories => helm-repositories}/components/HelmRepositoryForm.tsx (100%)
diff --git a/app/assets/ico/helm.svg b/app/assets/ico/helm.svg
index 79558ad76..28043d752 100644
--- a/app/assets/ico/helm.svg
+++ b/app/assets/ico/helm.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/kubernetes/__module.js b/app/kubernetes/__module.js
index 576fb422b..472601530 100644
--- a/app/kubernetes/__module.js
+++ b/app/kubernetes/__module.js
@@ -82,16 +82,6 @@ angular.module('portainer.kubernetes', ['portainer.app', registriesModule, custo
},
};
- const helmTemplates = {
- name: 'kubernetes.templates.helm',
- url: '/helm',
- views: {
- 'content@': {
- component: 'helmTemplatesView',
- },
- },
- };
-
const services = {
name: 'kubernetes.services',
url: '/services',
@@ -480,7 +470,6 @@ angular.module('portainer.kubernetes', ['portainer.app', registriesModule, custo
$stateRegistryProvider.register(kubernetes);
$stateRegistryProvider.register(helmApplication);
- $stateRegistryProvider.register(helmTemplates);
$stateRegistryProvider.register(applications);
$stateRegistryProvider.register(applicationCreation);
$stateRegistryProvider.register(application);
diff --git a/app/kubernetes/components/helm/helm-templates/helm-templates-list/helm-templates-list.html b/app/kubernetes/components/helm/helm-templates/helm-templates-list/helm-templates-list.html
index bd586ecc8..a7795915e 100644
--- a/app/kubernetes/components/helm/helm-templates/helm-templates-list/helm-templates-list.html
+++ b/app/kubernetes/components/helm/helm-templates/helm-templates-list/helm-templates-list.html
@@ -31,10 +31,6 @@
-
diff --git a/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js b/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js
index f6e9359eb..674652c3a 100644
--- a/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js
+++ b/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js
@@ -23,6 +23,7 @@ export default class HelmTemplatesController {
this.getHelmRepoURLs = this.getHelmRepoURLs.bind(this);
this.getLatestCharts = this.getLatestCharts.bind(this);
this.getResourcePools = this.getResourcePools.bind(this);
+ this.clearHelmChart = this.clearHelmChart.bind(this);
$window.onbeforeunload = () => {
if (this.state.isEditorDirty) {
@@ -31,6 +32,11 @@ export default class HelmTemplatesController {
};
}
+ clearHelmChart() {
+ this.state.chart = null;
+ this.onSelectHelmChart('');
+ }
+
editorUpdate(contentvalues) {
if (this.state.originalvalues === contentvalues) {
this.state.isEditorDirty = false;
@@ -85,6 +91,7 @@ export default class HelmTemplatesController {
window.scrollTo(0, 0);
this.state.showCustomValues = false;
this.state.chart = chart;
+ this.onSelectHelmChart(chart.name);
await this.getHelmValues();
}
diff --git a/app/kubernetes/components/helm/helm-templates/helm-templates.html b/app/kubernetes/components/helm/helm-templates/helm-templates.html
index 9c3ef3a42..166225041 100644
--- a/app/kubernetes/components/helm/helm-templates/helm-templates.html
+++ b/app/kubernetes/components/helm/helm-templates/helm-templates.html
@@ -20,7 +20,7 @@
-
- Build method
+ Deploy from
-
+
Selected Helm chart
+
diff --git a/app/kubernetes/views/deploy/deployController.js b/app/kubernetes/views/deploy/deployController.js
index 0f7012700..8d66fb914 100644
--- a/app/kubernetes/views/deploy/deployController.js
+++ b/app/kubernetes/views/deploy/deployController.js
@@ -32,7 +32,6 @@ class KubernetesDeployController {
{ ...git, value: KubernetesDeployBuildMethods.GIT },
{ ...editor, value: KubernetesDeployBuildMethods.WEB_EDITOR },
{ ...url, value: KubernetesDeployBuildMethods.URL },
- { ...customTemplate, value: KubernetesDeployBuildMethods.CUSTOM_TEMPLATE },
{ ...customTemplate, description: 'Use custom template', value: KubernetesDeployBuildMethods.CUSTOM_TEMPLATE },
{ ...helm, value: KubernetesDeployBuildMethods.HELM },
];
@@ -55,6 +54,7 @@ class KubernetesDeployController {
webhookId: createWebhookId(),
templateLoadFailed: false,
isEditorReadOnly: false,
+ selectedHelmChart: '',
};
this.currentUser = {
@@ -79,6 +79,7 @@ class KubernetesDeployController {
this.ManifestDeployTypes = KubernetesDeployManifestTypes;
this.BuildMethods = KubernetesDeployBuildMethods;
+ this.onSelectHelmChart = this.onSelectHelmChart.bind(this);
this.onChangeTemplateId = this.onChangeTemplateId.bind(this);
this.deployAsync = this.deployAsync.bind(this);
this.onChangeFileContent = this.onChangeFileContent.bind(this);
@@ -90,6 +91,10 @@ class KubernetesDeployController {
this.onChangeTemplateVariables = this.onChangeTemplateVariables.bind(this);
}
+ onSelectHelmChart(chart) {
+ this.state.selectedHelmChart = chart;
+ }
+
onChangeTemplateVariables(value) {
this.onChangeFormValues({ Variables: value });
diff --git a/app/portainer/components/datatables/access-tokens-datatable/access-tokens-datatable.html b/app/portainer/components/datatables/access-tokens-datatable/access-tokens-datatable.html
index a02511b37..dd6c9302e 100644
--- a/app/portainer/components/datatables/access-tokens-datatable/access-tokens-datatable.html
+++ b/app/portainer/components/datatables/access-tokens-datatable/access-tokens-datatable.html
@@ -1,4 +1,4 @@
-
+
diff --git a/app/portainer/react/views/index.ts b/app/portainer/react/views/index.ts
index acef414de..56657ba48 100644
--- a/app/portainer/react/views/index.ts
+++ b/app/portainer/react/views/index.ts
@@ -12,7 +12,7 @@ import { EdgeAutoCreateScriptView } from '@/react/portainer/environments/EdgeAut
import { ListView as EnvironmentsListView } from '@/react/portainer/environments/ListView';
import { BackupSettingsPanel } from '@/react/portainer/settings/SettingsView/BackupSettingsView/BackupSettingsPanel';
import { SettingsView } from '@/react/portainer/settings/SettingsView/SettingsView';
-import { CreateHelmRepositoriesView } from '@/react/portainer/account/help-repositories/CreateHelmRepositoryView';
+import { CreateHelmRepositoriesView } from '@/react/portainer/account/helm-repositories/CreateHelmRepositoryView';
import { wizardModule } from './wizard';
import { teamsModule } from './teams';
diff --git a/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatable.tsx b/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatable.tsx
index 491776f79..4694a41df 100644
--- a/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatable.tsx
+++ b/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatable.tsx
@@ -41,6 +41,7 @@ export function HelmRepositoryDatatable() {
return (
row.URL}
dataset={helmRepos}
settingsManager={tableState}
columns={columns}
diff --git a/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatableActions.tsx b/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatableActions.tsx
index c15f2c6d8..26b579c48 100644
--- a/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatableActions.tsx
+++ b/app/react/portainer/account/AccountView/HelmRepositoryDatatable/HelmRepositoryDatatableActions.tsx
@@ -55,6 +55,10 @@ export function HelmRepositoryDatatableActions({ selectedItems }: Props) {
return;
}
- deleteHelmRepoMutation.mutate(selectedItems);
+ deleteHelmRepoMutation.mutate(selectedItems, {
+ onSuccess: () => {
+ router.stateService.reload();
+ },
+ });
}
}
diff --git a/app/react/portainer/account/help-repositories/CreateHelmRepositoryView/CreateHelmRepositoriesView.tsx b/app/react/portainer/account/helm-repositories/CreateHelmRepositoryView/CreateHelmRepositoriesView.tsx
similarity index 100%
rename from app/react/portainer/account/help-repositories/CreateHelmRepositoryView/CreateHelmRepositoriesView.tsx
rename to app/react/portainer/account/helm-repositories/CreateHelmRepositoryView/CreateHelmRepositoriesView.tsx
diff --git a/app/react/portainer/account/help-repositories/CreateHelmRepositoryView/CreateHelmRespositoriesForm.tsx b/app/react/portainer/account/helm-repositories/CreateHelmRepositoryView/CreateHelmRespositoriesForm.tsx
similarity index 82%
rename from app/react/portainer/account/help-repositories/CreateHelmRepositoryView/CreateHelmRespositoriesForm.tsx
rename to app/react/portainer/account/helm-repositories/CreateHelmRepositoryView/CreateHelmRespositoriesForm.tsx
index 5ac249bab..4354dbd5b 100644
--- a/app/react/portainer/account/help-repositories/CreateHelmRepositoryView/CreateHelmRespositoriesForm.tsx
+++ b/app/react/portainer/account/helm-repositories/CreateHelmRepositoryView/CreateHelmRespositoriesForm.tsx
@@ -19,11 +19,17 @@ export function CreateHelmRepositoryForm() {
const createHelmRepositoryMutation = useCreateHelmRepositoryMutation();
const helmReposQuery = useHelmRepositories(currentUser.user.Id);
+ const allRepositories =
+ helmReposQuery.data?.UserRepositories.map((x) => x.URL) || [];
+ if (helmReposQuery.data?.GlobalRepository) {
+ allRepositories.push(helmReposQuery.data?.GlobalRepository);
+ }
+
return (
x.URL) || []}
+ URLs={allRepositories}
/>
);
diff --git a/app/react/portainer/account/help-repositories/CreateHelmRepositoryView/index.ts b/app/react/portainer/account/helm-repositories/CreateHelmRepositoryView/index.ts
similarity index 100%
rename from app/react/portainer/account/help-repositories/CreateHelmRepositoryView/index.ts
rename to app/react/portainer/account/helm-repositories/CreateHelmRepositoryView/index.ts
diff --git a/app/react/portainer/account/help-repositories/components/CreateHelmRepositoryForm.validation.ts b/app/react/portainer/account/helm-repositories/components/CreateHelmRepositoryForm.validation.ts
similarity index 100%
rename from app/react/portainer/account/help-repositories/components/CreateHelmRepositoryForm.validation.ts
rename to app/react/portainer/account/helm-repositories/components/CreateHelmRepositoryForm.validation.ts
diff --git a/app/react/portainer/account/help-repositories/components/HelmRepositoryForm.tsx b/app/react/portainer/account/helm-repositories/components/HelmRepositoryForm.tsx
similarity index 100%
rename from app/react/portainer/account/help-repositories/components/HelmRepositoryForm.tsx
rename to app/react/portainer/account/helm-repositories/components/HelmRepositoryForm.tsx