Skip to content

Commit

Permalink
Changes to make screens more responsive + incident status toggler cha…
Browse files Browse the repository at this point in the history
…nge (#1237)

# What this PR does

- Changes to make a few screens be more responsive
- Removed incident actions and replaced incident status with a toggler
- Renamed `IncidentStatus.new` to `IncidentStatus.Firing`
- Removed old schedules code (unused)

## Which issue(s) this PR fixes

#1000 

## Checklist

- [x] `CHANGELOG.md` updated

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
  • Loading branch information
teodosii and joeyorlando authored Feb 7, 2023
1 parent 89f2220 commit 81b5741
Show file tree
Hide file tree
Showing 44 changed files with 924 additions and 484 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.1.24 (2023-02-06)
## Unreleased

### Fixed

- Design polishing ([1290](https://github.com/grafana/oncall/pull/1290))
- Not showing contact details in User tooltip if User does not have edit/admin access

### Changes

- Incidents - Removed buttons column and replaced status with toggler ([#1237](https://github.com/grafana/oncall/issues/1237))
- Responsiveness changes across multiple pages (Incidents, Integrations, Schedules) ([#1237](https://github.com/grafana/oncall/issues/1237))

## v1.1.23 (2023-02-06)

### Fixed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { FC, useEffect, useState } from 'react';

import { Tooltip } from '@grafana/ui';
import { debounce } from 'throttle-debounce';

interface MatchMediaTooltipProps {
placement: 'top' | 'bottom' | 'right' | 'left';
content: string;
children: JSX.Element;

maxWidth?: number;
minWidth?: number;
}

const DEBOUNCE_MS = 200;

export const MatchMediaTooltip: FC<MatchMediaTooltipProps> = ({ minWidth, maxWidth, placement, content, children }) => {
const [match, setMatch] = useState<MediaQueryList>(getMatch());

useEffect(() => {
const debouncedResize = debounce(DEBOUNCE_MS, onWindowResize);
window.addEventListener('resize', debouncedResize);
return () => {
window.removeEventListener('resize', debouncedResize);
};
}, []);

if (match?.matches) {
return (
<Tooltip placement={placement} content={content}>
{children}
</Tooltip>
);
}

return <>{children}</>;

function onWindowResize() {
setMatch(getMatch());
}

function getMatch() {
if (minWidth && maxWidth) {
return window.matchMedia(`(min-width: ${minWidth}px) and (max-width: ${maxWidth}px)`);
} else if (minWidth) {
return window.matchMedia(`(min-width: ${minWidth}px)`);
} else if (maxWidth) {
return window.matchMedia(`(max-width: ${maxWidth}px)`);
}

return undefined;
}
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.right {
display: flex;
flex-wrap: wrap;
row-gap: 4px;
column-gap: 8px;
}

@media screen and (max-width: 1600px) {
.right {
order: 3;
width: 100%;
}
}
99 changes: 67 additions & 32 deletions grafana-plugin/src/components/SchedulesFilters/SchedulesFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,95 @@
import React, { useCallback, useMemo } from 'react';
import React, { ChangeEvent, useCallback } from 'react';

import { DatePickerWithInput, Field, HorizontalGroup, RadioButtonGroup } from '@grafana/ui';
import { Field, Icon, Input, RadioButtonGroup } from '@grafana/ui';
import cn from 'classnames/bind';
import moment from 'moment-timezone';

import { dateStringToOption, optionToDateString } from './SchedulesFilters.helpers';
import { SchedulesFiltersType } from './SchedulesFilters.types';
import { ScheduleType } from 'models/schedule/schedule.types';

import styles from './SchedulesFilters.module.css';
import styles from './SchedulesFilters.module.scss';
import { SchedulesFiltersType } from './SchedulesFilters.types';

const cx = cn.bind(styles);

interface SchedulesFiltersProps {
value: SchedulesFiltersType;
onChange: (filters: SchedulesFiltersType) => void;
className?: string;
}

const SchedulesFilters = ({ value, onChange, className }: SchedulesFiltersProps) => {
const handleDateChange = useCallback(
(date: Date) => {
onChange({ selectedDate: moment(date).format('YYYY-MM-DD') });
const SchedulesFilters = (props: SchedulesFiltersProps) => {
const { value, onChange } = props;

const onSearchTermChangeCallback = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
onChange({ ...value, searchTerm: e.currentTarget.value });
},
[onChange]
[value]
);

const option = useMemo(() => dateStringToOption(value.selectedDate), [value]);

const handleOptionChange = useCallback(
(option: string) => {
onChange({ ...value, selectedDate: optionToDateString(option) });
const handleStatusChange = useCallback(
(status) => {
onChange({ ...value, status });
},
[onChange, value]
[value]
);

const datePickerValue = useMemo(() => moment(value.selectedDate).toDate(), [value]);
const handleTypeChange = useCallback(
(type) => {
onChange({ ...value, type });
},
[value]
);

return (
<div className={cx('root', className)}>
<HorizontalGroup>
<Field label="Filter events">
<>
<div className={cx('left')}>
<Field label="Search by name">
<Input
autoFocus
className={cx('search')}
prefix={<Icon name="search" />}
placeholder="Search..."
value={value.searchTerm}
onChange={onSearchTermChangeCallback}
/>
</Field>
</div>
<div className={cx('right')}>
<Field label="Status">
<RadioButtonGroup
options={[
{ value: 'today', label: 'Today' },
{ value: 'tomorrow', label: 'Tomorrow' },
{ value: 'custom', label: 'Custom' },
{ label: 'All', value: 'all' },
{
label: 'Used in escalations',
value: 'used',
},
{ label: 'Unused', value: 'unused' },
]}
value={option}
onChange={handleOptionChange}
value={value.status}
onChange={handleStatusChange}
/>
</Field>
<Field label="Date">
<DatePickerWithInput closeOnSelect width={40} value={datePickerValue} onChange={handleDateChange} />
<Field label="Type">
<RadioButtonGroup
options={[
{ label: 'All', value: undefined },
{
label: 'Web',
value: ScheduleType.API,
},
{
label: 'ICal',
value: ScheduleType.Ical,
},
{
label: 'API',
value: ScheduleType.Calendar,
},
]}
value={value?.type}
onChange={handleTypeChange}
/>
</Field>
</HorizontalGroup>
</div>
</div>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { ScheduleType } from 'models/schedule/schedule.types';

export interface SchedulesFiltersType {
selectedDate: string;
searchTerm: string;
type: ScheduleType;
status: string;
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 9 additions & 2 deletions grafana-plugin/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ interface TagProps {
color: string;
className?: string;
children?: any;
onClick?: (ev) => void;
forwardedRef?: React.MutableRefObject<HTMLSpanElement>;
}

const cx = cn.bind(styles);

const Tag: FC<TagProps> = (props) => {
const { children, color, className } = props;
const { children, color, className, onClick } = props;

return (
<span style={{ backgroundColor: color }} className={cx('root', className)}>
<span
style={{ backgroundColor: color }}
className={cx('root', className)}
onClick={onClick}
ref={props.forwardedRef}
>
{children}
</span>
);
Expand Down
Loading

0 comments on commit 81b5741

Please sign in to comment.