wip fix delete workspace in default role

This commit is contained in:
shatfield4 2024-06-20 12:06:10 -07:00
parent 610c87ce19
commit 0e5e742c27
5 changed files with 15 additions and 1 deletions

View File

@ -69,7 +69,7 @@ export default function App() {
<Route path="/login" element={<Login />} />
<Route
path="/workspace/:slug/settings/:tab"
element={<ManagerRoute Component={WorkspaceSettings} />}
element={<PrivateRoute Component={WorkspaceSettings} />}
/>
<Route
path="/workspace/:slug"

View File

@ -25,6 +25,7 @@ export default function ActiveWorkspaces() {
const { user } = useUser();
const isInWorkspaceSettings = !!useMatch("/workspace/:slug/settings/:tab");
console.log(user?.role);
useEffect(() => {
async function getWorkspaces() {
const workspaces = await Workspace.all();

View File

@ -4,6 +4,7 @@ import Workspace from "@/models/workspace";
import paths from "@/utils/paths";
import System from "@/models/system";
import { useTranslation } from "react-i18next";
import showToast from "@/utils/toast";
export default function DeleteWorkspace({ workspace }) {
const { slug } = useParams();

View File

@ -6,6 +6,7 @@ import WorkspaceName from "./WorkspaceName";
import SuggestedChatMessages from "./SuggestedChatMessages";
import DeleteWorkspace from "./DeleteWorkspace";
import WorkspacePfp from "./WorkspacePfp";
import useUser from "@/hooks/useUser";
export default function GeneralInfo({ slug }) {
const [workspace, setWorkspace] = useState(null);
@ -13,6 +14,7 @@ export default function GeneralInfo({ slug }) {
const [saving, setSaving] = useState(false);
const [loading, setLoading] = useState(true);
const formEl = useRef(null);
const { user } = useUser();
useEffect(() => {
async function fetchWorkspace() {
@ -43,6 +45,13 @@ export default function GeneralInfo({ slug }) {
};
if (!workspace || loading) return null;
if (user?.role === "default") {
return (
<>
<DeleteWorkspace workspace={workspace} />
</>
);
}
return (
<>
<form

View File

@ -95,11 +95,13 @@ function ShowWorkspaceChat() {
title={t("workspaces—settings.chat")}
icon={<ChatText className="h-6 w-6" />}
to={paths.workspace.settings.chatSettings(slug)}
visible={["admin", "manager"].includes(user?.role)}
/>
<TabItem
title={t("workspaces—settings.vector")}
icon={<Database className="h-6 w-6" />}
to={paths.workspace.settings.vectorDatabase(slug)}
visible={["admin", "manager"].includes(user?.role)}
/>
<TabItem
title={t("workspaces—settings.members")}
@ -111,6 +113,7 @@ function ShowWorkspaceChat() {
title={t("workspaces—settings.agent")}
icon={<Robot className="h-6 w-6" />}
to={paths.workspace.settings.agentConfig(slug)}
visible={["admin", "manager"].includes(user?.role)}
/>
</div>
<div className="px-16 py-6">