Skip to content

Commit

Permalink
fix: update example code
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Dec 12, 2024
1 parent 2a7f302 commit ef72dd2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
11 changes: 11 additions & 0 deletions hide-tenant-manager-menu-item/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Hiding Navigation Menu Items

This examples shows how to hide navigation menu items in the Admin Area. More specifically, we're hiding the "Tenant Manager" menu item.

The Admin extension code can be found [here](./5.40.x/extensions/hideTenantManagerMenuItem/src/index.tsx).

The extension can also be easily downloaded into your Webiny project by running the following command:

```bash
yarn webiny extension hide-tenant-manager-menu-item
```
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ export const SpaceX = createRenderer(() => {
const { limit, offset, type } = element.data.variables;

// This is where we fetch the data and store it into component's state.
const { data, loading } = useLoader<Spacecraft[]>(() => {
return request(GQL_API_URL, QUERIES[type], {
limit: parseInt(limit),
offset: parseInt(offset)
}).then(res => res.data);
});
const { data, loading } = useLoader<Spacecraft[]>(
() => {
return request(GQL_API_URL, QUERIES[type], {
limit: parseInt(limit),
offset: parseInt(offset)
}).then(res => res.data);
},
{ cacheKey: [limit, offset, type] }
);

if (loading) {
return <>Loading...</>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from "@webiny/app-page-builder";
import { SpaceX, SpaceXElementData } from "./SpaceX";
import { OnCreateActions } from "@webiny/app-page-builder/types";
import { Element } from "@webiny/app-page-builder-elements/types";
import { AdvancedSettings } from "./admin/AdvancedSettings";

const INITIAL_ELEMENT_DATA: SpaceXElementData = {
Expand All @@ -15,10 +14,10 @@ const INITIAL_ELEMENT_DATA: SpaceXElementData = {

export const Extension = () => (
<>
<PbRenderElementPlugin elementType={"spaceX"} render={SpaceX} />
<PbRenderElementPlugin elementType={"spaceX"} renderer={SpaceX} />
<PbEditorPageElementPlugin
elementType={"spaceX"}
render={({ element }) => <SpaceX element={element as Element} />}
renderer={SpaceX}
toolbar={{
// We use `pb-editor-element-group-media` to put our new
// page element into the Media group in the left sidebar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import React from "react";
import { PbRenderElementPlugin } from "@webiny/app-website";
import { SpaceX } from "./SpaceX";

export const Extension = () => <PbRenderElementPlugin elementType={"spaceX"} render={SpaceX} />;
export const Extension = () => <PbRenderElementPlugin elementType={"spaceX"} renderer={SpaceX} />;

0 comments on commit ef72dd2

Please sign in to comment.