From d8bfc626deac5ab1c85dc9472592cdc07ea68b9b Mon Sep 17 00:00:00 2001 From: Rares Mardare Date: Mon, 20 Mar 2023 11:36:04 +0200 Subject: [PATCH] Rares/1448 permissions (#1529) # What this PR does Adds a few more permission checks for #1448 ## Which issue(s) this PR fixes #1448 ## Checklist - [x] `CHANGELOG.md` updated --- CHANGELOG.md | 1 + .../AlertTemplatesForm.module.css | 4 -- .../AlertTemplates/AlertTemplatesForm.tsx | 44 +++++++++---------- .../IntegrationSettings/parts/Autoresolve.tsx | 34 +++++++------- .../src/pages/incident/Incident.tsx | 18 ++++---- .../src/pages/schedule/Schedule.tsx | 9 ++-- 6 files changed, 58 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7ca9858..4837b64d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed a few permission issues on the UI ([1448](https://github.com/grafana/oncall/pull/1448)) - Fix resolution note rendering in Slack message threads where the Slack username was not being properly rendered ([1561](https://github.com/grafana/oncall/pull/1561)) diff --git a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.module.css b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.module.css index f5da34f8..924951cf 100644 --- a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.module.css +++ b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.module.css @@ -46,10 +46,6 @@ margin-top: 8px; } -.payloadExample { - margin-top: 24px; -} - .autoresolve-condition section { border: 1px solid var(--primary-text-link); } diff --git a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.tsx b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.tsx index 9cef300f..7f6637cf 100644 --- a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.tsx +++ b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.tsx @@ -18,7 +18,7 @@ import { AlertReceiveChannel } from 'models/alert_receive_channel/alert_receive_ import { Alert } from 'models/alertgroup/alertgroup.types'; import { makeRequest } from 'network'; import LocationHelper from 'utils/LocationHelper'; -import { UserActions } from 'utils/authorization'; +import { UserActions, isUserActionAllowed } from 'utils/authorization'; import styles from './AlertTemplatesForm.module.css'; @@ -254,29 +254,29 @@ const AlertTemplatesForm = (props: AlertTemplatesFormProps) => { {templates?.payload_example ? ( - - - - - {groups[activeGroup].map((template) => ( - - ))} - - -
+ + {isUserActionAllowed(UserActions.IntegrationsTest) && ( - - {JSON.stringify(templates?.payload_example, null, 4)} + + + {groups[activeGroup].map((template) => ( + + ))} + -
+ )} + + + {JSON.stringify(templates?.payload_example, null, 4)} +
) : ( sendDemoAlertBlock diff --git a/grafana-plugin/src/containers/IntegrationSettings/parts/Autoresolve.tsx b/grafana-plugin/src/containers/IntegrationSettings/parts/Autoresolve.tsx index 7f17f1eb..057cb0c6 100644 --- a/grafana-plugin/src/containers/IntegrationSettings/parts/Autoresolve.tsx +++ b/grafana-plugin/src/containers/IntegrationSettings/parts/Autoresolve.tsx @@ -128,18 +128,20 @@ const Autoresolve = ({ alertReceiveChannelId, onSwitchToTemplate, alertGroupId } Which team should this integration belong to? - + + +
- + + +
{showSaveConfirmationModal && ( diff --git a/grafana-plugin/src/pages/incident/Incident.tsx b/grafana-plugin/src/pages/incident/Incident.tsx index fe4b46de..c5861777 100644 --- a/grafana-plugin/src/pages/incident/Incident.tsx +++ b/grafana-plugin/src/pages/incident/Incident.tsx @@ -493,14 +493,16 @@ class IncidentPage extends React.Component onChange={(e: any) => this.setState({ resolutionNoteText: e.target.value })} /> - - Add resolution note - + + + Add resolution note + + ); }; diff --git a/grafana-plugin/src/pages/schedule/Schedule.tsx b/grafana-plugin/src/pages/schedule/Schedule.tsx index e34deae8..450452ea 100644 --- a/grafana-plugin/src/pages/schedule/Schedule.tsx +++ b/grafana-plugin/src/pages/schedule/Schedule.tsx @@ -22,6 +22,7 @@ import ScheduleOverrides from 'containers/Rotations/ScheduleOverrides'; import ScheduleForm from 'containers/ScheduleForm/ScheduleForm'; import ScheduleICalSettings from 'containers/ScheduleIcalLink/ScheduleIcalLink'; import UsersTimezones from 'containers/UsersTimezones/UsersTimezones'; +import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { Schedule, ScheduleType, Shift } from 'models/schedule/schedule.types'; import { Timezone } from 'models/timezone/timezone.types'; import { PageProps, WithStoreProps } from 'state/types'; @@ -183,9 +184,11 @@ class SchedulePage extends React.Component {(schedule?.type === ScheduleType.Ical || schedule?.type === ScheduleType.Calendar) && ( - + + + )}