diff --git a/apps/gitness/src/framework/context/AppContext.tsx b/apps/gitness/src/framework/context/AppContext.tsx index 966b1fbb88..62a1b13625 100644 --- a/apps/gitness/src/framework/context/AppContext.tsx +++ b/apps/gitness/src/framework/context/AppContext.tsx @@ -27,15 +27,22 @@ export const AppProvider: React.FC<{ children: ReactNode }> = ({ children }) => const [currentUser, setCurrentUser] = useLocalStorage('currentUser', {}) useEffect(() => { - Promise.all([ + Promise.allSettled([ membershipSpaces({ queryParams: { page: 1, limit: 100, sort: 'identifier', order: 'asc' } }), getUser({}) ]) - .then(([membershipResponse, userResponse]) => { - setSpaces(membershipResponse.body.filter(item => item?.space).map(item => item.space as TypesSpace)) - setCurrentUser(userResponse.body) + .then(results => { + const [membershipResult, userResult] = results + + if (membershipResult.status === 'fulfilled') { + setSpaces(membershipResult.value.body.filter(item => item?.space).map(item => item.space as TypesSpace)) + } + + if (userResult.status === 'fulfilled') { + setCurrentUser(userResult.value.body) + } }) .catch(() => { // Optionally handle error or show toast diff --git a/packages/ui/src/shared-style-variables.css b/packages/ui/src/shared-style-variables.css index 0244d53dce..392a637118 100644 --- a/packages/ui/src/shared-style-variables.css +++ b/packages/ui/src/shared-style-variables.css @@ -287,7 +287,7 @@ --canary-popover: 0 0% 100%; --canary-popover-foreground: 240 10% 3.9%; --canary-primary: 240 5.9% 10%; - --canary-primary-background: 240 5.9% 10%; + --canary-primary-background: 0 0% 100%; --canary-primary-foreground: 0 0% 98%; --canary-primary-muted: var(--canary-grey-70); --canary-primary-accent: 216 100% 60%; diff --git a/packages/ui/src/views/repo/pull-request/details/components/conversation/pull-request-overview.tsx b/packages/ui/src/views/repo/pull-request/details/components/conversation/pull-request-overview.tsx index 4bc0f498b0..7d07e2a673 100644 --- a/packages/ui/src/views/repo/pull-request/details/components/conversation/pull-request-overview.tsx +++ b/packages/ui/src/views/repo/pull-request/details/components/conversation/pull-request-overview.tsx @@ -236,192 +236,25 @@ const PullRequestOverview: React.FC = ({ ? parseStartingLineIfOne(codeDiffSnapshot ?? '') : null - return ( - payload?.id && ( - toggleReplyBox(state, payload?.id)} - quoteReplyText={quoteReplies[payload.id]?.text || ''} - onQuoteReply={handleQuoteReply} - key={payload?.id} - currentUser={currentUser?.display_name} - replyBoxClassName="p-4" - toggleConversationStatus={toggleConversationStatus} - isResolved={!!payload?.resolved} - icon={} - isLast={(data && data?.length - 1 === index) ?? false} - handleSaveComment={handleSaveComment} - parentCommentId={payload?.id} - header={[ - { - avatar: ( - - - - {/* TODO: fix fallback string */} - {getInitials((payload?.author as PayloadAuthor)?.display_name || '')} - - - - ), - name: (payload?.author as PayloadAuthor)?.display_name, - // TODO: fix comment to tell between comment or code comment? - description: payload?.created && `reviewed ${timeAgo(payload?.created)}` - } - ]} - contentHeader={{(payload?.code_comment as PayloadCodeComment)?.path}} - content={ -
- {startingLine ? ( -
-
{startingLine}
-
- ) : null} - - -
- {commentItems?.map((commentItem, idx) => { - const componentId = `activity-code-${commentItem?.id}` - const commentIdAttr = `comment-${payload?.id}` - - return ( - payload?.id && ( - toggleReplyBox(state, payload?.id)} - quoteReplyText={quoteReplies[payload.id]?.text || ''} - onQuoteReply={handleQuoteReply} - parentCommentId={payload?.id} - titleClassName="!flex max-w-full" - isComment - onCopyClick={onCopyClick} - commentId={commentItem.id} - isLast={commentItems.length - 1 === idx} - isDeleted={!!commentItem?.deleted} - handleDeleteComment={() => handleDeleteComment(commentItem?.id)} - onEditClick={() => - toggleEditMode(componentId, commentItem?.payload?.payload?.text || '') - } - contentClassName="border-transparent" - replyBoxClassName="p-4" - toggleConversationStatus={toggleConversationStatus} - icon={ - - - - {/* TODO: fix fallback string */} - {getInitials( - ( - (commentItem as unknown as TypesPullReqActivity)?.payload - ?.author as PayloadAuthor - )?.display_name || '' - )} - - - - } - header={[ - { - name: ( - (commentItem as unknown as TypesPullReqActivity)?.payload - ?.author as PayloadAuthor - )?.display_name, - // TODO: fix comment to tell between comment or code comment? - description: ( - - {timeAgo((commentItem as unknown as PayloadCreated)?.created)} - {commentItem?.deleted ? ( - <> -  |  - {t('views:pullRequests.deleted')} - - ) : null} - - ) - } - ]} - content={ - commentItem?.deleted ? ( -
- {t('views:pullRequests.deletedComment')} -
- ) : editModes[componentId] ? ( - { - if (commentItem?.id) { - handleUpdateComment?.(commentItem?.id, editComments[componentId]) - toggleEditMode(componentId, '') - } - }} - currentUser={currentUser?.display_name} - onCancelClick={() => { - toggleEditMode(componentId, '') - }} - comment={editComments[componentId]} - setComment={text => - setEditComments(prev => ({ ...prev, [componentId]: text })) - } - /> - ) : ( - - ) - } - key={`${commentItem.id}-${commentItem.author}`} - /> - ) - ) - })} -
-
- } - /> - ) - ) - } - return ( - payload?.id && ( + return payload?.id ? ( toggleReplyBox(state, payload?.id)} quoteReplyText={quoteReplies[payload.id]?.text || ''} onQuoteReply={handleQuoteReply} key={payload?.id} - titleClassName="!flex max-w-full" currentUser={currentUser?.display_name} replyBoxClassName="p-4" - isResolved={!!payload?.resolved} toggleConversationStatus={toggleConversationStatus} + isResolved={!!payload?.resolved} + icon={} + isLast={(data && data?.length - 1 === index) ?? false} + handleSaveComment={handleSaveComment} + parentCommentId={payload?.id} header={[ { avatar: ( @@ -436,46 +269,59 @@ const PullRequestOverview: React.FC = ({ ), name: (payload?.author as PayloadAuthor)?.display_name, // TODO: fix comment to tell between comment or code comment? - description: ( -
-
{payload?.created && `commented ${timeAgo(payload?.created)}`}
-
- ) + description: payload?.created && `reviewed ${timeAgo(payload?.created)}` } ]} + contentHeader={{(payload?.code_comment as PayloadCodeComment)?.path}} content={ -
- {commentItems?.map((commentItem, idx) => { - const componentId = `activity-comment-${commentItem?.id}` - // const diffCommentItem = activitiesToDiffCommentItems(commentItem) - const commentIdAttr = `comment-${payload?.id}` +
+ {startingLine ? ( +
+
{startingLine}
+
+ ) : null} + + +
+ {commentItems?.map((commentItem, idx) => { + const componentId = `activity-code-${commentItem?.id}` + const commentIdAttr = `comment-${payload?.id}` - return ( - payload?.id && ( + return payload?.id ? ( toggleReplyBox(state, payload?.id)} quoteReplyText={quoteReplies[payload.id]?.text || ''} onQuoteReply={handleQuoteReply} parentCommentId={payload?.id} - toggleConversationStatus={toggleConversationStatus} titleClassName="!flex max-w-full" - currentUser={currentUser?.display_name} - isLast={commentItems.length - 1 === idx} isComment onCopyClick={onCopyClick} commentId={commentItem.id} + isLast={commentItems.length - 1 === idx} isDeleted={!!commentItem?.deleted} handleDeleteComment={() => handleDeleteComment(commentItem?.id)} onEditClick={() => toggleEditMode(componentId, commentItem?.payload?.payload?.text || '') } - contentClassName="border-transparent pb-0" + contentClassName="border-transparent" replyBoxClassName="p-4" - key={`${commentItem.id}-${commentItem.author}-pr-comment`} + toggleConversationStatus={toggleConversationStatus} icon={ @@ -485,7 +331,7 @@ const PullRequestOverview: React.FC = ({ ( (commentItem as unknown as TypesPullReqActivity)?.payload ?.author as PayloadAuthor - ).display_name || '' + )?.display_name || '' )} @@ -498,16 +344,12 @@ const PullRequestOverview: React.FC = ({ )?.display_name, // TODO: fix comment to tell between comment or code comment? description: ( - - - {timeAgo((commentItem as unknown as PayloadCreated)?.created)} - + + {timeAgo((commentItem as unknown as PayloadCreated)?.created)} {commentItem?.deleted ? ( <> -  |  - - {t('views:pullRequests.deleted')}{' '} - +  |  + {t('views:pullRequests.deleted')} ) : null} @@ -521,8 +363,8 @@ const PullRequestOverview: React.FC = ({
) : editModes[componentId] ? ( { if (commentItem?.id) { handleUpdateComment?.(commentItem?.id, editComments[componentId]) @@ -547,20 +389,163 @@ const PullRequestOverview: React.FC = ({ /> ) } + key={`${commentItem.id}-${commentItem.author}`} /> - ) - ) - })} + ) : null + })} +
- // } - icon={} - isLast={activityBlocks.length - 1 === index} - handleSaveComment={handleSaveComment} - parentCommentId={payload?.id} /> - ) - ) + ) : null + } + return payload?.id ? ( + toggleReplyBox(state, payload?.id)} + quoteReplyText={quoteReplies[payload.id]?.text || ''} + onQuoteReply={handleQuoteReply} + key={payload?.id} + titleClassName="!flex max-w-full" + currentUser={currentUser?.display_name} + replyBoxClassName="p-4" + isResolved={!!payload?.resolved} + toggleConversationStatus={toggleConversationStatus} + header={[ + { + avatar: ( + + + + {/* TODO: fix fallback string */} + {getInitials((payload?.author as PayloadAuthor)?.display_name || '')} + + + + ), + name: (payload?.author as PayloadAuthor)?.display_name, + // TODO: fix comment to tell between comment or code comment? + description: ( +
+
{payload?.created && `commented ${timeAgo(payload?.created)}`}
+
+ ) + } + ]} + content={ +
+ {commentItems?.map((commentItem, idx) => { + const componentId = `activity-comment-${commentItem?.id}` + // const diffCommentItem = activitiesToDiffCommentItems(commentItem) + const commentIdAttr = `comment-${payload?.id}` + + return payload?.id ? ( + toggleReplyBox(state, payload?.id)} + quoteReplyText={quoteReplies[payload.id]?.text || ''} + onQuoteReply={handleQuoteReply} + parentCommentId={payload?.id} + toggleConversationStatus={toggleConversationStatus} + titleClassName="!flex max-w-full" + currentUser={currentUser?.display_name} + isLast={commentItems.length - 1 === idx} + isComment + onCopyClick={onCopyClick} + commentId={commentItem.id} + isDeleted={!!commentItem?.deleted} + handleDeleteComment={() => handleDeleteComment(commentItem?.id)} + onEditClick={() => toggleEditMode(componentId, commentItem?.payload?.payload?.text || '')} + contentClassName="border-transparent pb-0" + replyBoxClassName="p-4" + key={`${commentItem.id}-${commentItem.author}-pr-comment`} + icon={ + + + + {/* TODO: fix fallback string */} + {getInitials( + ( + (commentItem as unknown as TypesPullReqActivity)?.payload + ?.author as PayloadAuthor + ).display_name || '' + )} + + + + } + header={[ + { + name: ( + (commentItem as unknown as TypesPullReqActivity)?.payload?.author as PayloadAuthor + )?.display_name, + // TODO: fix comment to tell between comment or code comment? + description: ( + + + {timeAgo((commentItem as unknown as PayloadCreated)?.created)} + + {commentItem?.deleted ? ( + <> +  |  + {t('views:pullRequests.deleted')} + + ) : null} + + ) + } + ]} + content={ + commentItem?.deleted ? ( +
+ {t('views:pullRequests.deletedComment')} +
+ ) : editModes[componentId] ? ( + { + if (commentItem?.id) { + handleUpdateComment?.(commentItem?.id, editComments[componentId]) + toggleEditMode(componentId, '') + } + }} + currentUser={currentUser?.display_name} + onCancelClick={() => { + toggleEditMode(componentId, '') + }} + comment={editComments[componentId]} + setComment={text => setEditComments(prev => ({ ...prev, [componentId]: text }))} + /> + ) : ( + + ) + } + /> + ) : null + })} +
+ // + } + icon={} + isLast={activityBlocks.length - 1 === index} + handleSaveComment={handleSaveComment} + parentCommentId={payload?.id} + /> + ) : null } })}