Răsfoiți Sursa

disable email verification and feedback button on local version

sunguroku 5 ani în urmă
părinte
comite
9562d214b7

+ 10 - 1
dashboard/src/main/Main.tsx

@@ -22,6 +22,7 @@ type StateType = {
   isLoggedIn: boolean;
   isEmailVerified: boolean;
   initialized: boolean;
+  local: boolean;
 };
 
 export default class Main extends Component<PropsType, StateType> {
@@ -30,6 +31,7 @@ export default class Main extends Component<PropsType, StateType> {
     isLoggedIn: false,
     isEmailVerified: false,
     initialized: localStorage.getItem("init") === "true",
+    local: false,
   };
 
   componentDidMount() {
@@ -53,6 +55,13 @@ export default class Main extends Component<PropsType, StateType> {
         }
       })
       .catch((err) => this.setState({ isLoggedIn: false, loading: false }));
+    
+    api.getCapabilities("", {}, {})
+    .then((res) => {
+      console.log(res.data)
+      this.setState({local: !res.data?.provisioner})
+    })
+    .catch((err) => console.log(err));
   }
 
   initialize = () => {
@@ -100,7 +109,7 @@ export default class Main extends Component<PropsType, StateType> {
     }
 
     // if logged in but not verified, block until email verification
-    if (this.state.isLoggedIn && !this.state.isEmailVerified) {
+    if (!this.state.local && this.state.isLoggedIn && !this.state.isEmailVerified) {
       return (
         <Switch>
           <Route

+ 1 - 3
dashboard/src/main/home/Home.tsx

@@ -90,9 +90,7 @@ class Home extends Component<PropsType, StateType> {
       .getCapabilities(
         "<token>",
         {},
-        {
-          id: currentProject.id
-        }
+        {}
       )
       .then((res) => {
         console.log(res.data)

+ 9 - 1
dashboard/src/main/home/navbar/Navbar.tsx

@@ -40,10 +40,18 @@ export default class Navbar extends Component<PropsType, StateType> {
     }
   };
 
+  renderFeedbackButton = () => {
+    if (this.context?.capabilities?.provisioner) {
+      return (
+        <Feedback currentView={this.props.currentView} />
+      )
+    }
+  }
+
   render() {
     return (
       <StyledNavbar>
-        <Feedback currentView={this.props.currentView} />
+        {this.renderFeedbackButton()}
         <NavButton
           selected={this.state.showDropdown}
           onClick={() =>

+ 2 - 2
dashboard/src/shared/api.tsx

@@ -629,8 +629,8 @@ const getUser = baseApi<{}, { id: number }>("GET", (pathParams) => {
   return `/api/users/${pathParams.id}`;
 });
 
-const getCapabilities = baseApi<{}, { id: number }>("GET", (pathParams) => {
-  return `/api/projects/${pathParams.id}/capabilities`;
+const getCapabilities = baseApi<{}, {}>("GET", () => {
+  return `/api/capabilities`;
 });
 
 const linkGithubProject = baseApi<

+ 1 - 2
server/api/capability_handler.go

@@ -1,7 +1,6 @@
 package api
 
 import (
-	"fmt"
 	"encoding/json"
 	"net/http"
 )
@@ -16,7 +15,7 @@ type CapabilitiesExternal struct {
 func (app *App) HandleGetCapabilities(w http.ResponseWriter, r *http.Request) {
 
 	cap := app.CapConf
-	fmt.Println(app.CapConf)
+
 	capExternal := &CapabilitiesExternal{
 		Provisioner: cap.Provisioner,
 		GitHub: cap.Github,

+ 2 - 6
server/router/router.go

@@ -1356,12 +1356,8 @@ func New(a *api.App) *chi.Mux {
 		// capabilities
 		r.Method(
 			"GET",
-			"/projects/{project_id}/capabilities",
-			auth.DoesUserHaveProjectAccess(
-				requestlog.NewHandler(a.HandleGetCapabilities, l),
-				mw.URLParam,
-				mw.ReadAccess,
-			),
+			"/capabilities",
+			requestlog.NewHandler(a.HandleGetCapabilities, l),
 		)
 	})