Просмотр исходного кода

Fixed icon not showing on navbar and enable casing on preview envs enabled property

jnfrati 4 лет назад
Родитель
Сommit
86503bf2fb

+ 3 - 3
dashboard/src/main/home/cluster-dashboard/preview-environments/routes.tsx

@@ -9,9 +9,9 @@ export const Routes = () => {
   const { url } = useRouteMatch();
   const { url } = useRouteMatch();
   const { currentProject } = useContext(Context);
   const { currentProject } = useContext(Context);
 
 
-  // if (!currentProject?.preview_envs_enabled) {
-  //   return <Redirect to={`/`} />;
-  // }
+  if (!currentProject?.preview_envs_enabled) {
+    return <Redirect to={`/`} />;
+  }
 
 
   return (
   return (
     <>
     <>

+ 46 - 8
dashboard/src/main/home/sidebar/Sidebar.tsx

@@ -33,6 +33,7 @@ type StateType = {
   pressingCtrl: boolean;
   pressingCtrl: boolean;
   showTooltip: boolean;
   showTooltip: boolean;
   forceCloseDrawer: boolean;
   forceCloseDrawer: boolean;
+  showLinkTooltip: { [linkKey: string]: boolean };
 };
 };
 
 
 class Sidebar extends Component<PropsType, StateType> {
 class Sidebar extends Component<PropsType, StateType> {
@@ -43,6 +44,9 @@ class Sidebar extends Component<PropsType, StateType> {
     pressingCtrl: false,
     pressingCtrl: false,
     showTooltip: false,
     showTooltip: false,
     forceCloseDrawer: false,
     forceCloseDrawer: false,
+    showLinkTooltip: {
+      prev_envs: false,
+    },
   };
   };
 
 
   componentDidMount() {
   componentDidMount() {
@@ -173,10 +177,38 @@ class Sidebar extends Component<PropsType, StateType> {
                 Databases
                 Databases
               </NavButton>
               </NavButton>
             )}
             )}
-          <NavButton to="/preview-environments">
-            <StyledCodeBranchIcon />
-            Preview environments
-          </NavButton>
+          {currentProject?.preview_envs_enabled && (
+            <NavButton to="/preview-environments">
+              <InlineSVGWrapper>
+                <StyledCodeBranchIcon />
+              </InlineSVGWrapper>
+              <EllipsisTextWrapper
+                onMouseOver={() => {
+                  this.setState((prev) => ({
+                    ...prev,
+                    showLinkTooltip: {
+                      ...prev.showLinkTooltip,
+                      prev_envs: true,
+                    },
+                  }));
+                }}
+                onMouseOut={() => {
+                  this.setState((prev) => ({
+                    ...prev,
+                    showLinkTooltip: {
+                      ...prev.showLinkTooltip,
+                      prev_envs: false,
+                    },
+                  }));
+                }}
+              >
+                Preview environments
+                {this.state.showLinkTooltip["prev_envs"] && (
+                  <Tooltip>Preview environments</Tooltip>
+                )}
+              </EllipsisTextWrapper>
+            </NavButton>
+          )}
         </>
         </>
       );
       );
     }
     }
@@ -323,9 +355,6 @@ const NavButton = styled(NavLink)`
   font-size: 14px;
   font-size: 14px;
   font-family: "Work Sans", sans-serif;
   font-family: "Work Sans", sans-serif;
   color: #ffffff;
   color: #ffffff;
-  overflow: hidden;
-  white-space: nowrap;
-  text-overflow: ellipsis;
   cursor: ${(props: { disabled?: boolean }) =>
   cursor: ${(props: { disabled?: boolean }) =>
     props.disabled ? "not-allowed" : "pointer"};
     props.disabled ? "not-allowed" : "pointer"};
 
 
@@ -368,6 +397,15 @@ const StyledCodeBranchIcon = styled(CodeBranchIcon)`
   }
   }
 `;
 `;
 
 
+const InlineSVGWrapper = styled.div``;
+
+const EllipsisTextWrapper = styled.span`
+  display: block;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+`;
+
 const SidebarBg = styled.div`
 const SidebarBg = styled.div`
   position: absolute;
   position: absolute;
   top: 0;
   top: 0;
@@ -417,7 +455,7 @@ const Tooltip = styled.div`
   position: absolute;
   position: absolute;
   right: -60px;
   right: -60px;
   top: 34px;
   top: 34px;
-  width: 67px;
+  min-width: 67px;
   height: 18px;
   height: 18px;
   padding-bottom: 2px;
   padding-bottom: 2px;
   background: #383842dd;
   background: #383842dd;