このコミットが含まれているのは:
@@ -15,6 +15,7 @@ import { SITE_TITLE } from '@/config'
|
||||
import { isApiError } from '@/lib/api'
|
||||
import { fetchPost, toggleViewedFlg } from '@/lib/posts'
|
||||
import { postsKeys, tagsKeys } from '@/lib/queryKeys'
|
||||
import { canEditContent } from '@/lib/users'
|
||||
import { cn } from '@/lib/utils'
|
||||
import NotFound from '@/pages/NotFound'
|
||||
import ServiceUnavailable from '@/pages/ServiceUnavailable'
|
||||
@@ -27,6 +28,7 @@ type Props = { user: User | null }
|
||||
|
||||
|
||||
const PostDetailPage: FC<Props> = ({ user }) => {
|
||||
const editable = canEditContent (user)
|
||||
const { id } = useParams ()
|
||||
const postId = String (id ?? '')
|
||||
const postKey = postsKeys.show (postId)
|
||||
@@ -163,7 +165,7 @@ const PostDetailPage: FC<Props> = ({ user }) => {
|
||||
? <PostList posts={post.related}/>
|
||||
: 'まだないよ(笑)'}
|
||||
</Tab>
|
||||
{['admin', 'member'].some (r => user?.role === r) && (
|
||||
{editable && (
|
||||
<Tab name="編輯">
|
||||
<PostEditForm
|
||||
post={post}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Button } from '@/components/ui/button'
|
||||
import { toast } from '@/components/ui/use-toast'
|
||||
import { SITE_TITLE } from '@/config'
|
||||
import { apiGet, apiPost } from '@/lib/api'
|
||||
import { canEditContent } from '@/lib/users'
|
||||
import Forbidden from '@/pages/Forbidden'
|
||||
|
||||
import type { FC } from 'react'
|
||||
@@ -22,7 +23,7 @@ type Props = { user: User | null }
|
||||
|
||||
|
||||
const PostNewPage: FC<Props> = ({ user }) => {
|
||||
const editable = ['admin', 'member'].some (r => user?.role === r)
|
||||
const editable = canEditContent (user)
|
||||
|
||||
const navigate = useNavigate ()
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import MainArea from '@/components/layout/MainArea'
|
||||
import { toast } from '@/components/ui/use-toast'
|
||||
import { SITE_TITLE } from '@/config'
|
||||
import { apiGet, apiPut } from '@/lib/api'
|
||||
import { canEditContent } from '@/lib/users'
|
||||
|
||||
import type { NicoTag, Tag, User } from '@/types'
|
||||
|
||||
@@ -25,7 +26,7 @@ const NicoTagListPage: FC<Props> = ({ user }) => {
|
||||
|
||||
const loaderRef = useRef<HTMLDivElement | null> (null)
|
||||
|
||||
const memberFlg = ['admin', 'member'].some (r => user?.role === r)
|
||||
const editable = canEditContent (user)
|
||||
|
||||
const applyLoadedTags = useCallback ((data: { tags: NicoTag[]; nextCursor: string },
|
||||
withCursor: boolean) => {
|
||||
@@ -117,7 +118,7 @@ const NicoTagListPage: FC<Props> = ({ user }) => {
|
||||
<tr>
|
||||
<th className="p-2 text-left">ニコニコタグ</th>
|
||||
<th className="p-2 text-left">連携タグ</th>
|
||||
{memberFlg && <th></th>}
|
||||
{editable && <th></th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -139,7 +140,7 @@ const NicoTagListPage: FC<Props> = ({ user }) => {
|
||||
withCount={false}/>
|
||||
</span>))}
|
||||
</td>
|
||||
{memberFlg && (
|
||||
{editable && (
|
||||
<td className="p-2">
|
||||
<a href="#" onClick={ev => {
|
||||
ev.preventDefault ()
|
||||
|
||||
@@ -10,6 +10,7 @@ import { toast } from '@/components/ui/use-toast'
|
||||
import { SITE_TITLE } from '@/config'
|
||||
import { apiGet, apiPut } from '@/lib/api'
|
||||
import { wikiKeys } from '@/lib/queryKeys'
|
||||
import { canEditContent } from '@/lib/users'
|
||||
import Forbidden from '@/pages/Forbidden'
|
||||
|
||||
import 'react-markdown-editor-lite/lib/index.css'
|
||||
@@ -24,7 +25,7 @@ type Props = { user: User | null }
|
||||
|
||||
|
||||
const WikiEditPage: FC<Props> = ({ user }) => {
|
||||
const editable = ['admin', 'member'].some (r => user?.role === r)
|
||||
const editable = canEditContent (user)
|
||||
|
||||
const { id } = useParams ()
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import MainArea from '@/components/layout/MainArea'
|
||||
import { toast } from '@/components/ui/use-toast'
|
||||
import { SITE_TITLE } from '@/config'
|
||||
import { apiPost } from '@/lib/api'
|
||||
import { canEditContent } from '@/lib/users'
|
||||
import Forbidden from '@/pages/Forbidden'
|
||||
|
||||
import 'react-markdown-editor-lite/lib/index.css'
|
||||
@@ -22,7 +23,7 @@ type Props = { user: User | null }
|
||||
|
||||
|
||||
const WikiNewPage: FC<Props> = ({ user }) => {
|
||||
const editable = ['admin', 'member'].some (r => user?.role === r)
|
||||
const editable = canEditContent (user)
|
||||
|
||||
const location = useLocation ()
|
||||
const navigate = useNavigate ()
|
||||
|
||||
新しい課題から参照
ユーザをブロックする