This commit is contained in:
@@ -72,7 +72,7 @@ class WikiPagesController < ApplicationController
|
|||||||
|
|
||||||
return head :unprocessable_entity if title.blank? || body.blank?
|
return head :unprocessable_entity if title.blank? || body.blank?
|
||||||
|
|
||||||
page = WikiPage.new(title:)
|
page = WikiPage.new(title:, created_user: current_user, updated_user: current_user)
|
||||||
|
|
||||||
if page.save
|
if page.save
|
||||||
message = params[:message].presence
|
message = params[:message].presence
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ require 'set'
|
|||||||
|
|
||||||
class WikiPage < ApplicationRecord
|
class WikiPage < ApplicationRecord
|
||||||
has_many :wiki_revisions, dependent: :destroy
|
has_many :wiki_revisions, dependent: :destroy
|
||||||
|
belongs_to :created_user, class_name: 'User'
|
||||||
|
belongs_to :updated_user, class_name: 'User'
|
||||||
|
|
||||||
has_many :redirected_from_revisions,
|
has_many :redirected_from_revisions,
|
||||||
class_name: 'WikiRevision',
|
class_name: 'WikiRevision',
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class WikiRevision < ApplicationRecord
|
|||||||
has_many :wiki_revision_lines, dependent: :delete_all
|
has_many :wiki_revision_lines, dependent: :delete_all
|
||||||
has_many :wiki_lines, through: :wiki_revision_lines
|
has_many :wiki_lines, through: :wiki_revision_lines
|
||||||
|
|
||||||
enum kind: { content: 0, redirect: 1 }
|
enum :kind, { content: 0, redirect: 1 }
|
||||||
|
|
||||||
validates :kind, presence: true
|
validates :kind, presence: true
|
||||||
validates :lines_count, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
validates :lines_count, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ module Wiki
|
|||||||
end
|
end
|
||||||
|
|
||||||
if missing_rows.any?
|
if missing_rows.any?
|
||||||
WikiLine.upsert_all(missing_rows, unique_by: :index_wiki_lines_on_sha256)
|
WikiLine.upsert_all(missing_rows)
|
||||||
id_by_sha = WikiLine.where(sha256: line_shas).pluck(:sha256, :id).to_h
|
id_by_sha = WikiLine.where(sha256: line_shas).pluck(:sha256, :id).to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -41,30 +41,20 @@ export default () => {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{changes.map (change => (
|
{changes.map (change => (
|
||||||
<tr key={change.sha}>
|
<tr key={change.revisionId}>
|
||||||
<td>
|
<td>
|
||||||
{change.changeType === 'update' && (
|
{change.pred != null && (
|
||||||
<Link to={`/wiki/${ change.wikiPage.id }/diff?from=${ change.pred }&to=${ change.sha }`}>
|
<Link to={`/wiki/${ change.wikiPage.id }/diff?from=${ change.pred }&to=${ change.revisionId }`}>
|
||||||
差分
|
差分
|
||||||
</Link>)}
|
</Link>)}
|
||||||
</td>
|
</td>
|
||||||
<td className="p-2">
|
<td className="p-2">
|
||||||
<Link to={`/wiki/${ encodeURIComponent (change.wikiPage.title) }?version=${ change.sha }`}>
|
<Link to={`/wiki/${ encodeURIComponent (change.wikiPage.title) }?version=${ change.revisionId }`}>
|
||||||
{change.wikiPage.title}
|
{change.wikiPage.title}
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td className="p-2">
|
<td className="p-2">
|
||||||
{(() => {
|
{change.pred == null ? '新規' : '更新'}
|
||||||
switch (change.changeType)
|
|
||||||
{
|
|
||||||
case 'create':
|
|
||||||
return '新規'
|
|
||||||
case 'update':
|
|
||||||
return '更新'
|
|
||||||
case 'delete':
|
|
||||||
return '削除'
|
|
||||||
}
|
|
||||||
}) ()}
|
|
||||||
</td>
|
</td>
|
||||||
<td className="p-2">
|
<td className="p-2">
|
||||||
<Link to={`/users/${ change.user.id }`}>
|
<Link to={`/users/${ change.user.id }`}>
|
||||||
|
|||||||
+16
-12
@@ -61,26 +61,30 @@ export type ViewFlagBehavior = typeof ViewFlagBehavior[keyof typeof ViewFlagBeha
|
|||||||
export type WikiPage = {
|
export type WikiPage = {
|
||||||
id: number
|
id: number
|
||||||
title: string
|
title: string
|
||||||
|
createdUserId: number
|
||||||
|
updatedUserId: number
|
||||||
|
createdAt: string
|
||||||
|
updatedAt: string
|
||||||
body: string
|
body: string
|
||||||
sha: string
|
revisionId: number
|
||||||
pred?: string
|
pred: number | null
|
||||||
succ?: string
|
succ: number | null }
|
||||||
updatedAt?: string }
|
|
||||||
|
|
||||||
export type WikiPageChange = {
|
export type WikiPageChange = {
|
||||||
sha: string
|
revisionId: number
|
||||||
pred?: string
|
pred: number | null
|
||||||
succ?: string
|
succ: null
|
||||||
wikiPage: WikiPage
|
wikiPage: Pick<WikiPage, 'id' | 'title'>
|
||||||
user: User
|
user: Pick<User, 'id' | 'name'>
|
||||||
changeType: string
|
kind: 'content' | 'redirect'
|
||||||
|
message: string | null
|
||||||
timestamp: string }
|
timestamp: string }
|
||||||
|
|
||||||
export type WikiPageDiff = {
|
export type WikiPageDiff = {
|
||||||
wikiPageId: number
|
wikiPageId: number
|
||||||
title: string
|
title: string
|
||||||
olderSha: string
|
olderRevisionId: number | null
|
||||||
newerSha: string
|
newerRevisionId: number | null
|
||||||
diff: WikiPageDiffDiff[] }
|
diff: WikiPageDiffDiff[] }
|
||||||
|
|
||||||
export type WikiPageDiffDiff = {
|
export type WikiPageDiffDiff = {
|
||||||
|
|||||||
Reference in New Issue
Block a user