Skip to content

Commit

Permalink
Merge pull request reactplay#426 from 6km/fix-createplay-in-prod
Browse files Browse the repository at this point in the history
fix: Disable creating plays in Production
  • Loading branch information
koustov committed Aug 3, 2022
2 parents 2231460 + 14cdfc6 commit 32f98d8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/common/createplay/CreatePlay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ import Loader from "common/spinner/spinner";
import { Plays } from "common/services/plays";
import { useNavigate } from "react-router-dom";
import { useSearchParams } from "react-router-dom";
import { ReactComponent as NotAllowedImage } from "../../images/img-403.svg"

const NoCreationInProdScreen = () => {
return <div className="w-full h-full flex flex-col justify-center items-center gap-8">
<div>
<NotAllowedImage width={550} />
</div>

<div className="text-center">
You can't create plays in production
<br />
<a className="text-link-default" href="https://github.com/reactplay/react-play/blob/main/CREATE-PLAY.md" target="_blank" rel="noopener noreferrer">read this</a> for more details
</div>
</div>
}

const CreatePlay = () => {
const { isAuthenticated, isLoading } = useAuthenticationStatus();
Expand Down Expand Up @@ -86,6 +101,10 @@ const CreatePlay = () => {
});
};

if (process.env.NODE_ENV !== "development") {
return <NoCreationInProdScreen />
}

if (isLoading || isDataLoading) {
return (
<Loader
Expand All @@ -112,6 +131,7 @@ const CreatePlay = () => {
if (isDataLoading) {
<Loader title={"Loading data"} subtitle="Please wait...." />;
}

return (
<div className="w-full h-full flex flex-col justify-center items-center create-plays-wrapper">
<div>
Expand Down
6 changes: 3 additions & 3 deletions src/common/routing/RouteDefs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const RouteDefs = () => {
<Route path="/tech-stacks" element={<TechStack />} />
<Route path="/plays" element={<App />}>
<Route index element={<PlayList />} />
<Route exact path="create" element={<CreatePlay />} />
<Route exact path="created/:playid" element={<PlayCreated />} />
<Route exact path="create" element= {<CreatePlay />}/>
{process.env.NODE_ENV === "development" && <Route exact path="created/:playid" element={<PlayCreated />} />}
<Route idex exact path=":username" element={<PlayMeta />}>
<Route exact path=":playname" element={<PlayMeta />}>
<Route exact path=":param1" element={<PlayMeta />}>
Expand All @@ -56,4 +56,4 @@ const RouteDefs = () => {
);
};

export default RouteDefs;
export default RouteDefs;
1 change: 1 addition & 0 deletions src/images/img-403.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 32f98d8

Please sign in to comment.