AI: address review on PR #477
このコミットが含まれているのは:
@@ -29,7 +29,7 @@ import { fetchWikiPage } from '@/lib/wiki'
|
||||
import type { FC, MouseEvent } from 'react'
|
||||
|
||||
import type { AvailableLocale, LocaleCode } from '@/lib/locales'
|
||||
import type { Material, Menu, MenuVisibleItem, Tag, User } from '@/types'
|
||||
import type { Material, Menu, MenuVisibleItem, Tag, User, WikiPage } from '@/types'
|
||||
|
||||
type Props = {
|
||||
user: User | null
|
||||
@@ -39,10 +39,11 @@ type NavDensity = 'auto' | 'comfortable' | 'compact'
|
||||
|
||||
|
||||
export const menuOutline = (
|
||||
{ tag, material, wikiId, user, pathName: fullPathname }: {
|
||||
{ tag, material, wikiId, wikiResourceType, user, pathName: fullPathname }: {
|
||||
tag?: Tag | null
|
||||
material?: Material | null
|
||||
wikiId: number | null
|
||||
wikiResourceType?: WikiPage['resourceType']
|
||||
user: User | null
|
||||
pathName: string },
|
||||
): Menu => {
|
||||
@@ -99,17 +100,30 @@ export const menuOutline = (
|
||||
visible: materialFlg && Boolean (material?.tag) },
|
||||
{ ...message ('history'), to: `/materials/changes?material_id=${ material?.id }`,
|
||||
visible: materialFlg }] },
|
||||
{ ...message ('wiki'), to: '/wiki', subMenu: [
|
||||
{ ...message ('search'), to: '/wiki' },
|
||||
{ ...message ('create'), to: '/wiki/new', visible: editable },
|
||||
{ ...message ('allHistory'), to: '/wiki/changes' },
|
||||
{ ...message ('help'), to: '/wiki/ヘルプ:Wiki' },
|
||||
{ component: <Separator/>, visible: wikiPageFlg },
|
||||
{ ...message ('postsWithCount', { count: postCount }), to: `/posts?tags=${ wikiTitle }`,
|
||||
visible: wikiPageFlg },
|
||||
{ ...message ('history'), to: `/wiki/changes?id=${ wikiId }`, visible: wikiPageFlg },
|
||||
{ ...message ('edit'), to: `/wiki/${ wikiId || wikiTitle }/edit`,
|
||||
visible: wikiPageFlg && editable }] },
|
||||
...([
|
||||
{ key: 'tagDescriptions', path: '/tag-descriptions', type: 'tag_description' },
|
||||
{ key: 'tagGroups', path: '/tag-groups', type: 'tag_group' }] as const)
|
||||
.map (({ key, path, type }): MenuVisibleItem => {
|
||||
const current = (wikiResourceType ?? 'tag_description') === type
|
||||
const detailFlg = wikiPageFlg && current
|
||||
const creationPath =
|
||||
type === 'tag_group'
|
||||
? `/wiki/new?title=${ encodeURIComponent ('タググループ:') }` : '/wiki/new'
|
||||
return { ...message (key), to: path,
|
||||
base: (pathName.startsWith ('/wiki') && current) ? '/wiki' : path,
|
||||
subMenu: [
|
||||
{ ...message ('search'), to: path },
|
||||
{ ...message ('create'), to: creationPath, visible: editable },
|
||||
{ ...message ('allHistory'), to: '/wiki/changes' },
|
||||
{ ...message ('help'), to: '/wiki/ヘルプ:Wiki' },
|
||||
{ component: <Separator/>, visible: detailFlg },
|
||||
{ ...message ('postsWithCount', { count: postCount }),
|
||||
to: `/posts?tags=${ wikiTitle }`, visible: detailFlg },
|
||||
{ ...message ('history'), to: `/wiki/changes?id=${ wikiId }`,
|
||||
visible: detailFlg },
|
||||
{ ...message ('edit'), to: `/wiki/${ wikiId || wikiTitle }/edit`,
|
||||
visible: detailFlg && editable }] }
|
||||
}),
|
||||
{ ...message ('help'), to: '/help/home', base: '/help', subMenu: [
|
||||
{ ...message ('search'), to: '/help' },
|
||||
{ ...message ('allHistory'), to: '/help/changes' },
|
||||
@@ -229,7 +243,8 @@ const TopNav: FC<Props> = ({ user, locales, resolveLocaleSwitch }) => {
|
||||
queryKey: materialsKeys.show (effectiveTitle, locale),
|
||||
queryFn: () => fetchMaterial (effectiveTitle, locale) })
|
||||
|
||||
const menu = menuOutline ({ tag, material, wikiId, user, pathName: location.pathname })
|
||||
const menu = menuOutline ({ tag, material, wikiId,
|
||||
wikiResourceType: wikiPage?.resourceType, user, pathName: location.pathname })
|
||||
const visibleMenu = menu.filter ((item): item is MenuVisibleItem => item.visible ?? true)
|
||||
const menuLabels = visibleMenu.map (item => item.name).join ('\u0000')
|
||||
const moreMenu = menu.filter (item =>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする