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

feat(issue-stream): Update priority badge/selector #78726

Merged
merged 5 commits into from
Oct 8, 2024
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
46 changes: 39 additions & 7 deletions static/app/components/badge/groupPriority.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Fragment, useMemo} from 'react';
import type {Theme} from '@emotion/react';
import styled from '@emotion/styled';
import {VisuallyHidden} from '@react-aria/visually-hidden';

import bannerStar from 'sentry-images/spot/banner-star.svg';

Expand All @@ -15,6 +16,7 @@ import HookOrDefault from 'sentry/components/hookOrDefault';
import Placeholder from 'sentry/components/placeholder';
import {Tooltip} from 'sentry/components/tooltip';
import {IconClose} from 'sentry/icons';
import {IconCellSignal} from 'sentry/icons/iconCellSignal';
import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Activity} from 'sentry/types/group';
Expand All @@ -34,6 +36,8 @@ type GroupPriorityDropdownProps = {
type GroupPriorityBadgeProps = {
priority: PriorityLevel;
children?: React.ReactNode;
showLabel?: boolean;
variant?: 'default' | 'signal';
};

const PRIORITY_KEY_TO_LABEL: Record<PriorityLevel, string> = {
Expand Down Expand Up @@ -85,21 +89,40 @@ function useLastEditedBy({

export function makeGroupPriorityDropdownOptions({
onChange,
hasIssueStreamTableLayout,
}: {
hasIssueStreamTableLayout: boolean;
onChange: (value: PriorityLevel) => void;
}) {
return PRIORITY_OPTIONS.map(priority => ({
textValue: PRIORITY_KEY_TO_LABEL[priority],
key: priority,
label: <GroupPriorityBadge priority={priority} />,
label: (
<GroupPriorityBadge
variant={hasIssueStreamTableLayout ? 'signal' : 'default'}
priority={priority}
/>
),
onAction: () => onChange(priority),
}));
}

export function GroupPriorityBadge({priority, children}: GroupPriorityBadgeProps) {
export function GroupPriorityBadge({
priority,
showLabel = true,
variant = 'default',
children,
}: GroupPriorityBadgeProps) {
const bars =
priority === PriorityLevel.HIGH ? 3 : priority === PriorityLevel.MEDIUM ? 2 : 1;
const label = PRIORITY_KEY_TO_LABEL[priority] ?? t('Unknown');

return (
<StyledTag type={getTagTypeForPriority(priority)}>
{PRIORITY_KEY_TO_LABEL[priority] ?? t('Unknown')}
<StyledTag
type={variant === 'signal' ? 'default' : getTagTypeForPriority(priority)}
icon={variant === 'signal' && <IconCellSignal bars={bars} />}
>
{showLabel ? label : <VisuallyHidden>{label}</VisuallyHidden>}
{children}
</StyledTag>
);
Expand Down Expand Up @@ -187,9 +210,14 @@ export function GroupPriorityDropdown({
onChange,
lastEditedBy,
}: GroupPriorityDropdownProps) {
const organization = useOrganization();
const hasIssueStreamTableLayout = organization.features.includes(
'issue-stream-table-layout'
);

const options: MenuItemProps[] = useMemo(
() => makeGroupPriorityDropdownOptions({onChange}),
[onChange]
() => makeGroupPriorityDropdownOptions({onChange, hasIssueStreamTableLayout}),
[onChange, hasIssueStreamTableLayout]
);

return (
Expand All @@ -207,7 +235,11 @@ export function GroupPriorityDropdown({
aria-label={t('Modify issue priority')}
size="zero"
>
<GroupPriorityBadge priority={value}>
<GroupPriorityBadge
showLabel={!hasIssueStreamTableLayout}
variant={hasIssueStreamTableLayout ? 'signal' : 'default'}
priority={value}
>
<Chevron light direction={isOpen ? 'up' : 'down'} size="small" />
</GroupPriorityBadge>
</DropdownButton>
Expand Down
26 changes: 26 additions & 0 deletions static/app/icons/iconCellSignal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {forwardRef} from 'react';
import {useTheme} from '@emotion/react';

import {SvgIcon, type SVGIconProps} from 'sentry/icons/svgIcon';

interface Props extends SVGIconProps {
bars?: 0 | 1 | 2 | 3;
}
const IconCellSignal = forwardRef<SVGSVGElement, Props>(({bars = 3, ...props}, ref) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not attached to this name, feel free to give suggestions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like material icons has a similar name, so seems okay to me.

Only other think I could think of would be IconSignalBars

const theme = useTheme();
const firstBarColor = bars > 0 ? theme.gray300 : theme.gray100;
const secondBarColor = bars > 1 ? theme.gray300 : theme.gray100;
const thirdBarColor = bars > 2 ? theme.gray300 : theme.gray100;

return (
<SvgIcon {...props} ref={ref}>
<rect x="0" y="10" width="4" height="5" fill={firstBarColor} rx="1" />
<rect x="6.2" y="5" width="4" height="10" fill={secondBarColor} rx="1" />
<rect x="12.4" y="0" width="4" height="15" fill={thirdBarColor} rx="1" />
</SvgIcon>
);
});

IconCellSignal.displayName = 'IconCellSignal';

export {IconCellSignal};
5 changes: 5 additions & 0 deletions static/app/views/issueList/actions/actionSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {BaseGroup} from 'sentry/types/group';
import {GroupStatus} from 'sentry/types/group';
import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
import type {IssueTypeConfig} from 'sentry/utils/issueTypeConfig/types';
import useOrganization from 'sentry/utils/useOrganization';
import type {IssueUpdateData} from 'sentry/views/issueList/types';
import {FOR_REVIEW_QUERIES} from 'sentry/views/issueList/utils';

Expand Down Expand Up @@ -47,6 +48,7 @@ function ActionSet({
onMerge,
selectedProjectSlug,
}: Props) {
const organization = useOrganization();
const numIssues = issues.size;
const confirm = getConfirm({
numIssues,
Expand Down Expand Up @@ -232,6 +234,9 @@ function ActionSet({
confirmText: label('reprioritize'),
});
},
hasIssueStreamTableLayout: organization.features.includes(
'issue-stream-table-layout'
),
})}
/>
{!nestReview && <ReviewAction disabled={!canMarkReviewed} onUpdate={onUpdate} />}
Expand Down
Loading