mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-07 13:42:34 +00:00
feat: add public visibility
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { useEffect } from "react";
|
||||
import { Route, Routes, useNavigate } from "react-router-dom";
|
||||
import { Route, Routes, useLocation, useNavigate } from "react-router-dom";
|
||||
import { userService, workspaceService } from "./services";
|
||||
import useLoading from "./hooks/useLoading";
|
||||
import Only from "./components/common/OnlyWhen";
|
||||
@ -9,11 +9,27 @@ import WorkspaceDetail from "./pages/WorkspaceDetail";
|
||||
import UserDetail from "./pages/UserDetail";
|
||||
import ShortcutRedirector from "./pages/ShortcutRedirector";
|
||||
|
||||
const pathnameWhitelist = [/\/.+?\/go\/.+/];
|
||||
|
||||
function App() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const pageLoadingStatus = useLoading();
|
||||
|
||||
useEffect(() => {
|
||||
let needAuth = true;
|
||||
|
||||
for (const regexp of pathnameWhitelist) {
|
||||
if (regexp.test(location.pathname)) {
|
||||
needAuth = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!needAuth) {
|
||||
pageLoadingStatus.setFinish();
|
||||
return;
|
||||
}
|
||||
|
||||
userService.initialState().finally(() => {
|
||||
if (!userService.getState().user) {
|
||||
pageLoadingStatus.setFinish();
|
||||
|
@ -148,7 +148,7 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
||||
checked={state.shortcutCreate.visibility === "PRIVATE"}
|
||||
/>
|
||||
<label htmlFor="visibility-private" className="ml-1 mr-4">
|
||||
Only for myself
|
||||
Private
|
||||
</label>
|
||||
<input
|
||||
type="radio"
|
||||
@ -158,8 +158,19 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
||||
onChange={handleVisibilityInputChange}
|
||||
checked={state.shortcutCreate.visibility === "WORKSPACE"}
|
||||
/>
|
||||
<label htmlFor="visibility-workspace" className="ml-1">
|
||||
Public in workspace
|
||||
<label htmlFor="visibility-workspace" className="ml-1 mr-4">
|
||||
Workspace
|
||||
</label>
|
||||
<input
|
||||
type="radio"
|
||||
name="visibility"
|
||||
id="visibility-public"
|
||||
value="PUBLIC"
|
||||
onChange={handleVisibilityInputChange}
|
||||
checked={state.shortcutCreate.visibility === "PUBLIC"}
|
||||
/>
|
||||
<label htmlFor="visibility-public" className="ml-1">
|
||||
Public
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
2
web/src/types/modules/shortcut.d.ts
vendored
2
web/src/types/modules/shortcut.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
type ShortcutId = number;
|
||||
|
||||
type Visibility = "PRIVATE" | "WORKSPACE";
|
||||
type Visibility = "PRIVATE" | "WORKSPACE" | "PUBLIC";
|
||||
|
||||
interface Shortcut {
|
||||
id: ShortcutId;
|
||||
|
Reference in New Issue
Block a user