Skip to content

Commit

Permalink
Convert staff flag to zesty email flag for blocks (#3104)
Browse files Browse the repository at this point in the history
  • Loading branch information
agalin920 authored Dec 19, 2024
1 parent 5c4c30f commit 8ff7a03
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/apps/schema/src/app/components/CreateModelDialogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { formatPathPart } from "../../../../../utility/formatPathPart";
import { AppState } from "../../../../../shell/store/types";
import { SelectModelParentInput } from "./SelectModelParentInput";
import { SelectBlockGroupInput } from "./SelectBlockGroupInput";
import { isZestyEmail } from "../../../../../utility/isZestyEmail";

interface Props {
onClose: () => void;
Expand Down Expand Up @@ -256,7 +257,7 @@ export const CreateModelDialogue = ({ onClose, modelType = "" }: Props) => {
{modelTypes
?.filter((modelType) => {
if (modelType.key === "block") {
return user?.staff;
return isZestyEmail(user.email);
}
return true;
})
Expand Down
3 changes: 2 additions & 1 deletion src/apps/schema/src/app/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { CreateModelDialogue } from "../CreateModelDialogue";
import { ModelList } from "./ModelList";
import { useSelector } from "react-redux";
import { AppState } from "../../../../../../shell/store/types";
import { isZestyEmail } from "../../../../../../utility/isZestyEmail";

export const Sidebar = () => {
const { data: models, isLoading } = useGetContentModelsQuery();
Expand Down Expand Up @@ -81,7 +82,7 @@ export const Sidebar = () => {
}
/>
</Box>
{user?.staff && (
{isZestyEmail(user.email) && (
<Box pt={1.5}>
<ModelList
title="blocks"
Expand Down
8 changes: 7 additions & 1 deletion src/shell/store/products.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isZestyEmail } from "../../utility/isZestyEmail";

export function products(state = ["content", "media"], action) {
switch (action.type) {
case "FETCH_PRODUCTS_SUCCESS":
Expand Down Expand Up @@ -87,7 +89,6 @@ export function fetchProducts() {
data = [
"launchpad",
"content",
"blocks",
"schema",
"media",
"code",
Expand All @@ -100,6 +101,11 @@ export function fetchProducts() {
];
}

if (isZestyEmail(getState().user.email)) {
const contentIndex = data.indexOf("content");
data.splice(contentIndex + 1, 0, "blocks");
}

dispatch({
type: "FETCH_PRODUCTS_SUCCESS",
payload: {
Expand Down
3 changes: 3 additions & 0 deletions src/utility/isZestyEmail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isZestyEmail(email: string): boolean {
return email.endsWith("@zesty.io");
}

0 comments on commit 8ff7a03

Please sign in to comment.