Skip to content

Commit

Permalink
[GH-383] Fix UX for member_access_request in right hand sidebar (#407)
Browse files Browse the repository at this point in the history
* [MI-3567] Fix UX for member_access_request in right hand sidebar (#43)

* [MI-3567] Fix UX for member_access_request in right hand sidebar

* [MI-3567] Review fixes

* [MI-3567] Added a semicolon

* [MI-3567] Review fixes

* [MM-383] Review fixes
  • Loading branch information
raghavaggarwal2308 authored Nov 28, 2023
1 parent 90ed135 commit a7bba27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 9 additions & 5 deletions webapp/src/components/sidebar_right/gitlab_items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ export const notificationReasons: Record<string | symbol, string> = {
approval_required: 'Your approval is required on this issue/merge request.',
unmergeable: 'This merge request can\'t be merged.',
merge_train_removed: 'A merge train was removed.',
member_access_requested: 'requested access to a project/group.'
};

const SUCCESS = 'success';
const PENDING = 'pending';
const ACTION_NAME_MEMBER_ACCESS_REQUESTED = 'member_access_requested';

function GitlabItems({item, theme}: GitlabItemsProps) {
const style = getStyle(theme);
Expand All @@ -48,7 +50,7 @@ function GitlabItems({item, theme}: GitlabItemsProps) {
);
}

const titleText = item.title || item.target?.title || '';
const titleText = item.title || item.target?.title || item.body || '';

let title: React.ReactNode = titleText;
if (item.web_url || item.target_url) {
Expand Down Expand Up @@ -160,6 +162,8 @@ function GitlabItems({item, theme}: GitlabItemsProps) {
);
}

const includeNotificationAuthor = item.action_name == ACTION_NAME_MEMBER_ACCESS_REQUESTED;

return (
<div
key={item.id}
Expand All @@ -174,17 +178,16 @@ function GitlabItems({item, theme}: GitlabItemsProps) {
</div>
<div>
{number}
<span className='light'>{repoName}</span>
{repoName && <span className='light'>({repoName})</span>}
</div>
{labels}
<div
className='light'
style={style.subtitle}
>
{'Opened'}
{!item.action_name && 'Opened'}
{item.created_at && ` ${formatTimeSince(item.created_at)} ago`}
{userName && ` by ${userName}`}
{'.'}
{!item.action_name && userName && ` by ${userName}.`}
{milestone}
</div>
<div
Expand All @@ -194,6 +197,7 @@ function GitlabItems({item, theme}: GitlabItemsProps) {
{item.action_name && (
<>
<div>{item.updated_at && `Updated ${formatTimeSince(item.updated_at)} ago.`}</div>
{includeNotificationAuthor && <a href={item.author.web_url}>{item.author.name} </a>}
{notificationReasons[item.action_name]}
</>
)}
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/types/gitlab_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface Label {

export interface User {
username: string;
web_url: string;
name: string;
}

export interface References {
Expand Down Expand Up @@ -57,6 +59,7 @@ export interface Item {
num_approvers: number;
total_reviewers: number;
reviewers: User[];
body: string;
}

export interface GitlabItemsProps {
Expand Down

0 comments on commit a7bba27

Please sign in to comment.