|
|
@@ -3,37 +3,18 @@ import Container from './container'
|
|
|
import Toolbar from './toolbar/toolbar'
|
|
|
import Nav from './nav'
|
|
|
import Toggler from './toggler'
|
|
|
-import ChangeEntry from './entries/change-entry'
|
|
|
-import AggregateChangeEntry from './entries/aggregate-change-entry'
|
|
|
-import CommentEntry from './entries/comment-entry'
|
|
|
-import AddCommentEntry from './entries/add-comment-entry'
|
|
|
-import BulkActionsEntry from './entries/bulk-actions-entry/bulk-actions-entry'
|
|
|
import PositionedEntries from './positioned-entries'
|
|
|
import { useReviewPanelValueContext } from '../../context/review-panel/review-panel-context'
|
|
|
-import { useEditorContext } from '../../../../shared/context/editor-context'
|
|
|
import useCodeMirrorContentHeight from '../../hooks/use-codemirror-content-height'
|
|
|
import { ReviewPanelEntry } from '../../../../../../types/review-panel/entry'
|
|
|
-import {
|
|
|
- ReviewPanelDocEntries,
|
|
|
- ThreadId,
|
|
|
-} from '../../../../../../types/review-panel/review-panel'
|
|
|
-
|
|
|
-const isEntryAThreadId = (
|
|
|
- entry: keyof ReviewPanelDocEntries
|
|
|
-): entry is ThreadId => entry !== 'add-comment' && entry !== 'bulk-actions'
|
|
|
+import { ReviewPanelDocEntries } from '../../../../../../types/review-panel/review-panel'
|
|
|
+import Entry from './entry'
|
|
|
+import EmptyState from './empty-state'
|
|
|
+import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
|
|
|
|
function CurrentFileContainer() {
|
|
|
- const {
|
|
|
- commentThreads,
|
|
|
- entries,
|
|
|
- openDocId,
|
|
|
- permissions,
|
|
|
- loadingThreads,
|
|
|
- users,
|
|
|
- nVisibleSelectedChanges: nChanges,
|
|
|
- } = useReviewPanelValueContext()
|
|
|
+ const { entries, openDocId } = useReviewPanelValueContext()
|
|
|
const contentHeight = useCodeMirrorContentHeight()
|
|
|
- const { isRestrictedTokenMember } = useEditorContext()
|
|
|
|
|
|
const currentDocEntries =
|
|
|
openDocId && openDocId in entries ? entries[openDocId] : undefined
|
|
|
@@ -44,10 +25,19 @@ function CurrentFileContainer() {
|
|
|
>
|
|
|
}, [currentDocEntries])
|
|
|
|
|
|
+ const enableEmptyState = useFeatureFlag('review-panel-redesign')
|
|
|
+
|
|
|
+ const showEmptyState =
|
|
|
+ enableEmptyState &&
|
|
|
+ objectEntries.filter(
|
|
|
+ ([key]) => key !== 'add-comment' && key !== 'bulk-actions'
|
|
|
+ ).length === 0
|
|
|
+
|
|
|
return (
|
|
|
<Container className="rp-current-file-container">
|
|
|
<div className="review-panel-tools">
|
|
|
<Toolbar />
|
|
|
+ {showEmptyState && <EmptyState />}
|
|
|
<Nav />
|
|
|
</div>
|
|
|
<Toggler />
|
|
|
@@ -63,87 +53,7 @@ function CurrentFileContainer() {
|
|
|
>
|
|
|
{openDocId &&
|
|
|
objectEntries.map(([id, entry]) => {
|
|
|
- if (!entry.visible) {
|
|
|
- return null
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- isEntryAThreadId(id) &&
|
|
|
- (entry.type === 'insert' || entry.type === 'delete')
|
|
|
- ) {
|
|
|
- return (
|
|
|
- <ChangeEntry
|
|
|
- key={id}
|
|
|
- docId={openDocId}
|
|
|
- entryId={id}
|
|
|
- permissions={permissions}
|
|
|
- user={users[entry.metadata.user_id]}
|
|
|
- content={entry.content}
|
|
|
- offset={entry.offset}
|
|
|
- type={entry.type}
|
|
|
- focused={entry.focused}
|
|
|
- entryIds={entry.entry_ids}
|
|
|
- timestamp={entry.metadata.ts}
|
|
|
- />
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- if (isEntryAThreadId(id) && entry.type === 'aggregate-change') {
|
|
|
- return (
|
|
|
- <AggregateChangeEntry
|
|
|
- key={id}
|
|
|
- docId={openDocId}
|
|
|
- entryId={id}
|
|
|
- permissions={permissions}
|
|
|
- user={users[entry.metadata.user_id]}
|
|
|
- content={entry.content}
|
|
|
- replacedContent={entry.metadata.replaced_content}
|
|
|
- offset={entry.offset}
|
|
|
- focused={entry.focused}
|
|
|
- entryIds={entry.entry_ids}
|
|
|
- timestamp={entry.metadata.ts}
|
|
|
- />
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- isEntryAThreadId(id) &&
|
|
|
- entry.type === 'comment' &&
|
|
|
- !loadingThreads
|
|
|
- ) {
|
|
|
- return (
|
|
|
- <CommentEntry
|
|
|
- key={id}
|
|
|
- docId={openDocId}
|
|
|
- threadId={entry.thread_id}
|
|
|
- thread={commentThreads[entry.thread_id]}
|
|
|
- entryId={id}
|
|
|
- offset={entry.offset}
|
|
|
- focused={entry.focused}
|
|
|
- permissions={permissions}
|
|
|
- />
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- entry.type === 'add-comment' &&
|
|
|
- permissions.comment &&
|
|
|
- !isRestrictedTokenMember
|
|
|
- ) {
|
|
|
- return <AddCommentEntry key={id} />
|
|
|
- }
|
|
|
-
|
|
|
- if (entry.type === 'bulk-actions' && permissions.write) {
|
|
|
- return (
|
|
|
- <BulkActionsEntry
|
|
|
- key={id}
|
|
|
- entryId={entry.type}
|
|
|
- nChanges={nChanges}
|
|
|
- />
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- return null
|
|
|
+ return <Entry key={id} id={id} entry={entry} />
|
|
|
})}
|
|
|
</PositionedEntries>
|
|
|
</div>
|