From 7c8722e71485c6172ed2661d03a017f02a7df79d Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 8 Mar 2023 11:22:44 +0100 Subject: [PATCH] remove mobile app feature flag (#1484) # What this PR does ## Which issue(s) this PR fixes ## Checklist - [x] Tests updated - [ ] Documentation added (N/A) - [x] `CHANGELOG.md` updated --- CHANGELOG.md | 4 ++ engine/apps/api/tests/test_features.py | 2 - engine/apps/api/views/features.py | 4 -- .../apps/mobile_app/tests/test_fcm_relay.py | 3 -- engine/conftest.py | 6 --- engine/engine/urls.py | 9 +--- engine/settings/base.py | 16 +++--- .../containers/UserSettings/UserSettings.tsx | 3 +- .../parts/connectors/MobileAppConnector.tsx | 14 ++---- .../pages/settings/tabs/Cloud/CloudPage.tsx | 49 +++++++++---------- grafana-plugin/src/state/features.ts | 1 - 11 files changed, 38 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcda86cb0c..f7b3be7d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Jinja2 based routes ([1319](https://github.com/grafana/oncall/pull/1319)) +### Changed + +- Remove mobile app feature flag ([1484](https://github.com/grafana/oncall/pull/1484)) + ### Fixed - Prohibit creating & updating past overrides ([1474](https://github.com/grafana/oncall/pull/1474)) diff --git a/engine/apps/api/tests/test_features.py b/engine/apps/api/tests/test_features.py index 60484b6b2f..6f9192eea2 100644 --- a/engine/apps/api/tests/test_features.py +++ b/engine/apps/api/tests/test_features.py @@ -7,7 +7,6 @@ FEATURE_GRAFANA_CLOUD_CONNECTION, FEATURE_GRAFANA_CLOUD_NOTIFICATIONS, FEATURE_LIVE_SETTINGS, - FEATURE_MOBILE_APP, FEATURE_SLACK, FEATURE_TELEGRAM, FEATURE_WEB_SCHEDULES, @@ -39,7 +38,6 @@ def test_features_view( ("FEATURE_TELEGRAM_INTEGRATION_ENABLED", FEATURE_TELEGRAM), ("FEATURE_LIVE_SETTINGS_ENABLED", FEATURE_LIVE_SETTINGS), ("FEATURE_WEB_SCHEDULES_ENABLED", FEATURE_WEB_SCHEDULES), - ("FEATURE_MOBILE_APP_INTEGRATION_ENABLED", FEATURE_MOBILE_APP), ], ) def test_core_features_switch( diff --git a/engine/apps/api/views/features.py b/engine/apps/api/views/features.py index d296a1c839..b09a616050 100644 --- a/engine/apps/api/views/features.py +++ b/engine/apps/api/views/features.py @@ -9,7 +9,6 @@ FEATURE_SLACK = "slack" FEATURE_TELEGRAM = "telegram" FEATURE_LIVE_SETTINGS = "live_settings" -FEATURE_MOBILE_APP = "mobile_app" FEATURE_GRAFANA_CLOUD_NOTIFICATIONS = "grafana_cloud_notifications" FEATURE_GRAFANA_CLOUD_CONNECTION = "grafana_cloud_connection" FEATURE_WEB_SCHEDULES = "web_schedules" @@ -36,9 +35,6 @@ def _get_enabled_features(self, request): if settings.FEATURE_TELEGRAM_INTEGRATION_ENABLED: enabled_features.append(FEATURE_TELEGRAM) - if settings.FEATURE_MOBILE_APP_INTEGRATION_ENABLED: - enabled_features.append(FEATURE_MOBILE_APP) - if settings.IS_OPEN_SOURCE: # Features below should be enabled only in OSS enabled_features.append(FEATURE_GRAFANA_CLOUD_CONNECTION) diff --git a/engine/apps/mobile_app/tests/test_fcm_relay.py b/engine/apps/mobile_app/tests/test_fcm_relay.py index c694bd40a3..7cbfd9307b 100644 --- a/engine/apps/mobile_app/tests/test_fcm_relay.py +++ b/engine/apps/mobile_app/tests/test_fcm_relay.py @@ -13,7 +13,6 @@ @pytest.mark.django_db def test_fcm_relay_disabled( settings, - load_mobile_app_urls, make_organization_and_user_with_plugin_token, make_user_auth_headers, make_public_api_token, @@ -33,7 +32,6 @@ def test_fcm_relay_disabled( @pytest.mark.django_db def test_fcm_relay_post( settings, - load_mobile_app_urls, make_organization_and_user_with_plugin_token, make_user_auth_headers, make_public_api_token, @@ -59,7 +57,6 @@ def test_fcm_relay_post( @pytest.mark.django_db def test_fcm_relay_ratelimit( settings, - load_mobile_app_urls, make_organization_and_user_with_plugin_token, make_user_auth_headers, make_public_api_token, diff --git a/engine/conftest.py b/engine/conftest.py index 2a34be166e..7c58208a53 100644 --- a/engine/conftest.py +++ b/engine/conftest.py @@ -755,12 +755,6 @@ def load_slack_urls(settings): reload_urls(settings) -@pytest.fixture() -def load_mobile_app_urls(settings): - settings.FEATURE_MOBILE_APP_INTEGRATION_ENABLED = True - reload_urls(settings) - - @pytest.fixture def make_region(): def _make_region(**kwargs): diff --git a/engine/engine/urls.py b/engine/engine/urls.py index f840d4ccc5..be50be31ff 100644 --- a/engine/engine/urls.py +++ b/engine/engine/urls.py @@ -35,6 +35,8 @@ path("integrations/v1/", include("apps.integrations.urls", namespace="integrations")), path("twilioapp/", include("apps.twilioapp.urls")), path("api/v1/", include("apps.public_api.urls", namespace="api-public")), + path("mobile_app/v1/", include("apps.mobile_app.urls", namespace="mobile_app")), + path("api/internal/v1/mobile_app/", include("apps.mobile_app.urls", namespace="mobile_app_tmp")), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) if settings.FEATURE_SLACK_INTEGRATION_ENABLED: @@ -50,13 +52,6 @@ path("slack/", include("apps.slack.urls")), ] -if settings.FEATURE_MOBILE_APP_INTEGRATION_ENABLED: - urlpatterns += [ - path("mobile_app/v1/", include("apps.mobile_app.urls", namespace="mobile_app")), - path("api/internal/v1/mobile_app/", include("apps.mobile_app.urls", namespace="mobile_app_tmp")), - ] - - if settings.IS_OPEN_SOURCE: urlpatterns += [ path("api/internal/v1/", include("apps.oss_installation.urls", namespace="oss_installation")), diff --git a/engine/settings/base.py b/engine/settings/base.py index 8244085766..d6d7438ee6 100644 --- a/engine/settings/base.py +++ b/engine/settings/base.py @@ -2,6 +2,7 @@ from random import randrange from celery.schedules import crontab +from firebase_admin import initialize_app from common.utils import getenv_boolean, getenv_integer @@ -55,7 +56,6 @@ FEATURE_TELEGRAM_INTEGRATION_ENABLED = getenv_boolean("FEATURE_TELEGRAM_INTEGRATION_ENABLED", default=True) FEATURE_EMAIL_INTEGRATION_ENABLED = getenv_boolean("FEATURE_EMAIL_INTEGRATION_ENABLED", default=True) FEATURE_SLACK_INTEGRATION_ENABLED = getenv_boolean("FEATURE_SLACK_INTEGRATION_ENABLED", default=True) -FEATURE_MOBILE_APP_INTEGRATION_ENABLED = getenv_boolean("FEATURE_MOBILE_APP_INTEGRATION_ENABLED", default=True) FEATURE_WEB_SCHEDULES_ENABLED = getenv_boolean("FEATURE_WEB_SCHEDULES_ENABLED", default=False) FEATURE_MULTIREGION_ENABLED = getenv_boolean("FEATURE_MULTIREGION_ENABLED", default=False) GRAFANA_CLOUD_ONCALL_HEARTBEAT_ENABLED = getenv_boolean("GRAFANA_CLOUD_ONCALL_HEARTBEAT_ENABLED", default=True) @@ -556,16 +556,12 @@ class BrokerTypes: GRAFANA_API_KEY_NAME = "Grafana OnCall" -EXTRA_MESSAGING_BACKENDS = [] -if FEATURE_MOBILE_APP_INTEGRATION_ENABLED: - from firebase_admin import initialize_app - - EXTRA_MESSAGING_BACKENDS += [ - ("apps.mobile_app.backend.MobileAppBackend", 5), - ("apps.mobile_app.backend.MobileAppCriticalBackend", 6), - ] +EXTRA_MESSAGING_BACKENDS = [ + ("apps.mobile_app.backend.MobileAppBackend", 5), + ("apps.mobile_app.backend.MobileAppCriticalBackend", 6), +] - FIREBASE_APP = initialize_app(options={"projectId": os.environ.get("FCM_PROJECT_ID", None)}) +FIREBASE_APP = initialize_app(options={"projectId": os.environ.get("FCM_PROJECT_ID", None)}) FCM_RELAY_ENABLED = getenv_boolean("FCM_RELAY_ENABLED", default=False) FCM_DJANGO_SETTINGS = { diff --git a/grafana-plugin/src/containers/UserSettings/UserSettings.tsx b/grafana-plugin/src/containers/UserSettings/UserSettings.tsx index 02aa9d02f7..bfdf418427 100644 --- a/grafana-plugin/src/containers/UserSettings/UserSettings.tsx +++ b/grafana-plugin/src/containers/UserSettings/UserSettings.tsx @@ -7,7 +7,6 @@ import { useMediaQuery } from 'react-responsive'; import { Tabs, TabsContent } from 'containers/UserSettings/parts'; import { User as UserType } from 'models/user/user.types'; -import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; import { isUserActionAllowed, UserActions } from 'utils/authorization'; import { BREAKPOINT_TABS } from 'utils/consts'; @@ -53,7 +52,7 @@ const UserSettings = observer(({ id, onHide, tab = UserSettingsTab.UserInfo }: U !isDesktopOrLaptop, isCurrent && teamStore.currentTeam?.slack_team_identity && !storeUser.slack_user_identity, isCurrent && !storeUser.telegram_configuration, - isCurrent && store.hasFeature(AppFeature.MobileApp) && isUserActionAllowed(UserActions.UserSettingsWrite), + isCurrent && isUserActionAllowed(UserActions.UserSettingsWrite), ]; return ( diff --git a/grafana-plugin/src/containers/UserSettings/parts/connectors/MobileAppConnector.tsx b/grafana-plugin/src/containers/UserSettings/parts/connectors/MobileAppConnector.tsx index cd50e3906f..9d036526a8 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/connectors/MobileAppConnector.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/connectors/MobileAppConnector.tsx @@ -4,30 +4,22 @@ import { Button, Label } from '@grafana/ui'; import cn from 'classnames/bind'; import { UserSettingsTab } from 'containers/UserSettings/UserSettings.types'; -import { AppFeature } from 'state/features'; -import { useStore } from 'state/useStore'; import styles from './index.module.css'; const cx = cn.bind(styles); -interface SlackConnectorProps { +interface MobileAppConnectorProps { onTabChange: (tab: UserSettingsTab) => void; } -const SlackConnector = (props: SlackConnectorProps) => { +const MobileAppConnector = (props: MobileAppConnectorProps) => { const { onTabChange } = props; - const store = useStore(); - const handleClickConfirmMobileAppButton = useCallback(() => { onTabChange(UserSettingsTab.MobileAppConnection); }, [onTabChange]); - if (!store.hasFeature(AppFeature.MobileApp)) { - return null; - } - return (
@@ -40,4 +32,4 @@ const SlackConnector = (props: SlackConnectorProps) => { ); }; -export default SlackConnector; +export default MobileAppConnector; diff --git a/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx b/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx index bb5c60c3d0..7a50142073 100644 --- a/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx +++ b/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx @@ -11,7 +11,6 @@ import Text from 'components/Text/Text'; import WithConfirm from 'components/WithConfirm/WithConfirm'; import { CrossCircleIcon, HeartIcon } from 'icons'; import { Cloud } from 'models/cloud/cloud.types'; -import { AppFeature } from 'state/features'; import { WithStoreProps } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; @@ -309,19 +308,17 @@ const CloudPage = observer((props: CloudPageProps) => { )} - {store.hasFeature(AppFeature.MobileApp) && ( - - - - Mobile app push notifications - - - Connecting to Cloud OnCall enables sending push notifications on mobile devices using the Grafana OnCall - mobile app. - - - - )} + + + + Mobile app push notifications + + + Connecting to Cloud OnCall enables sending push notifications on mobile devices using the Grafana OnCall + mobile app. + + + ); @@ -370,19 +367,17 @@ const CloudPage = observer((props: CloudPageProps) => { - {store.hasFeature(AppFeature.MobileApp) && ( - - - - Mobile app push notifications - - - Connecting to Cloud OnCall enables sending push notifications on mobile devices using the Grafana OnCall - mobile app. - - - - )} + + + + Mobile app push notifications + + + Connecting to Cloud OnCall enables sending push notifications on mobile devices using the Grafana OnCall + mobile app. + + + ); diff --git a/grafana-plugin/src/state/features.ts b/grafana-plugin/src/state/features.ts index 856d26d087..7636481d15 100644 --- a/grafana-plugin/src/state/features.ts +++ b/grafana-plugin/src/state/features.ts @@ -2,7 +2,6 @@ export enum AppFeature { Slack = 'slack', Telegram = 'telegram', LiveSettings = 'live_settings', - MobileApp = 'mobile_app', CloudNotifications = 'grafana_cloud_notifications', CloudConnection = 'grafana_cloud_connection', WebSchedules = 'web_schedules',