コミットを比較
3 コミット
4c0a4f5d9b
...
d721a64e33
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
| d721a64e33 | |||
| 0eb45372c3 | |||
| 27aa5321a1 |
@@ -36,7 +36,8 @@ const verticalChrome = (el: HTMLElement): number => {
|
||||
const setChildrenById = (
|
||||
tags: MaterialSidebarTag[],
|
||||
targetId: number,
|
||||
children: MaterialSidebarTag[]): MaterialSidebarTag[] => (
|
||||
children: MaterialSidebarTag[],
|
||||
): MaterialSidebarTag[] => (
|
||||
tags.map (tag => {
|
||||
if (tag.id === targetId)
|
||||
return { ...tag, children }
|
||||
|
||||
@@ -4,7 +4,7 @@ import { cn } from '@/lib/utils'
|
||||
|
||||
import type { FC } from 'react'
|
||||
|
||||
type Props = { children: React.ReactNode }
|
||||
type Props = { children: React.ReactNode; className?: string }
|
||||
|
||||
|
||||
const PageTitle: FC<Props> = ({ children, className, ...rest }) => (
|
||||
|
||||
@@ -8,7 +8,6 @@ import WikiBody from '@/components/WikiBody'
|
||||
import FieldError from '@/components/common/FieldError'
|
||||
import FormField from '@/components/common/FormField'
|
||||
import PageTitle from '@/components/common/PageTitle'
|
||||
import PrefetchLink from '@/components/PrefetchLink'
|
||||
import TabGroup, { Tab } from '@/components/common/TabGroup'
|
||||
import TagInput from '@/components/common/TagInput'
|
||||
import MainArea from '@/components/layout/MainArea'
|
||||
|
||||
@@ -33,15 +33,11 @@ describe ('MaterialListPage', () => {
|
||||
} },
|
||||
)
|
||||
})
|
||||
expect (await screen.findByText ('素材はありません.')).toBeInTheDocument ()
|
||||
expect (await screen.findByText ('素材はありません。')).toBeInTheDocument ()
|
||||
expect (screen.getByRole ('link', { name: '新規素材を追加' })).toHaveAttribute (
|
||||
'href',
|
||||
'/materials/new',
|
||||
)
|
||||
expect (screen.getByRole ('link', { name: '履歴' })).toHaveAttribute (
|
||||
'href',
|
||||
'/materials/changes',
|
||||
)
|
||||
})
|
||||
|
||||
it ('shows materials in the default card view', async () => {
|
||||
@@ -159,16 +155,9 @@ describe ('MaterialListPage', () => {
|
||||
(_, element) => element?.textContent === '伊地知ニジカ 配下の素材を表示中',
|
||||
)).toBeInTheDocument ()
|
||||
|
||||
const addLinks = screen.getAllByRole ('link', { name: 'このタグに素材を追加' })
|
||||
expect (addLinks[0]).toHaveAttribute (
|
||||
expect (screen.getByRole ('link', { name: '泣き' })).toHaveAttribute (
|
||||
'href',
|
||||
'/materials/new?tag=%E4%BC%8A%E5%9C%B0%E7%9F%A5%E3%83%8B%E3%82%B8%E3%82%AB'
|
||||
+ '&return_to=%2Fmaterials%3Ftag_id%3D20%26include_descendants%3D1%26group_by%3Dparent_tag',
|
||||
)
|
||||
expect (addLinks[1]).toHaveAttribute (
|
||||
'href',
|
||||
'/materials/new?tag=%E6%B3%A3%E3%81%8D'
|
||||
+ '&return_to=%2Fmaterials%3Ftag_id%3D20%26include_descendants%3D1%26group_by%3Dparent_tag',
|
||||
'/materials?tag_id=30&include_descendants=1&group_by=parent_tag&material_filter=present',
|
||||
)
|
||||
expect (screen.getByRole ('link', { name: 'タグ選択を解除' })).toHaveAttribute (
|
||||
'href',
|
||||
|
||||
@@ -52,10 +52,6 @@ const SORT_LABELS: Record<MaterialIndexSort, string> = {
|
||||
version_no: 'バージョン',
|
||||
id: 'ID'}
|
||||
|
||||
const GROUP_BY_LABELS: Record<MaterialIndexGroupBy, string> = {
|
||||
none: 'オフ',
|
||||
parent_tag: '親タグ'}
|
||||
|
||||
|
||||
const setIf = (qs: URLSearchParams, key: string, value: string | null) => {
|
||||
const next = value?.trim ()
|
||||
@@ -87,21 +83,24 @@ const materialTitle = (material: Material): string =>
|
||||
|
||||
const groupedTagPath = (
|
||||
tagId: number,
|
||||
materialFilter: MaterialFilter): string =>
|
||||
materialFilter: MaterialFilter,
|
||||
): string =>
|
||||
`/materials?tag_id=${ tagId }&include_descendants=1&group_by=parent_tag`
|
||||
+ `&material_filter=${ materialFilter }`
|
||||
|
||||
|
||||
const materialNewPath = (
|
||||
tagName: string,
|
||||
returnTo: string): string =>
|
||||
returnTo: string,
|
||||
): string =>
|
||||
`/materials/new?tag=${ encodeURIComponent (tagName) }`
|
||||
+ `&return_to=${ encodeURIComponent (returnTo) }`
|
||||
|
||||
|
||||
const clearedTagSelectionPath = (
|
||||
locationSearch: string,
|
||||
materialFilter: MaterialFilter): string => {
|
||||
materialFilter: MaterialFilter,
|
||||
): string => {
|
||||
const qs = new URLSearchParams (locationSearch)
|
||||
qs.delete ('tag_id')
|
||||
qs.delete ('include_descendants')
|
||||
@@ -190,10 +189,9 @@ const MaterialListItem: FC<{ material: Material }> = ({ material }) => (
|
||||
const GroupHeading: FC<{
|
||||
count: number
|
||||
materialFilter: MaterialFilter
|
||||
returnTo: string
|
||||
title: string
|
||||
tagId: number
|
||||
}> = ({ count, materialFilter, returnTo, title, tagId }) => (
|
||||
}> = ({ count, materialFilter, title, tagId }) => (
|
||||
<div className="flex items-center gap-2 border-b border-stone-200 pb-2
|
||||
dark:border-stone-700">
|
||||
<PrefetchLink
|
||||
@@ -378,8 +376,7 @@ const MaterialListPage: FC = () => {
|
||||
tagId={group.tag.id}
|
||||
title={group.tag.name}
|
||||
count={group.count}
|
||||
materialFilter={materialFilter}
|
||||
returnTo={location.pathname + location.search}/>
|
||||
materialFilter={materialFilter}/>
|
||||
{renderMaterialCollection (groupMaterials)}
|
||||
</section>)
|
||||
})}
|
||||
@@ -601,7 +598,7 @@ const MaterialListPage: FC = () => {
|
||||
{(!isLoading && !isError && materials.length === 0) && (
|
||||
<p>
|
||||
素材はありません。
|
||||
{['character', 'material'].includes (tagScope?.tag.category) && (
|
||||
{(tagScope && ['character', 'material'].includes (tagScope.tag.category)) && (
|
||||
<>
|
||||
<PrefetchLink
|
||||
to={materialNewPath (tagScope.tag.name, location.pathname + location.search)}
|
||||
|
||||
新しい課題から参照
ユーザをブロックする