Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-383] Fix UX for member_access_request in right hand sidebar #407

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'}
raghavaggarwal2308 marked this conversation as resolved.
Show resolved Hide resolved
{!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
Loading