Skip to content

Commit

Permalink
Refactor: use StackLink wherever possible (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarnutsch authored Dec 7, 2023
1 parent f9e4606 commit 607b620
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 2 additions & 3 deletions demo/admin/src/pages/mainMenu/components/MainMenuItems.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { gql } from "@apollo/client";
import { MainContent, Table, TableQuery, Toolbar, ToolbarAutomaticTitleItem, useStackSwitchApi, useTableQuery } from "@comet/admin";
import { MainContent, StackLink, Table, TableQuery, Toolbar, ToolbarAutomaticTitleItem, useTableQuery } from "@comet/admin";
import { Edit } from "@comet/admin-icons";
import { IconButton } from "@mui/material";
import { ContentScopeIndicator } from "@src/common/ContentScopeIndicator";
Expand All @@ -25,7 +25,6 @@ const mainMenuQuery = gql`
`;

const MainMenuItems: React.FunctionComponent = () => {
const stackApi = useStackSwitchApi();
const { scope } = useContentScope();

const { tableData, api, loading, error } = useTableQuery<GQLMainMenuQuery, GQLMainMenuQueryVariables>()(mainMenuQuery, {
Expand Down Expand Up @@ -64,7 +63,7 @@ const MainMenuItems: React.FunctionComponent = () => {
header: "",
cellProps: { align: "right" },
render: (item) => (
<IconButton color="primary" onClick={() => stackApi.activatePage("edit", item.node.id)}>
<IconButton component={StackLink} color="primary" pageName="edit" payload={item.node.id}>
<Edit />
</IconButton>
),
Expand Down
9 changes: 1 addition & 8 deletions packages/admin/cms-admin/src/redirects/RedirectsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
muiGridPagingToGql,
muiGridSortToGql,
StackLink,
StackSwitchApiContext,
TableDeleteButton,
Toolbar,
ToolbarAutomaticTitleItem,
Expand Down Expand Up @@ -73,8 +72,6 @@ export function RedirectsTable({ linkBlock, scope }: Props): JSX.Element {
},
];

const stackApi = React.useContext(StackSwitchApiContext);

const columns: GridColDef[] = [
{
field: "source",
Expand Down Expand Up @@ -139,11 +136,7 @@ export function RedirectsTable({ linkBlock, scope }: Props): JSX.Element {
headerName: "",
renderCell: (params) => (
<IconWrapper>
<IconButton
onClick={() => {
stackApi.activatePage("edit", params.id.toString());
}}
>
<IconButton component={StackLink} pageName="edit" payload={params.id.toString()}>
<Edit color="primary" />
</IconButton>
<TableDeleteButton
Expand Down

0 comments on commit 607b620

Please sign in to comment.