Browse Source

Hotfix preview envs (#2926)

* install github app button

* general error component

* auto-generate cluster name

* fix button text color

* infra tab for porter user

* log register error

* jobs in preview envs, hide pr- namespaces in launch and list selectors
jusrhee 3 years ago
parent
commit
cd8fa2e9d5

+ 1 - 1
dashboard/src/main/home/ModalHandler.tsx

@@ -180,7 +180,7 @@ const ModalHandler: React.FC<{
         <Modal
           onRequestClose={() => setCurrentModal(null, null)}
           width="760px"
-          height="440px"
+          height="480px"
           title="Account Settings"
         >
           <AccountSettingsModal />

+ 9 - 7
dashboard/src/main/home/cluster-dashboard/NamespaceSelector.tsx

@@ -51,7 +51,7 @@ export const NamespaceSelector: React.FunctionComponent<Props> = ({
       .then((res) => {
         if (_isMounted) {
           let namespaceOptions: { label: string; value: string }[] = [
-            { label: "All", value: "ALL" },
+            // { label: "All", value: "ALL" },
           ];
 
           // Set namespace from URL if specified
@@ -79,10 +79,12 @@ export const NamespaceSelector: React.FunctionComponent<Props> = ({
             setDefaultNamespace("default");
           }
           availableNamespaces.forEach((x: { name: string }, i: number) => {
-            namespaceOptions.push({
-              label: x.name,
-              value: x.name,
-            });
+            if (!x.name.startsWith("pr-")) {
+              namespaceOptions.push({
+                label: x.name,
+                value: x.name,
+              });
+            }
             if (x.name === urlNamespace) {
               setDefaultNamespace(urlNamespace);
             }
@@ -92,7 +94,7 @@ export const NamespaceSelector: React.FunctionComponent<Props> = ({
       })
       .catch((err) => {
         if (_isMounted) {
-          setNamespaceOptions([{ label: "All", value: "ALL" }]);
+          setNamespaceOptions([]);
         }
       });
   };
@@ -105,7 +107,7 @@ export const NamespaceSelector: React.FunctionComponent<Props> = ({
       defaultNamespace === "" ||
       urlNamespace === "ALL"
     ) {
-      setNamespace("ALL");
+      setNamespace("default");
     } else if (namespace !== defaultNamespace) {
       setNamespace(defaultNamespace);
     }

+ 24 - 20
dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

@@ -30,6 +30,7 @@ type Props = {
   closeChartRedirectUrl?: string;
   selectedTag?: any;
   appFilters?: string[];
+  noPlaceholder?: boolean;
 };
 
 interface JobStatusWithTimeAndVersion extends JobStatusWithTimeType {
@@ -45,6 +46,7 @@ const ChartList: React.FunctionComponent<Props> = ({
   closeChartRedirectUrl,
   selectedTag,
   appFilters,
+  noPlaceholder,
 }) => {
   const {
     newWebsocket,
@@ -438,26 +440,28 @@ const ChartList: React.FunctionComponent<Props> = ({
   }, [charts, sortType, jobStatus, lastRunStatus, selectedTag]);
 
   const renderChartList = () => {
-    if (isLoading || (!namespace && namespace !== "")) {
-      return (
-        <LoadingWrapper>
-          <Loading />
-        </LoadingWrapper>
-      );
-    } else if (isError) {
-      return (
-        <Placeholder height="370px">
-          <i className="material-icons">error</i> Error connecting to cluster.
-        </Placeholder>
-      );
-    } else if (filteredCharts?.length === 0) {
-      return (
-        <Placeholder height="370px">
-          <i className="material-icons">category</i> No
-          {currentView === "jobs" ? ` jobs` : ` charts`} found with the given
-          filters.
-        </Placeholder>
-      );
+    if (!noPlaceholder) {
+      if (isLoading || (!namespace && namespace !== "")) {
+        return (
+          <LoadingWrapper>
+            <Loading />
+          </LoadingWrapper>
+        );
+      } else if (isError) {
+        return (
+          <Placeholder height="370px">
+            <i className="material-icons">error</i> Error connecting to cluster.
+          </Placeholder>
+        );
+      } else if (filteredCharts?.length === 0) {
+        return (
+          <Placeholder height="370px">
+            <i className="material-icons">category</i> No
+            {currentView === "jobs" ? ` jobs` : ` charts`} found with the given
+            filters.
+          </Placeholder>
+        );
+      }
     }
 
     return filteredCharts?.map((chart: ChartType, i: number) => {

+ 8 - 0
dashboard/src/main/home/cluster-dashboard/preview-environments/deployments/DeploymentDetail.tsx

@@ -337,6 +337,14 @@ const DeploymentDetail = () => {
             disableBottomPadding
             closeChartRedirectUrl={`${window.location.pathname}${window.location.search}`}
           />
+          <ChartList
+            currentView="jobs"
+            noPlaceholder={true}
+            lastRunStatus="all"
+            currentCluster={currentCluster}
+            namespace={prDeployment.namespace}
+            sortType="Newest"
+          />
         </ChartListWrapper>
       </StyledExpandedChart>
     </>

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/preview-environments/environments/CreatePREnvironment.tsx

@@ -109,7 +109,7 @@ const CreatePREnvironment = ({ environmentID }: Props) => {
       searchValue,
       {
         isCaseSensitive: false,
-        keys: ["pr_title", "branch_from", "branch_into"],
+        keys: ["pr_title"],
       }
     );
 

+ 1 - 1
dashboard/src/main/home/launch/launch-flow/SettingsPage.tsx

@@ -100,7 +100,7 @@ class SettingsPage extends Component<PropsType, StateType> {
       .then((res) => {
         if (res.data) {
           const availableNamespaces = res.data.filter((namespace: any) => {
-            return namespace.status !== "Terminating";
+            return (namespace.status !== "Terminating" && !namespace.name.startsWith("pr-"));
           });
           const namespaceOptions = availableNamespaces.map(
             (x: { name: string }) => {