mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
allow unprotected pages
This commit is contained in:
@@ -3,7 +3,7 @@ import React from "react";
|
||||
import Notification from "./Notification";
|
||||
|
||||
type Props = {
|
||||
error: Error
|
||||
error?: Error
|
||||
};
|
||||
|
||||
class ErrorNotification extends React.Component<Props> {
|
||||
|
||||
@@ -3,15 +3,19 @@ import React from "react";
|
||||
import type { Me } from "../types/me";
|
||||
|
||||
type Props = {
|
||||
me: Me
|
||||
me?: Me
|
||||
};
|
||||
|
||||
class Footer extends React.Component<Props> {
|
||||
render() {
|
||||
const { me } = this.props;
|
||||
if (!me) {
|
||||
return "";
|
||||
}
|
||||
return (
|
||||
<footer className="footer">
|
||||
<div className="container is-centered">
|
||||
<p className="has-text-centered">{this.props.me.username}</p>
|
||||
<p className="has-text-centered">{me.username}</p>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import PrimaryNavigationLink from "./PrimaryNavigationLink";
|
||||
import PrimaryNavigationAction from "./PrimaryNavigationAction";
|
||||
|
||||
type Props = {
|
||||
onLogout: () => void
|
||||
};
|
||||
type Props = {};
|
||||
|
||||
class PrimaryNavigation extends React.Component<Props> {
|
||||
render() {
|
||||
@@ -13,10 +10,7 @@ class PrimaryNavigation extends React.Component<Props> {
|
||||
<nav className="tabs is-boxed">
|
||||
<ul>
|
||||
<PrimaryNavigationLink to="/users" label="Users" />
|
||||
<PrimaryNavigationAction
|
||||
onClick={this.props.onLogout}
|
||||
label="Logout"
|
||||
/>
|
||||
<PrimaryNavigationLink to="/logout" label="Logout" />
|
||||
</ul>
|
||||
</nav>
|
||||
);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
//@flow
|
||||
import * as React from "react";
|
||||
|
||||
type Props = {
|
||||
label: string,
|
||||
onClick: () => void
|
||||
};
|
||||
|
||||
class PrimaryNavigationAction extends React.Component<Props> {
|
||||
render() {
|
||||
const { label, onClick } = this.props;
|
||||
return (
|
||||
<li>
|
||||
<a onClick={onClick}>{label}</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default PrimaryNavigationAction;
|
||||
39
scm-ui/src/components/ProtectedRoute.js
Normal file
39
scm-ui/src/components/ProtectedRoute.js
Normal file
@@ -0,0 +1,39 @@
|
||||
//@flow
|
||||
import React, { Component } from "react";
|
||||
import { Route, Redirect, withRouter } from "react-router-dom";
|
||||
|
||||
type Props = {
|
||||
authenticated?: boolean,
|
||||
component: Component<any, any>
|
||||
};
|
||||
|
||||
class ProtectedRoute extends React.Component<Props> {
|
||||
renderRoute = (Component: any, authenticated?: boolean) => {
|
||||
return (routeProps: any) => {
|
||||
if (authenticated) {
|
||||
return <Component {...routeProps} />;
|
||||
} else {
|
||||
return (
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: "/login",
|
||||
state: { from: routeProps.location }
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
render() {
|
||||
const { component, authenticated, ...routeProps } = this.props;
|
||||
return (
|
||||
<Route
|
||||
{...routeProps}
|
||||
render={this.renderRoute(component, authenticated)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(ProtectedRoute);
|
||||
@@ -22,7 +22,6 @@ class SubmitButton extends React.Component<Props> {
|
||||
<div className="field">
|
||||
<div className="control">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={disabled}
|
||||
className={classNames(
|
||||
"button",
|
||||
|
||||
Reference in New Issue
Block a user