From 81d7bdedf111cad665dcb4642d304e0a46aa56c5 Mon Sep 17 00:00:00 2001
From: danieldeng2 <danieldeng223@gmail.com>
Date: Thu, 20 Aug 2020 21:33:18 +0100
Subject: [PATCH] Hide switch button when scope is a folder

---
 .../components/TopSection/index.tsx           | 28 +++++++++++--------
 .../pages/ModuleResources/index.tsx           |  3 +-
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/components/pages/ModuleResources/components/TopSection/index.tsx b/src/components/pages/ModuleResources/components/TopSection/index.tsx
index 35f4526c1..028234905 100644
--- a/src/components/pages/ModuleResources/components/TopSection/index.tsx
+++ b/src/components/pages/ModuleResources/components/TopSection/index.tsx
@@ -8,31 +8,37 @@ import { faBorderAll, faList } from "@fortawesome/free-solid-svg-icons";
 export interface TopSectionProps {
   onViewButtonClick: (event: React.MouseEvent) => void;
   currentView: string;
+  scope: string;
 }
 
 const TopSection: React.FC<TopSectionProps> = ({
   onViewButtonClick,
   currentView,
+  scope,
 }) => {
   return (
     <div
       style={{
         display: "flex",
         justifyContent: "space-between",
-				alignItems: "center",
-				marginTop: "-0.375rem"
+        alignItems: "center",
+				marginTop: scope === "" ? "-0.375rem" : "0",
+        marginBottom: scope === "" ? "-0.375rem" : "0",
       }}
     >
       <MyBreadcrumbs />
-      <Button
-        className={styles.viewToggleButton}
-        onClick={onViewButtonClick}
-        variant="secondary"
-      >
-        <FontAwesomeIcon
-          icon={currentView === "folder" ? faBorderAll : faList}
-        />
-      </Button>
+
+      {scope === "" ? (
+        <Button
+          className={styles.viewToggleButton}
+          onClick={onViewButtonClick}
+          variant="secondary"
+        >
+          <FontAwesomeIcon
+            icon={currentView === "folder" ? faBorderAll : faList}
+          />
+        </Button>
+      ) : null}
     </div>
   );
 };
diff --git a/src/components/pages/ModuleResources/index.tsx b/src/components/pages/ModuleResources/index.tsx
index d6a591856..2312c4980 100644
--- a/src/components/pages/ModuleResources/index.tsx
+++ b/src/components/pages/ModuleResources/index.tsx
@@ -234,7 +234,8 @@ class ModuleResources extends React.Component<ResourcesProps, ResourceState> {
       <>
         <TopSection
           onViewButtonClick={() => this.toggleView()}
-          currentView={this.state.view}
+					currentView={this.state.view}
+					scope={scope}
         />
         <SearchBox
           searchText={this.state.searchText}
-- 
GitLab