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

Display warnings on users page in a clean and consistent way #1681

Merged
merged 4 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix team search when filtering resources by @vadimkerr ([#1680](https://github.com/grafana/oncall/pull/1680))
- Fix issue when trying to scroll in Safari ([#415](https://github.com/grafana/oncall/issues/415))

### Changed

- Display warnings on users page in a clean and consistent way by @iskhakov ([#1681](https://github.com/grafana/oncall/pull/1681))

## v1.2.6 (2023-03-30)

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Tooltip, VerticalGroup } from '@grafana/ui';
import cn from 'classnames/bind';

import PluginLink from 'components/PluginLink/PluginLink';
import ScheduleCounter from 'components/ScheduleCounter/ScheduleCounter';
import { ScheduleQualityDetails } from 'components/ScheduleQualityDetails/ScheduleQualityDetails';
import StatusCounterBadgeWithTooltip from 'components/StatusCounterBadgeWithTooltip/StatusCounterBadgeWithTooltip';
import Tag from 'components/Tag/Tag';
import Text from 'components/Text/Text';
import { Schedule, ScheduleScoreQualityResponse, ScheduleScoreQualityResult } from 'models/schedule/schedule.types';
Expand Down Expand Up @@ -40,7 +40,7 @@ const ScheduleQuality: FC<ScheduleQualityProps> = ({ schedule, lastUpdated }) =>
<>
<div className={cx('root')}>
{relatedEscalationChains?.length > 0 && schedule?.number_of_escalation_chains > 0 && (
<ScheduleCounter
<StatusCounterBadgeWithTooltip
type="link"
addPadding
count={schedule.number_of_escalation_chains}
Expand All @@ -60,7 +60,7 @@ const ScheduleQuality: FC<ScheduleQualityProps> = ({ schedule, lastUpdated }) =>
)}

{schedule.warnings?.length > 0 && (
<ScheduleCounter
<StatusCounterBadgeWithTooltip
type="warning"
addPadding
count={schedule.warnings.length}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import cn from 'classnames/bind';

import Text, { TextType } from 'components/Text/Text';

import styles from './ScheduleCounter.module.scss';
import styles from './StatusCounterBadgeWithTooltip.module.scss';

interface ScheduleCounterProps {
interface StatusCounterBadgeWithTooltipProps {
type: Partial<TextType>;
count: number;
tooltipTitle: string;
Expand All @@ -23,7 +23,7 @@ const typeToIcon = {

const cx = cn.bind(styles);

const ScheduleCounter: FC<ScheduleCounterProps> = (props) => {
const StatusCounterBadgeWithTooltip: FC<StatusCounterBadgeWithTooltipProps> = (props) => {
const { type, count, tooltipTitle, tooltipContent, onHover, addPadding } = props;

return (
Expand Down Expand Up @@ -55,4 +55,4 @@ const ScheduleCounter: FC<ScheduleCounterProps> = (props) => {
);
};

export default ScheduleCounter;
export default StatusCounterBadgeWithTooltip;
6 changes: 3 additions & 3 deletions grafana-plugin/src/pages/schedules/Schedules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import Avatar from 'components/Avatar/Avatar';
import { MatchMediaTooltip } from 'components/MatchMediaTooltip/MatchMediaTooltip';
import NewScheduleSelector from 'components/NewScheduleSelector/NewScheduleSelector';
import PluginLink from 'components/PluginLink/PluginLink';
import ScheduleCounter from 'components/ScheduleCounter/ScheduleCounter';
import { SchedulesFiltersType } from 'components/SchedulesFilters/SchedulesFilters.types';
import StatusCounterBadgeWithTooltip from 'components/StatusCounterBadgeWithTooltip/StatusCounterBadgeWithTooltip';
import Table from 'components/Table/Table';
import Text from 'components/Text/Text';
import TimelineMarks from 'components/TimelineMarks/TimelineMarks';
Expand Down Expand Up @@ -306,7 +306,7 @@ class SchedulesPage extends React.Component<SchedulesPageProps, SchedulesPageSta
return (
<HorizontalGroup>
{item.number_of_escalation_chains > 0 && (
<ScheduleCounter
<StatusCounterBadgeWithTooltip
type="link"
count={item.number_of_escalation_chains}
tooltipTitle="Used in escalations"
Expand Down Expand Up @@ -334,7 +334,7 @@ class SchedulesPage extends React.Component<SchedulesPageProps, SchedulesPageSta
)}

{item.warnings?.length > 0 && (
<ScheduleCounter
<StatusCounterBadgeWithTooltip
type="warning"
count={item.warnings.length}
tooltipTitle="Warnings"
Expand Down
23 changes: 18 additions & 5 deletions grafana-plugin/src/pages/users/Users.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { Alert, Button, HorizontalGroup, Icon, VerticalGroup } from '@grafana/ui';
import { Alert, Button, HorizontalGroup, VerticalGroup } from '@grafana/ui';
import cn from 'classnames/bind';
import { debounce } from 'lodash-es';
import { observer } from 'mobx-react';
Expand All @@ -15,6 +15,7 @@ import {
initErrorDataState,
} from 'components/PageErrorHandlingWrapper/PageErrorHandlingWrapper.helpers';
import PluginLink from 'components/PluginLink/PluginLink';
import StatusCounterBadgeWithTooltip from 'components/StatusCounterBadgeWithTooltip/StatusCounterBadgeWithTooltip';
import Text from 'components/Text/Text';
import UsersFilters from 'components/UsersFilters/UsersFilters';
import UserSettings from 'containers/UserSettings/UserSettings';
Expand Down Expand Up @@ -359,10 +360,22 @@ class Users extends React.Component<UsersProps, UsersState> {
}

return (
<div>
<Icon className={cx('warning-message-icon')} name="exclamation-triangle" />
{texts.join(', ')}
</div>
<HorizontalGroup>
<StatusCounterBadgeWithTooltip
type="warning"
count={texts.length}
tooltipTitle="Warnings"
tooltipContent={
<VerticalGroup spacing="none">
{texts.map((warning, index) => (
<Text type="primary" key={index}>
{warning}
</Text>
))}
</VerticalGroup>
}
/>
</HorizontalGroup>
);
}

Expand Down