Преглед изворни кода

only show default deployment target addons in addons tab (#4489)

Feroze Mohideen пре 2 година
родитељ
комит
3fd5ef4c9f

+ 4 - 9
dashboard/src/main/home/add-on-dashboard/AddOnDashboard.tsx

@@ -22,6 +22,7 @@ import Spacer from "components/porter/Spacer";
 import Text from "components/porter/Text";
 import Toggle from "components/porter/Toggle";
 import { useAuthState } from "main/auth/context";
+import { useDefaultDeploymentTarget } from "lib/hooks/useDeploymentTarget";
 
 import api from "shared/api";
 import { Context } from "shared/Context";
@@ -51,16 +52,10 @@ export const RestrictedNamespaces = [
   "external-secrets",
 ];
 
-const templateBlacklist = [
-  "web",
-  "worker",
-  "job",
-  "umbrella",
-  "postgresql-managed",
-  "redis-managed",
-];
+const templateBlacklist = ["web", "worker", "job", "umbrella"];
 
 const AddOnDashboard: React.FC<Props> = ({}) => {
+  const { defaultDeploymentTarget } = useDefaultDeploymentTarget();
   const { currentProject, currentCluster } = useContext(Context);
   const [addOns, setAddOns] = useState([]);
   const [searchValue, setSearchValue] = useState("");
@@ -70,7 +65,7 @@ const AddOnDashboard: React.FC<Props> = ({}) => {
   const filteredAddOns = useMemo(() => {
     const filtered = addOns.filter((app) => {
       return (
-        !RestrictedNamespaces.includes(app.namespace) &&
+        app.namespace === defaultDeploymentTarget.namespace &&
         !templateBlacklist.includes(app.chart.metadata.name)
       );
     });

+ 10 - 10
dashboard/src/main/home/add-on-dashboard/NewAddOnFlow.tsx

@@ -40,7 +40,7 @@ const HIDDEN_CHARTS = [
   "redis-managed",
 ];
 
-//For Charts that don't exist locally we need to add them in manually
+// For Charts that don't exist locally we need to add them in manually
 const TAG_MAPPING = {
   "DATA_STORE": ["mysql"],
   "DATA_BASE": ["mysql"]
@@ -99,7 +99,7 @@ const NewAddOnFlow: React.FC<Props> = ({
         }
       );
       setIsLoading(false);
-      var sortedVersionData = res.data.map((template: any) => {
+      let sortedVersionData = res.data.map((template: any) => {
         let versions = template.versions.reverse();
         versions = template.versions.sort(semver.rcompare);
         return {
@@ -114,9 +114,9 @@ const NewAddOnFlow: React.FC<Props> = ({
       );
 
       sortedVersionData = sortedVersionData.map((template: any) => {
-        let testTemplate: string[] = template?.tags || []
+        const testTemplate: string[] = template?.tags || []
         // Assign tags based on TAG_MAPPING
-        for (let tag in TAG_MAPPING) {
+        for (const tag in TAG_MAPPING) {
           if (TAG_MAPPING[tag].includes(template.name)) {
             testTemplate?.push(tag);
           }
@@ -142,7 +142,7 @@ const NewAddOnFlow: React.FC<Props> = ({
           <ConfigureTemplate
             currentTemplate={currentTemplate}
             currentForm={currentForm}
-            goBack={() => setCurrentForm(null)}
+            goBack={() => { setCurrentForm(null); }}
           />
         ) : (
           <>
@@ -159,8 +159,8 @@ const NewAddOnFlow: React.FC<Props> = ({
               currentTemplate ? (
                 <ExpandedTemplate
                   currentTemplate={currentTemplate}
-                  proceed={(form?: any) => setCurrentForm(form)}
-                  goBack={() => setCurrentTemplate(null)}
+                  proceed={(form?: any) => { setCurrentForm(form); }}
+                  goBack={() => { setCurrentTemplate(null); }}
                 />
               ) : (
                 <>
@@ -205,7 +205,7 @@ const NewAddOnFlow: React.FC<Props> = ({
                           </div>
                           <TemplateList
                             templates={appTemplates} // This is where you provide only APP templates
-                            setCurrentTemplate={(x) => setCurrentTemplate(x)}
+                            setCurrentTemplate={(x) => { setCurrentTemplate(x); }}
                           />
                         </>}
 
@@ -219,7 +219,7 @@ const NewAddOnFlow: React.FC<Props> = ({
                           </div>
                           <TemplateList
                             templates={dataStoreTemplates} // This is where you provide only DATA_STORE templates
-                            setCurrentTemplate={(x) => setCurrentTemplate(x)}
+                            setCurrentTemplate={(x) => { setCurrentTemplate(x); }}
                           />
                         </>}
 
@@ -235,7 +235,7 @@ const NewAddOnFlow: React.FC<Props> = ({
 
                           <TemplateList
                             templates={filteredTemplates} // This is where you provide only DATA_STORE templates
-                            setCurrentTemplate={(x) => setCurrentTemplate(x)}
+                            setCurrentTemplate={(x) => { setCurrentTemplate(x); }}
                           />
                         </>
                       }