From dcf08425ebb091e0165385fa889074d859deb091 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Mon, 13 Nov 2023 07:44:54 -0500 Subject: [PATCH] Fix few minor Slack connection issues (#3327) # What this PR does Closes https://github.com/grafana/oncall-private/issues/2289 - Fix issue where if you try connecting your Slack user to your OnCall user and the first time around you encounter an error (ex. connecting to the wrong Slack workspace), you will see the same error banner message despite a successful connection. Now we clear the session upon successful connection to ensure that you will not see any previously encountered errors. - Fix some alignment issues on the Slack connection buttons **Before** Screenshot 2023-11-10 at 15 07 48 Screenshot 2023-11-10 at 15 16 22 **After** Screenshot 2023-11-10 at 15 10 28 Screenshot 2023-11-10 at 15 16 42 - On the "User Info" user settings modal tab, render `display_name` instead of `slack_login`. Currently we prefix `@` before `slack_login`, which is a bit confusing as it makes you think that this is the handle you would use to `@` your user in Slack. `display_name` corresponds to the handle that would be used to `@` your user ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --- CHANGELOG.md | 1 + engine/apps/social_auth/pipeline.py | 5 +++++ .../containers/MobileAppConnection/MobileAppConnection.tsx | 7 +++++-- .../__snapshots__/MobileAppConnection.test.tsx.snap | 4 ++-- .../UserSettings/parts/connectors/SlackConnector.tsx | 2 +- .../UserSettings/parts/tabs/SlackTab/SlackTab.tsx | 6 ++++-- grafana-plugin/src/models/user/user.types.ts | 1 + .../tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx | 4 +++- 8 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abcb3298..a81e264f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fix issue where Slack user connection error message is sometimes shown despite successful connection by @joeyorlando ([#3327](https://github.com/grafana/oncall/pull/3327)) - Forward headers for Amazon SNS when organizations are moved @mderynck ([#3326](https://github.com/grafana/oncall/pull/3326)) ## v1.3.57 (2023-11-10) diff --git a/engine/apps/social_auth/pipeline.py b/engine/apps/social_auth/pipeline.py index 10acb47d..6eb6c621 100644 --- a/engine/apps/social_auth/pipeline.py +++ b/engine/apps/social_auth/pipeline.py @@ -57,6 +57,11 @@ def connect_user_to_slack(response, backend, strategy, user, organization, *args strategy.session[REDIRECT_FIELD_NAME] = url return HttpResponse(status=status.HTTP_400_BAD_REQUEST) + # at this point everything is correct and we can create the SlackUserIdentity + # be sure to clear any pre-existing sessions, in case the user previously enecountered errors we want + # to be sure to clear these so they do not see them again + strategy.session.flush() + slack_user_identity, _ = SlackUserIdentity.objects.get_or_create( slack_id=slack_user_id, slack_team_identity=slack_team_identity, diff --git a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx index 4e87938f..b1ae577a 100644 --- a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx +++ b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx @@ -152,7 +152,8 @@ const MobileAppConnection = observer(({ userPk }: Props) => { App connected - You can sync one application to your account. To setup new device please disconnect app first. + You can only sync one application to your account. To setup a new device, please disconnect the currently + connected device first.
@@ -168,7 +169,9 @@ const MobileAppConnection = observer(({ userPk }: Props) => { Sign In - Open Grafana IRM mobile application and scan this code to sync it with your account. + + Open the Grafana IRM mobile application and scan this code to sync it with your account. +
{isQRBlurry && } diff --git a/grafana-plugin/src/containers/MobileAppConnection/__snapshots__/MobileAppConnection.test.tsx.snap b/grafana-plugin/src/containers/MobileAppConnection/__snapshots__/MobileAppConnection.test.tsx.snap index 1f46a2a3..74d48e6f 100644 --- a/grafana-plugin/src/containers/MobileAppConnection/__snapshots__/MobileAppConnection.test.tsx.snap +++ b/grafana-plugin/src/containers/MobileAppConnection/__snapshots__/MobileAppConnection.test.tsx.snap @@ -120,7 +120,7 @@ exports[`MobileAppConnection if we disconnect the app, it disconnects and fetche - Open Grafana IRM mobile application and scan this code to sync it with your account. + Open the Grafana IRM mobile application and scan this code to sync it with your account.
- You can sync one application to your account. To setup new device please disconnect app first. + You can only sync one application to your account. To setup a new device, please disconnect the currently connected device first.
{ diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx index d6d72f0b..ae11270f 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; -import { Button, VerticalGroup, Icon } from '@grafana/ui'; +import { Button, VerticalGroup, Icon, HorizontalGroup } from '@grafana/ui'; import cn from 'classnames/bind'; import Block from 'components/GBlock/Block'; @@ -48,7 +48,9 @@ export const SlackTab = () => { diff --git a/grafana-plugin/src/models/user/user.types.ts b/grafana-plugin/src/models/user/user.types.ts index 6d3caae3..06a60c2d 100644 --- a/grafana-plugin/src/models/user/user.types.ts +++ b/grafana-plugin/src/models/user/user.types.ts @@ -34,6 +34,7 @@ export interface User extends BaseUser { unverified_phone_number?: string; slack_user_identity: { avatar: string; + display_name: string; name: string; slack_id: string; slack_login: string; diff --git a/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx b/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx index bac6f633..e0540ec6 100644 --- a/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx +++ b/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx @@ -289,7 +289,9 @@ class SlackSettings extends Component { ) : ( {store.hasFeature(AppFeature.LiveSettings) && (