広場投稿追加画面の刷新 (#399) #413
@@ -9,6 +9,7 @@ import TopNavUser from '@/components/TopNavUser'
|
|||||||
import { WikiIdBus } from '@/lib/eventBus/WikiIdBus'
|
import { WikiIdBus } from '@/lib/eventBus/WikiIdBus'
|
||||||
import { materialsKeys, tagsKeys, wikiKeys } from '@/lib/queryKeys'
|
import { materialsKeys, tagsKeys, wikiKeys } from '@/lib/queryKeys'
|
||||||
import { useClientBehaviourSettings } from '@/lib/useClientBehaviourSettings'
|
import { useClientBehaviourSettings } from '@/lib/useClientBehaviourSettings'
|
||||||
|
import { canEditContent } from '@/lib/users'
|
||||||
import { fetchTag, fetchTagByName } from '@/lib/tags'
|
import { fetchTag, fetchTagByName } from '@/lib/tags'
|
||||||
import { fetchMaterial } from '@/lib/materials'
|
import { fetchMaterial } from '@/lib/materials'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
@@ -30,6 +31,7 @@ export const menuOutline = (
|
|||||||
pathName: string },
|
pathName: string },
|
||||||
): Menu => {
|
): Menu => {
|
||||||
const postCount = tag?.postCount ?? material?.tag?.postCount ?? 0
|
const postCount = tag?.postCount ?? material?.tag?.postCount ?? 0
|
||||||
|
const editable = canEditContent (user)
|
||||||
|
|
||||||
const wikiPageFlg = Boolean (/^\/wiki\/(?!new|changes)[^/]+/.test (pathName) && wikiId)
|
const wikiPageFlg = Boolean (/^\/wiki\/(?!new|changes)[^/]+/.test (pathName) && wikiId)
|
||||||
const wikiTitle = pathName.split ('/')[2] ?? ''
|
const wikiTitle = pathName.split ('/')[2] ?? ''
|
||||||
@@ -42,10 +44,8 @@ export const menuOutline = (
|
|||||||
{ name: '広場', to: '/posts', subMenu: [
|
{ name: '広場', to: '/posts', subMenu: [
|
||||||
{ name: '一覧', to: '/posts' },
|
{ name: '一覧', to: '/posts' },
|
||||||
{ name: '検索', to: '/posts/search' },
|
{ name: '検索', to: '/posts/search' },
|
||||||
{ name: '追加', to: '/posts/new',
|
{ name: '追加', to: '/posts/new', visible: editable },
|
||||||
visible: ['admin', 'member'].includes (user?.role) },
|
{ name: '取込', to: '/posts/import', visible: editable },
|
||||||
{ name: '取込', to: '/posts/import',
|
|
||||||
visible: ['admin', 'member'].includes (user?.role) },
|
|
||||||
{ name: '全体履歴', to: '/posts/changes' },
|
{ name: '全体履歴', to: '/posts/changes' },
|
||||||
{ name: 'ヘルプ', to: '/wiki/ヘルプ:広場' }] },
|
{ name: 'ヘルプ', to: '/wiki/ヘルプ:広場' }] },
|
||||||
{ name: 'タグ', to: '/tags', subMenu: [
|
{ name: 'タグ', to: '/tags', subMenu: [
|
||||||
@@ -61,8 +61,7 @@ export const menuOutline = (
|
|||||||
visible: tagFlg && tag?.category !== 'nico' }] },
|
visible: tagFlg && tag?.category !== 'nico' }] },
|
||||||
{ name: '素材', to: '/materials', visible: true, subMenu: [
|
{ name: '素材', to: '/materials', visible: true, subMenu: [
|
||||||
{ name: '一覧', to: '/materials' },
|
{ name: '一覧', to: '/materials' },
|
||||||
{ name: '追加', to: '/materials/new',
|
{ name: '追加', to: '/materials/new', visible: editable },
|
||||||
visible: ['admin', 'member'].includes (user?.role) },
|
|
||||||
{ name: '抑止', to: '/materials/suppressions',
|
{ name: '抑止', to: '/materials/suppressions',
|
||||||
visible: user?.role === 'admin' },
|
visible: user?.role === 'admin' },
|
||||||
{ name: '全体履歴', to: '/materials/changes' },
|
{ name: '全体履歴', to: '/materials/changes' },
|
||||||
@@ -75,8 +74,7 @@ export const menuOutline = (
|
|||||||
visible: materialFlg }] },
|
visible: materialFlg }] },
|
||||||
{ name: 'Wiki', to: '/wiki/ヘルプ:ホーム', base: '/wiki', subMenu: [
|
{ name: 'Wiki', to: '/wiki/ヘルプ:ホーム', base: '/wiki', subMenu: [
|
||||||
{ name: '検索', to: '/wiki' },
|
{ name: '検索', to: '/wiki' },
|
||||||
{ name: '新規', to: '/wiki/new',
|
{ name: '新規', to: '/wiki/new', visible: editable },
|
||||||
visible: ['member', 'admin'].includes (user?.role) },
|
|
||||||
{ name: '全体履歴', to: '/wiki/changes' },
|
{ name: '全体履歴', to: '/wiki/changes' },
|
||||||
{ name: 'ヘルプ', to: '/wiki/ヘルプ:Wiki' },
|
{ name: 'ヘルプ', to: '/wiki/ヘルプ:Wiki' },
|
||||||
{ component: <Separator/>, visible: wikiPageFlg },
|
{ component: <Separator/>, visible: wikiPageFlg },
|
||||||
@@ -84,7 +82,7 @@ export const menuOutline = (
|
|||||||
visible: wikiPageFlg },
|
visible: wikiPageFlg },
|
||||||
{ name: '履歴', to: `/wiki/changes?id=${ wikiId }`, visible: wikiPageFlg },
|
{ name: '履歴', to: `/wiki/changes?id=${ wikiId }`, visible: wikiPageFlg },
|
||||||
{ name: '編輯', to: `/wiki/${ wikiId || wikiTitle }/edit`,
|
{ name: '編輯', to: `/wiki/${ wikiId || wikiTitle }/edit`,
|
||||||
visible: wikiPageFlg && ['admin', 'member'].includes (user?.role) }] },
|
visible: wikiPageFlg && editable }] },
|
||||||
{ name: 'おたのしみ', visible: false, subMenu: [
|
{ name: 'おたのしみ', visible: false, subMenu: [
|
||||||
{ name: '上映会 (β)', to: '/theatres/1' },
|
{ name: '上映会 (β)', to: '/theatres/1' },
|
||||||
{ name: 'グカネータ (β)', to: '/gekanator' }] },
|
{ name: 'グカネータ (β)', to: '/gekanator' }] },
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ const sanitiseRow = (value: unknown): PostImportRow | null => {
|
|||||||
value.importErrors == null
|
value.importErrors == null
|
||||||
? undefined
|
? undefined
|
||||||
: ensureStringListRecord (value.importErrors)
|
: ensureStringListRecord (value.importErrors)
|
||||||
if (value.importErrors != null && importErrors == null)
|
if (importErrors === null)
|
||||||
return null
|
return null
|
||||||
if (!(Array.isArray (value.baseWarnings))
|
if (!(Array.isArray (value.baseWarnings))
|
||||||
|| !(value.baseWarnings.every (_1 => typeof _1 === 'string')))
|
|| !(value.baseWarnings.every (_1 => typeof _1 === 'string')))
|
||||||
@@ -261,14 +261,14 @@ const sanitiseRow = (value: unknown): PostImportRow | null => {
|
|||||||
provenance: value.provenance as Record<string, PostImportOrigin>,
|
provenance: value.provenance as Record<string, PostImportOrigin>,
|
||||||
tagSources: value.tagSources as Record<PostImportOrigin, string> | undefined,
|
tagSources: value.tagSources as Record<PostImportOrigin, string> | undefined,
|
||||||
status: value.status,
|
status: value.status,
|
||||||
skipReason: value.skipReason,
|
skipReason: value.skipReason ?? undefined,
|
||||||
existingPostId:
|
existingPostId:
|
||||||
isPositiveInteger (value.existingPostId) ? Number (value.existingPostId) : undefined,
|
isPositiveInteger (value.existingPostId) ? Number (value.existingPostId) : undefined,
|
||||||
metadataUrl: typeof value.metadataUrl === 'string' ? value.metadataUrl : undefined,
|
metadataUrl: typeof value.metadataUrl === 'string' ? value.metadataUrl : undefined,
|
||||||
resetSnapshot,
|
resetSnapshot,
|
||||||
createdPostId:
|
createdPostId:
|
||||||
isPositiveInteger (value.createdPostId) ? Number (value.createdPostId) : undefined,
|
isPositiveInteger (value.createdPostId) ? Number (value.createdPostId) : undefined,
|
||||||
importStatus: value.importStatus }
|
importStatus: value.importStatus ?? undefined }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ const PostImportResultPage: FC<Props> = ({ user }) => {
|
|||||||
row.status === 'failed'
|
row.status === 'failed'
|
||||||
&& row.recoverable
|
&& row.recoverable
|
||||||
&& Object.keys (row.errors ?? { }).length > 0)
|
&& Object.keys (row.errors ?? { }).length > 0)
|
||||||
const nextRows = mergedRows.map (row => {
|
const nextRows = mergedRows.map ((row): PostImportRow => {
|
||||||
const recoverable = recoverableRows.find (_1 => _1.sourceRow === row.sourceRow)
|
const recoverable = recoverableRows.find (_1 => _1.sourceRow === row.sourceRow)
|
||||||
if (recoverable == null)
|
if (recoverable == null)
|
||||||
return row
|
return row
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
|||||||
row.status === 'failed'
|
row.status === 'failed'
|
||||||
&& row.recoverable
|
&& row.recoverable
|
||||||
&& Object.keys (row.errors ?? { }).length > 0)
|
&& Object.keys (row.errors ?? { }).length > 0)
|
||||||
const nextRows = mergedResults.map (row => {
|
const nextRows = mergedResults.map ((row): PostImportRow => {
|
||||||
const recoverable = recoverableRows.find (rr => rr.sourceRow === row.sourceRow)
|
const recoverable = recoverableRows.find (rr => rr.sourceRow === row.sourceRow)
|
||||||
if (recoverable == null)
|
if (recoverable == null)
|
||||||
return row
|
return row
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする