Skip to content

Commit

Permalink
chore: Add super admin configuration (#766)
Browse files Browse the repository at this point in the history
Co-authored-by: nina992 <[email protected]>
  • Loading branch information
nina992 and nina992 authored Oct 27, 2023
1 parent 6481527 commit 8bc811e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions web/e2e/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const config = {
signUpSecret: process.env["REEARTH_WEB_E2E_SIGNUP_SECRET"],
authProvider: process.env["REEARTH_WEB_AUTH_PROVIDER"],
developerMode: process.env["REEARTH_WEB_DEVELOPER_MODE"],
earlyAccessAdmins: process.env["REEARTH_WEB_EARLY_ACCESS_ADMINS"],
};

export type Config = typeof config;
Expand Down
13 changes: 11 additions & 2 deletions web/src/classic/components/molecules/Dashboard/QuickStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Text from "@reearth/classic/components/atoms/Text";
import ProjectCreationModal from "@reearth/classic/components/molecules/Common/ProjectCreationModal";
import WorkspaceCreationModal from "@reearth/classic/components/molecules/Common/WorkspaceCreationModal";
import { metrics, metricsSizes } from "@reearth/classic/theme";
import { useMeFetcher } from "@reearth/services/api";
import { useT } from "@reearth/services/i18n";
import { styled, useTheme, css } from "@reearth/services/theme";
import { ProjectType } from "@reearth/types";
Expand Down Expand Up @@ -46,11 +47,19 @@ const QuickStart: React.FC<Props> = ({
const [prjectType, setPrjectType] = useState<ProjectType>("classic");
const theme = useTheme();
const isSmallWindow = useMedia("(max-width: 1024px)");
const { useMeQuery } = useMeFetcher();
const {
me: { email = "" },
} = useMeQuery();

const handleCreateProjectClick = useCallback(() => {
if (window.REEARTH_CONFIG?.developerMode) setPrjTypeSelectOpen(true);
if (
window.REEARTH_CONFIG?.developerMode ||
window.REEARTH_CONFIG?.earlyAccessAdmins?.includes(email)
)
setPrjTypeSelectOpen(true);
else setPrjCreateOpen(true);
}, []);
}, [email]);

const handleProjModalClose = useCallback(() => {
setPrjCreateOpen(false);
Expand Down
13 changes: 11 additions & 2 deletions web/src/classic/components/organisms/Settings/ProjectList/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Visualizer,
GetProjectsQuery,
} from "@reearth/classic/gql";
import { useMeFetcher } from "@reearth/services/api";
import { useT } from "@reearth/services/i18n";
import { useWorkspace, useProject, useNotification } from "@reearth/services/state";
import { ProjectType } from "@reearth/types";
Expand Down Expand Up @@ -39,10 +40,18 @@ export default (workspaceId: string) => {
const gqlCache = useApolloClient().cache;

const [modalShown, setModalShown] = useState(false);
const { useMeQuery } = useMeFetcher();
const {
me: { email = "" },
} = useMeQuery();
const openModal = useCallback(() => {
if (window.REEARTH_CONFIG?.developerMode) setPrjTypeSelectOpen(true);
if (
window.REEARTH_CONFIG?.developerMode ||
window.REEARTH_CONFIG?.earlyAccessAdmins?.includes(email)
)
setPrjTypeSelectOpen(true);
else setModalShown(true);
}, []);
}, [email]);

const { data, loading, refetch } = useGetMeQuery();
const [createNewProject] = useCreateProjectMutation({
Expand Down
1 change: 1 addition & 0 deletions web/src/services/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type Config = {
sentryEnv?: string;
cesiumIonAccessToken?: string;
developerMode?: boolean;
earlyAccessAdmins?: string[];
brand?: {
logoUrl?: string;
background?: string;
Expand Down

0 comments on commit 8bc811e

Please sign in to comment.