Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/resolve stage conflicts #2907

Merged
merged 19 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e69736b
Enhancment/Grant app permissions to new system roles (#2863)
agalin920 Jul 22, 2024
7398833
[Content] Do not show edit template for datasets (#2870)
finnar-bin Jul 23, 2024
8d30954
Schema rules limit file type for media field (#2867)
agalin920 Jul 23, 2024
4d91e56
[Content] Do not show the model as a breadcrumb item when in multipag…
finnar-bin Jul 23, 2024
dc88b71
Fix/table sort by display date field by accounting for empty date val…
agalin920 Jul 23, 2024
b9acd99
Reference createdAt timestamp outside of history object (#2868)
agalin920 Jul 24, 2024
1727581
[Schema | Content] Currency field revamp (#2873)
finnar-bin Jul 25, 2024
bae5cea
[Schema] Currency field vqa updates (#2883)
finnar-bin Jul 26, 2024
8c0f3ac
vqa fixes media schema rules (#2890)
agalin920 Jul 29, 2024
88613eb
[Content] Show image placeholder in publish modal dialog (#2888)
finnar-bin Jul 30, 2024
f3271c2
Hide publish based on permissions on code app (#2887)
agalin920 Jul 30, 2024
361736c
[Content] Do not store pinned columns to local storage (#2892)
finnar-bin Jul 30, 2024
b88aa66
[Content] Multipage table advanced sorting (#2884)
finnar-bin Jul 31, 2024
d49cc5f
[Content] Filter button icon update & show api endpoints on hover (#2…
finnar-bin Jul 31, 2024
379c957
[Content] Only show publish actions when dropdown selection has chang…
finnar-bin Jul 31, 2024
21fc276
[Media] File replacement (#2849)
finnar-bin Aug 1, 2024
2362709
media rules vqa (#2904)
agalin920 Aug 1, 2024
4b76474
[Content] Remove replace file option for non-zesty media files (#2905)
finnar-bin Aug 1, 2024
4377fe2
Merge branch 'stage' into fix/resolve-stage-conflicts
finnar-bin Aug 2, 2024
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
Prev Previous commit
Next Next commit
[Content] Filter button icon update & show api endpoints on hover (#2896
)

Resolves #2889 
Resolves #2830 

### Demo
[Screencast from Wednesday, 31 July, 2024 10:52:37 AM
PST.webm](https://github.com/user-attachments/assets/74116615-c945-4943-9482-fa41404b854d)
finnar-bin authored Jul 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d49cc5fdde5a24669ef7201085e7d4d7e56efcc6
89 changes: 89 additions & 0 deletions src/apps/content-editor/src/app/components/APIEndpoints.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { useSelector } from "react-redux";
import { useParams } from "react-router";
import {
MenuList,
MenuItem,
ListItemIcon,
Typography,
Chip,
} from "@mui/material";
import { DesignServicesRounded, VisibilityRounded } from "@mui/icons-material";

import { AppState } from "../../../../../shell/store/types";
import { ContentItem } from "../../../../../shell/services/types";
import { useGetDomainsQuery } from "../../../../../shell/services/accounts";
import { ApiType } from "../../../../schema/src/app/components/ModelApi";

type APIEndpointsProps = {
type: Extract<ApiType, "quick-access" | "site-generators">;
};
export const APIEndpoints = ({ type }: APIEndpointsProps) => {
const { itemZUID } = useParams<{
itemZUID: string;
}>();
const item = useSelector(
(state: AppState) => state.content[itemZUID] as ContentItem
);
const instance = useSelector((state: AppState) => state.instance);
const { data: domains } = useGetDomainsQuery();

const apiTypeEndpointMap: Partial<Record<ApiType, string>> = {
"quick-access": `/-/instant/${itemZUID}.json`,
"site-generators": item ? `/${item?.web?.path}/?toJSON` : "/?toJSON",
};

const liveDomain = domains?.find((domain) => domain.branch == "live");

return (
<MenuList>
<MenuItem
onClick={() => {
window.open(
// @ts-expect-error config not typed
`${CONFIG.URL_PREVIEW_PROTOCOL}${instance.randomHashID}${CONFIG.URL_PREVIEW}${apiTypeEndpointMap[type]}`,
"_blank"
);
}}
>
<ListItemIcon>
<DesignServicesRounded />
</ListItemIcon>
<Typography
variant="inherit"
noWrap
sx={{
width: 172,
}}
>
{/* @ts-expect-error config not typed */}
{`${instance.randomHashID}${CONFIG.URL_PREVIEW}${apiTypeEndpointMap[type]}`}
</Typography>
<Chip size="small" label="Dev" />
</MenuItem>
{liveDomain && (
<MenuItem
onClick={() => {
window.open(
`https://${liveDomain.domain}${apiTypeEndpointMap[type]}`,
"_blank"
);
}}
>
<ListItemIcon>
<VisibilityRounded />
</ListItemIcon>
<Typography
variant="inherit"
noWrap
sx={{
width: 172,
}}
>
{`${liveDomain.domain}${apiTypeEndpointMap[type]}`}
</Typography>
<Chip size="small" label="Prod" />
</MenuItem>
)}
</MenuList>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
Chip,
IconButton,
ListItemIcon,
Menu,
MenuItem,
Typography,
Tooltip,
} from "@mui/material";
import {
@@ -16,23 +14,18 @@ import {
CodeRounded,
DeleteRounded,
CheckRounded,
DesignServicesRounded,
VisibilityRounded,
KeyboardArrowRightRounded,
} from "@mui/icons-material";
import { useState } from "react";
import { Database } from "@zesty-io/material";
import { useHistory, useParams } from "react-router";
import { useSelector } from "react-redux";
import { AppState } from "../../../../../../../../shell/store/types";
import { ContentItem } from "../../../../../../../../shell/services/types";
import { DuplicateItemDialog } from "./DuplicateItemDialog";
import { ApiType } from "../../../../../../../schema/src/app/components/ModelApi";
import { useGetDomainsQuery } from "../../../../../../../../shell/services/accounts";
import { useFilePath } from "../../../../../../../../shell/hooks/useFilePath";
import { DeleteItemDialog } from "./DeleteItemDialog";
import { useGetContentModelsQuery } from "../../../../../../../../shell/services/instance";
import { usePermission } from "../../../../../../../../shell/hooks/use-permissions";
import { CascadingMenuItem } from "../../../../../../../../shell/components/CascadingMenuItem";
import { APIEndpoints } from "../../../../components/APIEndpoints";

export const MoreMenu = () => {
const { modelZUID, itemZUID } = useParams<{
@@ -42,17 +35,8 @@ export const MoreMenu = () => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const [isCopied, setIsCopied] = useState(false);
const [showDuplicateItemDialog, setShowDuplicateItemDialog] = useState(false);
const [showApiEndpoints, setShowApiEndpoints] = useState<null | HTMLElement>(
null
);
const [showDeleteItemDialog, setShowDeleteItemDialog] = useState(false);
const [apiEndpointType, setApiEndpointType] = useState("quick-access");
const history = useHistory();
const item = useSelector(
(state: AppState) => state.content[itemZUID] as ContentItem
);
const instance = useSelector((state: AppState) => state.instance);
const { data: domains } = useGetDomainsQuery();
const codePath = useFilePath(modelZUID);
const { data: contentModels } = useGetContentModelsQuery();
const type =
@@ -73,13 +57,6 @@ export const MoreMenu = () => {
});
};

const apiTypeEndpointMap: Partial<Record<ApiType, string>> = {
"quick-access": `/-/instant/${itemZUID}.json`,
"site-generators": item ? `/${item?.web?.path}/?toJSON` : "/?toJSON",
};

const liveDomain = domains?.find((domain) => domain.branch == "live");

return (
<>
<Tooltip
@@ -135,31 +112,33 @@ export const MoreMenu = () => {
</ListItemIcon>
Copy ZUID
</MenuItem>
<MenuItem
onClick={(event) => {
setShowApiEndpoints(event.currentTarget);
setApiEndpointType("quick-access");
}}
<CascadingMenuItem
MenuItemComponent={
<>
<ListItemIcon>
<BoltRounded />
</ListItemIcon>
View Quick Access API
<KeyboardArrowRightRounded color="action" sx={{ ml: "auto" }} />
</>
}
>
<ListItemIcon>
<BoltRounded />
</ListItemIcon>
View Quick Access API
<KeyboardArrowRightRounded color="action" sx={{ ml: "auto" }} />
</MenuItem>
<APIEndpoints type="quick-access" />
</CascadingMenuItem>
{type !== "dataset" && (
<MenuItem
onClick={(event) => {
setShowApiEndpoints(event.currentTarget);
setApiEndpointType("site-generators");
}}
<CascadingMenuItem
MenuItemComponent={
<>
<ListItemIcon>
<DataObjectRounded />
</ListItemIcon>
View Site Generators API
<KeyboardArrowRightRounded color="action" sx={{ ml: "auto" }} />
</>
}
>
<ListItemIcon>
<DataObjectRounded />
</ListItemIcon>
View Site Generators API
<KeyboardArrowRightRounded color="action" sx={{ ml: "auto" }} />
</MenuItem>
<APIEndpoints type="site-generators" />
</CascadingMenuItem>
)}
<MenuItem
onClick={() => {
@@ -201,76 +180,6 @@ export const MoreMenu = () => {
onClose={() => setShowDuplicateItemDialog(false)}
/>
)}
<Menu
anchorEl={showApiEndpoints}
open={!!showApiEndpoints}
anchorOrigin={{
vertical: "top",
horizontal: "right",
}}
onClose={() => {
setShowApiEndpoints(null);
}}
>
<MenuItem
onClick={() => {
setShowApiEndpoints(null);
window.open(
// @ts-expect-error config not typed
`${CONFIG.URL_PREVIEW_PROTOCOL}${instance.randomHashID}${CONFIG.URL_PREVIEW}${apiTypeEndpointMap[apiEndpointType]}`,
"_blank"
);
}}
>
<ListItemIcon>
<DesignServicesRounded />
</ListItemIcon>
<Typography
variant="inherit"
noWrap
sx={{
width: 172,
}}
>
{/* @ts-expect-error config not typed */}
{`${instance.randomHashID}${CONFIG.URL_PREVIEW}${apiTypeEndpointMap[apiEndpointType]}`}
</Typography>
<Chip size="small" label="Dev" />
</MenuItem>
{liveDomain && (
<MenuItem
onClick={() => {
setShowApiEndpoints(null);
window.open(
`https://${liveDomain.domain}${
apiTypeEndpointMap[
apiEndpointType as keyof typeof apiTypeEndpointMap
]
}`,
"_blank"
);
}}
>
<ListItemIcon>
<VisibilityRounded />
</ListItemIcon>
<Typography
variant="inherit"
noWrap
sx={{
width: 172,
}}
>
{`${liveDomain.domain}${
apiTypeEndpointMap[
apiEndpointType as keyof typeof apiTypeEndpointMap
]
}`}
</Typography>
<Chip size="small" label="Prod" />
</MenuItem>
)}
</Menu>
{showDeleteItemDialog && (
<DeleteItemDialog onClose={() => setShowDeleteItemDialog(false)} />
)}
Loading