From af77e33993d018800ed42c3f38f5a1f3be285d6d Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Mon, 29 May 2023 15:06:14 +1200 Subject: [PATCH] refactor(app): details widget migration [EE-5352] (#8886) --- .vscode.example/portainer.code-snippets | 9 + app/docker/react/components/index.ts | 2 +- .../helpers/application/rollback.js | 76 ----- app/kubernetes/helpers/history/daemonset.js | 27 -- app/kubernetes/helpers/history/deployment.js | 56 ---- app/kubernetes/helpers/history/index.js | 50 --- app/kubernetes/helpers/history/statefulset.js | 27 -- .../horizontal-pod-auto-scaler/service.js | 17 - .../models/application/models/index.js | 2 - app/kubernetes/models/history/models.js | 1 - app/kubernetes/react/components/index.ts | 12 +- app/kubernetes/services/applicationService.js | 18 -- app/kubernetes/services/daemonSetService.js | 18 -- app/kubernetes/services/deploymentService.js | 18 -- app/kubernetes/services/historyService.js | 58 ---- app/kubernetes/services/replicaSetService.js | 31 -- app/kubernetes/services/statefulSetService.js | 18 -- .../views/applications/edit/application.html | 303 +----------------- .../edit/applicationController.js | 146 --------- .../ingress-table/ingress-table.controller.js | 30 -- .../ingress-table/ingress-table.html | 28 -- .../components/ingress-table/ingress-table.js | 11 - .../services-table/services-table.html | 62 ---- .../services-table/services-table.js | 10 - .../stack-redeploy-git-form.controller.js | 2 +- .../views/stacks/edit/stackController.js | 4 +- .../stacks/CreateView/.keep | 0 .../{docker => common}/stacks/ItemView/.keep | 0 .../ItemView/StackContainersDatatable.tsx | 4 +- .../{docker => common}/stacks/ListView/.keep | 0 .../stacks/common/confirm-stack-update.ts | 0 app/react/common/stacks/readme.md | 1 + app/react/common/stacks/stack.service.ts | 25 ++ app/react/{docker => common}/stacks/types.ts | 4 + app/react/kubernetes/ServicesView/service.ts | 24 +- .../ApplicationAutoScalingTable.tsx | 74 +++++ .../ApplicationDetailsWidget.tsx | 142 ++++++++ .../ApplicationEnvVarsTable.tsx | 172 ++++++++++ .../ApplicationIngressesTable.tsx | 125 ++++++++ .../ApplicationPersistentDataTable.tsx | 268 ++++++++++++++++ .../ApplicationServicesTable.tsx | 130 ++++++++ .../ApplicationVolumeConfigsTable.tsx | 148 +++++++++ .../RedeployApplicationButton.tsx | 101 ++++++ .../RestartApplicationButton.tsx | 19 ++ .../RollbackApplicationButton.tsx | 130 ++++++++ .../ApplicationDetailsWidget/index.ts | 1 + .../DetailsView/ApplicationSummaryWidget.tsx | 14 +- .../applications/DetailsView/index.ts | 1 + .../applications/application.queries.ts | 283 +++++++++++++++- .../applications/application.service.ts | 159 +++++++-- .../applications/autoscaling.service.ts | 14 + .../kubernetes/applications/constants.ts | 16 + .../kubernetes/applications/pod.service.ts | 41 ++- app/react/kubernetes/applications/types.ts | 15 + app/react/kubernetes/applications/utils.ts | 174 +++++++++- .../portainer/gitops/RefField/RefField.tsx | 2 +- .../portainer/gitops/RefField/RefSelector.tsx | 2 +- 57 files changed, 2046 insertions(+), 1079 deletions(-) delete mode 100644 app/kubernetes/helpers/application/rollback.js delete mode 100644 app/kubernetes/helpers/history/daemonset.js delete mode 100644 app/kubernetes/helpers/history/deployment.js delete mode 100644 app/kubernetes/helpers/history/index.js delete mode 100644 app/kubernetes/helpers/history/statefulset.js delete mode 100644 app/kubernetes/services/historyService.js delete mode 100644 app/kubernetes/services/replicaSetService.js delete mode 100644 app/kubernetes/views/applications/edit/components/ingress-table/ingress-table.controller.js delete mode 100644 app/kubernetes/views/applications/edit/components/ingress-table/ingress-table.html delete mode 100644 app/kubernetes/views/applications/edit/components/ingress-table/ingress-table.js delete mode 100644 app/kubernetes/views/applications/edit/components/services-table/services-table.html delete mode 100644 app/kubernetes/views/applications/edit/components/services-table/services-table.js rename app/react/{docker => common}/stacks/CreateView/.keep (100%) rename app/react/{docker => common}/stacks/ItemView/.keep (100%) rename app/react/{docker => common}/stacks/ItemView/StackContainersDatatable.tsx (95%) rename app/react/{docker => common}/stacks/ListView/.keep (100%) rename app/react/{docker => common}/stacks/common/confirm-stack-update.ts (100%) create mode 100644 app/react/common/stacks/readme.md create mode 100644 app/react/common/stacks/stack.service.ts rename app/react/{docker => common}/stacks/types.ts (87%) create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationAutoScalingTable.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationDetailsWidget.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationEnvVarsTable.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationIngressesTable.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationPersistentDataTable.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationServicesTable.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationVolumeConfigsTable.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/RedeployApplicationButton.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/RestartApplicationButton.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/RollbackApplicationButton.tsx create mode 100644 app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/index.ts create mode 100644 app/react/kubernetes/applications/autoscaling.service.ts diff --git a/.vscode.example/portainer.code-snippets b/.vscode.example/portainer.code-snippets index 9c7716c7c..0021850f2 100644 --- a/.vscode.example/portainer.code-snippets +++ b/.vscode.example/portainer.code-snippets @@ -15,6 +15,15 @@ // ], // "description": "Log output to console" // } + "React Named Export Component": { + "prefix": "rnec", + "body": [ + "export function $TM_FILENAME_BASE() {", + " return
Minimum instances | -Maximum instances | -
- Target CPU usage
- |
-
{{ ctrl.application.AutoScaler.MinReplicas }} | -{{ ctrl.application.AutoScaler.MaxReplicas }} | -{{ ctrl.application.AutoScaler.TargetCPUUtilization }}% | -
Container | -Environment variable | -Value | -ConfigMap or Secret | -
- {{ container.Name }}
-
- |
- {{ envvar.name }} | -
- {{ envvar.value }}
- |
-
- -
- |
-
Container | -Configuration path | -Value | -Configuration | -
- {{ container.Name }}
- |
- - {{ volume.fileMountPath }} - | -
- |
-
- |
-
Persisted folder | -Persistence | -|
- {{ volume.MountPath }} - | -
- |
- {{ volume.HostPath }} on host filesystem | -
Container name | -Pod name | -Persisted folder | -Persistence | -|
- {{ container.Name }}
- |
- {{ container.PodName }} | -- {{ volume.MountPath }} - | -
-
- |
- {{ volume.HostPath }} on host filesystem | -
Ingress name | -Service name | -Host | -Port | -Path | -HTTP Route | -
{{ - ingress.IngressName - }} | -{{ ingress.ServiceName }} | -{{ ingress.Host }} | -{{ ingress.Port }} | -{{ ingress.Path }} | -{{ ingress.Host }}{{ ingress.Path }} | -
Service name | -Type | -Cluster IP | -External IP | -Container port | -Service port(s) | -|
{{ service.metadata.name }} | -{{ service.spec.type }} | -{{ service.spec.clusterIP }} | -
-
-
-
-
- {{ service.spec.externalIP ? service.spec.externalIP : 'pending...' }}
-
- |
- {{ service.spec.externalIP ? service.spec.externalIP : '-' }} | - -
- {{ port.targetPort }}
- |
-
-
-
-
-
-
- {{ port.port }}
-
- {{ port.nodePort ? ':' : '' }}
- {{ port.nodePort }}/{{ port.protocol }}
-
- |
-
Minimum instances | +Maximum instances | +
+
+ Target CPU usage
+
+ |
+
+ {appAutoScalar.spec?.minReplicas} + | ++ {appAutoScalar.spec?.maxReplicas} + | ++ {appAutoScalar.spec?.targetCPUUtilizationPercentage}% + | +
Container | +Environment variable | +Value | +Configuration | +
+ {envVar.containerName}
+ {envVar.isInitContainer && (
+
+ |
+ {envVar.name} | +
+ {envVar.value && {envVar.value}}
+ {envVar.valueFrom?.fieldRef?.fieldPath && (
+
+ |
+
+ {!envVar.valueFrom?.configMapKeyRef?.name &&
+ !envVar.valueFrom?.secretKeyRef?.name && -}
+ {envVar.valueFrom?.configMapKeyRef && (
+
+
+ |
+
Ingress name | +Service name | +Host | +Port | +Path | +HTTP Route | +
+ |
+ {ingressPath.serviceName} | +{ingressPath.host} | +{ingressPath.port} | +{ingressPath.path} | ++ + {ingressPath.host} + {ingressPath.path} + + | +
Container name | +Pod name | +Persisted folder | +Persistence | +
+ {persistedFolder.volumeMount.container.name}
+ {persistedFolder.isContainerInit && (
+
+ |
+ {persistedFolder.volumeMount?.pod?.metadata?.name} | +{persistedFolder.volumeMount.mountPath} | +
+ {persistedFolder.volume.persistentVolumeClaim && (
+
+ |
+
Persisted folder | +Persistence | +
+ {persistedFolder.volumeMount.mountPath} + | +
+ {persistedFolder.volume.persistentVolumeClaim && (
+
+ |
+
Service name | +Type | +Cluster IP | +External IP | +Container port | +Service port(s) | +|
{service.metadata?.name} | +{service.spec?.type} | +{service.spec?.clusterIP} | + {service.spec?.type === 'LoadBalancer' && ( +
+ {service.status?.loadBalancer?.ingress?.[0] &&
+ service.spec?.ports?.[0] && (
+
+
+ {service.spec.externalIPs?.[0]
+ ? service.spec.externalIPs[0]
+ : 'pending...'}
+
+ )}
+ |
+ )}
+ {service.spec?.type !== 'LoadBalancer' && (
+ + {service.spec?.externalIPs?.[0] + ? service.spec.externalIPs[0] + : '-'} + | + )} +
+ {service.spec?.ports?.map((port) => (
+ {port.targetPort}
+ ))}
+ |
+
+ {service.spec?.ports?.map((port) => (
+
+ {environment?.PublicURL && port.nodePort && (
+
+
+ ))}
+
+
+ {port.port}
+
+ {port.nodePort ? ' : ' : ''}
+
+ {port.nodePort}/{port.protocol}
+
+
+ )}
+ |
+
Container | +Configuration path | +Value | +Configuration | +
+ {containerName}
+ {isInitContainer && (
+
+ |
+ + {item.path + ? `${containerVolumeMount?.mountPath}/${item.path}` + : `${containerVolumeMount?.mountPath}`} + | +
+ {item.key && (
+
+
+ )}
+ {!item.key && '-'}
+ |
+
+ {volumeConfigName && (
+
+ |
+