Skip to content

Commit

Permalink
Merge pull request #13 from Q42/fix/show-title-instead-of-schema-name
Browse files Browse the repository at this point in the history
show schema title
  • Loading branch information
djohalo2 authored Dec 21, 2023
2 parents 21e3587 + 98850e7 commit 1254412
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/PageTreeViewItemActions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AddIcon } from '@sanity/icons';
import { Button, Flex, Menu, MenuButton, MenuItem } from '@sanity/ui';
import { useEffect, useState } from 'react';
import { useClient } from 'sanity';
import { useClient, useSchema } from 'sanity';
import { useRouter } from 'sanity/router';

import { usePageTreeConfig } from '../hooks/usePageTreeConfig';
Expand All @@ -16,6 +16,7 @@ export type PageTreeViewItemActionsProps = {
};

export const PageTreeViewItemActions = ({ page, onActionOpen, onActionClose }: PageTreeViewItemActionsProps) => {
const schema = useSchema();
const config = usePageTreeConfig();
const client = useClient({ apiVersion: config.apiVersion });
const { navigateUrl, resolveIntentLink } = useRouter();
Expand Down Expand Up @@ -57,7 +58,7 @@ export const PageTreeViewItemActions = ({ page, onActionOpen, onActionClose }: P
{config.pageSchemaTypes
.filter(type => type !== config.rootSchemaType)
.map(type => (
<MenuItem key={type} onClick={() => onAdd(type)} text={type} value={type} />
<MenuItem key={type} onClick={() => onAdd(type)} text={schema.get(type)?.title ?? type} value={type} />
))}
</Menu>
}
Expand Down

0 comments on commit 1254412

Please sign in to comment.