Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

refactor: Purge reearth-web of reference to team-Setting page #610

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function AppRoutes() {
{ path: "/settings", element: <Navigate to="/settings/account" /> },
{ path: "/settings/account", element: <AccountSettings /> },
{ path: "/settings/workspaces", element: <WorkspaceList /> },
{ path: "/settings/workspaces/:teamId", element: <WorkspaceSettings /> },
{ path: "/settings/workspaces/:teamId/projects", element: <SettingsProjectList /> },
{ path: "/settings/workspaces/:teamId/asset", element: <AssetSettings /> },
{ path: "/settings/workspaces/:workspaceId", element: <WorkspaceSettings /> },
{ path: "/settings/workspaces/:workspaceId/projects", element: <SettingsProjectList /> },
{ path: "/settings/workspaces/:workspaceId/asset", element: <AssetSettings /> },
{ path: "/settings/projects/:projectId", element: <ProjectSettings /> },
{ path: "/settings/projects/:projectId/public", element: <PublicSettings /> },
{ path: "/settings/projects/:projectId/dataset", element: <DatasetSettings /> },
Expand Down Expand Up @@ -80,9 +80,9 @@ const StyledRouter = styled(Router)`

// Redirections for breaking changes in URLs
const redirects = [
["/settings/workspace/:teamId", "/settings/workspaces/:teamId"],
["/settings/workspace/:teamId/projects", "/settings/workspaces/:teamId/projects"],
["/settings/workspace/:teamId/asset", "/settings/workspaces/:teamId/asset"],
["/settings/workspace/:workspaceId", "/settings/workspaces/:workspaceId"],
["/settings/workspace/:workspaceId/projects", "/settings/workspaces/:workspaceId/projects"],
["/settings/workspace/:workspaceId/asset", "/settings/workspaces/:workspaceId/asset"],
["/settings/project/:projectId", "/settings/projects/:projectId"],
["/settings/project/:projectId/public", "/settings/projects/:projectId/public"],
["/settings/project/:projectId/dataset", "/settings/projects/:projectId/dataset"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type Asset = AssetType;
export type AssetSortType = SortType;

export type Props = {
teamId?: string;
workspaceId?: string;
initialAssetUrl?: string | null;
allowDeletion?: boolean;
className?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/Common/AssetModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type AssetSortType = SortType;

export type Props = {
className?: string;
teamId?: string;
workspaceId?: string;
initialAssetUrl?: string | null;
videoOnly?: boolean;
isOpen?: boolean;
Expand All @@ -34,7 +34,7 @@ export type Props = {
type Tabs = "assets" | "url";

const AssetModal: React.FC<Props> = ({
teamId,
workspaceId,
initialAssetUrl,
videoOnly,
isOpen,
Expand Down Expand Up @@ -119,7 +119,7 @@ const AssetModal: React.FC<Props> = ({
}>
{selectedTab === "assets" && AssetContainer && (
<AssetContainer
teamId={teamId}
workspaceId={workspaceId}
initialAssetUrl={initialAssetUrl}
onAssetUrlSelect={selectAssetUrl}
smallCardOnly
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/Common/ProjectMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { styled, useTheme } from "@reearth/theme";

type Props = {
currentProject: Project;
teamId?: string;
workspaceId?: string;
};

const ProjectMenu: React.FC<Props> = ({ currentProject, teamId }) => {
const ProjectMenu: React.FC<Props> = ({ currentProject, workspaceId }) => {
const documentationUrl = window.REEARTH_CONFIG?.documentationUrl;
const t = useT();
const theme = useTheme();
Expand Down Expand Up @@ -56,7 +56,7 @@ const ProjectMenu: React.FC<Props> = ({ currentProject, teamId }) => {
<Spacer />
<MenuListItem>
<MenuListItemLabel
linkTo={`/settings/workspaces/${teamId}/projects`}
linkTo={`/settings/workspaces/${workspaceId}/projects`}
text={t("Manage projects")}
/>
</MenuListItem>
Expand Down
4 changes: 3 additions & 1 deletion src/components/molecules/EarthEditor/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ const Header: React.FC<Props> = ({
return currentProjectStatus === "unpublished" ? true : false;
}, [currentProjectStatus]);

const center = currentProject && <ProjectMenu currentProject={currentProject} teamId={teamId} />;
const center = currentProject && (
<ProjectMenu currentProject={currentProject} workspaceId={teamId} />
);

const right = (
<RightArea justify="flex-end" align="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Props = {
name: string;
isArchived: boolean;
};
team?: {
workspace?: {
id: string;
name: string;
};
Expand Down
20 changes: 11 additions & 9 deletions src/components/molecules/Settings/Navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { styled } from "@reearth/theme";
import fonts from "@reearth/theme/fonts";
import { metricsSizes } from "@reearth/theme/metrics";

type Team = {
type Workspace = {
id?: string;
name?: string;
};
Expand All @@ -21,11 +21,11 @@ type Project = {
};

type Props = {
team?: Team;
workspace?: Workspace;
project?: Project;
};

const Navigation: React.FC<Props> = ({ team, project }) => {
const Navigation: React.FC<Props> = ({ workspace, project }) => {
const t = useT();

return (
Expand All @@ -41,22 +41,24 @@ const Navigation: React.FC<Props> = ({ team, project }) => {
<NavigationItem to="/settings/account" name={t("Account")} />
<Divider margin="0" />
<NavigationItem to={`/settings/workspaces`} name={t("Workspace List")}>
{team && (
{workspace && (
<NavigationItem
level={2}
to={`/settings/workspaces/${team.id}`}
key={team.id}
name={team.name as string}>
to={`/settings/workspaces/${workspace.id}`}
key={workspace.id}
name={workspace.name as string}>
<NavigationItem
level={3}
to={`/settings/workspaces/${team.id}/asset`}
to={`/settings/workspaces/${workspace.id}/asset`}
name={t("Assets")}
/>
</NavigationItem>
)}
</NavigationItem>
<Divider margin="0" />
<NavigationItem to={`/settings/workspaces/${team?.id}/projects`} name={t("Project List")}>
<NavigationItem
to={`/settings/workspaces/${workspace?.id}/projects`}
name={t("Project List")}>
{project && !project.isArchived && (
<NavigationItem
level={2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Props = {
name: string;
isArchived: boolean;
};
teamId?: string;
workspaceId?: string;
isVisible: boolean;
archiveProject?: (archived: boolean) => void;
deleteProject?: () => void;
Expand All @@ -30,7 +30,7 @@ type Props = {
const DangerModal: React.FC<Props> = ({
actionType,
project,
teamId,
workspaceId,
isVisible,
archiveProject,
deleteProject,
Expand All @@ -46,8 +46,8 @@ const DangerModal: React.FC<Props> = ({
if (actionType === "delete") deleteProject?.();
if (actionType === "archive") archiveProject?.(true);
if (actionType === "unarchive") archiveProject?.(false);
navigate(`/settings/workspaces/${teamId}/projects`);
}, [navigate, archiveProject, deleteProject, actionType, teamId, project, disabled]);
navigate(`/settings/workspaces/${workspaceId}/projects`);
}, [project, disabled, actionType, deleteProject, archiveProject, navigate, workspaceId]);

useEffect(() => {
if (text == project?.name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ export type Props = {
name: string;
isArchived: boolean;
};
teamId?: string;
workspaceId?: string;
archiveProject?: (archived: boolean) => void;
deleteProject?: () => void;
};

const DangerSection: React.FC<Props> = ({ project, teamId, archiveProject, deleteProject }) => {
const DangerSection: React.FC<Props> = ({
project,
workspaceId,
archiveProject,
deleteProject,
}) => {
const [isOpen, setIsOpen] = useState(false);
const [actionType, setActionType] = useState<ActionType>("archive");

Expand Down Expand Up @@ -83,7 +88,7 @@ const DangerSection: React.FC<Props> = ({ project, teamId, archiveProject, delet
<Modal
actionType={actionType}
project={project}
teamId={teamId}
workspaceId={workspaceId}
isVisible={isOpen}
archiveProject={archiveProject}
deleteProject={deleteProject}
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/Settings/SettingPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const SettingPage: React.FC<SettingPageProps> = ({
}
center={
currentProject && (
<ProjectMenu currentProject={currentProject} teamId={currentWorkspace?.id} />
<ProjectMenu currentProject={currentProject} workspaceId={currentWorkspace?.id} />
)
}
/>
Expand All @@ -62,7 +62,7 @@ const SettingPage: React.FC<SettingPageProps> = ({
!loading && hasMoreItems && onScrollToBottom(e, onScroll);
}}>
<LeftWrapper>
<Navigation team={currentWorkspace} project={currentProject} />
<Navigation workspace={currentWorkspace} project={currentProject} />
</LeftWrapper>
<RightWrapper>
<ContentWrapper>
Expand All @@ -74,7 +74,7 @@ const SettingPage: React.FC<SettingPageProps> = ({
/>
{isOpen && (
<Menu>
<Navigation team={currentWorkspace} project={currentProject} />
<Navigation workspace={currentWorkspace} project={currentProject} />
</Menu>
)}
</DeviceMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type Props = {
searchedUser?: User;
searchUser: (nameOrEmail: string) => void;
changeSearchedUser: (user: User | undefined) => void;
addMembersToTeam?: (userIds: string[]) => Promise<void>;
addMembersToWorkspace?: (userIds: string[]) => Promise<void>;
};

const AddMemberModal: React.FC<Props> = ({
Expand All @@ -29,7 +29,7 @@ const AddMemberModal: React.FC<Props> = ({
searchedUser,
searchUser,
changeSearchedUser,
addMembersToTeam,
addMembersToWorkspace,
}) => {
const t = useT();
const theme = useTheme();
Expand Down Expand Up @@ -69,12 +69,12 @@ const AddMemberModal: React.FC<Props> = ({
}, [setUsers, setNameOrEmail, changeSearchedUser, close]);

const add = useCallback(async () => {
await addMembersToTeam?.(users.map(({ id }) => id));
await addMembersToWorkspace?.(users.map(({ id }) => id));
changeSearchedUser(undefined);
setUsers([]);
setNameOrEmail("");
close();
}, [addMembersToTeam, users, setUsers, setNameOrEmail, changeSearchedUser, close]);
}, [addMembersToWorkspace, users, changeSearchedUser, close]);

return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ import { metricsSizes } from "@reearth/theme/metrics";

type Props = {
className?: string;
team?: {
workspace?: {
id: string;
name: string;
};
isVisible: boolean;
deleteTeam?: () => void;
deleteWorkspace?: () => void;
onClose?: () => void;
};

const DangerModal: React.FC<Props> = ({ team, isVisible, deleteTeam, onClose }) => {
const DangerModal: React.FC<Props> = ({ workspace, isVisible, deleteWorkspace, onClose }) => {
const [disabled, setDisabled] = useState(true);
const [text, setText] = useState<string>();
const navigate = useNavigate();
const t = useT();

const handleDeletion = useCallback(() => {
if (team && deleteTeam && !disabled) {
deleteTeam();
if (workspace && deleteWorkspace && !disabled) {
deleteWorkspace();
navigate(`/settings/workspaces`);
}
}, [navigate, team, deleteTeam, disabled]);
}, [navigate, workspace, deleteWorkspace, disabled]);

useEffect(() => {
setDisabled(text !== team?.name);
}, [text, team]);
setDisabled(text !== workspace?.name);
}, [text, workspace]);
const theme = useTheme();

return (
<Modal title={t("Delete workspace")} isVisible={isVisible} size="sm" onClose={onClose}>
<Subtitle size="s" color={theme.main.text} weight="bold" center>
{team?.name}
{workspace?.name}
</Subtitle>
<Description size="s" color={theme.main.text}>
{t(`This action cannot be undone.`)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { styled } from "@reearth/theme";
import Modal from "./Modal";

export type Props = {
team?: {
workspace?: {
id: string;
name: string;
};
deleteTeam?: () => void;
deleteWorkspace?: () => void;
};

const DangerSection: React.FC<Props> = ({ team, deleteTeam }) => {
const DangerSection: React.FC<Props> = ({ workspace, deleteWorkspace }) => {
const [isOpen, setIsOpen] = useState(false);

const t = useT();
Expand All @@ -37,9 +37,9 @@ const DangerSection: React.FC<Props> = ({ team, deleteTeam }) => {
/>
</Section>
<Modal
team={team}
workspace={workspace}
isVisible={isOpen}
deleteTeam={deleteTeam}
deleteWorkspace={deleteWorkspace}
onClose={() => setIsOpen(false)}
/>
</Wrapper>
Expand Down
Loading