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

Revert "Collection of bugs" #1671

Merged
merged 2 commits into from
Mar 30, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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.2.5 (2023-03-30)

### Fixed

- Fixed a bug with Slack links not working in the plugin UI ([#1671](https://github.com/grafana/oncall/pull/1671))

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

### Added
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/components/Tutorial/Tutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Tutorial: FC<TutorialProps> = (props) => {
</div>
<Arrow />
<div className={cx('step')}>
<PluginLink query={{ page: 'alert-groups' }}>
<PluginLink query={{ page: 'incidents' }}>
<div className={cx('icon', { icon_active: step === TutorialStep.Incidents })}>
<img src={bellIcon} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const AlertReceiveChannelCard = observer((props: AlertReceiveChannelCardProps) =
</Text>
{alertReceiveChannelCounter && (
<PluginLink
query={{ page: 'alert-groups', integration: alertReceiveChannel.id }}
query={{ page: 'incidents', integration: alertReceiveChannel.id }}
className={cx('alertsInfoText')}
>
<Badge
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/containers/AlertRules/AlertRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface AlertRulesState {
const Notification: React.FC = () => (
<div>
Demo alert was generated. Find it on the
<PluginLink query={{ page: 'alert-groups' }}> "Alert Groups" </PluginLink>
<PluginLink query={{ page: 'incidents' }}> "Alert Groups" </PluginLink>
page and make sure it didn't freak out your colleagues 😉
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ const AttachIncidentForm = observer(({ id, onUpdate, onHide }: AttachIncidentFor
title={
<HorizontalGroup>
<Icon size="lg" name="link" />
<Text.Title level={4}>Attach to another alert group</Text.Title>
<Text.Title level={4}>Attach to another incident</Text.Title>
</HorizontalGroup>
}
className={cx('root')}
onDismiss={onHide}
>
<Field
label="Alert group to be attached with"
description="Linking alert groups together can help the team investigate the underlying issue."
label="Incident to be attached with"
description="Linking incidents together can help the team investigate the underlying issue."
>
<WithPermissionControlTooltip userAction={UserActions.AlertGroupsWrite}>
<GSelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const IncidentMatcher = observer((props: IncidentMatcherProps) => {
{selectedAlertItem ? (
<SourceCode noMaxHeight>{JSON.stringify(selectedAlertItem, null, 2)}</SourceCode>
) : (
<Text type="secondary">← Select alert group first</Text>
<Text type="secondary">← Select incident first</Text>
)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const IntegrationSettings = observer((props: IntegrationSettingsProps) => {
const [expanded, _setExpanded] = useState(false);

const handleSwitchToTemplate = (templateName: string) => {
setActiveTab(IntegrationSettingsTab.Templates);
setSelectedTemplate(templateName);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@
padding: 4px 8px;
margin-top: 8px;
min-width: 500px;
width: 620px;
}

.autoresolve-div {
display: flex;
align-items: baseline;
width: 520px;
}

.warning-icon-color {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const Autoresolve = ({ alertReceiveChannelId, onSwitchToTemplate, alertGroupId }
<Label>
<div className={cx('settings-label')}>
Autoresolve
<Text type="secondary">How should this integration resolve alert groups?</Text>
<Text type="secondary">How should this integration resolve incidents?</Text>
</div>
</Label>
<div className={cx('team-select')}>
Expand All @@ -172,9 +172,9 @@ const Autoresolve = ({ alertReceiveChannelId, onSwitchToTemplate, alertGroupId }
{autoresolveSelected && (
<>
<Block shadowed bordered className={cx('autoresolve-block')}>
<div className={cx('autoresolve-div')}>
<div>
<Text type="secondary" size="small">
<Icon name="info-circle" /> Alert group will be automatically resolved when it matches{' '}
<Icon name="info-circle" /> Incident will be automatically resolved when it matches{' '}
</Text>
<Button fill="text" size="sm" onClick={handleGoToTemplateSettingsCllick}>
autoresolve condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const form: { name: string; fields: FormItem[] } = {
},
{
value: MaintenanceMode.Maintenance,
label: 'Maintenance (collect everything in one alert group)',
label: 'Maintenance (collect everything in one incident)',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
}

.draggable {
top: 10%;
position: absolute;
top: 0;

/* transition: transform 300ms ease; */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
.loadItem(id, true)
.catch((error) => this.setState({ errorData: { ...getWrongTeamResponseInfo(error) } }));

await escalationChainStore.updateEscalationChainDetails(id);
if (!escalationChain) {
return;
}
Expand Down
14 changes: 8 additions & 6 deletions grafana-plugin/src/pages/incident/Incident.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class IncidentPage extends React.Component<IncidentPageProps, IncidentPageState>
<VerticalGroup spacing="lg" align="center">
<Text.Title level={1}>404</Text.Title>
<Text.Title level={4}>Alert group not found</Text.Title>
<PluginLink query={{ page: 'alert-groups', cursor, start, perpage }}>
<PluginLink query={{ page: 'incidents', cursor, start, perpage }}>
<Button variant="secondary" icon="arrow-left" size="md">
Go to Alert Groups page
</Button>
Expand Down Expand Up @@ -244,7 +244,7 @@ class IncidentPage extends React.Component<IncidentPageProps, IncidentPageState>
<VerticalGroup>
<HorizontalGroup justify="space-between">
<HorizontalGroup className={cx('title')}>
<PluginLink query={{ page: 'alert-groups', cursor, start, perpage }}>
<PluginLink query={{ page: 'incidents', cursor, start, perpage }}>
<IconButton name="arrow-left" size="xxl" />
</PluginLink>
{/* @ts-ignore*/}
Expand All @@ -256,12 +256,12 @@ class IncidentPage extends React.Component<IncidentPageProps, IncidentPageState>
{incident.root_alert_group && (
<Text type="secondary">
Attached to{' '}
<PluginLink query={{ page: 'alert-groups', id: incident.root_alert_group.pk }}>
<PluginLink query={{ page: 'incident', id: incident.root_alert_group.pk }}>
#{incident.root_alert_group.inside_organization_number}{' '}
{incident.root_alert_group.render_for_web.title}
</PluginLink>{' '}
<WithPermissionControlTooltip userAction={UserActions.AlertGroupsWrite}>
<Button variant="secondary" onClick={() => this.getUnattachClickHandler(incident.pk)} size="sm">
<Button variant="secondary" onClick={this.getUnattachClickHandler(incident.pk)} size="sm">
Unattach
</Button>
</WithPermissionControlTooltip>
Expand Down Expand Up @@ -421,7 +421,9 @@ class IncidentPage extends React.Component<IncidentPageProps, IncidentPageState>
getUnattachClickHandler = (pk: Alert['pk']) => {
const { store } = this.props;

return store.alertGroupStore.unattachAlert(pk).then(this.update);
return () => {
store.alertGroupStore.unattachAlert(pk).then(this.update);
};
};

renderTimeline = () => {
Expand Down Expand Up @@ -760,7 +762,7 @@ function AttachedIncidentsList({
{alerts.map((incident) => {
return (
<HorizontalGroup key={incident.pk} justify={'space-between'}>
<PluginLink query={{ page: 'alert-groups', id: incident.pk }}>
<PluginLink query={{ page: 'incident', id: incident.pk }}>
#{incident.inside_organization_number} {incident.render_for_web.title}
</PluginLink>
<WithPermissionControlTooltip userAction={UserActions.AlertGroupsWrite}>
Expand Down
10 changes: 2 additions & 8 deletions grafana-plugin/src/pages/incidents/Incidents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Incidents extends React.Component<IncidentsPageProps, IncidentsPageState>
this.setState({ showAddAlertGroupForm: false });
}}
onCreate={(id: Alert['pk']) => {
history.push(`${PLUGIN_ROOT}/alert-groups/${id}`);
history.push(`${PLUGIN_ROOT}/incidents/${id}`);
}}
/>
)}
Expand Down Expand Up @@ -557,13 +557,7 @@ class Incidents extends React.Component<IncidentsPageProps, IncidentsPageState>
<VerticalGroup spacing="none" justify="center">
<div className={'table__wrap-column'}>
<PluginLink
query={{
page: 'alert-groups',
id: record.pk,
cursor: incidentsCursor,
perpage: incidentsItemsPerPage,
start,
}}
query={{ page: 'incidents', id: record.pk, cursor: incidentsCursor, perpage: incidentsItemsPerPage, start }}
>
<Tooltip placement="top" content={record.render_for_web.title}>
<span>{record.render_for_web.title}</span>
Expand Down
20 changes: 8 additions & 12 deletions grafana-plugin/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ function getPath(name = '') {
export const pages: { [id: string]: PageDefinition } = [
{
icon: 'bell',
id: 'alert-groups',
id: 'incidents',
hideFromBreadcrumbs: true,
text: 'Alert Groups',
hideTitle: true,
path: getPath('alert-groups'),
path: getPath('incidents'),
action: UserActions.AlertGroupsRead,
},
{
icon: 'bell',
id: 'alert-group',
id: 'incident',
text: '',
hideFromTabs: true,
hideFromBreadcrumbs: true,
parentItem: {
text: 'Alert Group',
url: `${PLUGIN_ROOT}/alert-groups`,
text: 'Incident',
url: `${PLUGIN_ROOT}/incidents`,
},
path: getPath('alert-groups'),
path: getPath('incident'),
action: UserActions.AlertGroupsRead,
},
{
Expand Down Expand Up @@ -189,8 +189,8 @@ export const pages: { [id: string]: PageDefinition } = [
}, {});

export const ROUTES = {
'alert-groups': ['alert-groups'],
'alert-group': ['alert-groups/:id'],
incidents: ['incidents'],
incident: ['incidents/:id'],
users: ['users', 'users/:id'],
integrations: ['integrations', 'integrations/:id'],
escalations: ['escalations', 'escalations/:id'],
Expand All @@ -205,10 +205,6 @@ export const ROUTES = {
'live-settings': ['live-settings'],
cloud: ['cloud'],
test: ['test'],

// backwards compatible to redirect to new alert-groups
incident: ['incidents/:id'],
incidents: ['incidents'],
};

export const getRoutesForPage = (name: string) => {
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{
"type": "page",
"name": "Alert Groups",
"path": "/a/grafana-oncall-app/alert-groups",
"path": "/a/grafana-oncall-app/incidents",
"role": "Viewer",
"action": "grafana-oncall-app.alert-groups:read",
"addToNav": true
Expand Down
32 changes: 3 additions & 29 deletions grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import weekday from 'dayjs/plugin/weekday';
import { observer, Provider } from 'mobx-react';
import Header from 'navbar/Header/Header';
import LegacyNavTabsBar from 'navbar/LegacyNavTabsBar';
import { Redirect, Route, Switch, useLocation } from 'react-router-dom';
import { Route, Switch, useLocation } from 'react-router-dom';
import { AppRootProps } from 'types';

import Unauthorized from 'components/Unauthorized';
Expand Down Expand Up @@ -138,10 +138,10 @@ export const Root = observer((props: AppRootProps) => {
>
{userHasAccess ? (
<Switch>
<Route path={getRoutesForPage('alert-groups')} exact>
<Route path={getRoutesForPage('incidents')} exact>
<Incidents query={query} />
</Route>
<Route path={getRoutesForPage('alert-group')} exact>
<Route path={getRoutesForPage('incident')} exact>
<Incident query={query} />
</Route>
<Route path={getRoutesForPage('users')} exact>
Expand Down Expand Up @@ -183,32 +183,6 @@ export const Root = observer((props: AppRootProps) => {
<Route path={getRoutesForPage('cloud')} exact>
<CloudPage />
</Route>

<Route
path={getRoutesForPage('incident')}
exact
render={({ location }) => (
<Redirect
to={{
...location,
pathname: location.pathname.replace(/incident/, 'alert-group'),
}}
></Redirect>
)}
></Route>
<Route
path={getRoutesForPage('incidents')}
exact
render={({ location }) => (
<Redirect
to={{
...location,
pathname: location.pathname.replace(/incidents/, 'alert-groups'),
}}
></Redirect>
)}
></Route>

<Route path="*">
<NoMatch />
</Route>
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const GRAFANA_LICENSE_OSS = 'OpenSource';
export const BREAKPOINT_TABS = 1024;

// Default redirect page
export const DEFAULT_PAGE = 'alert-groups';
export const DEFAULT_PAGE = 'incidents';

export const PLUGIN_ROOT = '/a/grafana-oncall-app';

Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function getPathFromQueryParams(query: ParsedQuery<string>) {
path += `/${normalizedQuery.page}`;

if (normalizedQuery.id) {
if (normalizedQuery.page === 'alert-group' || normalizedQuery.page === 'schedule') {
if (normalizedQuery.page === 'incident' || normalizedQuery.page === 'schedule') {
path += 's';
}

Expand Down