mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-07 13:42:34 +00:00
chore: add demo mode
This commit is contained in:
31
web/src/components/DemoBanner.tsx
Normal file
31
web/src/components/DemoBanner.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
import { globalService } from "../services";
|
||||
import Icon from "./Icon";
|
||||
|
||||
const DemoBanner: React.FC = () => {
|
||||
const {
|
||||
workspaceProfile: {
|
||||
profile: { mode },
|
||||
},
|
||||
} = globalService.getState();
|
||||
const shouldShow = mode === "demo";
|
||||
|
||||
if (!shouldShow) return null;
|
||||
|
||||
return (
|
||||
<div className="z-10 flex flex-row items-center justify-center w-full py-2 text-sm sm:text-lg font-medium dark:text-gray-300 bg-white dark:bg-zinc-700 shadow">
|
||||
<div className="w-full max-w-4xl px-4 flex flex-row justify-between items-center gap-x-3">
|
||||
<span>✨A bookmarking and url shortener, save and share your links very easily.✨</span>
|
||||
<a
|
||||
className="shadow flex flex-row justify-center items-center px-2 py-1 rounded-md text-sm sm:text-base text-white bg-blue-600 hover:bg-blue-700"
|
||||
href="https://github.com/boojack/slash#deploy-with-docker-in-seconds"
|
||||
target="_blank"
|
||||
>
|
||||
Install
|
||||
<Icon.ExternalLink className="w-4 h-auto ml-1" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DemoBanner;
|
@ -95,7 +95,7 @@ const ShortcutView = (props: Props) => {
|
||||
<div className="flex flex-row justify-end items-center space-x-2">
|
||||
{havePermission && (
|
||||
<Dropdown
|
||||
actionsClassName="!w-24"
|
||||
actionsClassName="!w-32"
|
||||
actions={
|
||||
<>
|
||||
<button
|
||||
@ -104,6 +104,12 @@ const ShortcutView = (props: Props) => {
|
||||
>
|
||||
<Icon.Edit className="w-4 h-auto mr-2" /> Edit
|
||||
</button>
|
||||
<button
|
||||
className="w-full px-2 flex flex-row justify-start items-center text-left leading-8 cursor-pointer rounded hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
||||
onClick={() => setShowAnalyticsDialog(true)}
|
||||
>
|
||||
<Icon.BarChart2 className="w-4 h-auto mr-2" /> Analytics
|
||||
</button>
|
||||
<button
|
||||
className="w-full px-2 flex flex-row justify-start items-center text-left leading-8 cursor-pointer rounded text-red-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
||||
onClick={() => {
|
||||
|
@ -2,6 +2,7 @@ import { useEffect } from "react";
|
||||
import { Outlet, useNavigate } from "react-router-dom";
|
||||
import useUserStore from "../stores/v1/user";
|
||||
import Header from "../components/Header";
|
||||
import DemoBanner from "../components/DemoBanner";
|
||||
|
||||
const Root: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
@ -19,6 +20,7 @@ const Root: React.FC = () => {
|
||||
<>
|
||||
{currentUser && (
|
||||
<div className="w-full h-full flex flex-col justify-start items-start">
|
||||
<DemoBanner />
|
||||
<Header />
|
||||
<Outlet />
|
||||
</div>
|
||||
|
@ -11,7 +11,10 @@ const SignIn: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const userStore = useUserStore();
|
||||
const {
|
||||
workspaceProfile: { disallowSignUp },
|
||||
workspaceProfile: {
|
||||
disallowSignUp,
|
||||
profile: { mode },
|
||||
},
|
||||
} = useAppSelector((state) => state.global);
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
@ -24,6 +27,11 @@ const SignIn: React.FC = () => {
|
||||
replace: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (mode === "demo") {
|
||||
setEmail("slash@stevenlgtm.com");
|
||||
setPassword("secret");
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleEmailInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
|
Reference in New Issue
Block a user