このコミットが含まれているのは:
@@ -18,6 +18,7 @@ import { clearPostImportSourceDraft,
|
||||
loadPostImportSession,
|
||||
mergeImportResults,
|
||||
mergeValidatedImportRows,
|
||||
resultSummaryCounts,
|
||||
retryImportRow,
|
||||
savePostImportSession,
|
||||
type PostImportResultRow,
|
||||
@@ -92,13 +93,9 @@ const PostImportResultPage: FC<Props> = ({ user }) => {
|
||||
toast ({ title: '取込状態を保存できませんでした', description: message }))
|
||||
}, [session, sessionId])
|
||||
|
||||
const counts = useMemo (() => ({
|
||||
created: session?.rows.filter (_1 => _1.importStatus === 'created').length ?? 0,
|
||||
skipped: session?.rows.filter (_1 => _1.importStatus === 'skipped').length ?? 0,
|
||||
failed: session?.rows.filter (_1 => _1.importStatus === 'failed').length ?? 0,
|
||||
invalid:
|
||||
session?.rows.filter (_1 => effectivePostImportStatus (_1) === 'error').length ?? 0,
|
||||
}), [session])
|
||||
const counts = useMemo (
|
||||
() => resultSummaryCounts (session?.rows ?? []),
|
||||
[session])
|
||||
|
||||
const retry = async (sourceRow: number) => {
|
||||
if (session == null)
|
||||
@@ -120,11 +117,7 @@ const PostImportResultPage: FC<Props> = ({ user }) => {
|
||||
tagSources: row.tagSources,
|
||||
metadataUrl: row.metadataUrl })),
|
||||
changed_row: -1 })
|
||||
const validatedRows = mergeValidatedImportRows (pendingRows, validated.rows).map (row =>
|
||||
row.sourceRow === sourceRow
|
||||
&& Object.keys (row.validationErrors ?? { }).length > 0
|
||||
? { ...row, importStatus: 'failed' as const }
|
||||
: row)
|
||||
const validatedRows = mergeValidatedImportRows (pendingRows, validated.rows)
|
||||
setSession (current =>
|
||||
current
|
||||
? { ...current, rows: validatedRows }
|
||||
@@ -238,20 +231,21 @@ const PostImportResultPage: FC<Props> = ({ user }) => {
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2 sm:flex-row">
|
||||
{row.createdPostId && (
|
||||
{(row.createdPostId != null || row.existingPostId != null) && (
|
||||
<Button type="button" variant="outline" asChild>
|
||||
<PrefetchLink to={`/posts/${ row.createdPostId }`}>
|
||||
<PrefetchLink
|
||||
to={`/posts/${ row.createdPostId ?? row.existingPostId }`}>
|
||||
投稿を開く
|
||||
</PrefetchLink>
|
||||
</Button>)}
|
||||
{status === 'error' && (
|
||||
{(status === 'error' || row.importStatus === 'failed') && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => openRepair (row.sourceRow)}>
|
||||
編輯
|
||||
</Button>)}
|
||||
{row.importStatus === 'failed' && (
|
||||
{row.importStatus === 'failed' && status !== 'error' && (
|
||||
<>
|
||||
<Button
|
||||
type="button"
|
||||
|
||||
@@ -81,12 +81,10 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
||||
const counts = useMemo (() => reviewSummaryCounts (rows), [rows])
|
||||
const processable = useMemo (
|
||||
() => processableImportRows (rows),
|
||||
[rows],
|
||||
)
|
||||
[rows])
|
||||
const creatable = useMemo (
|
||||
() => creatableImportRows (rows),
|
||||
[rows],
|
||||
)
|
||||
[rows])
|
||||
const reviewRows =
|
||||
session?.repairMode === 'failed'
|
||||
? [...rows].sort ((a, b) => {
|
||||
@@ -126,8 +124,7 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
||||
['originalCreatedFrom', draft.originalCreatedFrom],
|
||||
['originalCreatedBefore', draft.originalCreatedBefore],
|
||||
['duration', draft.duration],
|
||||
['parentPostIds', draft.parentPostIds],
|
||||
] as const
|
||||
['parentPostIds', draft.parentPostIds]] as const
|
||||
draftFields.forEach (([field, value]) => {
|
||||
nextAttributes[field] = value
|
||||
nextProvenance[field] =
|
||||
@@ -284,6 +281,7 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
||||
invalidCount={counts.invalid}
|
||||
processableCount={processable.length}
|
||||
creatableCount={creatable.length}
|
||||
skipPlannedCount={counts.skipPlanned}
|
||||
onBack={() => navigate ('/posts/import')}
|
||||
onSubmit={submit}/>
|
||||
|
||||
@@ -300,11 +298,18 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
||||
}
|
||||
|
||||
const PostImportFooter = (
|
||||
{ loading, invalidCount, processableCount, creatableCount, onBack, onSubmit }: {
|
||||
{ loading,
|
||||
invalidCount,
|
||||
processableCount,
|
||||
creatableCount,
|
||||
skipPlannedCount,
|
||||
onBack,
|
||||
onSubmit }: {
|
||||
loading: boolean
|
||||
invalidCount: number
|
||||
processableCount: number
|
||||
creatableCount: number
|
||||
skipPlannedCount: number
|
||||
onBack: () => void
|
||||
onSubmit: () => void },
|
||||
) => (
|
||||
@@ -315,7 +320,11 @@ const PostImportFooter = (
|
||||
md:items-center md:justify-between">
|
||||
<div className="flex flex-wrap items-center gap-2 text-sm">
|
||||
<PostImportStatusBadge value="pending"/>
|
||||
<span>処理対象 {processableCount} 件</span>
|
||||
<PostImportStatusBadge value="ready"/>
|
||||
<span>登録対象 {creatableCount} 件</span>
|
||||
<PostImportStatusBadge value="skipped"/>
|
||||
<span>スキップ予定 {skipPlannedCount} 件</span>
|
||||
<PostImportStatusBadge value="error"/>
|
||||
<span>要修正 {invalidCount} 件</span>
|
||||
</div>
|
||||
@@ -327,7 +336,7 @@ const PostImportFooter = (
|
||||
type="button"
|
||||
onClick={onSubmit}
|
||||
disabled={loading || processableCount === 0}>
|
||||
有効な投稿を一括登録
|
||||
取込を実行
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
新しい課題から参照
ユーザをブロックする