Kaynağa Gözat

Merge pull request #2070 from porter-dev/nico/por-473-job-chart-deletion-doesnt-show-any

[POR-473] Add support for deleting screen for job.
Nicolas Frati 4 yıl önce
ebeveyn
işleme
0fef938651

+ 34 - 29
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -231,8 +231,8 @@ export const ExpandedJobChartFC: React.FC<{
                 }}
                 }}
                 isDeployedFromGithub={!!chart?.git_action_config?.git_repo}
                 isDeployedFromGithub={!!chart?.git_action_config?.git_repo}
                 repositoryUrl={chart?.git_action_config?.git_repo}
                 repositoryUrl={chart?.git_action_config?.git_repo}
-                currentChartVersion={Number(chart.version)}
-                latestChartVersion={Number(chart.latest_version)}
+                currentChartVersion={Number(chart?.version)}
+                latestChartVersion={Number(chart?.latest_version)}
               />
               />
             </>
             </>
           )}
           )}
@@ -265,7 +265,7 @@ export const ExpandedJobChartFC: React.FC<{
           setShowDeleteOverlay={(showOverlay: boolean) => {
           setShowDeleteOverlay={(showOverlay: boolean) => {
             if (showOverlay) {
             if (showOverlay) {
               setCurrentOverlay({
               setCurrentOverlay({
-                message: `Are you sure you want to delete ${chart.name}?`,
+                message: `Are you sure you want to delete ${chart?.name}?`,
                 onYes: handleDeleteChart,
                 onYes: handleDeleteChart,
                 onNo: () => setCurrentOverlay(null),
                 onNo: () => setCurrentOverlay(null),
               });
               });
@@ -293,6 +293,7 @@ export const ExpandedJobChartFC: React.FC<{
         <ExpandedJobHeader
         <ExpandedJobHeader
           chart={chart}
           chart={chart}
           jobs={jobs}
           jobs={jobs}
+          disableRevisions
           closeChart={closeChart}
           closeChart={closeChart}
           refreshChart={refreshChart}
           refreshChart={refreshChart}
           upgradeChart={upgradeChart}
           upgradeChart={upgradeChart}
@@ -303,7 +304,7 @@ export const ExpandedJobChartFC: React.FC<{
         <Placeholder>
         <Placeholder>
           <TextWrap>
           <TextWrap>
             <Header>
             <Header>
-              <Spinner src={loading} /> Deleting "{chart.name}"
+              <Spinner src={loading} /> Deleting "{chart?.name}"
             </Header>
             </Header>
             You will be automatically redirected after deletion is complete.
             You will be automatically redirected after deletion is complete.
           </TextWrap>
           </TextWrap>
@@ -346,7 +347,7 @@ export const ExpandedJobChartFC: React.FC<{
             <PorterFormWrapper
             <PorterFormWrapper
               formData={formData}
               formData={formData}
               valuesToOverride={{
               valuesToOverride={{
-                namespace: chart.namespace,
+                namespace: chart?.namespace,
                 clusterId: currentCluster?.id,
                 clusterId: currentCluster?.id,
               }}
               }}
               renderTabContents={renderTabContents}
               renderTabContents={renderTabContents}
@@ -393,6 +394,7 @@ const ExpandedJobHeader: React.FC<{
   upgradeChart: () => Promise<void>;
   upgradeChart: () => Promise<void>;
   loadChartWithSpecificRevision: (revision: number) => void;
   loadChartWithSpecificRevision: (revision: number) => void;
   setDisableForm: (disable: boolean) => void;
   setDisableForm: (disable: boolean) => void;
+  disableRevisions?: boolean;
 }> = ({
 }> = ({
   chart,
   chart,
   closeChart,
   closeChart,
@@ -401,13 +403,14 @@ const ExpandedJobHeader: React.FC<{
   upgradeChart,
   upgradeChart,
   loadChartWithSpecificRevision,
   loadChartWithSpecificRevision,
   setDisableForm,
   setDisableForm,
+  disableRevisions,
 }) => (
 }) => (
   <HeaderWrapper>
   <HeaderWrapper>
     <BackButton onClick={closeChart}>
     <BackButton onClick={closeChart}>
       <BackButtonImg src={backArrow} />
       <BackButtonImg src={backArrow} />
     </BackButton>
     </BackButton>
-    <TitleSection icon={chart.chart.metadata.icon} iconWidth="33px">
-      {chart.name}
+    <TitleSection icon={chart?.chart.metadata.icon} iconWidth="33px">
+      {chart?.name}
       <DeploymentType currentChart={chart} />
       <DeploymentType currentChart={chart} />
       <TagWrapper>
       <TagWrapper>
         Namespace <NamespaceTag>{chart.namespace}</NamespaceTag>
         Namespace <NamespaceTag>{chart.namespace}</NamespaceTag>
@@ -423,28 +426,30 @@ const ExpandedJobHeader: React.FC<{
         {" " + readableDate(chart.info.last_deployed)}
         {" " + readableDate(chart.info.last_deployed)}
       </LastDeployed>
       </LastDeployed>
     </InfoWrapper>
     </InfoWrapper>
-    <RevisionSection
-      chart={chart}
-      refreshChart={() => refreshChart()}
-      setRevision={(chart, isCurrent) => {
-        loadChartWithSpecificRevision(chart?.version);
-        setDisableForm(!isCurrent);
-      }}
-      forceRefreshRevisions={false}
-      refreshRevisionsOff={() => {}}
-      shouldUpdate={
-        chart.latest_version &&
-        chart.latest_version !== chart.chart.metadata.version
-      }
-      latestVersion={chart.latest_version}
-      upgradeVersion={(_version, cb) => {
-        upgradeChart().then(() => {
-          if (typeof cb === "function") {
-            cb();
-          }
-        });
-      }}
-    />
+    {!disableRevisions ? (
+      <RevisionSection
+        chart={chart}
+        refreshChart={() => refreshChart()}
+        setRevision={(chart, isCurrent) => {
+          loadChartWithSpecificRevision(chart?.version);
+          setDisableForm(!isCurrent);
+        }}
+        forceRefreshRevisions={false}
+        refreshRevisionsOff={() => {}}
+        shouldUpdate={
+          chart?.latest_version &&
+          chart?.latest_version !== chart?.chart.metadata.version
+        }
+        latestVersion={chart?.latest_version}
+        upgradeVersion={(_version, cb) => {
+          upgradeChart().then(() => {
+            if (typeof cb === "function") {
+              cb();
+            }
+          });
+        }}
+      />
+    ) : null}
   </HeaderWrapper>
   </HeaderWrapper>
 );
 );
 
 

+ 1 - 0
dashboard/src/shared/hooks/useChart.ts

@@ -100,6 +100,7 @@ export const useChart = (oldChart: ChartType, closeChart: () => void) => {
    * Delete/Uninstall chart
    * Delete/Uninstall chart
    */
    */
   const deleteChart = async () => {
   const deleteChart = async () => {
+    setStatus("deleting");
     try {
     try {
       const syncedEnvGroups = chart.config?.container?.env?.synced || [];
       const syncedEnvGroups = chart.config?.container?.env?.synced || [];
       const removeApplicationToEnvGroupPromises = syncedEnvGroups.map(
       const removeApplicationToEnvGroupPromises = syncedEnvGroups.map(