Skip to content

Commit

Permalink
refactor: replace "team" word related to Team state with "workspace" (#…
Browse files Browse the repository at this point in the history
…607)

* refactor: replace team syntax  with workspace

* pr-1

---------

Co-authored-by: nina992 <nouralali992@gmail.com>
  • Loading branch information
nina992 and nina992 committed Apr 13, 2023
1 parent abd9a3c commit fb254b4
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 112 deletions.
4 changes: 2 additions & 2 deletions src/components/organisms/Authentication/RootPage/hooks.ts
Expand Up @@ -5,7 +5,7 @@ import { useNavigate } from "react-router-dom";
import { useAuth, useCleanUrl } from "@reearth/auth";
import { useGetTeamsQuery } from "@reearth/gql";
import { useT } from "@reearth/i18n";
import { useTeam, useNotification, useUserId } from "@reearth/state";
import { useWorkspace, useNotification, useUserId } from "@reearth/state";

export type Mode = "layer" | "widget";

Expand All @@ -14,7 +14,7 @@ export default () => {
const navigate = useNavigate();
const { isAuthenticated, isLoading, error: authError, login, logout } = useAuth();
const [error, isErrorChecked] = useCleanUrl();
const [currentWorkspace, setWorkspace] = useTeam();
const [currentWorkspace, setWorkspace] = useWorkspace();
const [currentUserId, setCurrentUserId] = useUserId();
const [, setNotification] = useNotification();

Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/Dashboard/hooks.ts
Expand Up @@ -15,14 +15,14 @@ import {
GetProjectsQuery,
} from "@reearth/gql";
import { useT } from "@reearth/i18n";
import { useTeam, useProject, useUnselectProject, useNotification } from "@reearth/state";
import { useWorkspace, useProject, useUnselectProject, useNotification } from "@reearth/state";

export type ProjectNodes = NonNullable<GetProjectsQuery["projects"]["nodes"][number]>[];

const projectsPerPage = 9;

export default (workspaceId?: string) => {
const [currentWorkspace, setCurrentWorkspace] = useTeam();
const [currentWorkspace, setCurrentWorkspace] = useWorkspace();

const [currentProject] = useProject();
const unselectProject = useUnselectProject();
Expand Down
22 changes: 11 additions & 11 deletions src/components/organisms/EarthEditor/Header/hooks.ts
Expand Up @@ -14,7 +14,7 @@ import {
useCreateTeamMutation,
} from "@reearth/gql";
import { useT } from "@reearth/i18n";
import { useSceneId, useTeam, useProject, useNotification } from "@reearth/state";
import { useSceneId, useWorkspace, useProject, useNotification } from "@reearth/state";

export default () => {
const url = window.REEARTH_CONFIG?.published?.split("{}");
Expand All @@ -23,7 +23,7 @@ export default () => {

const [, setNotification] = useNotification();
const [sceneId] = useSceneId();
const [currentTeam, setTeam] = useTeam();
const [currentWorkspace, setWorkspace] = useWorkspace();
const [currentProject, setProject] = useProject();

const navigate = useNavigate();
Expand Down Expand Up @@ -85,11 +85,11 @@ export default () => {
}, [validatingAlias, checkProjectAliasData, project]);

useEffect(() => {
if (currentTeam) return;
if (currentWorkspace) return;
const team = teams?.find(t => t.id === teamId);
if (!team) return;
setTeam(team);
}, [teams, currentTeam, teamId, setTeam]);
setWorkspace(team);
}, [teams, currentWorkspace, teamId, setWorkspace]);

useEffect(() => {
setProject(p =>
Expand Down Expand Up @@ -162,12 +162,12 @@ export default () => {
const handleTeamChange = useCallback(
(teamId: string) => {
const team = teams?.find(team => team.id === teamId);
if (team && teamId !== currentTeam?.id) {
setTeam(team);
if (team && teamId !== currentWorkspace?.id) {
setWorkspace(team);
navigate(`/dashboard/${teamId}`);
}
},
[teams, currentTeam?.id, setTeam, navigate],
[teams, currentWorkspace?.id, setWorkspace, navigate],
);

const [createTeamMutation] = useCreateTeamMutation();
Expand All @@ -178,11 +178,11 @@ export default () => {
refetchQueries: ["GetTeams"],
});
if (results.data?.createTeam) {
setTeam(results.data.createTeam.team);
setWorkspace(results.data.createTeam.team);
navigate(`/dashboard/${results.data.createTeam.team.id}`);
}
},
[createTeamMutation, setTeam, navigate],
[createTeamMutation, setWorkspace, navigate],
);

useEffect(() => {
Expand Down Expand Up @@ -213,7 +213,7 @@ export default () => {
projectStatus: convertStatus(project?.publishmentStatus),
publicationModalLoading,
user,
currentTeam,
currentWorkspace,
currentProject,
validAlias,
validatingAlias,
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/EarthEditor/Header/index.tsx
Expand Up @@ -25,7 +25,7 @@ const Header: React.FC<Props> = ({ className }) => {
projectStatus,
publicationModalLoading,
user,
currentTeam,
currentWorkspace,
currentProject,
validAlias,
validatingAlias,
Expand Down Expand Up @@ -53,7 +53,7 @@ const Header: React.FC<Props> = ({ className }) => {
user={user}
workspaces={teams}
teamId={teamId}
currentWorkspace={currentTeam}
currentWorkspace={currentWorkspace}
modalShown={workspaceModalVisible}
onPublishmentStatusClick={handlePublicationModalOpen}
onSignOut={handleLogout}
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/EarthEditor/PropertyPane/hooks.ts
Expand Up @@ -26,7 +26,7 @@ import {
useRootLayerId,
useIsCapturing,
useCamera,
useTeam,
useWorkspace,
useSceneId,
useSceneMode,
useSelectedBlock,
Expand Down Expand Up @@ -67,7 +67,7 @@ export default (mode: Mode) => {
const [isCapturing, onIsCapturingChange] = useIsCapturing();
const [camera, setCamera] = useCamera();
const [sceneMode] = useSceneMode();
const [team] = useTeam();
const [workspace] = useWorkspace();
const [sceneId] = useSceneId();
const [widgetAlignEditorActivated, setWidgetAlignEditorActivated] =
useWidgetAlignEditorActivated();
Expand Down Expand Up @@ -361,7 +361,7 @@ export default (mode: Mode) => {

return {
pane,
teamId: team?.id,
workspaceId: workspace?.id,
error,
loading,
isLayerGroup,
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/EarthEditor/PropertyPane/index.tsx
Expand Up @@ -16,7 +16,7 @@ export interface Props {
const PropertyPane: React.FC<Props> = ({ mode }) => {
const {
pane,
teamId,
workspaceId,
isLayerGroup,
linkedDatasetSchemaId,
linkedDatasetId,
Expand Down Expand Up @@ -49,8 +49,8 @@ const PropertyPane: React.FC<Props> = ({ mode }) => {
} = useHooks(mode);

const AssetModalComponent: ComponentType<AssetModalProps> = useCallback(
({ ...props }) => <AssetModal teamId={teamId} {...props} />,
[teamId],
({ ...props }) => <AssetModal teamId={workspaceId} {...props} />,
[workspaceId],
);

return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/Settings/Account/hooks.ts
Expand Up @@ -3,7 +3,7 @@ import { useCallback } from "react";

import { useUpdateMeMutation, useGetProfileQuery, Theme as GQLTheme } from "@reearth/gql";
import { useT } from "@reearth/i18n";
import { useTeam, useProject, useNotification } from "@reearth/state";
import { useWorkspace, useProject, useNotification } from "@reearth/state";

const enumTypeMapper: Partial<Record<GQLTheme, string>> = {
[GQLTheme.Default]: "default",
Expand All @@ -22,7 +22,7 @@ export default () => {
const t = useT();
const [, setNotification] = useNotification();
const client = useApolloClient();
const [currentTeam] = useTeam();
const [currentWorkspace] = useWorkspace();
const [currentProject] = useProject();

const { data: profileData } = useGetProfileQuery();
Expand Down Expand Up @@ -95,7 +95,7 @@ export default () => {
);

return {
currentTeam,
currentWorkspace,
currentProject,
me,
hasPassword,
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/Settings/Account/index.tsx
Expand Up @@ -13,7 +13,7 @@ export type Props = {};
const Account: React.FC<Props> = () => {
const t = useT();
const {
currentTeam,
currentWorkspace,
currentProject,
me,
hasPassword,
Expand All @@ -25,7 +25,7 @@ const Account: React.FC<Props> = () => {
} = useHooks();

return (
<SettingPage teamId={currentTeam?.id} projectId={currentProject?.id}>
<SettingPage teamId={currentWorkspace?.id} projectId={currentProject?.id}>
<SettingsHeader title={t("Account")} />
<ProfileSection username={me?.name} updateName={updateName} />
{me && (
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/Settings/Project/Dataset/hooks.ts
Expand Up @@ -9,7 +9,7 @@ import {
useDatasetsListQuery,
} from "@reearth/gql";
import { useT } from "@reearth/i18n";
import { useTeam, useProject, useNotification } from "@reearth/state";
import { useWorkspace, useProject, useNotification } from "@reearth/state";

type Nodes = NonNullable<DatasetsListQuery["datasetSchemas"]["nodes"]>;

Expand All @@ -19,7 +19,7 @@ const datasetPerPage = 20;

export default (projectId: string) => {
const t = useT();
const [currentTeam] = useTeam();
const [currentWorkspace] = useWorkspace();
const [currentProject] = useProject();
const [, setNotification] = useNotification();

Expand Down Expand Up @@ -107,7 +107,7 @@ export default (projectId: string) => {
);

return {
currentTeam,
currentWorkspace,
currentProject,
datasetSchemas,
datasetLoading: loading ?? isRefetchingDataSets,
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/Settings/Project/Dataset/index.tsx
Expand Up @@ -15,7 +15,7 @@ type Props = {
const Dataset: React.FC<Props> = ({ projectId }) => {
const t = useT();
const {
currentTeam,
currentWorkspace,
currentProject,
datasetSchemas,
datasetLoading,
Expand All @@ -27,7 +27,7 @@ const Dataset: React.FC<Props> = ({ projectId }) => {

return (
<SettingPage
teamId={currentTeam?.id}
teamId={currentWorkspace?.id}
projectId={projectId}
loading={datasetLoading}
hasMoreItems={hasMoreDataSets}
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/Settings/Project/Public/hooks.ts
Expand Up @@ -11,7 +11,7 @@ import {
} from "@reearth/gql";
import { useLang as useCurrentLang } from "@reearth/i18n";
import {
useTeam,
useWorkspace,
useProject,
useNotification,
NotificationType,
Expand All @@ -23,7 +23,7 @@ type Params = {
};

export default ({ projectId }: Params) => {
const [currentTeam] = useTeam();
const [currentWorkspace] = useWorkspace();
const [currentProject] = useProject();
const [, setNotification] = useNotification();

Expand Down Expand Up @@ -169,7 +169,7 @@ export default ({ projectId }: Params) => {
const [currentTheme] = useCurrentTheme();

return {
currentTeam,
currentWorkspace,
currentProject,
projectAlias,
projectStatus: convertStatus(project?.publishmentStatus),
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/Settings/Project/Public/index.tsx
Expand Up @@ -19,7 +19,7 @@ type Props = {
const Public: React.FC<Props> = ({ projectId }) => {
const t = useT();
const {
currentTeam,
currentWorkspace,
currentProject,
projectAlias,
projectStatus,
Expand All @@ -41,7 +41,7 @@ const Public: React.FC<Props> = ({ projectId }) => {
} = useHooks({ projectId });

return (
<SettingPage teamId={currentTeam?.id} projectId={projectId}>
<SettingPage teamId={currentWorkspace?.id} projectId={projectId}>
<SettingsHeader currentProject={currentProject?.name} title={t("Public")} />
{!project?.isArchived ? (
<>
Expand All @@ -60,7 +60,7 @@ const Public: React.FC<Props> = ({ projectId }) => {
toggleAssetModal={toggleAssetModal}
assetModal={
<AssetModal
teamId={currentTeam?.id}
teamId={currentWorkspace?.id}
isOpen={assetModalOpened}
onSelect={updatePublicImage}
toggleAssetModal={toggleAssetModal}
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/Settings/Project/hooks.ts
Expand Up @@ -7,7 +7,7 @@ import {
useDeleteProjectMutation,
} from "@reearth/gql";
import { useT } from "@reearth/i18n";
import { useTeam, useNotification } from "@reearth/state";
import { useWorkspace, useNotification } from "@reearth/state";

type Params = {
projectId: string;
Expand All @@ -16,7 +16,7 @@ type Params = {
export default ({ projectId }: Params) => {
const t = useT();
const [, setNotification] = useNotification();
const [currentTeam] = useTeam();
const [currentWorkspace] = useWorkspace();

const { data } = useGetProjectQuery({
variables: { projectId: projectId ?? "" },
Expand Down Expand Up @@ -131,7 +131,7 @@ export default ({ projectId }: Params) => {
return {
project,
projectId,
currentTeam,
currentWorkspace,
updateProjectName,
updateProjectDescription,
updateProjectImageUrl,
Expand Down
10 changes: 5 additions & 5 deletions src/components/organisms/Settings/Project/index.tsx
Expand Up @@ -16,7 +16,7 @@ type Props = {
const Project: React.FC<Props> = ({ projectId }) => {
const {
project,
currentTeam,
currentWorkspace,
updateProjectName,
updateProjectDescription,
updateProjectImageUrl,
Expand All @@ -27,8 +27,8 @@ const Project: React.FC<Props> = ({ projectId }) => {
} = useHooks({ projectId });

return (
<SettingPage teamId={currentTeam?.id} projectId={projectId}>
<SettingsHeader currentWorkspace={currentTeam} currentProject={project?.name} />
<SettingPage teamId={currentWorkspace?.id} projectId={projectId}>
<SettingsHeader currentWorkspace={currentWorkspace} currentProject={project?.name} />
{!project?.isArchived ? (
<ProfileSection
currentProject={project}
Expand All @@ -38,7 +38,7 @@ const Project: React.FC<Props> = ({ projectId }) => {
toggleAssetModal={toggleAssetModal}
assetModal={
<AssetModal
teamId={currentTeam?.id}
teamId={currentWorkspace?.id}
isOpen={assetModalOpened}
initialAssetUrl={project?.imageUrl}
onSelect={updateProjectImageUrl}
Expand All @@ -51,7 +51,7 @@ const Project: React.FC<Props> = ({ projectId }) => {
)}
<DangerSection
project={project}
teamId={currentTeam?.id}
teamId={currentWorkspace?.id}
archiveProject={archiveProject}
deleteProject={deleteProject}
/>
Expand Down

0 comments on commit fb254b4

Please sign in to comment.