Skip to content

Commit

Permalink
feat(issue-stream): Update priority badge/selector (#78726)
Browse files Browse the repository at this point in the history
closes #77819

Creates the new design for the issue priority badge under the `variant`
prop within the `<GroupPriorityBadge/>` component. This design is
currently under a feature flag, so it is not visible.

Demo with flag manually set to true: 


https://github.com/user-attachments/assets/d6f388a7-7c21-498c-afd2-7fc2f6faef23
  • Loading branch information
MichaelSun48 authored Oct 8, 2024
1 parent a21d310 commit 1d8bddb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 7 deletions.
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) => {
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

0 comments on commit 1d8bddb

Please sign in to comment.