diff --git a/README.md b/README.md index e83f0f14db..510a4a628b 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,11 @@ Developer-friendly incident response with brilliant Slack integration. ## Getting Started +> [!IMPORTANT] +> These instructions are for using Grafana 11 or newer. You must enable the feature toggle for +> `externalServiceAccounts`. This is already done for the docker files and helm charts. If you are running Grafana +> separately see the Grafana documentation on how to enable this. + We prepared multiple environments: - [production](https://grafana.com/docs/oncall/latest/open-source/#production-environment) @@ -82,17 +87,41 @@ We prepared multiple environments: docker-compose pull && docker-compose up -d ``` -5. Go to [OnCall Plugin Configuration](http://localhost:3000/plugins/grafana-oncall-app), using log in credentials - as defined above: `admin`/`admin` (or find OnCall plugin in configuration->plugins) and connect OnCall _plugin_ - with OnCall _backend_: +5. Provision the plugin (If you run Grafana outside the included docker files install the plugin before these steps): + + If you are using the included docker compose file use `admin`/`admin` credentials and `localhost:3000` to + perform this task. If you have configured Grafana differently adjust your credentials and hostnames accordingly. - ```text - OnCall backend URL: http://engine:8080 + ```bash + # Note: onCallApiUrl 'engine' and grafanaUrl 'grafana' use the name from the docker compose file. If you are + # running your grafana or oncall engine instance with another hostname adjust accordingly. + curl -X POST 'http://admin:admin@localhost:3000/api/plugins/grafana-oncall-app/settings' -H "Content-Type: application/json" -d '{"enabled":true, "jsonData":{"stackId":5, "orgId":100, "onCallApiUrl":"http://engine:8080", "grafanaUrl":"http://grafana:3000"}}' + curl -X POST 'http://admin:admin@localhost:3000/api/plugins/grafana-oncall-app/resources/plugin/install' ``` -6. Enjoy! Check our [OSS docs](https://grafana.com/docs/oncall/latest/open-source/) if you want to set up +6. Start using OnCall, log in to Grafana with credentials + as defined above: `admin`/`admin` + +7. Enjoy! Check our [OSS docs](https://grafana.com/docs/oncall/latest/open-source/) if you want to set up Slack, Telegram, Twilio or SMS/calls through Grafana Cloud. +## Troubleshooting + +Here are some API calls that can be made to help if you are having difficulty connecting Grafana and OnCall. +(Modify parameters to match your credentials and environment) + + ```bash + # Use this to get more information about the connection between Grafana and OnCall + curl -X GET 'http://admin:admin@localhost:3000/api/plugins/grafana-oncall-app/resources/plugin/status' + ``` + + ```bash + # If you added a user or changed permissions and don't see it show up in OnCall you can manually trigger sync. + # Note: This is called automatically when the app is loaded (page load/refresh) but there is a 5 min timeout so + # that it does not generate unnecessary activity. + curl -X POST 'http://admin:admin@localhost:3000/api/plugins/grafana-oncall-app/resources/plugin/sync' + ``` + ## Update version To update your Grafana OnCall hobby environment: diff --git a/docker-compose-mysql-rabbitmq.yml b/docker-compose-mysql-rabbitmq.yml index f7687a8e8e..f587902e76 100644 --- a/docker-compose-mysql-rabbitmq.yml +++ b/docker-compose-mysql-rabbitmq.yml @@ -139,6 +139,7 @@ services: GF_DATABASE_HOST: ${MYSQL_HOST:-mysql} GF_DATABASE_USER: ${MYSQL_USER:-root} GF_DATABASE_PASSWORD: ${MYSQL_PASSWORD:?err} + GF_FEATURE_TOGGLES_ENABLE: externalServiceAccounts GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-admin} GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-admin} GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: grafana-oncall-app diff --git a/docker-compose.yml b/docker-compose.yml index 23bc9d3e1f..b115199f8c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,6 +89,7 @@ services: ports: - "3000:3000" environment: + GF_FEATURE_TOGGLES_ENABLE: externalServiceAccounts GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-admin} GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-admin} GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: grafana-oncall-app diff --git a/engine/apps/auth_token/auth.py b/engine/apps/auth_token/auth.py index bb419eb3af..19374a7b16 100644 --- a/engine/apps/auth_token/auth.py +++ b/engine/apps/auth_token/auth.py @@ -52,7 +52,7 @@ def authenticate(self, request): auth = get_authorization_header(request).decode("utf-8") user, auth_token = self.authenticate_credentials(auth) - if not user_is_authorized(user, [RBACPermission.Permissions.API_KEYS_WRITE]): + if not user.is_active or not user_is_authorized(user, [RBACPermission.Permissions.API_KEYS_WRITE]): raise exceptions.AuthenticationFailed( "Only users with Admin permissions are allowed to perform this action." ) diff --git a/engine/apps/auth_token/tests/test_plugin_auth.py b/engine/apps/auth_token/tests/test_plugin_auth.py index 56fe56974a..d03c40b388 100644 --- a/engine/apps/auth_token/tests/test_plugin_auth.py +++ b/engine/apps/auth_token/tests/test_plugin_auth.py @@ -83,6 +83,26 @@ def test_plugin_authentication_fail(authorization, instance_context): PluginAuthentication().authenticate(request) +@pytest.mark.django_db +def test_plugin_authentication_inactive_user(make_organization, make_user, make_token_for_organization): + organization = make_organization(stack_id=42, org_id=24) + token, token_string = make_token_for_organization(organization) + user = make_user(organization=organization, user_id=12) + # user is set to inactive if deleted via queryset (ie. during sync) + user.is_active = False + user.save() + + headers = { + "HTTP_AUTHORIZATION": token_string, + "HTTP_X-Instance-Context": INSTANCE_CONTEXT, + "HTTP_X-Grafana-Context": '{"UserId": 12}', + } + request = APIRequestFactory().get("/", **headers) + + with pytest.raises(AuthenticationFailed): + PluginAuthentication().authenticate(request) + + @pytest.mark.django_db def test_plugin_authentication_gcom_setup_new_user(make_organization): # Setting gcom_token_org_last_time_synced to now, so it doesn't try to sync with gcom diff --git a/engine/apps/mobile_app/auth.py b/engine/apps/mobile_app/auth.py index 6363f9f254..8a5a7178b9 100644 --- a/engine/apps/mobile_app/auth.py +++ b/engine/apps/mobile_app/auth.py @@ -33,7 +33,7 @@ class MobileAppAuthTokenAuthentication(BaseAuthentication): def authenticate(self, request) -> Optional[Tuple[User, MobileAppAuthToken]]: auth = get_authorization_header(request).decode("utf-8") user, auth_token = self.authenticate_credentials(auth) - if user is None: + if user is None or not user.is_active: return None return user, auth_token diff --git a/engine/apps/mobile_app/tests/test_mobile_app_auth_token.py b/engine/apps/mobile_app/tests/test_mobile_app_auth_token.py index 2f5f2f4de9..34e7d9d011 100644 --- a/engine/apps/mobile_app/tests/test_mobile_app_auth_token.py +++ b/engine/apps/mobile_app/tests/test_mobile_app_auth_token.py @@ -4,6 +4,7 @@ from rest_framework.test import APIClient from apps.mobile_app.models import MobileAppAuthToken +from apps.user_management.models import User @pytest.mark.django_db @@ -76,3 +77,17 @@ def test_mobile_app_auth_token( response = client.get(url, HTTP_AUTHORIZATION=verification_token) assert response.status_code == status.HTTP_404_NOT_FOUND + + +@pytest.mark.django_db +def test_mobile_app_auth_token_deleted_user( + make_organization_and_user_with_mobile_app_auth_token, +): + _, user, auth_token = make_organization_and_user_with_mobile_app_auth_token() + # user is deleted via queryset (ie. setting it to inactive, during sync) + User.objects.filter(id=user.id).delete() + + client = APIClient() + url = reverse("api-internal:alertgroup-list") + response = client.get(url, HTTP_AUTHORIZATION=auth_token) + assert response.status_code == status.HTTP_403_FORBIDDEN diff --git a/engine/apps/public_api/tests/test_alert_groups.py b/engine/apps/public_api/tests/test_alert_groups.py index 9c88fec880..3cfc9c8537 100644 --- a/engine/apps/public_api/tests/test_alert_groups.py +++ b/engine/apps/public_api/tests/test_alert_groups.py @@ -180,6 +180,20 @@ def test_get_alert_groups(alert_group_public_api_setup): assert response.json() == expected_response +@pytest.mark.django_db +def test_get_alert_groups_inactive_user(make_organization_and_user_with_token): + _, user, token = make_organization_and_user_with_token() + # user is set to inactive if deleted via queryset (ie. during sync) + user.is_active = False + user.save() + + client = APIClient() + url = reverse("api-public:alert_groups-list") + response = client.get(url, format="json", HTTP_AUTHORIZATION=token) + + assert response.status_code == status.HTTP_403_FORBIDDEN + + @pytest.mark.django_db def test_get_alert_groups_include_labels(alert_group_public_api_setup, make_alert_group_label_association): token, _, _, _ = alert_group_public_api_setup diff --git a/grafana-plugin/.bra.toml b/grafana-plugin/.bra.toml index 24d10b6db9..eaa76a4d6d 100644 --- a/grafana-plugin/.bra.toml +++ b/grafana-plugin/.bra.toml @@ -4,19 +4,14 @@ [run] init_cmds = [ ["mage", "-v", "build:debug"], - ["mage", "-v" , "reloadPlugin"], ] watch_all = true follow_symlinks = false ignore = [".git", "node_modules", "dist"] ignore_files = ["mage_output_file.go"] -watch_dirs = [ - "pkg", - # "src", -] +watch_dirs = ["pkg"] watch_exts = [".go", ".json"] build_delay = 2000 cmds = [ ["mage", "-v", "build:debug"], - ["mage", "-v" , "reloadPlugin"], ] diff --git a/grafana-plugin/e2e-tests/pluginInitialization/configuration.test.ts b/grafana-plugin/e2e-tests/pluginInitialization/configuration.test.ts index 1c66b63bec..aecf58457e 100644 --- a/grafana-plugin/e2e-tests/pluginInitialization/configuration.test.ts +++ b/grafana-plugin/e2e-tests/pluginInitialization/configuration.test.ts @@ -1,4 +1,4 @@ -import { PLUGIN_CONFIG } from 'utils/consts'; +import { PLUGIN_CONFIG } from 'helpers/consts'; import { test, expect } from '../fixtures'; import { goToGrafanaPage } from '../utils/navigation'; diff --git a/grafana-plugin/e2e-tests/pluginInitialization/initialization.test.ts b/grafana-plugin/e2e-tests/pluginInitialization/initialization.test.ts index 774c18404b..4472548248 100644 --- a/grafana-plugin/e2e-tests/pluginInitialization/initialization.test.ts +++ b/grafana-plugin/e2e-tests/pluginInitialization/initialization.test.ts @@ -1,4 +1,4 @@ -import { waitInMs } from 'utils/async'; +import { waitInMs } from 'helpers/async'; import { test, expect, Page } from '../fixtures'; import { OrgRole, isGrafanaVersionLowerThan } from '../utils/constants'; diff --git a/grafana-plugin/e2e-tests/schedules/scheduleView.test.ts b/grafana-plugin/e2e-tests/schedules/scheduleView.test.ts index 4e0bfa640c..95b7b548e7 100644 --- a/grafana-plugin/e2e-tests/schedules/scheduleView.test.ts +++ b/grafana-plugin/e2e-tests/schedules/scheduleView.test.ts @@ -1,6 +1,7 @@ +import { HTML_ID } from 'helpers/DOM'; + import { scheduleViewToDaysInOneRow } from 'models/schedule/schedule.helpers'; import { ScheduleView } from 'models/schedule/schedule.types'; -import { HTML_ID } from 'utils/DOM'; import { expect, Page, test } from '../fixtures'; import { isGrafanaVersionLowerThan } from '../utils/constants'; diff --git a/grafana-plugin/e2e-tests/utils/navigation.ts b/grafana-plugin/e2e-tests/utils/navigation.ts index 3d8cdbefd9..3eb32a8bd6 100644 --- a/grafana-plugin/e2e-tests/utils/navigation.ts +++ b/grafana-plugin/e2e-tests/utils/navigation.ts @@ -1,8 +1,8 @@ import { KeyValue } from '@grafana/data'; import type { Page } from '@playwright/test'; +import { getPluginId } from 'helpers/consts'; import qs from 'query-string'; -import { getPluginId } from 'utils/consts'; import { BASE_URL } from './constants'; diff --git a/grafana-plugin/go.mod b/grafana-plugin/go.mod index f059ec7554..aecbb33233 100644 --- a/grafana-plugin/go.mod +++ b/grafana-plugin/go.mod @@ -1,4 +1,4 @@ -module github.com/grafana-labs/grafana-oncall-app +module github.com/grafana/grafana-oncall-app go 1.21.5 diff --git a/grafana-plugin/pkg/main.go b/grafana-plugin/pkg/main.go index 2d956202d4..948e5f08b5 100644 --- a/grafana-plugin/pkg/main.go +++ b/grafana-plugin/pkg/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/grafana-labs/grafana-oncall-app/pkg/plugin" + "github.com/grafana/grafana-oncall-app/pkg/plugin" "github.com/grafana/grafana-plugin-sdk-go/backend/app" "github.com/grafana/grafana-plugin-sdk-go/backend/log" ) @@ -16,7 +16,7 @@ func main() { // argument. This factory will be automatically called on incoming request // from Grafana to create different instances of `App` (per plugin // ID). - if err := app.Manage("grafana-oncall-app", plugin.NewApp, app.ManageOpts{}); err != nil { + if err := app.Manage("grafana-oncall-app", plugin.NewInstance, app.ManageOpts{}); err != nil { log.DefaultLogger.Error(err.Error()) os.Exit(1) } diff --git a/grafana-plugin/pkg/plugin/app.go b/grafana-plugin/pkg/plugin/app.go index cd51cd4a10..84e03b93d4 100644 --- a/grafana-plugin/pkg/plugin/app.go +++ b/grafana-plugin/pkg/plugin/app.go @@ -38,15 +38,9 @@ type App struct { } // NewApp creates a new example *App instance. -func NewApp(ctx context.Context, settings backend.AppInstanceSettings) (instancemgmt.Instance, error) { +func NewApp(ctx context.Context, settings backend.AppInstanceSettings) (*App, error) { var app App - // Use a httpadapter (provided by the SDK) for resource calls. This allows us - // to use a *http.ServeMux for resource calls, so we can map multiple routes - // to CallResource without having to implement extra logic. - mux := http.NewServeMux() - app.registerRoutes(mux) - app.CallResourceHandler = httpadapter.New(mux) app.OnCallSyncCache = &OnCallSyncCache{} app.OnCallSettingsCache = &OnCallSettingsCache{} app.OnCallUserCache = NewOnCallUserCache() @@ -66,6 +60,25 @@ func NewApp(ctx context.Context, settings backend.AppInstanceSettings) (instance return &app, nil } +// NewInstance creates a new example *Instance instance. +func NewInstance(ctx context.Context, settings backend.AppInstanceSettings) (instancemgmt.Instance, error) { + app, err := NewApp(ctx, settings) + + if err != nil { + log.DefaultLogger.Error("Error creating new app", "error", err) + return nil, err + } + + // Use a httpadapter (provided by the SDK) for resource calls. This allows us + // to use a *http.ServeMux for resource calls, so we can map multiple routes + // to CallResource without having to implement extra logic. + mux := http.NewServeMux() + app.registerRoutes(mux) + app.CallResourceHandler = httpadapter.New(mux) + + return app, nil +} + // Dispose here tells plugin SDK that plugin wants to clean up resources when a new instance // created. func (a *App) Dispose() { diff --git a/grafana-plugin/pkg/plugin/debug.go b/grafana-plugin/pkg/plugin/debug.go index e362c9ccd1..7c429d4412 100644 --- a/grafana-plugin/pkg/plugin/debug.go +++ b/grafana-plugin/pkg/plugin/debug.go @@ -2,9 +2,10 @@ package plugin import ( "encoding/json" + "net/http" + "github.com/grafana/grafana-plugin-sdk-go/backend/log" "github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter" - "net/http" ) type OnCallDebugStats struct { @@ -47,7 +48,7 @@ func (a *App) handleDebugSync(w http.ResponseWriter, req *http.Request) { return } - onCallSync, err := a.GetSyncData(req.Context(), onCallPluginSettings) + onCallSync, err := a.GetSyncData(onCallPluginSettings) if err != nil { log.DefaultLogger.Error("Error getting sync data", "error", err) return diff --git a/grafana-plugin/pkg/plugin/install.go b/grafana-plugin/pkg/plugin/install.go index da6f94b2cb..6f4d108d04 100644 --- a/grafana-plugin/pkg/plugin/install.go +++ b/grafana-plugin/pkg/plugin/install.go @@ -41,7 +41,7 @@ func (a *App) handleInstall(w http.ResponseWriter, req *http.Request) { return } - onCallSync, err := a.GetSyncData(req.Context(), onCallPluginSettings) + onCallSync, err := a.GetSyncData(onCallPluginSettings) if err != nil { log.DefaultLogger.Error("Error getting sync data", "error", err) return diff --git a/grafana-plugin/pkg/plugin/resources.go b/grafana-plugin/pkg/plugin/resources.go index 7dad9564e0..b43420844e 100644 --- a/grafana-plugin/pkg/plugin/resources.go +++ b/grafana-plugin/pkg/plugin/resources.go @@ -84,7 +84,7 @@ func afterRequest(handler http.Handler, afterFunc func(*responseWriter, *http.Re }) } -func (a *App) handleInternalApi(w http.ResponseWriter, req *http.Request) { +func (a *App) HandleInternalApi(w http.ResponseWriter, req *http.Request) { a.ProxyRequestToOnCall(w, req, "api/internal/v1/") } @@ -121,10 +121,10 @@ func (a *App) handleLegacyInstall(w *responseWriter, req *http.Request) { // registerRoutes takes a *http.ServeMux and registers some HTTP handlers. func (a *App) registerRoutes(mux *http.ServeMux) { mux.HandleFunc("/plugin/install", a.handleInstall) - mux.HandleFunc("/plugin/status", a.handleStatus) - mux.HandleFunc("/plugin/sync", a.handleSync) + mux.HandleFunc("/plugin/status", a.HandleStatus) + mux.HandleFunc("/plugin/sync", a.HandleSync) - mux.Handle("/plugin/self-hosted/install", afterRequest(http.HandlerFunc(a.handleInternalApi), a.handleLegacyInstall)) + mux.Handle("/plugin/self-hosted/install", afterRequest(http.HandlerFunc(a.HandleInternalApi), a.handleLegacyInstall)) // Disable debug endpoints //mux.HandleFunc("/debug/user", a.handleDebugUser) @@ -134,5 +134,5 @@ func (a *App) registerRoutes(mux *http.ServeMux) { //mux.HandleFunc("/debug/stats", a.handleDebugStats) //mux.HandleFunc("/debug/unlock", a.handleDebugUnlock) - mux.HandleFunc("/", a.handleInternalApi) + mux.HandleFunc("/", a.HandleInternalApi) } diff --git a/grafana-plugin/pkg/plugin/resources_test.go b/grafana-plugin/pkg/plugin/resources_test.go index 7506326a7e..e3a88e81b5 100644 --- a/grafana-plugin/pkg/plugin/resources_test.go +++ b/grafana-plugin/pkg/plugin/resources_test.go @@ -3,8 +3,9 @@ package plugin import ( "bytes" "context" - "github.com/grafana/grafana-plugin-sdk-go/backend" "testing" + + "github.com/grafana/grafana-plugin-sdk-go/backend" ) // mockCallResourceResponseSender implements backend.CallResourceResponseSender @@ -23,7 +24,7 @@ func (s *mockCallResourceResponseSender) Send(response *backend.CallResourceResp // This ensures the httpadapter for CallResource works correctly. func TestCallResource(t *testing.T) { // Initialize app - inst, err := NewApp(context.Background(), backend.AppInstanceSettings{}) + inst, err := NewInstance(context.Background(), backend.AppInstanceSettings{}) if err != nil { t.Fatalf("new app: %s", err) } diff --git a/grafana-plugin/pkg/plugin/settings.go b/grafana-plugin/pkg/plugin/settings.go index 700bc42383..8386c7dbee 100644 --- a/grafana-plugin/pkg/plugin/settings.go +++ b/grafana-plugin/pkg/plugin/settings.go @@ -317,32 +317,29 @@ func (a *App) SaveOnCallSettings(settings *OnCallPluginSettings) error { return nil } -func (a *App) GetSyncData(ctx context.Context, settings *OnCallPluginSettings) (*OnCallSync, error) { +func (a *App) GetSyncData(pluginSettings *OnCallPluginSettings) (*OnCallSync, error) { + var err error + startGetSyncData := time.Now() defer func() { elapsed := time.Since(startGetSyncData) log.DefaultLogger.Info("GetSyncData", "time", elapsed.Milliseconds()) }() - onCallPluginSettings, err := a.OnCallSettingsFromContext(ctx) - if err != nil { - return nil, fmt.Errorf("error getting settings from context = %v", err) - } - onCallSync := OnCallSync{ - Settings: *settings, + Settings: *pluginSettings, } - onCallSync.Users, err = a.GetAllUsersWithPermissions(onCallPluginSettings) + onCallSync.Users, err = a.GetAllUsersWithPermissions(pluginSettings) if err != nil { return nil, fmt.Errorf("error getting users = %v", err) } - onCallSync.Teams, err = a.GetAllTeams(onCallPluginSettings) + onCallSync.Teams, err = a.GetAllTeams(pluginSettings) if err != nil { return nil, fmt.Errorf("error getting teams = %v", err) } - teamMembers, err := a.GetAllTeamMembers(onCallPluginSettings, onCallSync.Teams) + teamMembers, err := a.GetAllTeamMembers(pluginSettings, onCallSync.Teams) if err != nil { return nil, fmt.Errorf("error getting team members = %v", err) } diff --git a/grafana-plugin/pkg/plugin/status.go b/grafana-plugin/pkg/plugin/status.go index 935e9bf387..ab93a742f8 100644 --- a/grafana-plugin/pkg/plugin/status.go +++ b/grafana-plugin/pkg/plugin/status.go @@ -244,7 +244,7 @@ func (a *App) ValidateOnCallStatus(ctx context.Context, settings *OnCallPluginSe return &status, nil } -func (a *App) handleStatus(w http.ResponseWriter, req *http.Request) { +func (a *App) HandleStatus(w http.ResponseWriter, req *http.Request) { if req.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) return diff --git a/grafana-plugin/pkg/plugin/sync.go b/grafana-plugin/pkg/plugin/sync.go index 72a1c6f636..d79e22fad3 100644 --- a/grafana-plugin/pkg/plugin/sync.go +++ b/grafana-plugin/pkg/plugin/sync.go @@ -7,13 +7,14 @@ import ( "encoding/json" "errors" "fmt" - "github.com/grafana/grafana-plugin-sdk-go/backend/log" "io" "net/http" "net/url" "strconv" "sync" "time" + + "github.com/grafana/grafana-plugin-sdk-go/backend/log" ) type OnCallSyncCache struct { @@ -38,7 +39,7 @@ func (oc *OnCallSyncCache) UnlockAfterDelay(delay time.Duration) { }) } -func (a *App) handleSync(w http.ResponseWriter, req *http.Request) { +func (a *App) HandleSync(w http.ResponseWriter, req *http.Request) { if req.Method != http.MethodPost { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) return @@ -122,7 +123,7 @@ func (a *App) makeSyncRequest(ctx context.Context, forceSend bool) error { return fmt.Errorf("error getting settings from context: %v ", err) } - onCallSync, err := a.GetSyncData(ctx, onCallPluginSettings) + onCallSync, err := a.GetSyncData(onCallPluginSettings) if err != nil { return fmt.Errorf("error getting sync data: %v", err) } diff --git a/grafana-plugin/src/PluginPage.tsx b/grafana-plugin/src/PluginPage.tsx index 895a190583..70020c93f7 100644 --- a/grafana-plugin/src/PluginPage.tsx +++ b/grafana-plugin/src/PluginPage.tsx @@ -1,12 +1,12 @@ import React from 'react'; import { PluginPageProps, PluginPage as RealPluginPage } from '@grafana/runtime'; +import { DEFAULT_PAGE } from 'helpers/consts'; import { Header } from 'navbar/Header/Header'; import { RenderConditionally } from 'components/RenderConditionally/RenderConditionally'; import { pages } from 'pages/pages'; import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; -import { DEFAULT_PAGE } from 'utils/consts'; interface AppPluginPageProps extends PluginPageProps { page?: string; diff --git a/grafana-plugin/src/types.ts b/grafana-plugin/src/app-types.ts similarity index 96% rename from grafana-plugin/src/types.ts rename to grafana-plugin/src/app-types.ts index 44547883c5..497d3488dd 100644 --- a/grafana-plugin/src/types.ts +++ b/grafana-plugin/src/app-types.ts @@ -1,6 +1,5 @@ import { AppRootProps as BaseAppRootProps, AppPluginMeta, PluginConfigPageProps } from '@grafana/data'; - -import { getPluginId } from 'utils/consts'; +import { getPluginId } from 'helpers/consts'; export type OnCallPluginMetaJSONData = { stackId: number; diff --git a/grafana-plugin/src/components/CardButton/CardButton.tsx b/grafana-plugin/src/components/CardButton/CardButton.tsx index 43d0da6177..102a49db13 100644 --- a/grafana-plugin/src/components/CardButton/CardButton.tsx +++ b/grafana-plugin/src/components/CardButton/CardButton.tsx @@ -2,10 +2,10 @@ import React, { FC } from 'react'; import { cx } from '@emotion/css'; import { Stack, useStyles2 } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { Block } from 'components/GBlock/Block'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; import { getCardButtonStyles } from './CardButton.styles'; diff --git a/grafana-plugin/src/components/CheatSheet/CheatSheet.tsx b/grafana-plugin/src/components/CheatSheet/CheatSheet.tsx index bb28a07ba6..b60354a9f7 100644 --- a/grafana-plugin/src/components/CheatSheet/CheatSheet.tsx +++ b/grafana-plugin/src/components/CheatSheet/CheatSheet.tsx @@ -1,13 +1,13 @@ import React from 'react'; import { IconButton, Stack, useStyles2 } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; import CopyToClipboard from 'react-copy-to-clipboard'; import { bem, getUtilStyles } from 'styles/utils.styles'; import { Block } from 'components/GBlock/Block'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; -import { openNotification } from 'utils/utils'; import { CheatSheetInterface, CheatSheetItem } from './CheatSheet.config'; import { getCheatSheetStyles } from './CheatSheet.styles'; diff --git a/grafana-plugin/src/components/CopyToClipboardIcon/CopyToClipboardIcon.tsx b/grafana-plugin/src/components/CopyToClipboardIcon/CopyToClipboardIcon.tsx index 2bbfa34d56..a474da16eb 100644 --- a/grafana-plugin/src/components/CopyToClipboardIcon/CopyToClipboardIcon.tsx +++ b/grafana-plugin/src/components/CopyToClipboardIcon/CopyToClipboardIcon.tsx @@ -1,10 +1,9 @@ import React, { FC } from 'react'; import { IconButton } from '@grafana/ui'; +import { openNotification } from 'helpers/helpers'; import CopyToClipboard from 'react-copy-to-clipboard'; -import { openNotification } from 'utils/utils'; - interface CopyToClipboardProps { text: string; iconButtonProps?: Partial[0]>; diff --git a/grafana-plugin/src/components/CursorPagination/CursorPagination.tsx b/grafana-plugin/src/components/CursorPagination/CursorPagination.tsx index a24eb49a09..124c0220b8 100644 --- a/grafana-plugin/src/components/CursorPagination/CursorPagination.tsx +++ b/grafana-plugin/src/components/CursorPagination/CursorPagination.tsx @@ -2,9 +2,9 @@ import React, { FC, useCallback, useEffect, useState } from 'react'; import { SelectableValue } from '@grafana/data'; import { Button, Icon, Select, Stack } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; interface CursorPaginationProps { current: string; diff --git a/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkDropdown.tsx b/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkDropdown.tsx index 16d077f8d4..29b0545e21 100644 --- a/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkDropdown.tsx +++ b/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkDropdown.tsx @@ -7,7 +7,7 @@ import { usePluginLinks as originalUsePluginLinks, } from '@grafana/runtime'; import { Dropdown, ToolbarButton } from '@grafana/ui'; -import { OnCallPluginExtensionPoints } from 'types'; +import { OnCallPluginExtensionPoints } from 'app-types'; import { ApiSchemas } from 'network/oncall-api/api.types'; diff --git a/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkMenu.tsx b/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkMenu.tsx index f271a00cba..f8f530f832 100644 --- a/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkMenu.tsx +++ b/grafana-plugin/src/components/ExtensionLinkMenu/ExtensionLinkMenu.tsx @@ -2,10 +2,10 @@ import React, { ReactElement, useMemo } from 'react'; import { locationUtil, PluginExtensionLink, PluginExtensionTypes } from '@grafana/data'; import { IconName, Menu } from '@grafana/ui'; +import { getPluginId } from 'helpers/consts'; +import { truncateTitle } from 'helpers/string'; import { PluginBridge, SupportedPlugin } from 'components/PluginBridge/PluginBridge'; -import { getPluginId } from 'utils/consts'; -import { truncateTitle } from 'utils/string'; type Props = { extensions: PluginExtensionLink[]; diff --git a/grafana-plugin/src/components/FullPageError/FullPageError.tsx b/grafana-plugin/src/components/FullPageError/FullPageError.tsx index 8b440d7ca5..129c7f6bfa 100644 --- a/grafana-plugin/src/components/FullPageError/FullPageError.tsx +++ b/grafana-plugin/src/components/FullPageError/FullPageError.tsx @@ -2,10 +2,10 @@ import React, { FC } from 'react'; import { css } from '@emotion/css'; import { useStyles2, Stack } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import errorSVG from 'assets/img/error.svg'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; interface FullPageErrorProps { children?: React.ReactNode; diff --git a/grafana-plugin/src/components/HamburgerContextMenu/HamburgerContextMenu.tsx b/grafana-plugin/src/components/HamburgerContextMenu/HamburgerContextMenu.tsx index bd84f8cff2..9c36e97da0 100644 --- a/grafana-plugin/src/components/HamburgerContextMenu/HamburgerContextMenu.tsx +++ b/grafana-plugin/src/components/HamburgerContextMenu/HamburgerContextMenu.tsx @@ -3,11 +3,11 @@ import React, { FC, ReactNode } from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; +import { isUserActionAllowed, UserAction } from 'helpers/authorization/authorization'; import { HamburgerMenuIcon } from 'components/HamburgerMenuIcon/HamburgerMenuIcon'; import { WithContextMenu } from 'components/WithContextMenu/WithContextMenu'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; -import { isUserActionAllowed, UserAction } from 'utils/authorization/authorization'; interface HamburgerContextMenuProps { items: Array< diff --git a/grafana-plugin/src/components/IntegrationContactPoint/IntegrationContactPoint.tsx b/grafana-plugin/src/components/IntegrationContactPoint/IntegrationContactPoint.tsx index 25abaf35ef..da9ef14295 100644 --- a/grafana-plugin/src/components/IntegrationContactPoint/IntegrationContactPoint.tsx +++ b/grafana-plugin/src/components/IntegrationContactPoint/IntegrationContactPoint.tsx @@ -3,6 +3,8 @@ import React, { useEffect, useReducer } from 'react'; import { SelectableValue } from '@grafana/data'; import { Button, Drawer, Icon, IconButton, Input, RadioButtonGroup, Select, Tooltip, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { GENERIC_ERROR, StackSize } from 'helpers/consts'; +import { openErrorNotification, openNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { GTable } from 'components/GTable/GTable'; @@ -15,8 +17,6 @@ import { ContactPoint } from 'models/alert_receive_channel/alert_receive_channel import { ApiSchemas } from 'network/oncall-api/api.types'; import styles from 'pages/integration/Integration.module.scss'; import { useStore } from 'state/useStore'; -import { GENERIC_ERROR, StackSize } from 'utils/consts'; -import { openErrorNotification, openNotification } from 'utils/utils'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/components/IntegrationHowToConnect/IntegrationHowToConnect.tsx b/grafana-plugin/src/components/IntegrationHowToConnect/IntegrationHowToConnect.tsx index aa4f3ed74d..a3a7295dbe 100644 --- a/grafana-plugin/src/components/IntegrationHowToConnect/IntegrationHowToConnect.tsx +++ b/grafana-plugin/src/components/IntegrationHowToConnect/IntegrationHowToConnect.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Icon, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { noop } from 'lodash-es'; import { IntegrationInputField } from 'components/IntegrationInputField/IntegrationInputField'; @@ -11,7 +12,6 @@ import { Text } from 'components/Text/Text'; import { ApiSchemas } from 'network/oncall-api/api.types'; import styles from 'pages/integration/Integration.module.scss'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/components/IntegrationInputField/IntegrationInputField.tsx b/grafana-plugin/src/components/IntegrationInputField/IntegrationInputField.tsx index 8b01302345..c79fdac45e 100644 --- a/grafana-plugin/src/components/IntegrationInputField/IntegrationInputField.tsx +++ b/grafana-plugin/src/components/IntegrationInputField/IntegrationInputField.tsx @@ -2,9 +2,9 @@ import React, { useState } from 'react'; import { cx } from '@emotion/css'; import { IconButton, Input, Stack, useStyles2 } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { CopyToClipboardIcon } from 'components/CopyToClipboardIcon/CopyToClipboardIcon'; -import { StackSize } from 'utils/consts'; import { getIntegrationInputFieldStyles } from './IntegrationInputField.styles'; diff --git a/grafana-plugin/src/components/IntegrationLogo/IntegrationLogoWithTitle.tsx b/grafana-plugin/src/components/IntegrationLogo/IntegrationLogoWithTitle.tsx index 203bb241be..037229ccc6 100644 --- a/grafana-plugin/src/components/IntegrationLogo/IntegrationLogoWithTitle.tsx +++ b/grafana-plugin/src/components/IntegrationLogo/IntegrationLogoWithTitle.tsx @@ -1,9 +1,9 @@ import React, { FC } from 'react'; import { Stack } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; import { IntegrationLogo, IntegrationLogoProps } from './IntegrationLogo'; diff --git a/grafana-plugin/src/components/IntegrationSendDemoAlertModal/IntegrationSendDemoAlertModal.tsx b/grafana-plugin/src/components/IntegrationSendDemoAlertModal/IntegrationSendDemoAlertModal.tsx index eac18542cf..fefd973b5b 100644 --- a/grafana-plugin/src/components/IntegrationSendDemoAlertModal/IntegrationSendDemoAlertModal.tsx +++ b/grafana-plugin/src/components/IntegrationSendDemoAlertModal/IntegrationSendDemoAlertModal.tsx @@ -2,6 +2,8 @@ import React, { useState } from 'react'; import { Button, Icon, Modal, Tooltip, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; import CopyToClipboard from 'react-copy-to-clipboard'; import Emoji from 'react-emoji-render'; import { debounce } from 'throttle-debounce'; @@ -14,8 +16,6 @@ import { AlertReceiveChannelHelper } from 'models/alert_receive_channel/alert_re import { ApiSchemas } from 'network/oncall-api/api.types'; import styles from 'pages/integration/Integration.module.scss'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; -import { openNotification } from 'utils/utils'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/components/Integrations/IntegrationTemplateBlock.tsx b/grafana-plugin/src/components/Integrations/IntegrationTemplateBlock.tsx index d25ea77aba..65c47112ea 100644 --- a/grafana-plugin/src/components/Integrations/IntegrationTemplateBlock.tsx +++ b/grafana-plugin/src/components/Integrations/IntegrationTemplateBlock.tsx @@ -3,10 +3,10 @@ import React from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, InlineLabel, LoadingPlaceholder, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; import { WithConfirm } from 'components/WithConfirm/WithConfirm'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; -import { UserActions } from 'utils/authorization/authorization'; interface IntegrationTemplateBlockProps { label: string; diff --git a/grafana-plugin/src/components/LabelsTooltipBadge/LabelsTooltipBadge.tsx b/grafana-plugin/src/components/LabelsTooltipBadge/LabelsTooltipBadge.tsx index 77eea52451..d42e5109ee 100644 --- a/grafana-plugin/src/components/LabelsTooltipBadge/LabelsTooltipBadge.tsx +++ b/grafana-plugin/src/components/LabelsTooltipBadge/LabelsTooltipBadge.tsx @@ -2,12 +2,12 @@ import React, { FC } from 'react'; import { LabelTag } from '@grafana/labels'; import { Stack, Button, Tooltip } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { RenderConditionally } from 'components/RenderConditionally/RenderConditionally'; import { TooltipBadge } from 'components/TooltipBadge/TooltipBadge'; import { LabelKeyValue } from 'models/label/label.types'; import { components } from 'network/oncall-api/autogenerated-api.types'; -import { StackSize } from 'utils/consts'; interface LabelsTooltipBadgeProps { labels: LabelKeyValue[]; diff --git a/grafana-plugin/src/components/ManualAlertGroup/ManualAlertGroup.tsx b/grafana-plugin/src/components/ManualAlertGroup/ManualAlertGroup.tsx index 0321db1566..09511065ef 100644 --- a/grafana-plugin/src/components/ManualAlertGroup/ManualAlertGroup.tsx +++ b/grafana-plugin/src/components/ManualAlertGroup/ManualAlertGroup.tsx @@ -2,6 +2,7 @@ import React, { FC, useCallback } from 'react'; import { css } from '@emotion/css'; import { Button, Drawer, Field, TextArea, useStyles2, Stack } from '@grafana/ui'; +import { openWarningNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { Controller, FormProvider, useForm } from 'react-hook-form'; import { getUtilStyles } from 'styles/utils.styles'; @@ -11,7 +12,6 @@ import { prepareForUpdate } from 'containers/AddResponders/AddResponders.helpers import { AlertReceiveChannelStore } from 'models/alert_receive_channel/alert_receive_channel'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { openWarningNotification } from 'utils/utils'; export type FormData = { message: string; diff --git a/grafana-plugin/src/components/MonacoEditor/MonacoEditor.tsx b/grafana-plugin/src/components/MonacoEditor/MonacoEditor.tsx index b108eb6b86..4dcbbca921 100644 --- a/grafana-plugin/src/components/MonacoEditor/MonacoEditor.tsx +++ b/grafana-plugin/src/components/MonacoEditor/MonacoEditor.tsx @@ -2,8 +2,7 @@ import React, { ComponentProps, FC, useCallback } from 'react'; import { CodeEditor, CodeEditorSuggestionItemKind, LoadingPlaceholder } from '@grafana/ui'; import cn from 'classnames'; - -import { getPaths } from 'utils/utils'; +import { getPaths } from 'helpers/helpers'; import { conf, language as jinja2Language } from './jinja2'; diff --git a/grafana-plugin/src/components/NewScheduleSelector/NewScheduleSelector.tsx b/grafana-plugin/src/components/NewScheduleSelector/NewScheduleSelector.tsx index 2b0a4e1610..5a4ca4302d 100644 --- a/grafana-plugin/src/components/NewScheduleSelector/NewScheduleSelector.tsx +++ b/grafana-plugin/src/components/NewScheduleSelector/NewScheduleSelector.tsx @@ -2,14 +2,14 @@ import React, { FC, useCallback, useState } from 'react'; import { css } from '@emotion/css'; import { Button, Drawer, Icon, Stack, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { Block } from 'components/GBlock/Block'; import { Text } from 'components/Text/Text'; import { ScheduleForm } from 'containers/ScheduleForm/ScheduleForm'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { Schedule, ScheduleType } from 'models/schedule/schedule.types'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; interface NewScheduleSelectorProps { onHide: () => void; diff --git a/grafana-plugin/src/components/PageErrorHandlingWrapper/PageErrorHandlingWrapper.tsx b/grafana-plugin/src/components/PageErrorHandlingWrapper/PageErrorHandlingWrapper.tsx index bf9598f55e..cca9d052f8 100644 --- a/grafana-plugin/src/components/PageErrorHandlingWrapper/PageErrorHandlingWrapper.tsx +++ b/grafana-plugin/src/components/PageErrorHandlingWrapper/PageErrorHandlingWrapper.tsx @@ -3,11 +3,11 @@ import React, { ReactElement, useEffect } from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Stack, useStyles2 } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; +import { openWarningNotification } from 'helpers/helpers'; import { PluginLink } from 'components/PluginLink/PluginLink'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; -import { openWarningNotification } from 'utils/utils'; export interface PageBaseState { errorData: PageErrorData; diff --git a/grafana-plugin/src/components/PluginLink/PluginLink.tsx b/grafana-plugin/src/components/PluginLink/PluginLink.tsx index a6d5d2cd1b..412366d5a0 100644 --- a/grafana-plugin/src/components/PluginLink/PluginLink.tsx +++ b/grafana-plugin/src/components/PluginLink/PluginLink.tsx @@ -3,11 +3,10 @@ import React, { FC, useCallback, useMemo } from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; +import { getPathFromQueryParams } from 'helpers/url'; import { Link } from 'react-router-dom-v5-compat'; import { bem } from 'styles/utils.styles'; -import { getPathFromQueryParams } from 'utils/url'; - interface PluginLinkProps { disabled?: boolean; className?: string; diff --git a/grafana-plugin/src/components/Policy/EscalationPolicy.tsx b/grafana-plugin/src/components/Policy/EscalationPolicy.tsx index 719c9bc029..c9a145d4ce 100644 --- a/grafana-plugin/src/components/Policy/EscalationPolicy.tsx +++ b/grafana-plugin/src/components/Policy/EscalationPolicy.tsx @@ -3,6 +3,8 @@ import React, { ChangeEvent } from 'react'; import { cx } from '@emotion/css'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; import { Button, Input, Select, IconButton, withTheme2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { openWarningNotification } from 'helpers/helpers'; import { isNumber } from 'lodash-es'; import { observer } from 'mobx-react'; import moment from 'moment-timezone'; @@ -30,8 +32,6 @@ import { UserGroup } from 'models/user_group/user_group.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { openWarningNotification } from 'utils/utils'; import { DragHandle } from './DragHandle'; import { getEscalationPolicyStyles } from './EscalationPolicy.styles'; diff --git a/grafana-plugin/src/components/Policy/NotificationPolicy.tsx b/grafana-plugin/src/components/Policy/NotificationPolicy.tsx index b6fb4a9f3e..c2ad3722e5 100644 --- a/grafana-plugin/src/components/Policy/NotificationPolicy.tsx +++ b/grafana-plugin/src/components/Policy/NotificationPolicy.tsx @@ -3,6 +3,8 @@ import React from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; import { Button, IconButton, Select, withTheme2 } from '@grafana/ui'; +import { UserAction } from 'helpers/authorization/authorization'; +import { openWarningNotification } from 'helpers/helpers'; import { isNumber } from 'lodash'; import { SortableElement } from 'react-sortable-hoc'; @@ -15,8 +17,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { RootStore } from 'state/rootStore'; import { SelectOption } from 'state/types'; -import { UserAction } from 'utils/authorization/authorization'; -import { openWarningNotification } from 'utils/utils'; import { DragHandle } from './DragHandle'; import { POLICY_DURATION_LIST_MINUTES, POLICY_DURATION_LIST_SECONDS } from './Policy.consts'; diff --git a/grafana-plugin/src/components/ScheduleQuality/ScheduleQuality.tsx b/grafana-plugin/src/components/ScheduleQuality/ScheduleQuality.tsx index fd0c71e56d..68724896ca 100644 --- a/grafana-plugin/src/components/ScheduleQuality/ScheduleQuality.tsx +++ b/grafana-plugin/src/components/ScheduleQuality/ScheduleQuality.tsx @@ -2,6 +2,7 @@ import React, { FC, useEffect } from 'react'; import { cx } from '@emotion/css'; import { Tooltip, Stack, useStyles2 } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { getUtilStyles } from 'styles/utils.styles'; @@ -12,7 +13,6 @@ import { Text } from 'components/Text/Text'; import { TooltipBadge } from 'components/TooltipBadge/TooltipBadge'; import { Schedule, ScheduleScoreQualityResult } from 'models/schedule/schedule.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; import { getScheduleQualityStyles } from './ScheduleQuality.styles'; diff --git a/grafana-plugin/src/components/ScheduleQualityDetails/ScheduleQualityDetails.tsx b/grafana-plugin/src/components/ScheduleQualityDetails/ScheduleQualityDetails.tsx index ec36031818..a31cd567ba 100644 --- a/grafana-plugin/src/components/ScheduleQualityDetails/ScheduleQualityDetails.tsx +++ b/grafana-plugin/src/components/ScheduleQualityDetails/ScheduleQualityDetails.tsx @@ -2,11 +2,11 @@ import React, { FC, useCallback, useState } from 'react'; import { cx } from '@emotion/css'; import { Icon, IconButton, Stack, useStyles2 } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { bem, getUtilStyles } from 'styles/utils.styles'; import { Text } from 'components/Text/Text'; import { ScheduleScoreQualityResponse, ScheduleScoreQualityResult } from 'models/schedule/schedule.types'; -import { StackSize } from 'utils/consts'; import { getScheduleQualityDetailsStyles } from './ScheduleQualityDetails.styles'; import { ScheduleQualityProgressBar } from './ScheduleQualityProgressBar'; diff --git a/grafana-plugin/src/components/SourceCode/SourceCode.tsx b/grafana-plugin/src/components/SourceCode/SourceCode.tsx index 96158c522b..fb43d7a38e 100644 --- a/grafana-plugin/src/components/SourceCode/SourceCode.tsx +++ b/grafana-plugin/src/components/SourceCode/SourceCode.tsx @@ -3,12 +3,11 @@ import React, { FC } from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, IconButton, useStyles2 } from '@grafana/ui'; +import { openNotification } from 'helpers/helpers'; +import { formatSourceCodeJsonString } from 'helpers/string'; import CopyToClipboard from 'react-copy-to-clipboard'; import { bem } from 'styles/utils.styles'; -import { formatSourceCodeJsonString } from 'utils/string'; -import { openNotification } from 'utils/utils'; - interface SourceCodeProps { noMaxHeight?: boolean; noMinHeight?: boolean; diff --git a/grafana-plugin/src/components/Tabs/Tabs.tsx b/grafana-plugin/src/components/Tabs/Tabs.tsx index 19e2e68eae..715e60d23a 100644 --- a/grafana-plugin/src/components/Tabs/Tabs.tsx +++ b/grafana-plugin/src/components/Tabs/Tabs.tsx @@ -3,8 +3,7 @@ import React, { FC, useEffect, useState } from 'react'; import { css } from '@emotion/css'; import { Tab, TabsBar, TabContent, useStyles2 } from '@grafana/ui'; import cn from 'classnames'; - -import { LocationHelper } from 'utils/LocationHelper'; +import { LocationHelper } from 'helpers/LocationHelper'; interface TabConfig { label: string; diff --git a/grafana-plugin/src/components/Text/Text.tsx b/grafana-plugin/src/components/Text/Text.tsx index b62540b468..ba8c5ee8d8 100644 --- a/grafana-plugin/src/components/Text/Text.tsx +++ b/grafana-plugin/src/components/Text/Text.tsx @@ -2,11 +2,10 @@ import React, { FC, HTMLAttributes, ChangeEvent, useState, useCallback } from 'r import { cx } from '@emotion/css'; import { IconButton, Modal, Input, Stack, Button, useStyles2 } from '@grafana/ui'; +import { openNotification } from 'helpers/helpers'; import CopyToClipboard from 'react-copy-to-clipboard'; import { bem } from 'styles/utils.styles'; -import { openNotification } from 'utils/utils'; - import { getTextStyles } from './Text.styles'; export type TextType = 'primary' | 'secondary' | 'disabled' | 'link' | 'success' | 'warning' | 'danger'; diff --git a/grafana-plugin/src/components/TextEllipsisTooltip/TextEllipsisTooltip.tsx b/grafana-plugin/src/components/TextEllipsisTooltip/TextEllipsisTooltip.tsx index 8aaae76df0..bb70c8574b 100644 --- a/grafana-plugin/src/components/TextEllipsisTooltip/TextEllipsisTooltip.tsx +++ b/grafana-plugin/src/components/TextEllipsisTooltip/TextEllipsisTooltip.tsx @@ -2,9 +2,9 @@ import React, { ReactElement, useEffect, useRef, useState } from 'react'; import { Tooltip } from '@grafana/ui'; import cn from 'classnames/bind'; +import { TEXT_ELLIPSIS_CLASS } from 'helpers/consts'; import styles from 'assets/style/utils.css'; -import { TEXT_ELLIPSIS_CLASS } from 'utils/consts'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/components/TooltipBadge/TooltipBadge.tsx b/grafana-plugin/src/components/TooltipBadge/TooltipBadge.tsx index 9678d17da7..b3d85a06dc 100644 --- a/grafana-plugin/src/components/TooltipBadge/TooltipBadge.tsx +++ b/grafana-plugin/src/components/TooltipBadge/TooltipBadge.tsx @@ -2,10 +2,10 @@ import React, { FC } from 'react'; import { cx } from '@emotion/css'; import { Icon, Tooltip, IconName, Stack, useStyles2 } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { bem } from 'styles/utils.styles'; import { Text, TextType } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; import { getTooltipBadgeStyles } from './TooltipBadge.styles'; diff --git a/grafana-plugin/src/components/Unauthorized/Unauthorized.tsx b/grafana-plugin/src/components/Unauthorized/Unauthorized.tsx index 31929e6564..83295b37c4 100644 --- a/grafana-plugin/src/components/Unauthorized/Unauthorized.tsx +++ b/grafana-plugin/src/components/Unauthorized/Unauthorized.tsx @@ -4,10 +4,10 @@ import { css } from '@emotion/css'; import { GrafanaTheme2, OrgRole } from '@grafana/data'; import { Stack, useStyles2 } from '@grafana/ui'; import { contextSrv } from 'grafana/app/core/core'; +import { UserAction } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { Text } from 'components/Text/Text'; -import { UserAction } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; type Props = { requiredUserAction: UserAction; diff --git a/grafana-plugin/src/components/UserGroups/UserGroups.tsx b/grafana-plugin/src/components/UserGroups/UserGroups.tsx index 5478b956fe..0f35269b63 100644 --- a/grafana-plugin/src/components/UserGroups/UserGroups.tsx +++ b/grafana-plugin/src/components/UserGroups/UserGroups.tsx @@ -3,13 +3,13 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react'; import { cx } from '@emotion/css'; import { Stack, IconButton, useStyles2 } from '@grafana/ui'; import { arrayMoveImmutable } from 'array-move'; +import { UserActions } from 'helpers/authorization/authorization'; import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc'; import { bem } from 'styles/utils.styles'; import { Text } from 'components/Text/Text'; import { RemoteSelect } from 'containers/RemoteSelect/RemoteSelect'; import { ApiSchemas } from 'network/oncall-api/api.types'; -import { UserActions } from 'utils/authorization/authorization'; import { fromPlainArray, toPlainArray } from './UserGroups.helpers'; import { getUserGroupStyles } from './UserGroups.styles'; diff --git a/grafana-plugin/src/components/UsersFilters/UsersFilters.tsx b/grafana-plugin/src/components/UsersFilters/UsersFilters.tsx index f6725b6ff0..8b11021c7d 100644 --- a/grafana-plugin/src/components/UsersFilters/UsersFilters.tsx +++ b/grafana-plugin/src/components/UsersFilters/UsersFilters.tsx @@ -3,8 +3,7 @@ import React, { ChangeEvent, useCallback, useEffect, useRef } from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Icon, Input, useStyles2 } from '@grafana/ui'; - -import { useDebouncedCallback } from 'utils/hooks'; +import { useDebouncedCallback } from 'helpers/hooks'; interface UsersFiltersProps { value: any; diff --git a/grafana-plugin/src/components/Webhooks/WebhookLastEventDetails.tsx b/grafana-plugin/src/components/Webhooks/WebhookLastEventDetails.tsx index 0606becb5e..a908b622a6 100644 --- a/grafana-plugin/src/components/Webhooks/WebhookLastEventDetails.tsx +++ b/grafana-plugin/src/components/Webhooks/WebhookLastEventDetails.tsx @@ -4,13 +4,13 @@ import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Stack, Badge, useStyles2, useTheme2 } from '@grafana/ui'; import dayjs from 'dayjs'; +import { StackSize } from 'helpers/consts'; import { SourceCode } from 'components/SourceCode/SourceCode'; import { Tabs } from 'components/Tabs/Tabs'; import { Text } from 'components/Text/Text'; import { getTzOffsetString } from 'models/timezone/timezone.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; -import { StackSize } from 'utils/consts'; import { WebhookStatusCodeBadge } from './WebhookStatusCodeBadge'; diff --git a/grafana-plugin/src/containers/AddResponders/AddResponders.tsx b/grafana-plugin/src/containers/AddResponders/AddResponders.tsx index f72b0cd765..52aca97b88 100644 --- a/grafana-plugin/src/containers/AddResponders/AddResponders.tsx +++ b/grafana-plugin/src/containers/AddResponders/AddResponders.tsx @@ -3,6 +3,8 @@ import React, { useState, useCallback, useMemo } from 'react'; import { SelectableValue } from '@grafana/data'; import { Button, Modal, Alert, Stack, Icon, useStyles2 } from '@grafana/ui'; import dayjs from 'dayjs'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Block } from 'components/GBlock/Block'; @@ -11,8 +13,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { UserHelper } from 'models/user/user.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; import { getAddRespondersStyles } from './AddResponders.styles'; import { NotificationPolicyValue, UserResponder as UserResponderType } from './AddResponders.types'; diff --git a/grafana-plugin/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx b/grafana-plugin/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx index da2fb3d963..6a7f65a543 100644 --- a/grafana-plugin/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx +++ b/grafana-plugin/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx @@ -2,6 +2,8 @@ import React, { useState, useCallback, useEffect, useRef, FC } from 'react'; import { Alert, Icon, Input, LoadingPlaceholder, RadioButtonGroup, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; +import { useDebouncedCallback, useOnClickOutside } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { ColumnsType } from 'rc-table/lib/interface'; @@ -12,8 +14,6 @@ import { GrafanaTeam } from 'models/grafana_team/grafana_team.types'; import { UserHelper } from 'models/user/user.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; -import { useDebouncedCallback, useOnClickOutside } from 'utils/hooks'; import styles from './AddRespondersPopup.module.scss'; diff --git a/grafana-plugin/src/containers/AlertRules/parts/connectors/MSTeamsConnector.tsx b/grafana-plugin/src/containers/AlertRules/parts/connectors/MSTeamsConnector.tsx index c4ff554807..401caf6217 100644 --- a/grafana-plugin/src/containers/AlertRules/parts/connectors/MSTeamsConnector.tsx +++ b/grafana-plugin/src/containers/AlertRules/parts/connectors/MSTeamsConnector.tsx @@ -2,6 +2,8 @@ import React, { useCallback } from 'react'; import { InlineSwitch, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { GSelect } from 'containers/GSelect/GSelect'; @@ -9,8 +11,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { ChannelFilter } from 'models/channel_filter/channel_filter.types'; import { MSTeamsChannel } from 'models/msteams_channel/msteams_channel.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; import styles from 'containers/AlertRules/parts/connectors/Connectors.module.css'; diff --git a/grafana-plugin/src/containers/AlertRules/parts/connectors/SlackConnector.tsx b/grafana-plugin/src/containers/AlertRules/parts/connectors/SlackConnector.tsx index f887cb183b..9eb037a926 100644 --- a/grafana-plugin/src/containers/AlertRules/parts/connectors/SlackConnector.tsx +++ b/grafana-plugin/src/containers/AlertRules/parts/connectors/SlackConnector.tsx @@ -2,6 +2,8 @@ import React, { useCallback } from 'react'; import { InlineSwitch, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { GSelect } from 'containers/GSelect/GSelect'; @@ -10,8 +12,6 @@ import { ChannelFilter } from 'models/channel_filter/channel_filter.types'; import { PRIVATE_CHANNEL_NAME } from 'models/slack_channel/slack_channel.config'; import { SlackChannel } from 'models/slack_channel/slack_channel.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; import styles from './Connectors.module.css'; diff --git a/grafana-plugin/src/containers/AlertRules/parts/connectors/TelegramConnector.tsx b/grafana-plugin/src/containers/AlertRules/parts/connectors/TelegramConnector.tsx index b53cdba288..5ed5b18abd 100644 --- a/grafana-plugin/src/containers/AlertRules/parts/connectors/TelegramConnector.tsx +++ b/grafana-plugin/src/containers/AlertRules/parts/connectors/TelegramConnector.tsx @@ -2,6 +2,8 @@ import React, { useCallback } from 'react'; import { InlineSwitch, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { GSelect } from 'containers/GSelect/GSelect'; @@ -9,8 +11,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { ChannelFilter } from 'models/channel_filter/channel_filter.types'; import { TelegramChannel } from 'models/telegram_channel/telegram_channel.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; import styles from './Connectors.module.css'; diff --git a/grafana-plugin/src/containers/Alerts/Alerts.tsx b/grafana-plugin/src/containers/Alerts/Alerts.tsx index 5b6ccde89b..3f1a179abe 100644 --- a/grafana-plugin/src/containers/Alerts/Alerts.tsx +++ b/grafana-plugin/src/containers/Alerts/Alerts.tsx @@ -3,6 +3,10 @@ import React, { useCallback, useEffect, useState } from 'react'; import { Alert } from '@grafana/ui'; import cn from 'classnames/bind'; import { sanitize } from 'dompurify'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { isUserActionAllowed, UserActions } from 'helpers/authorization/authorization'; +import { useForceUpdate, useQueryParams } from 'helpers/hooks'; +import { getItem, setItem } from 'helpers/localStorage'; import { observer } from 'mobx-react'; import { PluginLink } from 'components/PluginLink/PluginLink'; @@ -13,10 +17,6 @@ import { UserHelper } from 'models/user/user.helpers'; import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; -import { useForceUpdate, useQueryParams } from 'utils/hooks'; -import { getItem, setItem } from 'utils/localStorage'; import styles from './Alerts.module.scss'; diff --git a/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx b/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx index c5d32a7d85..09b6352dda 100644 --- a/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx +++ b/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx @@ -2,6 +2,7 @@ import React, { HTMLAttributes, useState } from 'react'; import { Button, Field, Input, Label, Modal, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { openErrorNotification, openNotification } from 'helpers/helpers'; import { get } from 'lodash-es'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -10,7 +11,6 @@ import { Controller, FormProvider, useForm } from 'react-hook-form'; import { RenderConditionally } from 'components/RenderConditionally/RenderConditionally'; import { SourceCode } from 'components/SourceCode/SourceCode'; import { useStore } from 'state/useStore'; -import { openErrorNotification, openNotification } from 'utils/utils'; import styles from './ApiTokenForm.module.css'; diff --git a/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenSettings.tsx b/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenSettings.tsx index e2dbd9f325..f91b536363 100644 --- a/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenSettings.tsx +++ b/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenSettings.tsx @@ -2,6 +2,11 @@ import React from 'react'; import { Button, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { + generateMissingPermissionMessage, + isUserActionAllowed, + UserActions, +} from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import moment from 'moment-timezone'; @@ -12,7 +17,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { ApiToken } from 'models/api_token/api_token.types'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { generateMissingPermissionMessage, isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; import { ApiTokenForm } from './ApiTokenForm'; diff --git a/grafana-plugin/src/containers/AttachIncidentForm/AttachIncidentForm.tsx b/grafana-plugin/src/containers/AttachIncidentForm/AttachIncidentForm.tsx index 37c65138e0..3901922334 100644 --- a/grafana-plugin/src/containers/AttachIncidentForm/AttachIncidentForm.tsx +++ b/grafana-plugin/src/containers/AttachIncidentForm/AttachIncidentForm.tsx @@ -3,6 +3,7 @@ import React, { useCallback, useState } from 'react'; import { SelectableValue } from '@grafana/data'; import { Button, Field, Icon, Modal, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import moment from 'moment-timezone'; @@ -12,7 +13,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { AlertGroupHelper } from 'models/alertgroup/alertgroup.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; import styles from './AttachIncidentForm.module.css'; diff --git a/grafana-plugin/src/containers/ColumnsSelector/ColumnsSelector.tsx b/grafana-plugin/src/containers/ColumnsSelector/ColumnsSelector.tsx index 3758f19725..848ad81045 100644 --- a/grafana-plugin/src/containers/ColumnsSelector/ColumnsSelector.tsx +++ b/grafana-plugin/src/containers/ColumnsSelector/ColumnsSelector.tsx @@ -19,6 +19,9 @@ import { } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { Button, Checkbox, Icon, IconButton, LoadingPlaceholder, Tooltip, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { openErrorNotification } from 'helpers/helpers'; +import { useIsLoading } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; @@ -28,9 +31,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { AlertGroupColumn, AlertGroupColumnType } from 'models/alertgroup/alertgroup.types'; import { ActionKey } from 'models/loader/action-keys'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { useIsLoading } from 'utils/hooks'; -import { openErrorNotification } from 'utils/utils'; import { getColumnsSelectorStyles } from './ColumnsSelector.styles'; diff --git a/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsModal.tsx b/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsModal.tsx index 25e4809c9c..8648d6c94d 100644 --- a/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsModal.tsx +++ b/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsModal.tsx @@ -3,6 +3,11 @@ import React, { useMemo, useState } from 'react'; import { LabelTag } from '@grafana/labels'; import { Button, Checkbox, IconButton, Input, LoadingPlaceholder, Modal, Stack, useStyles2 } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { PROCESSING_REQUEST_ERROR, StackSize } from 'helpers/consts'; +import { WrapWithGlobalNotification } from 'helpers/decorators'; +import { pluralize } from 'helpers/helpers'; +import { useDebouncedCallback, useIsLoading } from 'helpers/hooks'; import { observer } from 'mobx-react'; import styles from 'assets/style/utils.css'; @@ -15,11 +20,6 @@ import { ActionKey } from 'models/loader/action-keys'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { components } from 'network/oncall-api/autogenerated-api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { PROCESSING_REQUEST_ERROR, StackSize } from 'utils/consts'; -import { WrapWithGlobalNotification } from 'utils/decorators'; -import { useDebouncedCallback, useIsLoading } from 'utils/hooks'; -import { pluralize } from 'utils/utils'; import { getColumnsSelectorWrapperStyles } from './ColumnsSelectorWrapper.styles'; diff --git a/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsSelectorWrapper.tsx b/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsSelectorWrapper.tsx index 84b2d7b083..c7a9bada87 100644 --- a/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsSelectorWrapper.tsx +++ b/grafana-plugin/src/containers/ColumnsSelectorWrapper/ColumnsSelectorWrapper.tsx @@ -1,6 +1,10 @@ import React, { useEffect, useRef, useState } from 'react'; import { useStyles2, Button, Icon, LoadingPlaceholder, Modal, Stack } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { PROCESSING_REQUEST_ERROR, StackSize } from 'helpers/consts'; +import { WrapAutoLoadingState, WrapWithGlobalNotification } from 'helpers/decorators'; +import { useIsLoading } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { Text } from 'components/Text/Text'; @@ -12,10 +16,6 @@ import { AlertGroupColumn } from 'models/alertgroup/alertgroup.types'; import { ActionKey } from 'models/loader/action-keys'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { PROCESSING_REQUEST_ERROR, StackSize } from 'utils/consts'; -import { WrapAutoLoadingState, WrapWithGlobalNotification } from 'utils/decorators'; -import { useIsLoading } from 'utils/hooks'; import { ColumnsModal } from './ColumnsModal'; diff --git a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx index 3b36716210..3a13a3f597 100644 --- a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx +++ b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx @@ -2,9 +2,9 @@ import React, { FC, ReactElement } from 'react'; import { NavModelItem } from '@grafana/data'; import { PluginPage } from 'PluginPage'; +import { AppRootProps } from 'app-types'; import cn from 'classnames/bind'; import { observer } from 'mobx-react'; -import { AppRootProps } from 'types'; import { Alerts } from 'containers/Alerts/Alerts'; import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; diff --git a/grafana-plugin/src/containers/EditRegexpRouteTemplateModal/EditRegexpRouteTemplateModal.tsx b/grafana-plugin/src/containers/EditRegexpRouteTemplateModal/EditRegexpRouteTemplateModal.tsx index 2b3a4df21f..e16ce0f036 100644 --- a/grafana-plugin/src/containers/EditRegexpRouteTemplateModal/EditRegexpRouteTemplateModal.tsx +++ b/grafana-plugin/src/containers/EditRegexpRouteTemplateModal/EditRegexpRouteTemplateModal.tsx @@ -2,6 +2,8 @@ import React, { useState, useCallback } from 'react'; import { Stack, Modal, Tooltip, Icon, Button } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; +import { openErrorNotification } from 'helpers/helpers'; import { debounce } from 'lodash-es'; import { observer } from 'mobx-react'; @@ -13,8 +15,6 @@ import { AlertReceiveChannelHelper } from 'models/alert_receive_channel/alert_re import { ChannelFilter } from 'models/channel_filter/channel_filter.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; -import { openErrorNotification } from 'utils/utils'; import styles from './EditRegexpRouteTemplateModal.module.css'; diff --git a/grafana-plugin/src/containers/EscalationChainCard/EscalationChainCard.tsx b/grafana-plugin/src/containers/EscalationChainCard/EscalationChainCard.tsx index 855bfcb4ec..4dca5d915e 100644 --- a/grafana-plugin/src/containers/EscalationChainCard/EscalationChainCard.tsx +++ b/grafana-plugin/src/containers/EscalationChainCard/EscalationChainCard.tsx @@ -2,13 +2,13 @@ import React from 'react'; import { Stack, Badge } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Text } from 'components/Text/Text'; import { TeamName } from 'containers/TeamName/TeamName'; import { EscalationChain } from 'models/escalation_chain/escalation_chain.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; import styles from './EscalationChainCard.module.css'; diff --git a/grafana-plugin/src/containers/EscalationChainForm/EscalationChainForm.tsx b/grafana-plugin/src/containers/EscalationChainForm/EscalationChainForm.tsx index 402eba69a3..b72dee6764 100644 --- a/grafana-plugin/src/containers/EscalationChainForm/EscalationChainForm.tsx +++ b/grafana-plugin/src/containers/EscalationChainForm/EscalationChainForm.tsx @@ -2,6 +2,7 @@ import React, { FC } from 'react'; import { Button, Field, Input, Modal, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { openWarningNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { Controller, FormProvider, useForm } from 'react-hook-form'; @@ -9,7 +10,6 @@ import { GSelect } from 'containers/GSelect/GSelect'; import { EscalationChain } from 'models/escalation_chain/escalation_chain.types'; import { GrafanaTeam } from 'models/grafana_team/grafana_team.types'; import { useStore } from 'state/useStore'; -import { openWarningNotification } from 'utils/utils'; import styles from 'containers/EscalationChainForm/EscalationChainForm.module.css'; diff --git a/grafana-plugin/src/containers/EscalationChainSteps/EscalationChainSteps.tsx b/grafana-plugin/src/containers/EscalationChainSteps/EscalationChainSteps.tsx index f3e324262a..b657796ef4 100644 --- a/grafana-plugin/src/containers/EscalationChainSteps/EscalationChainSteps.tsx +++ b/grafana-plugin/src/containers/EscalationChainSteps/EscalationChainSteps.tsx @@ -4,6 +4,7 @@ import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { LoadingPlaceholder, Select, useStyles2, useTheme2 } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { getLabelBackgroundTextColorObject } from 'styles/utils.styles'; @@ -14,7 +15,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { EscalationChain } from 'models/escalation_chain/escalation_chain.types'; import { EscalationPolicyOption } from 'models/escalation_policy/escalation_policy.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; import styles from './EscalationChainSteps.module.css'; diff --git a/grafana-plugin/src/containers/GSelect/GSelect.tsx b/grafana-plugin/src/containers/GSelect/GSelect.tsx index fe18d5dacd..3d87aaf21a 100644 --- a/grafana-plugin/src/containers/GSelect/GSelect.tsx +++ b/grafana-plugin/src/containers/GSelect/GSelect.tsx @@ -3,11 +3,10 @@ import React, { ReactElement, useCallback, useEffect } from 'react'; import { SelectableValue } from '@grafana/data'; import { AsyncMultiSelect, AsyncSelect } from '@grafana/ui'; import cn from 'classnames/bind'; +import { useDebouncedCallback } from 'helpers/hooks'; import { get, isNil } from 'lodash-es'; import { observer } from 'mobx-react'; -import { useDebouncedCallback } from 'utils/hooks'; - import styles from './GSelect.module.scss'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/containers/GrafanaTeamSelect/GrafanaTeamSelect.tsx b/grafana-plugin/src/containers/GrafanaTeamSelect/GrafanaTeamSelect.tsx index 6ac090f7a0..d3f96badea 100644 --- a/grafana-plugin/src/containers/GrafanaTeamSelect/GrafanaTeamSelect.tsx +++ b/grafana-plugin/src/containers/GrafanaTeamSelect/GrafanaTeamSelect.tsx @@ -2,13 +2,13 @@ import React, { useCallback, useState } from 'react'; import { Button, Icon, Label, Modal, Tooltip, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { GSelect } from 'containers/GSelect/GSelect'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { GrafanaTeam } from 'models/grafana_team/grafana_team.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; import styles from './GrafanaTeamSelect.module.scss'; diff --git a/grafana-plugin/src/containers/IntegrationContainers/CollapsedIntegrationRouteDisplay/CollapsedIntegrationRouteDisplay.tsx b/grafana-plugin/src/containers/IntegrationContainers/CollapsedIntegrationRouteDisplay/CollapsedIntegrationRouteDisplay.tsx index 6908310617..be5f9e5920 100644 --- a/grafana-plugin/src/containers/IntegrationContainers/CollapsedIntegrationRouteDisplay/CollapsedIntegrationRouteDisplay.tsx +++ b/grafana-plugin/src/containers/IntegrationContainers/CollapsedIntegrationRouteDisplay/CollapsedIntegrationRouteDisplay.tsx @@ -2,6 +2,7 @@ import React, { useMemo, useState } from 'react'; import { ConfirmModal, Icon, IconName, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { IntegrationBlock } from 'components/Integrations/IntegrationBlock'; @@ -15,7 +16,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { CommonIntegrationHelper } from 'pages/integration/CommonIntegration.helper'; import { IntegrationHelper } from 'pages/integration/Integration.helper'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/containers/IntegrationContainers/ExpandedIntegrationRouteDisplay/ExpandedIntegrationRouteDisplay.tsx b/grafana-plugin/src/containers/IntegrationContainers/ExpandedIntegrationRouteDisplay/ExpandedIntegrationRouteDisplay.tsx index 83140b9e0e..5785c763af 100644 --- a/grafana-plugin/src/containers/IntegrationContainers/ExpandedIntegrationRouteDisplay/ExpandedIntegrationRouteDisplay.tsx +++ b/grafana-plugin/src/containers/IntegrationContainers/ExpandedIntegrationRouteDisplay/ExpandedIntegrationRouteDisplay.tsx @@ -13,6 +13,9 @@ import { Alert, } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -42,9 +45,6 @@ import { IntegrationHelper } from 'pages/integration/Integration.helper'; import { MONACO_INPUT_HEIGHT_SMALL } from 'pages/integration/IntegrationCommon.config'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; -import { openNotification } from 'utils/utils'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/containers/IntegrationContainers/IntegrationHeartbeatForm/IntegrationHeartbeatForm.tsx b/grafana-plugin/src/containers/IntegrationContainers/IntegrationHeartbeatForm/IntegrationHeartbeatForm.tsx index 7602ea991f..3dff84fea5 100644 --- a/grafana-plugin/src/containers/IntegrationContainers/IntegrationHeartbeatForm/IntegrationHeartbeatForm.tsx +++ b/grafana-plugin/src/containers/IntegrationContainers/IntegrationHeartbeatForm/IntegrationHeartbeatForm.tsx @@ -3,6 +3,9 @@ import React, { ReactElement, useEffect, useState } from 'react'; import { SelectableValue } from '@grafana/data'; import { Button, Drawer, Field, Icon, Select, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { IntegrationInputField } from 'components/IntegrationInputField/IntegrationInputField'; @@ -13,9 +16,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { SelectOption } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; -import { openNotification } from 'utils/utils'; import styles from './IntegrationHeartbeatForm.module.scss'; diff --git a/grafana-plugin/src/containers/IntegrationContainers/IntegrationTemplatesList.tsx b/grafana-plugin/src/containers/IntegrationContainers/IntegrationTemplatesList.tsx index 85b68d9335..71015714eb 100644 --- a/grafana-plugin/src/containers/IntegrationContainers/IntegrationTemplatesList.tsx +++ b/grafana-plugin/src/containers/IntegrationContainers/IntegrationTemplatesList.tsx @@ -2,6 +2,7 @@ import React, { useState, useCallback } from 'react'; import { InlineSwitch, Tooltip } from '@grafana/ui'; import cn from 'classnames/bind'; +import { openErrorNotification, openNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { IntegrationBlockItem } from 'components/Integrations/IntegrationBlockItem'; @@ -16,7 +17,6 @@ import { IntegrationHelper } from 'pages/integration/Integration.helper'; import styles from 'pages/integration/Integration.module.scss'; import { MONACO_INPUT_HEIGHT_TALL } from 'pages/integration/IntegrationCommon.config'; import { useStore } from 'state/useStore'; -import { openErrorNotification, openNotification } from 'utils/utils'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx b/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx index e61eb91acf..c30f538f0f 100644 --- a/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx +++ b/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx @@ -16,6 +16,17 @@ import { Stack, useStyles2, } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { + PLUGIN_ROOT, + generateAssignToTeamInputDescription, + DOCS_ROOT, + INTEGRATION_SERVICENOW, + StackSize, +} from 'helpers/consts'; +import { useIsLoading } from 'helpers/hooks'; +import { validateURL } from 'helpers/string'; +import { OmitReadonlyMembers } from 'helpers/types'; import { observer } from 'mobx-react'; import { Controller, useForm, useFormContext, FormProvider } from 'react-hook-form'; import { useNavigate } from 'react-router-dom-v5-compat'; @@ -35,17 +46,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { IntegrationHelper, getIsBidirectionalIntegration } from 'pages/integration/Integration.helper'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { - PLUGIN_ROOT, - generateAssignToTeamInputDescription, - DOCS_ROOT, - INTEGRATION_SERVICENOW, - StackSize, -} from 'utils/consts'; -import { useIsLoading } from 'utils/hooks'; -import { validateURL } from 'utils/string'; -import { OmitReadonlyMembers } from 'utils/types'; import { prepareForEdit } from './IntegrationForm.helpers'; import { getIntegrationFormStyles } from './IntegrationForm.styles'; diff --git a/grafana-plugin/src/containers/IntegrationForm/IntegrationFormContainer.tsx b/grafana-plugin/src/containers/IntegrationForm/IntegrationFormContainer.tsx index 8ec381f452..be17c17e14 100644 --- a/grafana-plugin/src/containers/IntegrationForm/IntegrationFormContainer.tsx +++ b/grafana-plugin/src/containers/IntegrationForm/IntegrationFormContainer.tsx @@ -2,6 +2,7 @@ import React, { useState, ChangeEvent } from 'react'; import { Drawer, Stack, Input, Tag, EmptySearchResult } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Block } from 'components/GBlock/Block'; @@ -9,7 +10,6 @@ import { IntegrationLogo } from 'components/IntegrationLogo/IntegrationLogo'; import { Text } from 'components/Text/Text'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; import { IntegrationForm } from './IntegrationForm'; import styles from './IntegrationFormContainer.module.scss'; diff --git a/grafana-plugin/src/containers/IntegrationLabelsForm/IntegrationLabelsForm.tsx b/grafana-plugin/src/containers/IntegrationLabelsForm/IntegrationLabelsForm.tsx index 8e3ea458e2..6875186706 100644 --- a/grafana-plugin/src/containers/IntegrationLabelsForm/IntegrationLabelsForm.tsx +++ b/grafana-plugin/src/containers/IntegrationLabelsForm/IntegrationLabelsForm.tsx @@ -3,6 +3,8 @@ import React, { ChangeEvent, useState } from 'react'; import { ServiceLabels } from '@grafana/labels'; import { Alert, Button, Drawer, Dropdown, InlineSwitch, Input, Menu, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { DOCS_ROOT, GENERIC_ERROR, StackSize } from 'helpers/consts'; +import { openErrorNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { Collapse } from 'components/Collapse/Collapse'; @@ -16,8 +18,6 @@ import { LabelsErrors } from 'models/label/label.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { LabelTemplateOptions } from 'pages/integration/IntegrationCommon.config'; import { useStore } from 'state/useStore'; -import { DOCS_ROOT, GENERIC_ERROR, StackSize } from 'utils/consts'; -import { openErrorNotification } from 'utils/utils'; import { getIsAddBtnDisabled, getIsTooManyLabelsWarningVisible } from './IntegrationLabelsForm.helpers'; diff --git a/grafana-plugin/src/containers/IntegrationTemplate/IntegrationTemplate.tsx b/grafana-plugin/src/containers/IntegrationTemplate/IntegrationTemplate.tsx index 6481b64efc..0cce3b48f4 100644 --- a/grafana-plugin/src/containers/IntegrationTemplate/IntegrationTemplate.tsx +++ b/grafana-plugin/src/containers/IntegrationTemplate/IntegrationTemplate.tsx @@ -2,6 +2,8 @@ import React, { useCallback, useState, useEffect } from 'react'; import { Button, Drawer, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { UserActions } from 'helpers/authorization/authorization'; import { debounce } from 'lodash-es'; import { observer } from 'mobx-react'; @@ -26,8 +28,6 @@ import { ChannelFilter } from 'models/channel_filter/channel_filter.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { IntegrationTemplateOptions, LabelTemplateOptions } from 'pages/integration/IntegrationCommon.config'; import { useStore } from 'state/useStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { UserActions } from 'utils/authorization/authorization'; import styles from './IntegrationTemplate.module.scss'; diff --git a/grafana-plugin/src/containers/Labels/Labels.tsx b/grafana-plugin/src/containers/Labels/Labels.tsx index 02625f461b..78555a7816 100644 --- a/grafana-plugin/src/containers/Labels/Labels.tsx +++ b/grafana-plugin/src/containers/Labels/Labels.tsx @@ -2,14 +2,14 @@ import React, { forwardRef, useImperativeHandle, useState } from 'react'; import { ServiceLabelsProps, ServiceLabels } from '@grafana/labels'; import { Field, Label } from '@grafana/ui'; +import { GENERIC_ERROR } from 'helpers/consts'; +import { openErrorNotification } from 'helpers/helpers'; import { isEmpty } from 'lodash-es'; import { observer } from 'mobx-react'; import { splitToGroups } from 'models/label/label.helpers'; import { LabelKeyValue } from 'models/label/label.types'; import { useStore } from 'state/useStore'; -import { GENERIC_ERROR } from 'utils/consts'; -import { openErrorNotification } from 'utils/utils'; export interface LabelsProps { value: LabelKeyValue[]; diff --git a/grafana-plugin/src/containers/MSTeams/MSTeamsInstructions.tsx b/grafana-plugin/src/containers/MSTeams/MSTeamsInstructions.tsx index e546a5fe8d..30d71291bf 100644 --- a/grafana-plugin/src/containers/MSTeams/MSTeamsInstructions.tsx +++ b/grafana-plugin/src/containers/MSTeams/MSTeamsInstructions.tsx @@ -2,6 +2,8 @@ import React, { FC } from 'react'; import { Button, Icon, Stack, Field, Input } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; +import { openNotification, openWarningNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -10,8 +12,6 @@ import { PluginLink } from 'components/PluginLink/PluginLink'; import { Text } from 'components/Text/Text'; import MSTeamsLogo from 'icons/MSTeamsLogo'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; -import { openNotification, openWarningNotification } from 'utils/utils'; import styles from './MSTeamsInstructions.module.css'; diff --git a/grafana-plugin/src/containers/MSTeamsIntegrationButton/MSTeamsIntegrationButton.tsx b/grafana-plugin/src/containers/MSTeamsIntegrationButton/MSTeamsIntegrationButton.tsx index f6920b3a28..a2ecea4c5c 100644 --- a/grafana-plugin/src/containers/MSTeamsIntegrationButton/MSTeamsIntegrationButton.tsx +++ b/grafana-plugin/src/containers/MSTeamsIntegrationButton/MSTeamsIntegrationButton.tsx @@ -2,12 +2,12 @@ import React, { useCallback, useState, useEffect } from 'react'; import { Button, Modal } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { MSTeamsInstructions } from 'containers/MSTeams/MSTeamsInstructions'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; import styles from './MSTeamsIntegrationButton.module.css'; diff --git a/grafana-plugin/src/containers/MaintenanceForm/MaintenanceForm.tsx b/grafana-plugin/src/containers/MaintenanceForm/MaintenanceForm.tsx index f1f367baec..3b009a4730 100644 --- a/grafana-plugin/src/containers/MaintenanceForm/MaintenanceForm.tsx +++ b/grafana-plugin/src/containers/MaintenanceForm/MaintenanceForm.tsx @@ -3,6 +3,8 @@ import React, { useCallback } from 'react'; import { SelectableValue } from '@grafana/data'; import { Button, Drawer, Field, Select, Stack, useStyles2 } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { openNotification, showApiError } from 'helpers/helpers'; import { observer } from 'mobx-react'; import Emoji from 'react-emoji-render'; import { Controller, FormProvider, useForm } from 'react-hook-form'; @@ -14,8 +16,6 @@ import { AlertReceiveChannelHelper } from 'models/alert_receive_channel/alert_re import { MaintenanceMode } from 'models/alert_receive_channel/alert_receive_channel.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { openNotification, showApiError } from 'utils/utils'; import styles from './MaintenanceForm.module.css'; diff --git a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.test.tsx b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.test.tsx index 932cc87658..124fde2a7e 100644 --- a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.test.tsx +++ b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.test.tsx @@ -13,8 +13,8 @@ jest.mock('plugin/GrafanaPluginRootPage.helpers', () => ({ isTopNavbar: () => false, })); -jest.mock('utils/authorization/authorization', () => ({ - ...jest.requireActual('utils/authorization/authorization'), +jest.mock('helpers/authorization/authorization', () => ({ + ...jest.requireActual('helpers/authorization/authorization'), isUserActionAllowed: jest.fn().mockReturnValue(true), })); diff --git a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx index 1ab887b21e..b672f53bce 100644 --- a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx +++ b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx @@ -2,6 +2,10 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { Button, Icon, LoadingPlaceholder, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; +import { isMobile, openErrorNotification, openNotification, openWarningNotification } from 'helpers/helpers'; +import { useInitializePlugin } from 'helpers/hooks'; import { observer } from 'mobx-react'; import qrCodeImage from 'assets/img/qr-code.png'; @@ -15,10 +19,6 @@ import { UserHelper } from 'models/user/user.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { RootStore, rootStore as store } from 'state/rootStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; -import { useInitializePlugin } from 'utils/hooks'; -import { isMobile, openErrorNotification, openNotification, openWarningNotification } from 'utils/utils'; import styles from './MobileAppConnection.module.scss'; import { DisconnectButton } from './parts/DisconnectButton/DisconnectButton'; diff --git a/grafana-plugin/src/containers/MobileAppConnection/parts/DownloadIcons/DownloadIcons.tsx b/grafana-plugin/src/containers/MobileAppConnection/parts/DownloadIcons/DownloadIcons.tsx index 076c63705b..5d39a25651 100644 --- a/grafana-plugin/src/containers/MobileAppConnection/parts/DownloadIcons/DownloadIcons.tsx +++ b/grafana-plugin/src/containers/MobileAppConnection/parts/DownloadIcons/DownloadIcons.tsx @@ -2,12 +2,12 @@ import React, { FC } from 'react'; import { Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import AppleLogoSVG from 'assets/img/apple-logo.svg'; import PlayStoreLogoSVG from 'assets/img/play-store-logo.svg'; import { Block } from 'components/GBlock/Block'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; import styles from './DownloadIcons.module.scss'; diff --git a/grafana-plugin/src/containers/MobileAppConnection/parts/LinkLoginButton/LinkLoginButton.tsx b/grafana-plugin/src/containers/MobileAppConnection/parts/LinkLoginButton/LinkLoginButton.tsx index a6b5cde521..55d51554b6 100644 --- a/grafana-plugin/src/containers/MobileAppConnection/parts/LinkLoginButton/LinkLoginButton.tsx +++ b/grafana-plugin/src/containers/MobileAppConnection/parts/LinkLoginButton/LinkLoginButton.tsx @@ -1,9 +1,9 @@ import React, { FC } from 'react'; import { Button, Stack } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; type Props = { baseUrl: string; diff --git a/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookForm.tsx b/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookForm.tsx index 7de7a09d2e..05db8418d9 100644 --- a/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookForm.tsx +++ b/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookForm.tsx @@ -2,6 +2,9 @@ import React, { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'r import { Button, ConfirmModal, ConfirmModalProps, Drawer, Input, Tab, TabsBar, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { PLUGIN_ROOT } from 'helpers/consts'; +import { KeyValuePair } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { FormProvider, useForm, useFormContext } from 'react-hook-form'; import { useNavigate } from 'react-router-dom-v5-compat'; @@ -15,9 +18,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { WebhookFormActionType } from 'pages/outgoing_webhooks/OutgoingWebhooks.types'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { PLUGIN_ROOT } from 'utils/consts'; -import { KeyValuePair } from 'utils/utils'; import { TemplateParams, WebhookFormFieldName } from './OutgoingWebhookForm.types'; import { OutgoingWebhookFormFields } from './OutgoingWebhookFormFields'; diff --git a/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookFormFields.tsx b/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookFormFields.tsx index 0250c06bf7..e7a4ac9711 100644 --- a/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookFormFields.tsx +++ b/grafana-plugin/src/containers/OutgoingWebhookForm/OutgoingWebhookFormFields.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { SelectableValue } from '@grafana/data'; import { Button, Field, Input, RadioButtonList, Select, Switch, useStyles2 } from '@grafana/ui'; +import { generateAssignToTeamInputDescription } from 'helpers/consts'; import { observer } from 'mobx-react'; import Emoji from 'react-emoji-render'; import { Controller, useFormContext } from 'react-hook-form'; @@ -20,7 +21,6 @@ import { } from 'models/outgoing_webhook/outgoing_webhook.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { generateAssignToTeamInputDescription } from 'utils/consts'; import { getStyles } from './OutgoingWebhookForm.styles'; import { TemplateParams, WebhookFormFieldName } from './OutgoingWebhookForm.types'; diff --git a/grafana-plugin/src/containers/OutgoingWebhookForm/WebhookPresetBlocks.tsx b/grafana-plugin/src/containers/OutgoingWebhookForm/WebhookPresetBlocks.tsx index 82a6592dac..fa8fd2e205 100644 --- a/grafana-plugin/src/containers/OutgoingWebhookForm/WebhookPresetBlocks.tsx +++ b/grafana-plugin/src/containers/OutgoingWebhookForm/WebhookPresetBlocks.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { EmptySearchResult, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Block } from 'components/GBlock/Block'; @@ -11,7 +12,6 @@ import { Text } from 'components/Text/Text'; import { getWebhookPresetIcons } from 'containers/OutgoingWebhookForm/WebhookPresetIcons.config'; import { OutgoingWebhookPreset } from 'models/outgoing_webhook/outgoing_webhook.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; import styles from 'containers/OutgoingWebhookForm/OutgoingWebhookForm.module.css'; diff --git a/grafana-plugin/src/containers/OutgoingWebhookStatus/OutgoingWebhookStatus.tsx b/grafana-plugin/src/containers/OutgoingWebhookStatus/OutgoingWebhookStatus.tsx index d62156e1ed..ee7dbf18ba 100644 --- a/grafana-plugin/src/containers/OutgoingWebhookStatus/OutgoingWebhookStatus.tsx +++ b/grafana-plugin/src/containers/OutgoingWebhookStatus/OutgoingWebhookStatus.tsx @@ -2,12 +2,12 @@ import React from 'react'; import { Button, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { useCommonStyles } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { WebhookLastEventDetails } from 'components/Webhooks/WebhookLastEventDetails'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { useCommonStyles } from 'utils/hooks'; import styles from 'containers/OutgoingWebhookForm/OutgoingWebhookForm.module.css'; diff --git a/grafana-plugin/src/containers/PersonalNotificationSettings/PersonalNotificationSettings.tsx b/grafana-plugin/src/containers/PersonalNotificationSettings/PersonalNotificationSettings.tsx index 0758740f1e..58b408e786 100644 --- a/grafana-plugin/src/containers/PersonalNotificationSettings/PersonalNotificationSettings.tsx +++ b/grafana-plugin/src/containers/PersonalNotificationSettings/PersonalNotificationSettings.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from 'react'; import { Button, Icon, LoadingPlaceholder, Stack, Tooltip } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; import { get } from 'lodash-es'; import { observer } from 'mobx-react'; @@ -14,7 +15,6 @@ import { NotificationPolicyType } from 'models/notification_policy/notification_ import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; import { getColor } from './PersonalNotificationSettings.helpers'; import img from './img/default-step.png'; diff --git a/grafana-plugin/src/containers/PluginConfigPage/PluginConfigPage.tsx b/grafana-plugin/src/containers/PluginConfigPage/PluginConfigPage.tsx index a421a13799..722a16e903 100644 --- a/grafana-plugin/src/containers/PluginConfigPage/PluginConfigPage.tsx +++ b/grafana-plugin/src/containers/PluginConfigPage/PluginConfigPage.tsx @@ -3,10 +3,21 @@ import React, { useEffect, useState } from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2, PluginConfigPageProps, PluginMeta } from '@grafana/data'; import { Alert, Field, Input, LoadingPlaceholder, useStyles2, Stack } from '@grafana/ui'; +import { OnCallPluginMetaJSONData } from 'app-types'; +import { + DEFAULT_PAGE, + DOCS_ONCALL_OSS_INSTALL, + DOCS_SERVICE_ACCOUNTS, + PLUGIN_CONFIG, + PLUGIN_ROOT, + REQUEST_HELP_URL, +} from 'helpers/consts'; +import { getIsExternalServiceAccountFeatureAvailable, getIsRunningOpenSourceVersion } from 'helpers/helpers'; +import { useOnMount } from 'helpers/hooks'; +import { validateURL } from 'helpers/string'; import { observer } from 'mobx-react'; import { Controller, useForm } from 'react-hook-form'; import { useNavigate } from 'react-router-dom-v5-compat'; -import { OnCallPluginMetaJSONData } from 'types'; import { Button } from 'components/Button/Button'; import { CollapsibleTreeView } from 'components/CollapsibleTreeView/CollapsibleTreeView'; @@ -14,17 +25,6 @@ import { RenderConditionally } from 'components/RenderConditionally/RenderCondit import { Text } from 'components/Text/Text'; import { ActionKey } from 'models/loader/action-keys'; import { rootStore } from 'state/rootStore'; -import { - DEFAULT_PAGE, - DOCS_ONCALL_OSS_INSTALL, - DOCS_SERVICE_ACCOUNTS, - PLUGIN_CONFIG, - PLUGIN_ROOT, - REQUEST_HELP_URL, -} from 'utils/consts'; -import { useOnMount } from 'utils/hooks'; -import { validateURL } from 'utils/string'; -import { getIsExternalServiceAccountFeatureAvailable, getIsRunningOpenSourceVersion } from 'utils/utils'; type PluginConfigFormValues = { onCallApiUrl: string; diff --git a/grafana-plugin/src/containers/PluginInitializer/PluginInitializer.tsx b/grafana-plugin/src/containers/PluginInitializer/PluginInitializer.tsx index 2ba9aa66cb..ffdb6b3bbf 100644 --- a/grafana-plugin/src/containers/PluginInitializer/PluginInitializer.tsx +++ b/grafana-plugin/src/containers/PluginInitializer/PluginInitializer.tsx @@ -1,14 +1,14 @@ import React, { FC } from 'react'; import { Button, Stack, LoadingPlaceholder } from '@grafana/ui'; +import { REQUEST_HELP_URL, PLUGIN_CONFIG } from 'helpers/consts'; +import { getIsRunningOpenSourceVersion } from 'helpers/helpers'; +import { useInitializePlugin } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { useNavigate } from 'react-router-dom-v5-compat'; import { FullPageError } from 'components/FullPageError/FullPageError'; import { RenderConditionally } from 'components/RenderConditionally/RenderConditionally'; -import { REQUEST_HELP_URL, PLUGIN_CONFIG } from 'utils/consts'; -import { useInitializePlugin } from 'utils/hooks'; -import { getIsRunningOpenSourceVersion } from 'utils/utils'; interface PluginInitializerProps { children: React.ReactNode; diff --git a/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx b/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx index 0c35a0fee7..92474fdcee 100644 --- a/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx +++ b/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx @@ -14,6 +14,9 @@ import { withTheme2, } from '@grafana/ui'; import { capitalCase } from 'change-case'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { PAGE } from 'helpers/consts'; +import { convertTimerangeToFilterValue, getValueForDateRangeFilterType } from 'helpers/datetime'; import { debounce, isUndefined, omitBy, pickBy } from 'lodash-es'; import { observer } from 'mobx-react'; import moment from 'moment-timezone'; @@ -29,9 +32,6 @@ import { FilterExtraInformation, FilterExtraInformationValues } from 'models/fil import { GrafanaTeamStore } from 'models/grafana_team/grafana_team'; import { SelectOption, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { PAGE } from 'utils/consts'; -import { convertTimerangeToFilterValue, getValueForDateRangeFilterType } from 'utils/datetime'; import { parseFilters } from './RemoteFilters.helpers'; import { FilterOption } from './RemoteFilters.types'; diff --git a/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx b/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx index 94ec2fbc47..f33ab4c21a 100644 --- a/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx +++ b/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx @@ -2,11 +2,11 @@ import React, { useCallback, useMemo, useReducer, useState } from 'react'; import { SelectableValue } from '@grafana/data'; import { AsyncMultiSelect, AsyncSelect } from '@grafana/ui'; +import { UserAction, generateMissingPermissionMessage } from 'helpers/authorization/authorization'; +import { useDebouncedCallback } from 'helpers/hooks'; import { inject, observer } from 'mobx-react'; import { makeRequest, isNetworkError } from 'network/network'; -import { UserAction, generateMissingPermissionMessage } from 'utils/authorization/authorization'; -import { useDebouncedCallback } from 'utils/hooks'; interface RemoteSelectProps { autoFocus?: boolean; diff --git a/grafana-plugin/src/containers/RotationForm/RotationForm.helpers.ts b/grafana-plugin/src/containers/RotationForm/RotationForm.helpers.ts index 37671a36fe..7043f614bd 100644 --- a/grafana-plugin/src/containers/RotationForm/RotationForm.helpers.ts +++ b/grafana-plugin/src/containers/RotationForm/RotationForm.helpers.ts @@ -1,8 +1,8 @@ import { Dayjs, ManipulateType } from 'dayjs'; +import { GRAFANA_HEADER_HEIGHT, GRAFANA_LEGACY_SIDEBAR_WIDTH } from 'helpers/consts'; import { DraggableData } from 'react-draggable'; import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; -import { GRAFANA_HEADER_HEIGHT, GRAFANA_LEGACY_SIDEBAR_WIDTH } from 'utils/consts'; import { RepeatEveryPeriod } from './RotationForm.types'; diff --git a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx index 8e5d38c6f0..e3f10fd678 100644 --- a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx +++ b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx @@ -3,6 +3,8 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Alert, Button, Field, Icon, IconButton, InlineSwitch, Select, Switch, Tooltip, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; import dayjs from 'dayjs'; +import { GRAFANA_HEADER_HEIGHT, StackSize } from 'helpers/consts'; +import { useDebouncedCallback, useResize } from 'helpers/hooks'; import { observer } from 'mobx-react'; import Draggable, { DraggableData, DraggableEvent } from 'react-draggable'; @@ -51,8 +53,6 @@ import { toDateWithTimezoneOffsetAtMidnight, } from 'pages/schedule/Schedule.helpers'; import { useStore } from 'state/useStore'; -import { GRAFANA_HEADER_HEIGHT, StackSize } from 'utils/consts'; -import { useDebouncedCallback, useResize } from 'utils/hooks'; import styles from './RotationForm.module.css'; diff --git a/grafana-plugin/src/containers/RotationForm/ScheduleOverrideForm.tsx b/grafana-plugin/src/containers/RotationForm/ScheduleOverrideForm.tsx index 12a69d5ae4..9a23727a30 100644 --- a/grafana-plugin/src/containers/RotationForm/ScheduleOverrideForm.tsx +++ b/grafana-plugin/src/containers/RotationForm/ScheduleOverrideForm.tsx @@ -3,6 +3,8 @@ import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { IconButton, Stack, Field, Button, useTheme2 } from '@grafana/ui'; import cn from 'classnames/bind'; import dayjs from 'dayjs'; +import { StackSize } from 'helpers/consts'; +import { useDebouncedCallback, useResize } from 'helpers/hooks'; import Draggable, { DraggableData, DraggableEvent } from 'react-draggable'; import { Modal } from 'components/Modal/Modal'; @@ -16,8 +18,6 @@ import { Schedule, Shift } from 'models/schedule/schedule.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { getDateTime, getUTCString, toDateWithTimezoneOffset } from 'pages/schedule/Schedule.helpers'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; -import { useDebouncedCallback, useResize } from 'utils/hooks'; import { getDraggableModalCoordinatesOnInit } from './RotationForm.helpers'; import { DateTimePicker } from './parts/DateTimePicker'; diff --git a/grafana-plugin/src/containers/RotationForm/ShiftSwapForm.tsx b/grafana-plugin/src/containers/RotationForm/ShiftSwapForm.tsx index 12176718c0..f8e01084ae 100644 --- a/grafana-plugin/src/containers/RotationForm/ShiftSwapForm.tsx +++ b/grafana-plugin/src/containers/RotationForm/ShiftSwapForm.tsx @@ -3,6 +3,9 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Button, Field, IconButton, Input, TextArea, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; import dayjs from 'dayjs'; +import { UserActions } from 'helpers/authorization/authorization'; +import { GRAFANA_HEADER_HEIGHT, StackSize } from 'helpers/consts'; +import { useDebouncedCallback, useResize } from 'helpers/hooks'; import Draggable, { DraggableData, DraggableEvent } from 'react-draggable'; import { Modal } from 'components/Modal/Modal'; @@ -15,9 +18,6 @@ import { SHIFT_SWAP_COLOR } from 'models/schedule/schedule.helpers'; import { Schedule, ShiftSwap } from 'models/schedule/schedule.types'; import { getUTCString } from 'pages/schedule/Schedule.helpers'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { GRAFANA_HEADER_HEIGHT, StackSize } from 'utils/consts'; -import { useDebouncedCallback, useResize } from 'utils/hooks'; import { getDraggableModalCoordinatesOnInit } from './RotationForm.helpers'; import { DateTimePicker } from './parts/DateTimePicker'; diff --git a/grafana-plugin/src/containers/RotationForm/parts/DeletionModal.tsx b/grafana-plugin/src/containers/RotationForm/parts/DeletionModal.tsx index 5132a69a5d..d5cef9b69b 100644 --- a/grafana-plugin/src/containers/RotationForm/parts/DeletionModal.tsx +++ b/grafana-plugin/src/containers/RotationForm/parts/DeletionModal.tsx @@ -2,9 +2,9 @@ import React, { ChangeEvent, useCallback, useState } from 'react'; import { Stack, Modal as GrafanaModal, Button, InlineSwitch } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { Text } from 'components/Text/Text'; -import { StackSize } from 'utils/consts'; import styles from 'containers/RotationForm/RotationForm.module.css'; diff --git a/grafana-plugin/src/containers/Rotations/Rotations.helpers.ts b/grafana-plugin/src/containers/Rotations/Rotations.helpers.ts index 0c6dfb18c8..5ee4382340 100644 --- a/grafana-plugin/src/containers/Rotations/Rotations.helpers.ts +++ b/grafana-plugin/src/containers/Rotations/Rotations.helpers.ts @@ -1,10 +1,10 @@ import dayjs from 'dayjs'; +import { waitForElement } from 'helpers/DOM'; import { getColor, getOverrideColor } from 'models/schedule/schedule.helpers'; import { Layer, Shift } from 'models/schedule/schedule.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { toDateWithTimezoneOffset } from 'pages/schedule/Schedule.helpers'; -import { waitForElement } from 'utils/DOM'; export const calculateScheduleFormOffset = async (queryClassName: string) => { const modal = await waitForElement(queryClassName); diff --git a/grafana-plugin/src/containers/Rotations/Rotations.tsx b/grafana-plugin/src/containers/Rotations/Rotations.tsx index a769c76efe..9034d7b719 100644 --- a/grafana-plugin/src/containers/Rotations/Rotations.tsx +++ b/grafana-plugin/src/containers/Rotations/Rotations.tsx @@ -4,6 +4,8 @@ import { cx } from '@emotion/css'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; import { ValuePicker, Button, Tooltip, withTheme2, Stack } from '@grafana/ui'; import dayjs from 'dayjs'; +import { HTML_ID } from 'helpers/DOM'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; @@ -19,8 +21,6 @@ import { Schedule, ScheduleType, Shift, ShiftSwap, Event, Layer } from 'models/s import { getCurrentTimeX, toDateWithTimezoneOffset } from 'pages/schedule/Schedule.helpers'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { HTML_ID } from 'utils/DOM'; -import { UserActions } from 'utils/authorization/authorization'; import { DEFAULT_TRANSITION_TIMEOUT } from './Rotations.config'; import { findColor, getCalendarStartDateInTimezone } from './Rotations.helpers'; diff --git a/grafana-plugin/src/containers/Rotations/ScheduleFinal.tsx b/grafana-plugin/src/containers/Rotations/ScheduleFinal.tsx index 9effe9a648..a2e7485f97 100644 --- a/grafana-plugin/src/containers/Rotations/ScheduleFinal.tsx +++ b/grafana-plugin/src/containers/Rotations/ScheduleFinal.tsx @@ -4,6 +4,7 @@ import { cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Stack, useStyles2, withTheme2 } from '@grafana/ui'; import dayjs from 'dayjs'; +import { HTML_ID } from 'helpers/DOM'; import { observer } from 'mobx-react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; import { bem } from 'styles/utils.styles'; @@ -24,7 +25,6 @@ import { Event, Schedule, ScheduleView, ShiftSwap } from 'models/schedule/schedu import { getCurrentTimeX } from 'pages/schedule/Schedule.helpers'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { HTML_ID } from 'utils/DOM'; import { DEFAULT_TRANSITION_TIMEOUT } from './Rotations.config'; import { findColor } from './Rotations.helpers'; diff --git a/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx b/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx index eb09c17b5d..db490348ad 100644 --- a/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx +++ b/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx @@ -4,6 +4,8 @@ import { cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, Stack, Tooltip, withTheme2 } from '@grafana/ui'; import dayjs from 'dayjs'; +import { HTML_ID } from 'helpers/DOM'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; @@ -25,8 +27,6 @@ import { Schedule, Shift, ShiftEvents, ShiftSwap } from 'models/schedule/schedul import { getCurrentTimeX, toDateWithTimezoneOffset } from 'pages/schedule/Schedule.helpers'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { HTML_ID } from 'utils/DOM'; -import { UserActions } from 'utils/authorization/authorization'; import { DEFAULT_TRANSITION_TIMEOUT } from './Rotations.config'; import { findColor } from './Rotations.helpers'; diff --git a/grafana-plugin/src/containers/Rotations/SchedulePersonal.tsx b/grafana-plugin/src/containers/Rotations/SchedulePersonal.tsx index 2d18d994ff..91b360e809 100644 --- a/grafana-plugin/src/containers/Rotations/SchedulePersonal.tsx +++ b/grafana-plugin/src/containers/Rotations/SchedulePersonal.tsx @@ -4,6 +4,8 @@ import { cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Badge, BadgeColor, Button, Icon, Stack, useStyles2, withTheme2 } from '@grafana/ui'; import dayjs from 'dayjs'; +import { PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { useIsLoading } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { useNavigate } from 'react-router-dom-v5-compat'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; @@ -24,8 +26,6 @@ import { Event, ScheduleView } from 'models/schedule/schedule.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { getCurrentTimeX, getStartOfWeekBasedOnCurrentDate } from 'pages/schedule/Schedule.helpers'; import { useStore } from 'state/useStore'; -import { PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { useIsLoading } from 'utils/hooks'; import { DEFAULT_TRANSITION_TIMEOUT } from './Rotations.config'; import { getRotationsStyles } from './Rotations.styles'; diff --git a/grafana-plugin/src/containers/RouteLabelsDisplay/RouteLabelsDisplay.tsx b/grafana-plugin/src/containers/RouteLabelsDisplay/RouteLabelsDisplay.tsx index 5674438fe5..e2e3d5ff01 100644 --- a/grafana-plugin/src/containers/RouteLabelsDisplay/RouteLabelsDisplay.tsx +++ b/grafana-plugin/src/containers/RouteLabelsDisplay/RouteLabelsDisplay.tsx @@ -2,12 +2,12 @@ import React from 'react'; import { ServiceLabels } from '@grafana/labels'; import { Button, Stack } from '@grafana/ui'; +import { GENERIC_ERROR } from 'helpers/consts'; +import { openErrorNotification } from 'helpers/helpers'; import { splitToGroups } from 'models/label/label.helpers'; import { components } from 'network/oncall-api/autogenerated-api.types'; import { useStore } from 'state/useStore'; -import { GENERIC_ERROR } from 'utils/consts'; -import { openErrorNotification } from 'utils/utils'; interface RouteLabelsDisplayProps { labels: Array; diff --git a/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx b/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx index d3364ff66c..4161e7aa12 100644 --- a/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx +++ b/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx @@ -2,6 +2,8 @@ import React, { useCallback, useMemo } from 'react'; import { css } from '@emotion/css'; import { Button, Drawer, Field, Input, Switch, TextArea, Stack, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { openWarningNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { Controller, FormProvider, useForm, useFormContext } from 'react-hook-form'; import { getUtilStyles } from 'styles/utils.styles'; @@ -16,8 +18,6 @@ import { PRIVATE_CHANNEL_NAME } from 'models/slack_channel/slack_channel.config' import { SlackChannel } from 'models/slack_channel/slack_channel.types'; import { UserGroup } from 'models/user_group/user_group.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { openWarningNotification } from 'utils/utils'; import { prepareForEdit } from './ScheduleForm.helpers'; diff --git a/grafana-plugin/src/containers/ScheduleIcalLink/ScheduleIcalLink.tsx b/grafana-plugin/src/containers/ScheduleIcalLink/ScheduleIcalLink.tsx index 2f71a05c94..111a68ed54 100644 --- a/grafana-plugin/src/containers/ScheduleIcalLink/ScheduleIcalLink.tsx +++ b/grafana-plugin/src/containers/ScheduleIcalLink/ScheduleIcalLink.tsx @@ -2,13 +2,13 @@ import React, { FC, useEffect, useState } from 'react'; import { Button, Icon, Label, LoadingPlaceholder, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { openNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; import { Text } from 'components/Text/Text'; import { CreateScheduleExportTokenResponse, Schedule } from 'models/schedule/schedule.types'; import { useStore } from 'state/useStore'; -import { openNotification } from 'utils/utils'; import styles from './ScheduleIcalLink.module.css'; diff --git a/grafana-plugin/src/containers/ScheduleSlot/ScheduleSlot.tsx b/grafana-plugin/src/containers/ScheduleSlot/ScheduleSlot.tsx index 8e0f8fb5b8..2cd9735092 100644 --- a/grafana-plugin/src/containers/ScheduleSlot/ScheduleSlot.tsx +++ b/grafana-plugin/src/containers/ScheduleSlot/ScheduleSlot.tsx @@ -4,6 +4,8 @@ import { css, cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, Icon, Tooltip, useStyles2, Stack } from '@grafana/ui'; import dayjs from 'dayjs'; +import { StackSize } from 'helpers/consts'; +import { truncateTitle } from 'helpers/string'; import { observer } from 'mobx-react'; import { Colors, getLabelCss } from 'styles/utils.styles'; @@ -17,8 +19,6 @@ import { Event, ScheduleView, ShiftSwap } from 'models/schedule/schedule.types'; import { getTzOffsetString } from 'models/timezone/timezone.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; -import { truncateTitle } from 'utils/string'; import { getScheduleSlotStyleParams, getTitle } from './ScheduleSlot.helpers'; diff --git a/grafana-plugin/src/containers/ServiceNowConfigDrawer/CompleteServiceNowConfigModal.tsx b/grafana-plugin/src/containers/ServiceNowConfigDrawer/CompleteServiceNowConfigModal.tsx index 20569cd8e5..d9e71d3053 100644 --- a/grafana-plugin/src/containers/ServiceNowConfigDrawer/CompleteServiceNowConfigModal.tsx +++ b/grafana-plugin/src/containers/ServiceNowConfigDrawer/CompleteServiceNowConfigModal.tsx @@ -3,13 +3,13 @@ import React, { useState } from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, Modal, Stack, useStyles2 } from '@grafana/ui'; +import { openNotification } from 'helpers/helpers'; +import { OmitReadonlyMembers } from 'helpers/types'; import { FormProvider, useForm } from 'react-hook-form'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useCurrentIntegration } from 'pages/integration/OutgoingTab/OutgoingTab.hooks'; import { useStore } from 'state/useStore'; -import { OmitReadonlyMembers } from 'utils/types'; -import { openNotification } from 'utils/utils'; import { getCommonServiceNowConfigStyles } from './ServiceNow.styles'; import { ServiceNowStatusSection } from './ServiceNowStatusSection'; diff --git a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx index ce2a7ae7f7..3f84bb6b64 100644 --- a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx +++ b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx @@ -2,6 +2,8 @@ import React, { forwardRef, useImperativeHandle, useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Alert, Button, LoadingPlaceholder, Stack, useStyles2 } from '@grafana/ui'; +import { INTEGRATION_SERVICENOW } from 'helpers/consts'; +import { OmitReadonlyMembers } from 'helpers/types'; import { observer } from 'mobx-react'; import { useFormContext } from 'react-hook-form'; @@ -11,8 +13,6 @@ import { IntegrationFormFields } from 'containers/IntegrationForm/IntegrationFor import { AlertReceiveChannelHelper } from 'models/alert_receive_channel/alert_receive_channel.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useCurrentIntegration } from 'pages/integration/OutgoingTab/OutgoingTab.hooks'; -import { INTEGRATION_SERVICENOW } from 'utils/consts'; -import { OmitReadonlyMembers } from 'utils/types'; import { getCommonServiceNowConfigStyles } from './ServiceNow.styles'; import { ServiceNowFormFields } from './ServiceNowStatusSection'; diff --git a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfig.helpers.ts b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfig.helpers.ts index d479942ef5..0b395bf07e 100644 --- a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfig.helpers.ts +++ b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfig.helpers.ts @@ -1,8 +1,8 @@ import { SelectableValue } from '@grafana/data'; +import { OnCallAGStatus } from 'helpers/consts'; import { UseFormGetValues } from 'react-hook-form'; import { AlertReceiveChannelStore } from 'models/alert_receive_channel/alert_receive_channel'; -import { OnCallAGStatus } from 'utils/consts'; import { ServiceNowFormFields } from './ServiceNowStatusSection'; diff --git a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfigDrawer.tsx b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfigDrawer.tsx index 4110a869cf..6ff772df1a 100644 --- a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfigDrawer.tsx +++ b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowConfigDrawer.tsx @@ -3,6 +3,10 @@ import React from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Drawer, Field, Input, useStyles2, Button, Stack } from '@grafana/ui'; +import { openNotification } from 'helpers/helpers'; +import { useIsLoading } from 'helpers/hooks'; +import { validateURL } from 'helpers/string'; +import { OmitReadonlyMembers } from 'helpers/types'; import { observer } from 'mobx-react'; import { Controller, FormProvider, useForm } from 'react-hook-form'; @@ -10,10 +14,6 @@ import { ActionKey } from 'models/loader/action-keys'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useCurrentIntegration } from 'pages/integration/OutgoingTab/OutgoingTab.hooks'; import { useStore } from 'state/useStore'; -import { useIsLoading } from 'utils/hooks'; -import { validateURL } from 'utils/string'; -import { OmitReadonlyMembers } from 'utils/types'; -import { openNotification } from 'utils/utils'; import { getCommonServiceNowConfigStyles } from './ServiceNow.styles'; import { ServiceNowAuthSection } from './ServiceNowAuthSection'; diff --git a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowStatusSection.tsx b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowStatusSection.tsx index 131319d42b..01fbfd2b4e 100644 --- a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowStatusSection.tsx +++ b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowStatusSection.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useReducer } from 'react'; import { SelectableValue } from '@grafana/data'; import { Select, SelectBaseProps, Stack } from '@grafana/ui'; +import { OnCallAGStatus, StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Controller, useFormContext } from 'react-hook-form'; @@ -9,7 +10,6 @@ import { Text } from 'components/Text/Text'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useCurrentIntegration } from 'pages/integration/OutgoingTab/OutgoingTab.hooks'; import { useStore } from 'state/useStore'; -import { OnCallAGStatus, StackSize } from 'utils/consts'; import { ServiceNowHelper } from './ServiceNowConfig.helpers'; diff --git a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowTokenSection.tsx b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowTokenSection.tsx index 7f1a7411f1..67aa8617c6 100644 --- a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowTokenSection.tsx +++ b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowTokenSection.tsx @@ -3,6 +3,8 @@ import React, { useEffect, useState } from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, Input, LoadingPlaceholder, Stack, useStyles2 } from '@grafana/ui'; +import { DOCS_ROOT, StackSize } from 'helpers/consts'; +import { useIsLoading } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { RenderConditionally } from 'components/RenderConditionally/RenderConditionally'; @@ -11,8 +13,6 @@ import { Text } from 'components/Text/Text'; import { AlertReceiveChannelHelper } from 'models/alert_receive_channel/alert_receive_channel.helpers'; import { ActionKey } from 'models/loader/action-keys'; import { useCurrentIntegration } from 'pages/integration/OutgoingTab/OutgoingTab.hooks'; -import { DOCS_ROOT, StackSize } from 'utils/consts'; -import { useIsLoading } from 'utils/hooks'; import { getCommonServiceNowConfigStyles } from './ServiceNow.styles'; diff --git a/grafana-plugin/src/containers/TeamsList/TeamsList.tsx b/grafana-plugin/src/containers/TeamsList/TeamsList.tsx index a780574d7e..8242780c2f 100644 --- a/grafana-plugin/src/containers/TeamsList/TeamsList.tsx +++ b/grafana-plugin/src/containers/TeamsList/TeamsList.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useState } from 'react'; import { Badge, Button, Field, Modal, RadioButtonList, Tooltip, Stack } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { Avatar } from 'components/Avatar/Avatar'; @@ -9,7 +10,6 @@ import { Text } from 'components/Text/Text'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { GrafanaTeam } from 'models/grafana_team/grafana_team.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; export const TeamsList = observer(() => { const store = useStore(); diff --git a/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx b/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx index 50c19963eb..513d44985c 100644 --- a/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx +++ b/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx @@ -2,6 +2,9 @@ import React, { useCallback, useState, useEffect } from 'react'; import { Button, Modal, Icon, Stack, Field, Input } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -9,9 +12,6 @@ import { Block } from 'components/GBlock/Block'; import { Text } from 'components/Text/Text'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; -import { openNotification } from 'utils/utils'; import styles from './TelegramIntegrationButton.module.css'; diff --git a/grafana-plugin/src/containers/TemplatePreview/TemplatePreview.tsx b/grafana-plugin/src/containers/TemplatePreview/TemplatePreview.tsx index 4ce1f76edb..d993af3398 100644 --- a/grafana-plugin/src/containers/TemplatePreview/TemplatePreview.tsx +++ b/grafana-plugin/src/containers/TemplatePreview/TemplatePreview.tsx @@ -2,6 +2,9 @@ import React, { useEffect, useState } from 'react'; import { Badge, Icon, LoadingPlaceholder, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { openErrorNotification } from 'helpers/helpers'; +import { useDebouncedCallback } from 'helpers/hooks'; +import { sanitize } from 'helpers/sanitize'; import { observer } from 'mobx-react'; import { Text } from 'components/Text/Text'; @@ -10,9 +13,6 @@ import { AlertGroupHelper } from 'models/alertgroup/alertgroup.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { LabelTemplateOptions } from 'pages/integration/IntegrationCommon.config'; import { useStore } from 'state/useStore'; -import { useDebouncedCallback } from 'utils/hooks'; -import { sanitize } from 'utils/sanitize'; -import { openErrorNotification } from 'utils/utils'; import styles from './TemplatePreview.module.css'; diff --git a/grafana-plugin/src/containers/TemplateResult/TemplateResult.tsx b/grafana-plugin/src/containers/TemplateResult/TemplateResult.tsx index e7746c4612..ac5538dfff 100644 --- a/grafana-plugin/src/containers/TemplateResult/TemplateResult.tsx +++ b/grafana-plugin/src/containers/TemplateResult/TemplateResult.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Button, Icon, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { TemplateForEdit } from 'components/AlertTemplates/CommonAlertTemplatesForm.config'; import { Block } from 'components/GBlock/Block'; @@ -9,7 +10,6 @@ import { Text } from 'components/Text/Text'; import styles from 'containers/IntegrationTemplate/IntegrationTemplate.module.scss'; import { TemplatePreview, TemplatePage } from 'containers/TemplatePreview/TemplatePreview'; import { ApiSchemas } from 'network/oncall-api/api.types'; -import { StackSize } from 'utils/consts'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/containers/UserDisplay/UserDisplayWithAvatar.tsx b/grafana-plugin/src/containers/UserDisplay/UserDisplayWithAvatar.tsx index e05344e35d..c48fda5edd 100644 --- a/grafana-plugin/src/containers/UserDisplay/UserDisplayWithAvatar.tsx +++ b/grafana-plugin/src/containers/UserDisplay/UserDisplayWithAvatar.tsx @@ -1,13 +1,13 @@ import React, { useEffect } from 'react'; import { Stack } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Avatar } from 'components/Avatar/Avatar'; import { Text } from 'components/Text/Text'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; interface UserDisplayProps { id: ApiSchemas['User']['pk']; diff --git a/grafana-plugin/src/containers/UserSettings/UserSettings.tsx b/grafana-plugin/src/containers/UserSettings/UserSettings.tsx index 25e63e715e..238467741f 100644 --- a/grafana-plugin/src/containers/UserSettings/UserSettings.tsx +++ b/grafana-plugin/src/containers/UserSettings/UserSettings.tsx @@ -2,6 +2,9 @@ import React, { useEffect, useState, useCallback } from 'react'; import { Alert, Modal, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { BREAKPOINT_TABS } from 'helpers/consts'; +import { useQueryParams } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { useMediaQuery } from 'react-responsive'; @@ -10,9 +13,6 @@ import { Tabs, TabsContent } from 'containers/UserSettings/parts/UserSettingsPar import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { BREAKPOINT_TABS } from 'utils/consts'; -import { useQueryParams } from 'utils/hooks'; import { UserSettingsTab } from './UserSettings.types'; diff --git a/grafana-plugin/src/containers/UserSettings/parts/UserSettingsParts.tsx b/grafana-plugin/src/containers/UserSettings/parts/UserSettingsParts.tsx index a6262e5852..d50b8e840c 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/UserSettingsParts.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/UserSettingsParts.tsx @@ -2,6 +2,7 @@ import React, { useCallback, useEffect } from 'react'; import { Tab, TabContent, TabsBar } from '@grafana/ui'; import cn from 'classnames/bind'; +import { isUseProfileExtensionPointEnabled } from 'helpers/helpers'; import { observer } from 'mobx-react'; import { Block } from 'components/GBlock/Block'; @@ -19,7 +20,6 @@ import { UserInfoTab } from 'containers/UserSettings/parts/tabs/UserInfoTab/User import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { isUseProfileExtensionPointEnabled } from 'utils/utils'; import styles from 'containers/UserSettings/parts/UserSettingsParts.module.css'; diff --git a/grafana-plugin/src/containers/UserSettings/parts/connectors/GoogleConnector.tsx b/grafana-plugin/src/containers/UserSettings/parts/connectors/GoogleConnector.tsx index 9f5b8f4442..29e9ebee15 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/connectors/GoogleConnector.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/connectors/GoogleConnector.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { Button, InlineField, Stack } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { WithConfirm } from 'components/WithConfirm/WithConfirm'; @@ -8,8 +10,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { UserHelper } from 'models/user/user.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; interface GoogleConnectorProps { id: ApiSchemas['User']['pk']; diff --git a/grafana-plugin/src/containers/UserSettings/parts/connectors/ICalConnector.tsx b/grafana-plugin/src/containers/UserSettings/parts/connectors/ICalConnector.tsx index 1782b0b1d2..459287919f 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/connectors/ICalConnector.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/connectors/ICalConnector.tsx @@ -1,6 +1,9 @@ import React, { useEffect, useState } from 'react'; import { Alert, Button, InlineField, Input, LoadingPlaceholder, Stack, Tooltip } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; import CopyToClipboard from 'react-copy-to-clipboard'; import { WithConfirm } from 'components/WithConfirm/WithConfirm'; @@ -8,9 +11,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { UserHelper } from 'models/user/user.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; -import { openNotification } from 'utils/utils'; // eslint-disable-next-line @typescript-eslint/naming-convention interface ICalConnectorProps { diff --git a/grafana-plugin/src/containers/UserSettings/parts/connectors/MSTeamsConnector.tsx b/grafana-plugin/src/containers/UserSettings/parts/connectors/MSTeamsConnector.tsx index 072c8afe48..9b1c437979 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/connectors/MSTeamsConnector.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/connectors/MSTeamsConnector.tsx @@ -2,13 +2,13 @@ import React, { useCallback } from 'react'; import { Button, InlineField, Input, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { WithConfirm } from 'components/WithConfirm/WithConfirm'; import { UserSettingsTab } from 'containers/UserSettings/UserSettings.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; import styles from 'containers/UserSettings/parts/connectors/Connectors.module.css'; diff --git a/grafana-plugin/src/containers/UserSettings/parts/connectors/PhoneConnector.tsx b/grafana-plugin/src/containers/UserSettings/parts/connectors/PhoneConnector.tsx index 8abe428460..877e68a91c 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/connectors/PhoneConnector.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/connectors/PhoneConnector.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from 'react'; import { Alert, Button, InlineField, Input, Stack, useTheme2 } from '@grafana/ui'; import cn from 'classnames/bind'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Tag } from 'components/Tag/Tag'; @@ -11,7 +12,6 @@ import { UserSettingsTab } from 'containers/UserSettings/UserSettings.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; import styles from 'containers/UserSettings/parts/UserSettingsParts.module.css'; diff --git a/grafana-plugin/src/containers/UserSettings/parts/connectors/SlackConnector.tsx b/grafana-plugin/src/containers/UserSettings/parts/connectors/SlackConnector.tsx index 742d8afb50..6c6917a049 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/connectors/SlackConnector.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/connectors/SlackConnector.tsx @@ -1,14 +1,14 @@ import React, { useCallback, useMemo } from 'react'; import { Button, InlineField, Input, Stack } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; +import { getPathFromQueryParams } from 'helpers/url'; import { observer } from 'mobx-react'; import { WithConfirm } from 'components/WithConfirm/WithConfirm'; import { UserSettingsTab } from 'containers/UserSettings/UserSettings.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; -import { getPathFromQueryParams } from 'utils/url'; interface SlackConnectorProps { id: ApiSchemas['User']['pk']; diff --git a/grafana-plugin/src/containers/UserSettings/parts/connectors/TelegramConnector.tsx b/grafana-plugin/src/containers/UserSettings/parts/connectors/TelegramConnector.tsx index 46cb91a19f..27d7191f21 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/connectors/TelegramConnector.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/connectors/TelegramConnector.tsx @@ -1,13 +1,13 @@ import React, { useCallback } from 'react'; import { Button, InlineField, Input, Stack } from '@grafana/ui'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { WithConfirm } from 'components/WithConfirm/WithConfirm'; import { UserSettingsTab } from 'containers/UserSettings/UserSettings.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { StackSize } from 'utils/consts'; interface TelegramConnectorProps { id: ApiSchemas['User']['pk']; diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/CloudPhoneSettings/CloudPhoneSettings.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/CloudPhoneSettings/CloudPhoneSettings.tsx index 43359ea164..c583f4c864 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/CloudPhoneSettings/CloudPhoneSettings.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/CloudPhoneSettings/CloudPhoneSettings.tsx @@ -1,6 +1,8 @@ import React, { useEffect, useState } from 'react'; import { Button, LoadingPlaceholder, Stack } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { PluginLink } from 'components/PluginLink/PluginLink'; @@ -10,8 +12,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { WithStoreProps } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; interface CloudPhoneSettingsProps extends WithStoreProps { userPk?: ApiSchemas['User']['pk']; diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/GoogleCalendar/GoogleCalendar.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/GoogleCalendar/GoogleCalendar.tsx index 53988ecc59..4cbd8ad2ae 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/GoogleCalendar/GoogleCalendar.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/GoogleCalendar/GoogleCalendar.tsx @@ -2,6 +2,8 @@ import React, { useEffect, useState } from 'react'; import { css } from '@emotion/css'; import { Button, Switch, Stack, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { DOCS_ROOT, StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { getUtilStyles } from 'styles/utils.styles'; @@ -15,8 +17,6 @@ import { Schedule } from 'models/schedule/schedule.types'; import { UserHelper } from 'models/user/user.helpers'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { DOCS_ROOT, StackSize } from 'utils/consts'; const GoogleCalendar: React.FC<{ id: ApiSchemas['User']['pk'] }> = observer(({ id }) => { const { diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/PhoneVerification/PhoneVerification.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/PhoneVerification/PhoneVerification.tsx index 13add81269..1a3dcd2792 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/PhoneVerification/PhoneVerification.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/PhoneVerification/PhoneVerification.tsx @@ -2,6 +2,9 @@ import React, { HTMLAttributes, useCallback, useRef, useReducer } from 'react'; import { Alert, Button, Field, Icon, Input, Switch, Tooltip, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { isUserActionAllowed, UserAction, UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; +import { useIsLoading } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { PluginLink } from 'components/PluginLink/PluginLink'; @@ -15,9 +18,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { rootStore } from 'state/rootStore'; import { useStore } from 'state/useStore'; -import { isUserActionAllowed, UserAction, UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; -import { useIsLoading } from 'utils/hooks'; import styles from './PhoneVerification.module.css'; 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 e14c7b2264..20489da2ad 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx @@ -2,14 +2,14 @@ import React, { useCallback } from 'react'; import { Button, Stack, Icon } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { DOCS_SLACK_SETUP, getPluginId, StackSize } from 'helpers/consts'; import { Block } from 'components/GBlock/Block'; import { Text } from 'components/Text/Text'; import { WithPermissionControlDisplay } from 'containers/WithPermissionControl/WithPermissionControlDisplay'; import { SlackNewIcon } from 'icons/Icons'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { DOCS_SLACK_SETUP, getPluginId, StackSize } from 'utils/consts'; import styles from './SlackTab.module.css'; diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx index 567ba82f39..4090c40b95 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx @@ -2,6 +2,9 @@ import React, { HTMLAttributes, useEffect, useState } from 'react'; import { Button, Icon, Stack, Field, Input } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { DOCS_TELEGRAM_SETUP, StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -13,9 +16,6 @@ import { TelegramColorIcon } from 'icons/Icons'; import { UserHelper } from 'models/user/user.helpers'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { DOCS_TELEGRAM_SETUP, StackSize } from 'utils/consts'; -import { openNotification } from 'utils/utils'; import styles from './TelegramInfo.module.css'; diff --git a/grafana-plugin/src/containers/UsersTimezones/ScheduleUserDetails/ScheduleUserDetails.tsx b/grafana-plugin/src/containers/UsersTimezones/ScheduleUserDetails/ScheduleUserDetails.tsx index bfb5e1ac0d..83610a6ec9 100644 --- a/grafana-plugin/src/containers/UsersTimezones/ScheduleUserDetails/ScheduleUserDetails.tsx +++ b/grafana-plugin/src/containers/UsersTimezones/ScheduleUserDetails/ScheduleUserDetails.tsx @@ -3,6 +3,8 @@ import React, { FC } from 'react'; import { Stack, Icon, Badge } from '@grafana/ui'; import cn from 'classnames/bind'; import dayjs from 'dayjs'; +import { isUserActionAllowed, UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Avatar } from 'components/Avatar/Avatar'; @@ -17,8 +19,6 @@ import { import { ApiSchemas } from 'network/oncall-api/api.types'; import { getColorSchemeMappingForUsers } from 'pages/schedule/Schedule.helpers'; import { useStore } from 'state/useStore'; -import { isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; import styles from './ScheduleUserDetails.module.css'; diff --git a/grafana-plugin/src/containers/WebhooksTemplateEditor/WebhooksTemplateEditor.tsx b/grafana-plugin/src/containers/WebhooksTemplateEditor/WebhooksTemplateEditor.tsx index 20921c56ef..60f7606384 100644 --- a/grafana-plugin/src/containers/WebhooksTemplateEditor/WebhooksTemplateEditor.tsx +++ b/grafana-plugin/src/containers/WebhooksTemplateEditor/WebhooksTemplateEditor.tsx @@ -2,6 +2,7 @@ import React, { useCallback, useState } from 'react'; import { Button, Drawer, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; import { debounce } from 'lodash-es'; import { CheatSheet } from 'components/CheatSheet/CheatSheet'; @@ -14,7 +15,6 @@ import { TemplateResult } from 'containers/TemplateResult/TemplateResult'; import { TemplatesAlertGroupsList } from 'containers/TemplatesAlertGroupsList/TemplatesAlertGroupsList'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { ApiSchemas } from 'network/oncall-api/api.types'; -import { UserActions } from 'utils/authorization/authorization'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlDisplay.tsx b/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlDisplay.tsx index 21335c8b54..6cb9a82666 100644 --- a/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlDisplay.tsx +++ b/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlDisplay.tsx @@ -1,10 +1,10 @@ import React, { ReactElement } from 'react'; import { Stack } from '@grafana/ui'; +import { isUserActionAllowed, UserAction } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { Text } from 'components/Text/Text'; -import { isUserActionAllowed, UserAction } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; interface WithPermissionControlDisplayProps { userAction: UserAction; diff --git a/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlTooltip.tsx b/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlTooltip.tsx index 846a279105..6a559618c3 100644 --- a/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlTooltip.tsx +++ b/grafana-plugin/src/containers/WithPermissionControl/WithPermissionControlTooltip.tsx @@ -2,10 +2,9 @@ import React, { ReactElement, useCallback } from 'react'; import { Tooltip } from '@grafana/ui'; import cn from 'classnames/bind'; +import { isUserActionAllowed, UserAction } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; -import { isUserActionAllowed, UserAction } from 'utils/authorization/authorization'; - import styles from './WithPermissionControlTooltip.module.css'; const cx = cn.bind(styles); diff --git a/grafana-plugin/src/utils/DOM.ts b/grafana-plugin/src/helpers/DOM.ts similarity index 100% rename from grafana-plugin/src/utils/DOM.ts rename to grafana-plugin/src/helpers/DOM.ts diff --git a/grafana-plugin/src/utils/LocationHelper.ts b/grafana-plugin/src/helpers/LocationHelper.ts similarity index 100% rename from grafana-plugin/src/utils/LocationHelper.ts rename to grafana-plugin/src/helpers/LocationHelper.ts diff --git a/grafana-plugin/src/utils/async.test.ts b/grafana-plugin/src/helpers/async.test.ts similarity index 100% rename from grafana-plugin/src/utils/async.test.ts rename to grafana-plugin/src/helpers/async.test.ts diff --git a/grafana-plugin/src/utils/async.ts b/grafana-plugin/src/helpers/async.ts similarity index 100% rename from grafana-plugin/src/utils/async.ts rename to grafana-plugin/src/helpers/async.ts diff --git a/grafana-plugin/src/utils/authorization/authorization.test.ts b/grafana-plugin/src/helpers/authorization/authorization.test.ts similarity index 98% rename from grafana-plugin/src/utils/authorization/authorization.test.ts rename to grafana-plugin/src/helpers/authorization/authorization.test.ts index c9c3d52dc4..753e4fd5c9 100644 --- a/grafana-plugin/src/utils/authorization/authorization.test.ts +++ b/grafana-plugin/src/helpers/authorization/authorization.test.ts @@ -1,8 +1,7 @@ import { OrgRole } from '@grafana/data'; import { config } from '@grafana/runtime'; import { contextSrv } from 'grafana/app/core/core'; - -import { getPluginId } from 'utils/consts'; +import { getPluginId } from 'helpers/consts'; import * as auth from './authorization'; diff --git a/grafana-plugin/src/utils/authorization/authorization.ts b/grafana-plugin/src/helpers/authorization/authorization.ts similarity index 99% rename from grafana-plugin/src/utils/authorization/authorization.ts rename to grafana-plugin/src/helpers/authorization/authorization.ts index 149a896273..4019e7a30a 100644 --- a/grafana-plugin/src/utils/authorization/authorization.ts +++ b/grafana-plugin/src/helpers/authorization/authorization.ts @@ -1,8 +1,7 @@ import { OrgRole } from '@grafana/data'; import { config } from '@grafana/runtime'; import { contextSrv } from 'grafana/app/core/core'; - -import { PluginId } from 'utils/consts'; +import { PluginId } from 'helpers/consts'; export type UserAction = { permission: string; diff --git a/grafana-plugin/src/utils/consts.ts b/grafana-plugin/src/helpers/consts.ts similarity index 98% rename from grafana-plugin/src/utils/consts.ts rename to grafana-plugin/src/helpers/consts.ts index 2aec11fbf2..d11503e097 100644 --- a/grafana-plugin/src/utils/consts.ts +++ b/grafana-plugin/src/helpers/consts.ts @@ -1,4 +1,4 @@ -import { OnCallAppPluginMeta } from 'types'; +import { OnCallAppPluginMeta } from 'app-types'; //@ts-ignore import plugin from '../../package.json'; // eslint-disable-line diff --git a/grafana-plugin/src/utils/datetime.test.ts b/grafana-plugin/src/helpers/datetime.test.ts similarity index 100% rename from grafana-plugin/src/utils/datetime.test.ts rename to grafana-plugin/src/helpers/datetime.test.ts diff --git a/grafana-plugin/src/utils/datetime.ts b/grafana-plugin/src/helpers/datetime.ts similarity index 100% rename from grafana-plugin/src/utils/datetime.ts rename to grafana-plugin/src/helpers/datetime.ts diff --git a/grafana-plugin/src/utils/decorators.ts b/grafana-plugin/src/helpers/decorators.ts similarity index 98% rename from grafana-plugin/src/utils/decorators.ts rename to grafana-plugin/src/helpers/decorators.ts index c1d10a751a..8ebb865fbf 100644 --- a/grafana-plugin/src/utils/decorators.ts +++ b/grafana-plugin/src/helpers/decorators.ts @@ -1,5 +1,6 @@ +import { openErrorNotification, openNotification, openWarningNotification } from 'helpers/helpers'; + import { LoaderStore } from 'models/loader/loader'; -import { openErrorNotification, openNotification, openWarningNotification } from 'utils/utils'; export function AutoLoadingState(actionKey: string) { return function (_target: object, _key: string, descriptor: PropertyDescriptor) { diff --git a/grafana-plugin/src/utils/faro.test.tsx b/grafana-plugin/src/helpers/faro.test.tsx similarity index 97% rename from grafana-plugin/src/utils/faro.test.tsx rename to grafana-plugin/src/helpers/faro.test.tsx index bf0f697699..f9e8a56e9d 100644 --- a/grafana-plugin/src/utils/faro.test.tsx +++ b/grafana-plugin/src/helpers/faro.test.tsx @@ -1,7 +1,6 @@ import 'jest/matchMedia'; import { describe, test } from '@jest/globals'; - -import { FaroHelper } from 'utils/faro'; +import { FaroHelper } from 'helpers/faro'; import '@testing-library/jest-dom'; import { ONCALL_DEV, ONCALL_OPS, ONCALL_PROD } from './consts'; diff --git a/grafana-plugin/src/utils/faro.ts b/grafana-plugin/src/helpers/faro.ts similarity index 100% rename from grafana-plugin/src/utils/faro.ts rename to grafana-plugin/src/helpers/faro.ts diff --git a/grafana-plugin/src/utils/utils.test.ts b/grafana-plugin/src/helpers/helpers.test.ts similarity index 98% rename from grafana-plugin/src/utils/utils.test.ts rename to grafana-plugin/src/helpers/helpers.test.ts index 0accc9164d..bed4aac3a8 100644 --- a/grafana-plugin/src/utils/utils.test.ts +++ b/grafana-plugin/src/helpers/helpers.test.ts @@ -1,6 +1,5 @@ import * as runtime from '@grafana/runtime'; - -import { getGrafanaVersion, isCurrentGrafanaVersionEqualOrGreaterThan } from 'utils/utils'; +import { getGrafanaVersion, isCurrentGrafanaVersionEqualOrGreaterThan } from 'helpers/helpers'; jest.mock('@grafana/runtime', () => ({ config: jest.fn(), diff --git a/grafana-plugin/src/utils/utils.ts b/grafana-plugin/src/helpers/helpers.ts similarity index 100% rename from grafana-plugin/src/utils/utils.ts rename to grafana-plugin/src/helpers/helpers.ts diff --git a/grafana-plugin/src/utils/hoc.tsx b/grafana-plugin/src/helpers/hoc.tsx similarity index 100% rename from grafana-plugin/src/utils/hoc.tsx rename to grafana-plugin/src/helpers/hoc.tsx diff --git a/grafana-plugin/src/utils/hooks.tsx b/grafana-plugin/src/helpers/hooks.tsx similarity index 100% rename from grafana-plugin/src/utils/hooks.tsx rename to grafana-plugin/src/helpers/hooks.tsx diff --git a/grafana-plugin/src/utils/loadJs.ts b/grafana-plugin/src/helpers/loadJs.ts similarity index 100% rename from grafana-plugin/src/utils/loadJs.ts rename to grafana-plugin/src/helpers/loadJs.ts diff --git a/grafana-plugin/src/utils/localStorage.ts b/grafana-plugin/src/helpers/localStorage.ts similarity index 100% rename from grafana-plugin/src/utils/localStorage.ts rename to grafana-plugin/src/helpers/localStorage.ts diff --git a/grafana-plugin/src/utils/sanitize.ts b/grafana-plugin/src/helpers/sanitize.ts similarity index 100% rename from grafana-plugin/src/utils/sanitize.ts rename to grafana-plugin/src/helpers/sanitize.ts diff --git a/grafana-plugin/src/utils/string.ts b/grafana-plugin/src/helpers/string.ts similarity index 100% rename from grafana-plugin/src/utils/string.ts rename to grafana-plugin/src/helpers/string.ts diff --git a/grafana-plugin/src/utils/styles.ts b/grafana-plugin/src/helpers/styles.ts similarity index 100% rename from grafana-plugin/src/utils/styles.ts rename to grafana-plugin/src/helpers/styles.ts diff --git a/grafana-plugin/src/utils/types.ts b/grafana-plugin/src/helpers/types.ts similarity index 100% rename from grafana-plugin/src/utils/types.ts rename to grafana-plugin/src/helpers/types.ts diff --git a/grafana-plugin/src/utils/url.ts b/grafana-plugin/src/helpers/url.ts similarity index 100% rename from grafana-plugin/src/utils/url.ts rename to grafana-plugin/src/helpers/url.ts diff --git a/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts b/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts index c920b0090c..298fb56432 100644 --- a/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts +++ b/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts @@ -1,3 +1,7 @@ +import { AutoLoadingState, WithGlobalNotification } from 'helpers/decorators'; +import { showApiError } from 'helpers/helpers'; +import { OmitReadonlyMembers } from 'helpers/types'; + import { ChannelFilter } from 'models/channel_filter/channel_filter.types'; import { GrafanaTeam } from 'models/grafana_team/grafana_team.types'; import { ActionKey } from 'models/loader/action-keys'; @@ -5,9 +9,6 @@ import { makeRequest } from 'network/network'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { onCallApi } from 'network/oncall-api/http-client'; import { SelectOption } from 'state/types'; -import { AutoLoadingState, WithGlobalNotification } from 'utils/decorators'; -import { OmitReadonlyMembers } from 'utils/types'; -import { showApiError } from 'utils/utils'; import { AlertReceiveChannelStore } from './alert_receive_channel'; import { MaintenanceMode } from './alert_receive_channel.types'; diff --git a/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.ts b/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.ts index 4173e8b701..bf17bfb8b0 100644 --- a/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.ts +++ b/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.ts @@ -1,3 +1,5 @@ +import { AutoLoadingState, WithGlobalNotification } from 'helpers/decorators'; +import { OmitReadonlyMembers } from 'helpers/types'; import { omit } from 'lodash-es'; import { runInAction, makeAutoObservable } from 'mobx'; @@ -11,8 +13,6 @@ import { operations } from 'network/oncall-api/autogenerated-api.types'; import { onCallApi } from 'network/oncall-api/http-client'; import { move } from 'state/helpers'; import { RootBaseStore } from 'state/rootBaseStore/RootBaseStore'; -import { AutoLoadingState, WithGlobalNotification } from 'utils/decorators'; -import { OmitReadonlyMembers } from 'utils/types'; import { AlertReceiveChannelCounters, ContactPoint } from './alert_receive_channel.types'; diff --git a/grafana-plugin/src/models/alert_receive_channel_connected_channels/alert_receive_channel_connected_channels.ts b/grafana-plugin/src/models/alert_receive_channel_connected_channels/alert_receive_channel_connected_channels.ts index e5e0dab87c..1eaf46e80c 100644 --- a/grafana-plugin/src/models/alert_receive_channel_connected_channels/alert_receive_channel_connected_channels.ts +++ b/grafana-plugin/src/models/alert_receive_channel_connected_channels/alert_receive_channel_connected_channels.ts @@ -1,3 +1,4 @@ +import { AutoLoadingState } from 'helpers/decorators'; import { keyBy } from 'lodash-es'; import { makeAutoObservable, runInAction } from 'mobx'; @@ -5,7 +6,6 @@ import { ActionKey } from 'models/loader/action-keys'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { onCallApi } from 'network/oncall-api/http-client'; import { RootBaseStore } from 'state/rootBaseStore/RootBaseStore'; -import { AutoLoadingState } from 'utils/decorators'; export class AlertReceiveChannelConnectedChannelsStore { rootStore: RootBaseStore; diff --git a/grafana-plugin/src/models/alert_receive_channel_webhooks/alert_receive_channel_webhooks.ts b/grafana-plugin/src/models/alert_receive_channel_webhooks/alert_receive_channel_webhooks.ts index ce01395ae9..9d85ca62cb 100644 --- a/grafana-plugin/src/models/alert_receive_channel_webhooks/alert_receive_channel_webhooks.ts +++ b/grafana-plugin/src/models/alert_receive_channel_webhooks/alert_receive_channel_webhooks.ts @@ -1,11 +1,11 @@ +import { WithGlobalNotification } from 'helpers/decorators'; +import { OmitReadonlyMembers } from 'helpers/types'; import { keyBy } from 'lodash-es'; import { makeAutoObservable, runInAction } from 'mobx'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { onCallApi } from 'network/oncall-api/http-client'; import { RootBaseStore } from 'state/rootBaseStore/RootBaseStore'; -import { WithGlobalNotification } from 'utils/decorators'; -import { OmitReadonlyMembers } from 'utils/types'; export class AlertReceiveChannelWebhooksStore { rootStore: RootBaseStore; diff --git a/grafana-plugin/src/models/alertgroup/alertgroup.helpers.ts b/grafana-plugin/src/models/alertgroup/alertgroup.helpers.ts index 72a9d45000..7fa206a8c2 100644 --- a/grafana-plugin/src/models/alertgroup/alertgroup.helpers.ts +++ b/grafana-plugin/src/models/alertgroup/alertgroup.helpers.ts @@ -1,9 +1,10 @@ +import { AutoLoadingState } from 'helpers/decorators'; + import { ActionKey } from 'models/loader/action-keys'; import { makeRequest } from 'network/network'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { components } from 'network/oncall-api/autogenerated-api.types'; import { onCallApi } from 'network/oncall-api/http-client'; -import { AutoLoadingState } from 'utils/decorators'; import { AlertGroupStore } from './alertgroup'; diff --git a/grafana-plugin/src/models/alertgroup/alertgroup.ts b/grafana-plugin/src/models/alertgroup/alertgroup.ts index bc22ed4bd7..5f3619a182 100644 --- a/grafana-plugin/src/models/alertgroup/alertgroup.ts +++ b/grafana-plugin/src/models/alertgroup/alertgroup.ts @@ -1,3 +1,6 @@ +import { LocationHelper } from 'helpers/LocationHelper'; +import { GENERIC_ERROR, PAGE, PROCESSING_REQUEST_ERROR } from 'helpers/consts'; +import { AutoLoadingState, WithGlobalNotification } from 'helpers/decorators'; import { runInAction, makeAutoObservable } from 'mobx'; import qs from 'query-string'; @@ -8,9 +11,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { onCallApi } from 'network/oncall-api/http-client'; import { RootStore } from 'state/rootStore'; import { SelectOption } from 'state/types'; -import { LocationHelper } from 'utils/LocationHelper'; -import { GENERIC_ERROR, PAGE, PROCESSING_REQUEST_ERROR } from 'utils/consts'; -import { AutoLoadingState, WithGlobalNotification } from 'utils/decorators'; import { AlertGroupHelper } from './alertgroup.helpers'; import { AlertGroupColumn, AlertAction, IncidentStatus } from './alertgroup.types'; diff --git a/grafana-plugin/src/models/base_store.ts b/grafana-plugin/src/models/base_store.ts index b3dc76fe00..47b036b6f1 100644 --- a/grafana-plugin/src/models/base_store.ts +++ b/grafana-plugin/src/models/base_store.ts @@ -1,9 +1,9 @@ import { sentenceCase } from 'change-case'; +import { openWarningNotification } from 'helpers/helpers'; import { action } from 'mobx'; import { makeRequest } from 'network/network'; import { RootStore } from 'state/rootStore'; -import { openWarningNotification } from 'utils/utils'; export class BaseStore { protected rootStore: RootStore; diff --git a/grafana-plugin/src/models/filters/filters.helpers.ts b/grafana-plugin/src/models/filters/filters.helpers.ts index 531055a6b9..f4ffc7908e 100644 --- a/grafana-plugin/src/models/filters/filters.helpers.ts +++ b/grafana-plugin/src/models/filters/filters.helpers.ts @@ -1,4 +1,4 @@ -import { convertRelativeToAbsoluteDate } from 'utils/datetime'; +import { convertRelativeToAbsoluteDate } from 'helpers/datetime'; import { FilterOption, FiltersValues } from './filters.types'; diff --git a/grafana-plugin/src/models/filters/filters.ts b/grafana-plugin/src/models/filters/filters.ts index dd452dcb64..4bbdf3c17e 100644 --- a/grafana-plugin/src/models/filters/filters.ts +++ b/grafana-plugin/src/models/filters/filters.ts @@ -1,12 +1,12 @@ +import { LocationHelper } from 'helpers/LocationHelper'; +import { PAGE } from 'helpers/consts'; +import { getItem, setItem } from 'helpers/localStorage'; import { action, observable, makeObservable, runInAction } from 'mobx'; import { BaseStore } from 'models/base_store'; import { LabelKeyValue } from 'models/label/label.types'; import { makeRequest } from 'network/network'; import { RootStore } from 'state/rootStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { PAGE } from 'utils/consts'; -import { getItem, setItem } from 'utils/localStorage'; import { getApiPathByPage } from './filters.helpers'; import { FilterOption, FiltersValues } from './filters.types'; diff --git a/grafana-plugin/src/models/heartbeat/heartbeat.ts b/grafana-plugin/src/models/heartbeat/heartbeat.ts index a102973ada..987a214a07 100644 --- a/grafana-plugin/src/models/heartbeat/heartbeat.ts +++ b/grafana-plugin/src/models/heartbeat/heartbeat.ts @@ -1,10 +1,10 @@ +import { WithGlobalNotification } from 'helpers/decorators'; import { action, observable, makeObservable, runInAction } from 'mobx'; import { BaseStore } from 'models/base_store'; import { makeRequest } from 'network/network'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { RootStore } from 'state/rootStore'; -import { WithGlobalNotification } from 'utils/decorators'; import { Heartbeat } from './heartbeat.types'; diff --git a/grafana-plugin/src/models/label/label.ts b/grafana-plugin/src/models/label/label.ts index 7559632ac8..d723626627 100644 --- a/grafana-plugin/src/models/label/label.ts +++ b/grafana-plugin/src/models/label/label.ts @@ -1,3 +1,5 @@ +import { PROCESSING_REQUEST_ERROR } from 'helpers/consts'; +import { WithGlobalNotification } from 'helpers/decorators'; import { action, makeObservable } from 'mobx'; import { BaseStore } from 'models/base_store'; @@ -6,8 +8,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { components } from 'network/oncall-api/autogenerated-api.types'; import { onCallApi } from 'network/oncall-api/http-client'; import { RootStore } from 'state/rootStore'; -import { PROCESSING_REQUEST_ERROR } from 'utils/consts'; -import { WithGlobalNotification } from 'utils/decorators'; export class LabelStore extends BaseStore { constructor(rootStore: RootStore) { diff --git a/grafana-plugin/src/models/outgoing_webhook/outgoing_webhook.types.ts b/grafana-plugin/src/models/outgoing_webhook/outgoing_webhook.types.ts index a063bb1066..661404ef5b 100644 --- a/grafana-plugin/src/models/outgoing_webhook/outgoing_webhook.types.ts +++ b/grafana-plugin/src/models/outgoing_webhook/outgoing_webhook.types.ts @@ -1,4 +1,4 @@ -import { KeyValuePair } from 'utils/utils'; +import { KeyValuePair } from 'helpers/helpers'; export interface OutgoingWebhookResponse { timestamp: string; diff --git a/grafana-plugin/src/models/plugin/plugin.ts b/grafana-plugin/src/models/plugin/plugin.ts index c8ffe32d60..db18373973 100644 --- a/grafana-plugin/src/models/plugin/plugin.ts +++ b/grafana-plugin/src/models/plugin/plugin.ts @@ -1,14 +1,14 @@ +import { OnCallPluginMetaJSONData } from 'app-types'; +import { waitInMs } from 'helpers/async'; +import { AutoLoadingState } from 'helpers/decorators'; import { isEqual } from 'lodash-es'; import { makeAutoObservable, runInAction } from 'mobx'; -import { OnCallPluginMetaJSONData } from 'types'; import { ActionKey } from 'models/loader/action-keys'; import { GrafanaApiClient } from 'network/grafana-api/http-client'; import { makeRequest } from 'network/network'; import { PluginConnection, StatusResponse } from 'network/oncall-api/api.types'; import { RootBaseStore } from 'state/rootBaseStore/RootBaseStore'; -import { waitInMs } from 'utils/async'; -import { AutoLoadingState } from 'utils/decorators'; import { PluginHelper } from './plugin.helper'; diff --git a/grafana-plugin/src/models/schedule/schedule.ts b/grafana-plugin/src/models/schedule/schedule.ts index d44469042f..520338a77a 100644 --- a/grafana-plugin/src/models/schedule/schedule.ts +++ b/grafana-plugin/src/models/schedule/schedule.ts @@ -1,4 +1,5 @@ import dayjs from 'dayjs'; +import { AutoLoadingState } from 'helpers/decorators'; import { action, makeObservable, observable, runInAction } from 'mobx'; import { PageErrorData } from 'components/PageErrorHandlingWrapper/PageErrorHandlingWrapper'; @@ -11,7 +12,6 @@ import { makeRequest } from 'network/network'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { RootStore } from 'state/rootStore'; import { SelectOption } from 'state/types'; -import { AutoLoadingState } from 'utils/decorators'; import { createShiftSwapEventFromShiftSwap, diff --git a/grafana-plugin/src/models/slack/slack.ts b/grafana-plugin/src/models/slack/slack.ts index 6a4b6ce82d..20aa19689b 100644 --- a/grafana-plugin/src/models/slack/slack.ts +++ b/grafana-plugin/src/models/slack/slack.ts @@ -1,11 +1,11 @@ +import { GENERIC_ERROR } from 'helpers/consts'; +import { openErrorNotification } from 'helpers/helpers'; import { action, observable, makeObservable, runInAction } from 'mobx'; import { BaseStore } from 'models/base_store'; import { SlackChannel } from 'models/slack_channel/slack_channel.types'; import { makeRequest, makeRequestRaw } from 'network/network'; import { RootStore } from 'state/rootStore'; -import { GENERIC_ERROR } from 'utils/consts'; -import { openErrorNotification } from 'utils/utils'; import { SlackSettings } from './slack.types'; diff --git a/grafana-plugin/src/models/user/user.helpers.tsx b/grafana-plugin/src/models/user/user.helpers.tsx index fecb1db2c6..7f02e2cf70 100644 --- a/grafana-plugin/src/models/user/user.helpers.tsx +++ b/grafana-plugin/src/models/user/user.helpers.tsx @@ -1,10 +1,10 @@ import React from 'react'; +import { throttlingError } from 'helpers/helpers'; import { pick } from 'lodash-es'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { onCallApi } from 'network/oncall-api/http-client'; -import { throttlingError } from 'utils/utils'; import { UserStore } from './user'; diff --git a/grafana-plugin/src/models/user/user.ts b/grafana-plugin/src/models/user/user.ts index d18f4d7762..7f905ea728 100644 --- a/grafana-plugin/src/models/user/user.ts +++ b/grafana-plugin/src/models/user/user.ts @@ -1,5 +1,7 @@ import { config } from '@grafana/runtime'; import dayjs from 'dayjs'; +import { isUserActionAllowed, UserActions } from 'helpers/authorization/authorization'; +import { AutoLoadingState } from 'helpers/decorators'; import { get } from 'lodash-es'; import { action, computed, runInAction, makeAutoObservable } from 'mobx'; @@ -10,8 +12,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { onCallApi } from 'network/oncall-api/http-client'; import { move } from 'state/helpers'; import { RootStore } from 'state/rootStore'; -import { isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; -import { AutoLoadingState } from 'utils/decorators'; import { UserHelper } from './user.helpers'; diff --git a/grafana-plugin/src/module.ts b/grafana-plugin/src/module.ts index 8a36c224f9..f73db2ac20 100644 --- a/grafana-plugin/src/module.ts +++ b/grafana-plugin/src/module.ts @@ -1,14 +1,14 @@ import { ComponentClass } from 'react'; import { AppPlugin, PluginExtensionPoints } from '@grafana/data'; +import { IRM_TAB } from 'helpers/consts'; +import { isCurrentGrafanaVersionEqualOrGreaterThan } from 'helpers/helpers'; import { MobileAppConnectionWrapper } from 'containers/MobileAppConnection/MobileAppConnection'; import { PluginConfigPage } from 'containers/PluginConfigPage/PluginConfigPage'; import { GrafanaPluginRootPage } from 'plugin/GrafanaPluginRootPage'; -import { IRM_TAB } from 'utils/consts'; -import { isCurrentGrafanaVersionEqualOrGreaterThan } from 'utils/utils'; -import { OnCallPluginConfigPageProps, OnCallPluginMetaJSONData } from './types'; +import { OnCallPluginConfigPageProps, OnCallPluginMetaJSONData } from './app-types'; const plugin = new AppPlugin().setRootPage(GrafanaPluginRootPage).addConfigPage({ title: 'Configuration', diff --git a/grafana-plugin/src/navbar/Header/Header.tsx b/grafana-plugin/src/navbar/Header/Header.tsx index e501e06c56..d69837c8d6 100644 --- a/grafana-plugin/src/navbar/Header/Header.tsx +++ b/grafana-plugin/src/navbar/Header/Header.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { cx } from '@emotion/css'; import { Card, Stack, useStyles2 } from '@grafana/ui'; +import { APP_SUBTITLE } from 'helpers/consts'; import { observer } from 'mobx-react'; import gitHubStarSVG from 'assets/img/github_star.svg'; @@ -9,7 +10,6 @@ import logo from 'assets/img/logo.svg'; import { Alerts } from 'containers/Alerts/Alerts'; import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; import { useStore } from 'state/useStore'; -import { APP_SUBTITLE } from 'utils/consts'; import { getHeaderStyles } from './Header.styles'; diff --git a/grafana-plugin/src/network/grafana-api/api.types.d.ts b/grafana-plugin/src/network/grafana-api/api.types.d.ts index 918bef67b6..fcc75ba8a0 100644 --- a/grafana-plugin/src/network/grafana-api/api.types.d.ts +++ b/grafana-plugin/src/network/grafana-api/api.types.d.ts @@ -1,4 +1,4 @@ -import { OnCallPluginMetaJSONData, OnCallPluginMetaSecureJSONData } from 'types'; +import { OnCallPluginMetaJSONData, OnCallPluginMetaSecureJSONData } from 'app-types'; export type ServiceAccountDTO = { description: string; diff --git a/grafana-plugin/src/network/grafana-api/http-client.ts b/grafana-plugin/src/network/grafana-api/http-client.ts index e4173c3303..d0ff66f492 100644 --- a/grafana-plugin/src/network/grafana-api/http-client.ts +++ b/grafana-plugin/src/network/grafana-api/http-client.ts @@ -1,7 +1,6 @@ import { getBackendSrv } from '@grafana/runtime'; -import { OnCallPluginMetaJSONData } from 'types'; - -import { getPluginId } from 'utils/consts'; +import { OnCallPluginMetaJSONData } from 'app-types'; +import { getPluginId, PluginId } from 'helpers/consts'; import { ApiAuthKeyDTO, @@ -12,18 +11,26 @@ import { UpdateGrafanaPluginSettingsProps, } from './api.types'; +const pluginId = getPluginId(); +const KEY_NAME = { + [PluginId.OnCall]: 'OnCall', + [PluginId.Irm]: 'IRM', +}[pluginId]; +const SERVICE_ACCOUNT_NAME = { + [PluginId.OnCall]: 'sa-autogen-OnCall', + [PluginId.Irm]: 'sa-autogen-IRM', +}[pluginId]; + const KEYS_BASE_URL = '/api/auth/keys'; const SERVICE_ACCOUNTS_BASE_URL = '/api/serviceaccounts'; -const ONCALL_KEY_NAME = 'OnCall'; -const ONCALL_SERVICE_ACCOUNT_NAME = 'sa-autogen-OnCall'; -const GRAFANA_PLUGIN_SETTINGS_URL = `/api/plugins/${getPluginId()}/settings`; +const GRAFANA_PLUGIN_SETTINGS_URL = `/api/plugins/${pluginId}/settings`; export class GrafanaApiClient { static grafanaBackend = getBackendSrv(); private static getServiceAccount = async () => { const serviceAccounts = await this.grafanaBackend.get( - `${SERVICE_ACCOUNTS_BASE_URL}/search?query=${ONCALL_SERVICE_ACCOUNT_NAME}` + `${SERVICE_ACCOUNTS_BASE_URL}/search?query=${SERVICE_ACCOUNT_NAME}` ); return serviceAccounts.serviceAccounts.length > 0 ? serviceAccounts.serviceAccounts[0] : null; }; @@ -35,7 +42,7 @@ export class GrafanaApiClient { } return await this.grafanaBackend.post(SERVICE_ACCOUNTS_BASE_URL, { - name: ONCALL_SERVICE_ACCOUNT_NAME, + name: SERVICE_ACCOUNT_NAME, role: 'Admin', isDisabled: false, }); @@ -45,7 +52,7 @@ export class GrafanaApiClient { const tokens = await this.grafanaBackend.get( `${SERVICE_ACCOUNTS_BASE_URL}/${serviceAccount.id}/tokens` ); - return tokens.find(({ name }) => name === ONCALL_KEY_NAME); + return tokens.find(({ name }) => name === KEY_NAME); }; private static getGrafanaToken = async () => { @@ -55,7 +62,7 @@ export class GrafanaApiClient { } const keys = await this.grafanaBackend.get(KEYS_BASE_URL); - return keys.find(({ name }) => name === ONCALL_KEY_NAME); + return keys.find(({ name }) => name === KEY_NAME); }; static updateGrafanaPluginSettings = async (data: UpdateGrafanaPluginSettingsProps, enabled = true) => @@ -80,7 +87,7 @@ export class GrafanaApiClient { const { key: grafanaToken } = await this.grafanaBackend.post( `${SERVICE_ACCOUNTS_BASE_URL}/${serviceAccount.id}/tokens`, { - name: ONCALL_KEY_NAME, + name: KEY_NAME, role: 'Admin', } ); diff --git a/grafana-plugin/src/network/network.ts b/grafana-plugin/src/network/network.ts index f111126f17..6f92684548 100644 --- a/grafana-plugin/src/network/network.ts +++ b/grafana-plugin/src/network/network.ts @@ -1,10 +1,9 @@ import axios, { AxiosError } from 'axios'; +import { getOnCallApiPath } from 'helpers/consts'; +import { FaroHelper } from 'helpers/faro'; +import { safeJSONStringify } from 'helpers/string'; import qs from 'query-string'; -import { getOnCallApiPath } from 'utils/consts'; -import { FaroHelper } from 'utils/faro'; -import { safeJSONStringify } from 'utils/string'; - const instance = axios.create(); instance.interceptors.request.use(function (config) { diff --git a/grafana-plugin/src/network/oncall-api/http-client.test.ts b/grafana-plugin/src/network/oncall-api/http-client.test.ts index fda1430220..fd910e0730 100644 --- a/grafana-plugin/src/network/oncall-api/http-client.test.ts +++ b/grafana-plugin/src/network/oncall-api/http-client.test.ts @@ -1,8 +1,8 @@ -import { FaroHelper } from 'utils/faro'; +import { FaroHelper } from 'helpers/faro'; import { getCustomFetchFn } from './http-client'; -jest.mock('utils/faro', () => ({ +jest.mock('helpers/faro', () => ({ __esModule: true, FaroHelper: { diff --git a/grafana-plugin/src/network/oncall-api/http-client.ts b/grafana-plugin/src/network/oncall-api/http-client.ts index ab08d3ac76..795718f2bf 100644 --- a/grafana-plugin/src/network/oncall-api/http-client.ts +++ b/grafana-plugin/src/network/oncall-api/http-client.ts @@ -1,11 +1,10 @@ +import { getOnCallApiPath } from 'helpers/consts'; +import { FaroHelper } from 'helpers/faro'; +import { formatBackendError, openErrorNotification } from 'helpers/helpers'; +import { safeJSONStringify } from 'helpers/string'; import createClient from 'openapi-fetch'; import qs from 'query-string'; -import { getOnCallApiPath } from 'utils/consts'; -import { FaroHelper } from 'utils/faro'; -import { safeJSONStringify } from 'utils/string'; -import { formatBackendError, openErrorNotification } from 'utils/utils'; - import { paths } from './autogenerated-api.types'; const showApiError = (status: number, errorData: string | Record) => { diff --git a/grafana-plugin/src/pages/NoMatch.tsx b/grafana-plugin/src/pages/NoMatch.tsx index 414c9fd0ac..fc861c9baf 100644 --- a/grafana-plugin/src/pages/NoMatch.tsx +++ b/grafana-plugin/src/pages/NoMatch.tsx @@ -1,11 +1,10 @@ import React, { useEffect, useMemo } from 'react'; +import { DEFAULT_PAGE, PLUGIN_ROOT } from 'helpers/consts'; +import { getPathFromQueryParams } from 'helpers/url'; import qs from 'query-string'; import { useNavigate } from 'react-router-dom-v5-compat'; -import { DEFAULT_PAGE, PLUGIN_ROOT } from 'utils/consts'; -import { getPathFromQueryParams } from 'utils/url'; - export const NoMatch = () => { const navigate = useNavigate(); diff --git a/grafana-plugin/src/pages/escalation-chains/EscalationChains.tsx b/grafana-plugin/src/pages/escalation-chains/EscalationChains.tsx index ee13ac1bc7..883fefe808 100644 --- a/grafana-plugin/src/pages/escalation-chains/EscalationChains.tsx +++ b/grafana-plugin/src/pages/escalation-chains/EscalationChains.tsx @@ -2,6 +2,9 @@ import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, Icon, IconButton, Tooltip, Stack, withTheme2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { PAGE, PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; import { observer } from 'mobx-react'; import { getUtilStyles } from 'styles/utils.styles'; @@ -27,9 +30,6 @@ import { EscalationChain } from 'models/escalation_chain/escalation_chain.types' import { FiltersValues } from 'models/filters/filters.types'; import { PageProps, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { PAGE, PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; import { getEscalationChainStyles } from './EscalationChains.styles'; diff --git a/grafana-plugin/src/pages/incident/Incident.helpers.tsx b/grafana-plugin/src/pages/incident/Incident.helpers.tsx index a3925429a1..b52ba753b5 100644 --- a/grafana-plugin/src/pages/incident/Incident.helpers.tsx +++ b/grafana-plugin/src/pages/incident/Incident.helpers.tsx @@ -2,6 +2,8 @@ import React from 'react'; import { css, cx } from '@emotion/css'; import { Button, IconButton, Tooltip, Stack, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; import { getUtilStyles } from 'styles/utils.styles'; import { Avatar } from 'components/Avatar/Avatar'; @@ -13,8 +15,6 @@ import { IncidentStatus } from 'models/alertgroup/alertgroup.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { SilenceSelect } from 'pages/incidents/parts/SilenceSelect'; import { move } from 'state/helpers'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; export const IncidentRelatedUsers = (props: { incident: ApiSchemas['AlertGroup']; isFull: boolean }) => { const { incident, isFull } = props; diff --git a/grafana-plugin/src/pages/incident/Incident.tsx b/grafana-plugin/src/pages/incident/Incident.tsx index aa4a577298..bedd93687b 100644 --- a/grafana-plugin/src/pages/incident/Incident.tsx +++ b/grafana-plugin/src/pages/incident/Incident.tsx @@ -19,13 +19,19 @@ import { withTheme2, useStyles2, } from '@grafana/ui'; +import { OnCallPluginExtensionPoints } from 'app-types'; +import { UserActions } from 'helpers/authorization/authorization'; +import { INTEGRATION_SERVICENOW, PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; +import { sanitize } from 'helpers/sanitize'; +import { parseURL } from 'helpers/url'; import Linkify from 'linkify-react'; import { observer } from 'mobx-react'; import moment from 'moment-timezone'; import CopyToClipboard from 'react-copy-to-clipboard'; import Emoji from 'react-emoji-render'; import reactStringReplace from 'react-string-replace'; -import { OnCallPluginExtensionPoints } from 'types'; import { Collapse } from 'components/Collapse/Collapse'; import { ExtensionLinkDropdown } from 'components/ExtensionLinkMenu/ExtensionLinkDropdown'; @@ -59,12 +65,6 @@ import { AppFeature } from 'state/features'; import { PageProps, WithStoreProps } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { INTEGRATION_SERVICENOW, PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; -import { sanitize } from 'utils/sanitize'; -import { parseURL } from 'utils/url'; -import { openNotification } from 'utils/utils'; import { getActionButtons } from './Incident.helpers'; import { getIncidentStyles } from './Incident.styles'; diff --git a/grafana-plugin/src/pages/incidents/Incidents.tsx b/grafana-plugin/src/pages/incidents/Incidents.tsx index 0460a460c8..7507aac66d 100644 --- a/grafana-plugin/src/pages/incidents/Incidents.tsx +++ b/grafana-plugin/src/pages/incidents/Incidents.tsx @@ -4,6 +4,12 @@ import { cx } from '@emotion/css'; import { GrafanaTheme2, durationToMilliseconds, parseDuration, SelectableValue } from '@grafana/data'; import { LabelTag } from '@grafana/labels'; import { Button, Icon, RadioButtonGroup, RefreshPicker, Tooltip, Stack, withTheme2 } from '@grafana/ui'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { UserActions } from 'helpers/authorization/authorization'; +import { INCIDENT_HORIZONTAL_SCROLLING_STORAGE, PAGE, PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; +import { getItem, setItem } from 'helpers/localStorage'; +import { TableColumn } from 'helpers/types'; import { capitalize } from 'lodash-es'; import { observer } from 'mobx-react'; import moment from 'moment-timezone'; @@ -43,12 +49,6 @@ import { AppFeature } from 'state/features'; import { RootStore } from 'state/rootStore'; import { PageProps, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { UserActions } from 'utils/authorization/authorization'; -import { INCIDENT_HORIZONTAL_SCROLLING_STORAGE, PAGE, PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; -import { getItem, setItem } from 'utils/localStorage'; -import { TableColumn } from 'utils/types'; import { getIncidentsStyles } from './Incidents.styles'; import { IncidentDropdown } from './parts/IncidentDropdown'; diff --git a/grafana-plugin/src/pages/incidents/parts/IncidentDropdown.tsx b/grafana-plugin/src/pages/incidents/parts/IncidentDropdown.tsx index 66580eadeb..070b77b473 100644 --- a/grafana-plugin/src/pages/incidents/parts/IncidentDropdown.tsx +++ b/grafana-plugin/src/pages/incidents/parts/IncidentDropdown.tsx @@ -3,6 +3,7 @@ import React, { FC, SyntheticEvent, useRef, useState } from 'react'; import { cx } from '@emotion/css'; import { intervalToAbbreviatedDurationString } from '@grafana/data'; import { Icon, LoadingPlaceholder, Tooltip, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; import { getUtilStyles } from 'styles/utils.styles'; import { CUSTOM_SILENCE_VALUE } from 'components/Policy/Policy.consts'; @@ -12,7 +13,6 @@ import { WithContextMenu } from 'components/WithContextMenu/WithContextMenu'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { AlertAction, IncidentStatus } from 'models/alertgroup/alertgroup.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; -import { UserActions } from 'utils/authorization/authorization'; import { getIncidentDropdownStyles } from './IncidentDropdown.styles'; import { IncidentSilenceModal } from './IncidentSilenceModal'; diff --git a/grafana-plugin/src/pages/incidents/parts/IncidentSilenceModal.tsx b/grafana-plugin/src/pages/incidents/parts/IncidentSilenceModal.tsx index 0a046057d0..d38532e43a 100644 --- a/grafana-plugin/src/pages/incidents/parts/IncidentSilenceModal.tsx +++ b/grafana-plugin/src/pages/incidents/parts/IncidentSilenceModal.tsx @@ -11,12 +11,12 @@ import { parseDuration, } from '@grafana/data'; import { Button, DateTimePicker, Field, Input, Modal, Stack, useStyles2 } from '@grafana/ui'; +import { openWarningNotification } from 'helpers/helpers'; +import { useDebouncedCallback } from 'helpers/hooks'; import { Controller, useForm } from 'react-hook-form'; import { bem, getUtilStyles } from 'styles/utils.styles'; import { Text } from 'components/Text/Text'; -import { useDebouncedCallback } from 'utils/hooks'; -import { openWarningNotification } from 'utils/utils'; interface IncidentSilenceModalProps { isOpen: boolean; diff --git a/grafana-plugin/src/pages/incidents/parts/SilenceSelect.tsx b/grafana-plugin/src/pages/incidents/parts/SilenceSelect.tsx index 4f0c0b15a1..57d26a4dab 100644 --- a/grafana-plugin/src/pages/incidents/parts/SilenceSelect.tsx +++ b/grafana-plugin/src/pages/incidents/parts/SilenceSelect.tsx @@ -1,11 +1,11 @@ import React from 'react'; import { Select } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { SILENCE_DURATION_LIST } from 'components/Policy/Policy.consts'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; -import { UserActions } from 'utils/authorization/authorization'; interface SilenceSelectProps { placeholder?: string; diff --git a/grafana-plugin/src/pages/insights/Insights.tsx b/grafana-plugin/src/pages/insights/Insights.tsx index 3657834f9e..b40cc735dd 100644 --- a/grafana-plugin/src/pages/insights/Insights.tsx +++ b/grafana-plugin/src/pages/insights/Insights.tsx @@ -15,13 +15,13 @@ import { useSceneApp, } from '@grafana/scenes'; import { Alert, LoadingPlaceholder, Stack } from '@grafana/ui'; +import { DOCS_ROOT, PLUGIN_ROOT, StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Text } from 'components/Text/Text'; import { Tutorial } from 'components/Tutorial/Tutorial'; import { TutorialStep } from 'components/Tutorial/Tutorial.types'; import { useStore } from 'state/useStore'; -import { DOCS_ROOT, PLUGIN_ROOT, StackSize } from 'utils/consts'; import { useAlertCreationChecker } from './Insights.hooks'; import styles from './Insights.module.scss'; diff --git a/grafana-plugin/src/pages/integration/Integration.helper.ts b/grafana-plugin/src/pages/integration/Integration.helper.ts index 042b2606d2..0812cc8ff5 100644 --- a/grafana-plugin/src/pages/integration/Integration.helper.ts +++ b/grafana-plugin/src/pages/integration/Integration.helper.ts @@ -1,12 +1,12 @@ import { IconName } from '@grafana/ui'; import dayjs from 'dayjs'; +import { INTEGRATION_SERVICENOW } from 'helpers/consts'; import { MaintenanceMode } from 'models/alert_receive_channel/alert_receive_channel.types'; import { ChannelFilter } from 'models/channel_filter/channel_filter.types'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { RootStore } from 'state/rootStore'; -import { INTEGRATION_SERVICENOW } from 'utils/consts'; import { MAX_CHARACTERS_COUNT, TEXTAREA_ROWS_COUNT } from './IntegrationCommon.config'; diff --git a/grafana-plugin/src/pages/integration/Integration.tsx b/grafana-plugin/src/pages/integration/Integration.tsx index f4b87ec264..33ea7b1eda 100644 --- a/grafana-plugin/src/pages/integration/Integration.tsx +++ b/grafana-plugin/src/pages/integration/Integration.tsx @@ -4,6 +4,13 @@ import { GrafanaTheme2 } from '@grafana/data'; import { LabelTag } from '@grafana/labels'; import { Button, Stack, LoadingPlaceholder, IconButton, Drawer, Alert } from '@grafana/ui'; import cn from 'classnames/bind'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { UserActions } from 'helpers/authorization/authorization'; +import { INTEGRATION_SERVICENOW, PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { openNotification, openErrorNotification } from 'helpers/helpers'; +import { PropsWithRouter, withDrawer, withRouter } from 'helpers/hoc'; +import { getItem, setItem } from 'helpers/localStorage'; +import { sanitize } from 'helpers/sanitize'; import { get } from 'lodash-es'; import { observer } from 'mobx-react'; import moment from 'moment-timezone'; @@ -43,13 +50,6 @@ import { AppFeature } from 'state/features'; import { PageProps, SelectOption, WithDrawerConfig, WithStoreProps } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { UserActions } from 'utils/authorization/authorization'; -import { INTEGRATION_SERVICENOW, PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { PropsWithRouter, withDrawer, withRouter } from 'utils/hoc'; -import { getItem, setItem } from 'utils/localStorage'; -import { sanitize } from 'utils/sanitize'; -import { openNotification, openErrorNotification } from 'utils/utils'; import { IntegrationActions } from './IntegrationActions'; import { OutgoingTab } from './OutgoingTab/OutgoingTab'; diff --git a/grafana-plugin/src/pages/integration/IntegrationActions.tsx b/grafana-plugin/src/pages/integration/IntegrationActions.tsx index d364ded140..115ce7ddd0 100644 --- a/grafana-plugin/src/pages/integration/IntegrationActions.tsx +++ b/grafana-plugin/src/pages/integration/IntegrationActions.tsx @@ -2,6 +2,10 @@ import React, { useEffect, useState } from 'react'; import { Button, ConfirmModal, Icon, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { GENERIC_ERROR, INTEGRATION_SERVICENOW, PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { openErrorNotification, openNotification } from 'helpers/helpers'; +import { useDrawer } from 'helpers/hooks'; import CopyToClipboard from 'react-copy-to-clipboard'; import Emoji from 'react-emoji-render'; import { useNavigate } from 'react-router-dom-v5-compat'; @@ -21,10 +25,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import styles from 'pages/integration/Integration.module.scss'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { GENERIC_ERROR, INTEGRATION_SERVICENOW, PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { useDrawer } from 'utils/hooks'; -import { openErrorNotification, openNotification } from 'utils/utils'; import { IntegrationDrawerKey } from './Integration'; import { getIsBidirectionalIntegration } from './Integration.helper'; diff --git a/grafana-plugin/src/pages/integration/IntegrationCommon.config.ts b/grafana-plugin/src/pages/integration/IntegrationCommon.config.ts index d56bfa57c8..e794eaf620 100644 --- a/grafana-plugin/src/pages/integration/IntegrationCommon.config.ts +++ b/grafana-plugin/src/pages/integration/IntegrationCommon.config.ts @@ -1,4 +1,4 @@ -import { KeyValuePair } from 'utils/utils'; +import { KeyValuePair } from 'helpers/helpers'; export const TEXTAREA_ROWS_COUNT = 4; export const MAX_CHARACTERS_COUNT = 50; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/ConnectIntegrationModal.tsx b/grafana-plugin/src/pages/integration/OutgoingTab/ConnectIntegrationModal.tsx index de89b5ddee..7e144f66b2 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/ConnectIntegrationModal.tsx +++ b/grafana-plugin/src/pages/integration/OutgoingTab/ConnectIntegrationModal.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import { Button, Icon, Input, Modal, Stack, useStyles2 } from '@grafana/ui'; import cn from 'classnames'; +import { useCommonStyles, useIsLoading } from 'helpers/hooks'; import { debounce } from 'lodash-es'; import { observer } from 'mobx-react'; @@ -10,7 +11,6 @@ import { AlertReceiveChannelHelper } from 'models/alert_receive_channel/alert_re import { ActionKey } from 'models/loader/action-keys'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { useCommonStyles, useIsLoading } from 'utils/hooks'; import ConnectedIntegrationsTable from './ConnectedIntegrationsTable'; import { useCurrentIntegration } from './OutgoingTab.hooks'; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/ConnectedIntegrationsTable.tsx b/grafana-plugin/src/pages/integration/OutgoingTab/ConnectedIntegrationsTable.tsx index 691d5b02be..aa71a6fac7 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/ConnectedIntegrationsTable.tsx +++ b/grafana-plugin/src/pages/integration/OutgoingTab/ConnectedIntegrationsTable.tsx @@ -1,6 +1,8 @@ import React, { FC } from 'react'; import { Tooltip, Icon, useStyles2, IconButton, Switch, Checkbox, ConfirmModal, useTheme2, Stack } from '@grafana/ui'; +import { PLUGIN_ROOT } from 'helpers/consts'; +import { useConfirmModal } from 'helpers/hooks'; import { observer } from 'mobx-react'; import Emoji from 'react-emoji-render'; @@ -11,8 +13,6 @@ import { AlertReceiveChannelHelper } from 'models/alert_receive_channel/alert_re import { ApiSchemas } from 'network/oncall-api/api.types'; import { useIntegrationTokenCheck } from 'pages/integration/Integration.hooks'; import { useStore } from 'state/useStore'; -import { PLUGIN_ROOT } from 'utils/consts'; -import { useConfirmModal } from 'utils/hooks'; import { useIntegrationIdFromUrl } from './OutgoingTab.hooks'; import { getStyles } from './OutgoingTab.styles'; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/NewOutgoingWebhookDrawerContent.tsx b/grafana-plugin/src/pages/integration/OutgoingTab/NewOutgoingWebhookDrawerContent.tsx index 086f522a49..015ace2952 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/NewOutgoingWebhookDrawerContent.tsx +++ b/grafana-plugin/src/pages/integration/OutgoingTab/NewOutgoingWebhookDrawerContent.tsx @@ -1,12 +1,12 @@ import React, { FC } from 'react'; import { Button, Stack, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { useCommonStyles } from 'helpers/hooks'; import { useForm, FormProvider } from 'react-hook-form'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { useCommonStyles } from 'utils/hooks'; import { useIntegrationIdFromUrl } from './OutgoingTab.hooks'; import { getStyles } from './OutgoingTab.styles'; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.hooks.ts b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.hooks.ts index 90c61c0698..ffcb886251 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.hooks.ts +++ b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.hooks.ts @@ -1,7 +1,7 @@ +import { LocationHelper } from 'helpers/LocationHelper'; import { useParams } from 'react-router-dom-v5-compat'; import { useStore } from 'state/useStore'; -import { LocationHelper } from 'utils/LocationHelper'; import { TriggerDetailsQueryStringKey } from './OutgoingTab.types'; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.tsx b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.tsx index 2efbaa8336..020a5e384c 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.tsx +++ b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingTab.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { useStyles2, Input, IconButton, Drawer, Stack } from '@grafana/ui'; +import { useDrawer } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { Button } from 'components/Button/Button'; @@ -9,7 +10,6 @@ import { CopyToClipboardIcon } from 'components/CopyToClipboardIcon/CopyToClipbo import { IntegrationBlock } from 'components/Integrations/IntegrationBlock'; import { IntegrationTag } from 'components/Integrations/IntegrationTag'; import { Text } from 'components/Text/Text'; -import { useDrawer } from 'utils/hooks'; import { NewOutgoingWebhookDrawerContent } from './NewOutgoingWebhookDrawerContent'; import { OtherIntegrations } from './OtherIntegrations'; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookDetailsDrawerTabs.tsx b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookDetailsDrawerTabs.tsx index 25dc51fd86..667b76e74c 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookDetailsDrawerTabs.tsx +++ b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookDetailsDrawerTabs.tsx @@ -1,6 +1,8 @@ import React, { FC } from 'react'; import { Button, ConfirmModal, useStyles2, Stack } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; +import { useCommonStyles, useConfirmModal } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { useForm, FormProvider } from 'react-hook-form'; @@ -9,8 +11,6 @@ import { Tabs } from 'components/Tabs/Tabs'; import { WebhookLastEventDetails } from 'components/Webhooks/WebhookLastEventDetails'; import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { useCommonStyles, useConfirmModal } from 'utils/hooks'; import { useDrawerWebhook, useIntegrationIdFromUrl } from './OutgoingTab.hooks'; import { getStyles } from './OutgoingTab.styles'; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookFormFields.tsx b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookFormFields.tsx index 900ac88440..4a8cac51b3 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookFormFields.tsx +++ b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhookFormFields.tsx @@ -2,13 +2,13 @@ import React, { FC, useState } from 'react'; import { Button, Field, Label, Select, Switch, useStyles2, Stack } from '@grafana/ui'; import cn from 'classnames'; +import { StackSize } from 'helpers/consts'; import { Controller, useFormContext } from 'react-hook-form'; import { MonacoEditor } from 'components/MonacoEditor/MonacoEditor'; import { MONACO_EDITABLE_CONFIG, MONACO_READONLY_CONFIG } from 'components/MonacoEditor/MonacoEditor.config'; import { WebhooksTemplateEditor } from 'containers/WebhooksTemplateEditor/WebhooksTemplateEditor'; import { HTTP_METHOD_OPTIONS, WEBHOOK_TRIGGGER_TYPE_OPTIONS } from 'models/outgoing_webhook/outgoing_webhook.types'; -import { StackSize } from 'utils/consts'; import { getStyles } from './OutgoingTab.styles'; import { OutgoingTabFormValues } from './OutgoingTab.types'; diff --git a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhooksTable.tsx b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhooksTable.tsx index b040b74938..b8e8d073d4 100644 --- a/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhooksTable.tsx +++ b/grafana-plugin/src/pages/integration/OutgoingTab/OutgoingWebhooksTable.tsx @@ -1,6 +1,11 @@ import React, { FC, ReactElement, useEffect } from 'react'; import { IconButton, Icon, ConfirmModal, useStyles2, Stack } from '@grafana/ui'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { UserActions } from 'helpers/authorization/authorization'; +import { StackSize } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; +import { useConfirmModal } from 'helpers/hooks'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -11,11 +16,6 @@ import { WebhookLastEventTimestamp } from 'components/Webhooks/WebhookLastEventT import { WebhookName } from 'components/Webhooks/WebhookName'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { useStore } from 'state/useStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { UserActions } from 'utils/authorization/authorization'; -import { StackSize } from 'utils/consts'; -import { useConfirmModal } from 'utils/hooks'; -import { openNotification } from 'utils/utils'; import { useIntegrationIdFromUrl } from './OutgoingTab.hooks'; import { getStyles } from './OutgoingTab.styles'; diff --git a/grafana-plugin/src/pages/integrations/Integrations.tsx b/grafana-plugin/src/pages/integrations/Integrations.tsx index 8a5e6e4cd8..f1f9a0da5c 100644 --- a/grafana-plugin/src/pages/integrations/Integrations.tsx +++ b/grafana-plugin/src/pages/integrations/Integrations.tsx @@ -3,6 +3,11 @@ import React from 'react'; import { cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, Stack, Icon, ConfirmModal, Tooltip, Tab, TabsBar, TabContent, Alert, withTheme2 } from '@grafana/ui'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { UserActions } from 'helpers/authorization/authorization'; +import { PAGE, StackSize, TEXT_ELLIPSIS_CLASS } from 'helpers/consts'; +import { openNotification } from 'helpers/helpers'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; import { debounce } from 'lodash-es'; import { runInAction } from 'mobx'; import { observer } from 'mobx-react'; @@ -40,11 +45,6 @@ import { IntegrationHelper } from 'pages/integration/Integration.helper'; import { AppFeature } from 'state/features'; import { PageProps, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { UserActions } from 'utils/authorization/authorization'; -import { PAGE, StackSize, TEXT_ELLIPSIS_CLASS } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; -import { openNotification } from 'utils/utils'; import { getIntegrationsStyles } from './Integrations.styles'; diff --git a/grafana-plugin/src/pages/outgoing_webhooks/OutgoingWebhooks.tsx b/grafana-plugin/src/pages/outgoing_webhooks/OutgoingWebhooks.tsx index 44baa96f36..39e66c4d33 100644 --- a/grafana-plugin/src/pages/outgoing_webhooks/OutgoingWebhooks.tsx +++ b/grafana-plugin/src/pages/outgoing_webhooks/OutgoingWebhooks.tsx @@ -3,6 +3,10 @@ import React from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, ConfirmModal, ConfirmModalProps, Icon, IconButton, Stack, withTheme2 } from '@grafana/ui'; +import { isUserActionAllowed, UserActions } from 'helpers/authorization/authorization'; +import { PAGE, PLUGIN_ROOT, StackSize, TEXT_ELLIPSIS_CLASS } from 'helpers/consts'; +import { openErrorNotification, openNotification } from 'helpers/helpers'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; import { observer } from 'mobx-react'; import { LegacyNavHeading } from 'navbar/LegacyNavHeading'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -30,10 +34,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { PageProps, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; -import { PAGE, PLUGIN_ROOT, StackSize, TEXT_ELLIPSIS_CLASS } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; -import { openErrorNotification, openNotification } from 'utils/utils'; import { WebhookFormActionType } from './OutgoingWebhooks.types'; diff --git a/grafana-plugin/src/pages/pages.tsx b/grafana-plugin/src/pages/pages.tsx index 980497a4c6..8379ba9b5d 100644 --- a/grafana-plugin/src/pages/pages.tsx +++ b/grafana-plugin/src/pages/pages.tsx @@ -1,11 +1,11 @@ import { NavModelItem } from '@grafana/data'; +import { UserActions, UserAction, isUserActionAllowed } from 'helpers/authorization/authorization'; +import { PLUGIN_ROOT } from 'helpers/consts'; import { matchPath } from 'react-router-dom-v5-compat'; import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; import { AppFeature } from 'state/features'; import { RootBaseStore } from 'state/rootBaseStore/RootBaseStore'; -import { UserActions, UserAction, isUserActionAllowed } from 'utils/authorization/authorization'; -import { PLUGIN_ROOT } from 'utils/consts'; export type PageDefinition = { path: string; diff --git a/grafana-plugin/src/pages/schedule/Schedule.tsx b/grafana-plugin/src/pages/schedule/Schedule.tsx index a08a485673..4f5a861a55 100644 --- a/grafana-plugin/src/pages/schedule/Schedule.tsx +++ b/grafana-plugin/src/pages/schedule/Schedule.tsx @@ -16,6 +16,10 @@ import { DatePicker, } from '@grafana/ui'; import dayjs from 'dayjs'; +import { HTML_ID, scrollToElement } from 'helpers/DOM'; +import { isUserActionAllowed, UserActions } from 'helpers/authorization/authorization'; +import { PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; import { observer } from 'mobx-react'; import { PageErrorHandlingWrapper } from 'components/PageErrorHandlingWrapper/PageErrorHandlingWrapper'; @@ -41,10 +45,6 @@ import { Event, Layer, Schedule, ScheduleType, ScheduleView, Shift, ShiftSwap } import { UserHelper } from 'models/user/user.helpers'; import { PageProps, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { HTML_ID, scrollToElement } from 'utils/DOM'; -import { isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; -import { PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; import { getCalendarStartDate, diff --git a/grafana-plugin/src/pages/schedules/Schedules.tsx b/grafana-plugin/src/pages/schedules/Schedules.tsx index a0db5d5a20..bc3ff0a6c0 100644 --- a/grafana-plugin/src/pages/schedules/Schedules.tsx +++ b/grafana-plugin/src/pages/schedules/Schedules.tsx @@ -3,6 +3,10 @@ import React, { SyntheticEvent } from 'react'; import { cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Button, IconButton, LoadingPlaceholder, Stack, withTheme2 } from '@grafana/ui'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { UserActions } from 'helpers/authorization/authorization'; +import { PAGE, PLUGIN_ROOT, StackSize, TEXT_ELLIPSIS_CLASS } from 'helpers/consts'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; import { observer } from 'mobx-react'; import qs from 'query-string'; import { getUtilStyles } from 'styles/utils.styles'; @@ -27,10 +31,6 @@ import { Schedule, ScheduleView } from 'models/schedule/schedule.types'; import { getSlackChannelName } from 'models/slack_channel/slack_channel.helpers'; import { WithStoreProps, PageProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { UserActions } from 'utils/authorization/authorization'; -import { PAGE, PLUGIN_ROOT, StackSize, TEXT_ELLIPSIS_CLASS } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; import { getSchedulesStyles } from './Schedules.styles'; diff --git a/grafana-plugin/src/pages/settings/SettingsPage.tsx b/grafana-plugin/src/pages/settings/SettingsPage.tsx index 758a84555d..ca13d2ded0 100644 --- a/grafana-plugin/src/pages/settings/SettingsPage.tsx +++ b/grafana-plugin/src/pages/settings/SettingsPage.tsx @@ -3,6 +3,8 @@ import React from 'react'; import { css } from '@emotion/css'; import { AppRootProps } from '@grafana/data'; import { Tab, TabsBar, useStyles2 } from '@grafana/ui'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { isUserActionAllowed, UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { ChatOpsPage } from 'pages/settings/tabs/ChatOps/ChatOps'; @@ -11,8 +13,6 @@ import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; import { AppFeature } from 'state/features'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; import { SettingsPageTab } from './SettingsPage.types'; import { CloudPage } from './tabs/Cloud/CloudPage'; diff --git a/grafana-plugin/src/pages/settings/SettingsPage.types.ts b/grafana-plugin/src/pages/settings/SettingsPage.types.ts index 940343d0ec..d88213085c 100644 --- a/grafana-plugin/src/pages/settings/SettingsPage.types.ts +++ b/grafana-plugin/src/pages/settings/SettingsPage.types.ts @@ -1,4 +1,4 @@ -import { KeyValuePair } from 'utils/utils'; +import { KeyValuePair } from 'helpers/helpers'; export const SettingsPageTab = { MainSettings: new KeyValuePair('MainSettings', 'Organization Settings'), diff --git a/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts index 4313ec5f7a..cbd88fe189 100644 --- a/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts +++ b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts @@ -1,5 +1,5 @@ -import { LocationHelper } from 'utils/LocationHelper'; -import { openErrorNotification } from 'utils/utils'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { openErrorNotification } from 'helpers/helpers'; export const handleChatOpsQueryParamError = () => { const error = LocationHelper.getQueryParam('error'); diff --git a/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx index 5ee30c39df..5434d48d6c 100644 --- a/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx +++ b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx @@ -3,6 +3,7 @@ import React from 'react'; import { AppRootProps } from '@grafana/data'; import { Alert, Icon, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { LocationHelper } from 'helpers/LocationHelper'; import { observer } from 'mobx-react'; import { VerticalTabsBar, VerticalTab } from 'components/VerticalTabsBar/VerticalTabsBar'; @@ -13,7 +14,6 @@ import { AppFeature } from 'state/features'; import { WithStoreProps } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; import { handleChatOpsQueryParamError } from './ChatOps.helpers'; 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 4d5227c8e6..e5ea47c625 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 @@ -2,6 +2,10 @@ import React, { Component } from 'react'; import { Alert, LoadingPlaceholder, Icon, Button, InlineField, Input, Legend, ConfirmModal, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions } from 'helpers/authorization/authorization'; +import { DOCS_SLACK_SETUP, getPluginId, StackSize } from 'helpers/consts'; +import { showApiError } from 'helpers/helpers'; +import { useConfirmModal } from 'helpers/hooks'; import { observer } from 'mobx-react'; import { Block } from 'components/GBlock/Block'; @@ -19,10 +23,6 @@ import { AppFeature } from 'state/features'; import { WithStoreProps } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; -import { UserActions } from 'utils/authorization/authorization'; -import { DOCS_SLACK_SETUP, getPluginId, StackSize } from 'utils/consts'; -import { useConfirmModal } from 'utils/hooks'; -import { showApiError } from 'utils/utils'; import styles from './SlackSettings.module.css'; diff --git a/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/TelegramSettings/TelegramSettings.tsx b/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/TelegramSettings/TelegramSettings.tsx index eb7bf4d828..de07ef2c76 100644 --- a/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/TelegramSettings/TelegramSettings.tsx +++ b/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/TelegramSettings/TelegramSettings.tsx @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import { Badge, Button, Icon, LoadingPlaceholder, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { DOCS_TELEGRAM_SETUP, StackSize } from 'helpers/consts'; import { observer } from 'mobx-react'; import { Block } from 'components/GBlock/Block'; @@ -15,7 +16,6 @@ import { TelegramChannel } from 'models/telegram_channel/telegram_channel.types' import { AppFeature } from 'state/features'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { DOCS_TELEGRAM_SETUP, StackSize } from 'utils/consts'; import styles from './TelegramSettings.module.css'; diff --git a/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx b/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx index b64424cf1f..1f92fe3d5b 100644 --- a/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx +++ b/grafana-plugin/src/pages/settings/tabs/Cloud/CloudPage.tsx @@ -2,6 +2,10 @@ import React, { useCallback, useEffect, useState } from 'react'; import { Button, Field, Icon, Input, LoadingPlaceholder, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { UserActions, determineRequiredAuthString } from 'helpers/authorization/authorization'; +import { PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { openErrorNotification } from 'helpers/helpers'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; import { observer } from 'mobx-react'; import { Block } from 'components/GBlock/Block'; @@ -13,10 +17,6 @@ import { Cloud } from 'models/cloud/cloud.types'; import { WithStoreProps } from 'state/types'; import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; -import { UserActions, determineRequiredAuthString } from 'utils/authorization/authorization'; -import { PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; -import { openErrorNotification } from 'utils/utils'; import styles from './CloudPage.module.css'; diff --git a/grafana-plugin/src/pages/settings/tabs/LiveSettings/LiveSettingsPage.tsx b/grafana-plugin/src/pages/settings/tabs/LiveSettings/LiveSettingsPage.tsx index d044ee7e20..123ca87bd6 100644 --- a/grafana-plugin/src/pages/settings/tabs/LiveSettings/LiveSettingsPage.tsx +++ b/grafana-plugin/src/pages/settings/tabs/LiveSettings/LiveSettingsPage.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Button, Checkbox, Icon, Stack } from '@grafana/ui'; import cn from 'classnames/bind'; +import { isUserActionAllowed, UserActions } from 'helpers/authorization/authorization'; import { Lambda, observe } from 'mobx'; import { observer } from 'mobx-react'; @@ -12,7 +13,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { GlobalSetting } from 'models/global_setting/global_setting.types'; import { WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { isUserActionAllowed, UserActions } from 'utils/authorization/authorization'; import { PLACEHOLDER } from './LiveSettings.config'; import { normalizeValue, prepareForUpdate } from './LiveSettings.helpers'; diff --git a/grafana-plugin/src/pages/settings/tabs/MainSettings/MainSettings.tsx b/grafana-plugin/src/pages/settings/tabs/MainSettings/MainSettings.tsx index fea4751d3e..4eae4d7494 100644 --- a/grafana-plugin/src/pages/settings/tabs/MainSettings/MainSettings.tsx +++ b/grafana-plugin/src/pages/settings/tabs/MainSettings/MainSettings.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { css } from '@emotion/css'; import { Field, Input, Switch, useStyles2 } from '@grafana/ui'; +import { UserActions } from 'helpers/authorization/authorization'; import { observer } from 'mobx-react'; import { LegacyNavHeading } from 'navbar/LegacyNavHeading'; @@ -11,7 +12,6 @@ import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/W import { TeamsSettings } from 'pages/settings/tabs/TeamsSettings/TeamsSettings'; import { isTopNavbar } from 'plugin/GrafanaPluginRootPage.helpers'; import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization/authorization'; export const MainSettings = observer(() => { const styles = useStyles2(getStyles); diff --git a/grafana-plugin/src/pages/users/Users.tsx b/grafana-plugin/src/pages/users/Users.tsx index aecac4d977..a2fe503e98 100644 --- a/grafana-plugin/src/pages/users/Users.tsx +++ b/grafana-plugin/src/pages/users/Users.tsx @@ -3,6 +3,14 @@ import React from 'react'; import { cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { Alert, Button, Stack, withTheme2 } from '@grafana/ui'; +import { LocationHelper } from 'helpers/LocationHelper'; +import { + UserActions, + generateMissingPermissionMessage, + isUserActionAllowed, +} from 'helpers/authorization/authorization'; +import { PAGE, PLUGIN_ROOT, StackSize } from 'helpers/consts'; +import { PropsWithRouter, withRouter } from 'helpers/hoc'; import { debounce } from 'lodash-es'; import { observer } from 'mobx-react'; import { LegacyNavHeading } from 'navbar/LegacyNavHeading'; @@ -25,10 +33,6 @@ import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; import { PageProps, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; -import { LocationHelper } from 'utils/LocationHelper'; -import { UserActions, generateMissingPermissionMessage, isUserActionAllowed } from 'utils/authorization/authorization'; -import { PAGE, PLUGIN_ROOT, StackSize } from 'utils/consts'; -import { PropsWithRouter, withRouter } from 'utils/hoc'; import { getUserRowClassNameFn } from './Users.helpers'; import { getUsersStyles } from './Users.styles'; diff --git a/grafana-plugin/src/plugin/GrafanaPluginRootPage.helpers.test.tsx b/grafana-plugin/src/plugin/GrafanaPluginRootPage.helpers.test.tsx index 3b35235080..611fbb80ed 100644 --- a/grafana-plugin/src/plugin/GrafanaPluginRootPage.helpers.test.tsx +++ b/grafana-plugin/src/plugin/GrafanaPluginRootPage.helpers.test.tsx @@ -1,6 +1,5 @@ import * as runtime from '@grafana/runtime'; - -import { getGrafanaVersion } from 'utils/utils'; +import { getGrafanaVersion } from 'helpers/helpers'; jest.mock('@grafana/runtime', () => ({ config: jest.fn(), diff --git a/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx b/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx index 064146f7d6..cc510fad04 100644 --- a/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx +++ b/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx @@ -1,12 +1,16 @@ import React, { useEffect } from 'react'; import { ErrorBoundary, LoadingPlaceholder } from '@grafana/ui'; +import { AppRootProps } from 'app-types'; import classnames from 'classnames'; +import { isUserActionAllowed } from 'helpers/authorization/authorization'; +import { DEFAULT_PAGE, getOnCallApiUrl } from 'helpers/consts'; +import { FaroHelper } from 'helpers/faro'; +import { useOnMount } from 'helpers/hooks'; import { observer, Provider } from 'mobx-react'; import { Header } from 'navbar/Header/Header'; import { LegacyNavTabsBar } from 'navbar/LegacyNavTabsBar'; import { Navigate, Route, Routes, useLocation } from 'react-router-dom-v5-compat'; -import { AppRootProps } from 'types'; import { RenderConditionally } from 'components/RenderConditionally/RenderConditionally'; import { Unauthorized } from 'components/Unauthorized/Unauthorized'; @@ -30,13 +34,9 @@ import LiveSettings from 'pages/settings/tabs/LiveSettings/LiveSettingsPage'; import { UsersPage } from 'pages/users/Users'; import { rootStore } from 'state/rootStore'; import { useStore } from 'state/useStore'; -import { isUserActionAllowed } from 'utils/authorization/authorization'; -import { DEFAULT_PAGE, getOnCallApiUrl } from 'utils/consts'; import 'assets/style/vars.css'; import 'assets/style/global.css'; import 'assets/style/utils.css'; -import { FaroHelper } from 'utils/faro'; -import { useOnMount } from 'utils/hooks'; import { getQueryParams, isTopNavbar } from './GrafanaPluginRootPage.helpers'; diff --git a/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts b/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts index 2839ad30d3..8087436c3f 100644 --- a/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts +++ b/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts @@ -1,6 +1,9 @@ +import { OnCallAppPluginMeta } from 'app-types'; +import { retryFailingPromises } from 'helpers/async'; +import { APP_VERSION, CLOUD_VERSION_REGEX, GRAFANA_LICENSE_CLOUD, GRAFANA_LICENSE_OSS } from 'helpers/consts'; +import { loadJs } from 'helpers/loadJs'; import { action, computed, makeObservable, observable, runInAction } from 'mobx'; import qs from 'query-string'; -import { OnCallAppPluginMeta } from 'types'; import { AlertReceiveChannelStore } from 'models/alert_receive_channel/alert_receive_channel'; import { AlertReceiveChannelConnectedChannelsStore } from 'models/alert_receive_channel_connected_channels/alert_receive_channel_connected_channels'; @@ -33,9 +36,6 @@ import { UserGroupStore } from 'models/user_group/user_group'; import { makeRequest } from 'network/network'; import { ApiSchemas } from 'network/oncall-api/api.types'; import { AppFeature } from 'state/features'; -import { retryFailingPromises } from 'utils/async'; -import { APP_VERSION, CLOUD_VERSION_REGEX, GRAFANA_LICENSE_CLOUD, GRAFANA_LICENSE_OSS } from 'utils/consts'; -import { loadJs } from 'utils/loadJs'; // ------ Dashboard ------ // diff --git a/grafana-plugin/src/state/types.ts b/grafana-plugin/src/state/types.ts index 4e0cf218c0..262eaa2ce0 100644 --- a/grafana-plugin/src/state/types.ts +++ b/grafana-plugin/src/state/types.ts @@ -1,7 +1,7 @@ import { AppPluginMeta, KeyValue } from '@grafana/data'; +import { useDrawer } from 'helpers/hooks'; import { RootStore } from 'state/rootStore'; -import { useDrawer } from 'utils/hooks'; export interface WithStoreProps { store: RootStore; diff --git a/helm/README.md b/helm/README.md index f3fce70841..7e998340a3 100644 --- a/helm/README.md +++ b/helm/README.md @@ -2,8 +2,7 @@ 1. Create the cluster with [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) - > Make sure ports 30001, 30002 (Grafana, optional) and - > 30003 (detached integrations server, optional) are free on your machine + > Make sure ports 30001, 30002 (Grafana, optional) are available ```bash kind create cluster --image kindest/node:v1.24.7 --config kind.yml diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index 178455147b..c3836dbbd8 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.7.2 -appVersion: v1.7.2 +version: 1.9.22 +appVersion: v1.9.22 dependencies: - name: cert-manager version: v1.8.0 @@ -26,7 +26,7 @@ dependencies: repository: https://charts.bitnami.com/bitnami condition: redis.enabled - name: grafana - version: 6.57.1 + version: 8.4.6 repository: https://grafana.github.io/helm-charts condition: grafana.enabled - name: ingress-nginx diff --git a/helm/oncall/charts/grafana-6.57.1.tgz b/helm/oncall/charts/grafana-6.57.1.tgz deleted file mode 100644 index 25121669ba..0000000000 Binary files a/helm/oncall/charts/grafana-6.57.1.tgz and /dev/null differ diff --git a/helm/oncall/charts/grafana-8.4.6.tgz b/helm/oncall/charts/grafana-8.4.6.tgz new file mode 100644 index 0000000000..3e185d3a1f Binary files /dev/null and b/helm/oncall/charts/grafana-8.4.6.tgz differ diff --git a/helm/oncall/templates/_env.tpl b/helm/oncall/templates/_env.tpl index 6821d2a92b..20a52493e0 100644 --- a/helm/oncall/templates/_env.tpl +++ b/helm/oncall/templates/_env.tpl @@ -106,7 +106,7 @@ value: {{ .Values.telegramPolling.enabled | toString | title | quote }} {{- end }} - name: TELEGRAM_WEBHOOK_HOST - value: {{ .Values.oncall.telegram.webhookUrl | default (printf "https://%s" .Values.base_url) | quote }} + value: {{ .Values.oncall.telegram.webhookUrl | default (printf "%s://%s" .Values.base_url_protocol .Values.base_url) | quote }} {{- if .Values.oncall.telegram.existingSecret }} - name: TELEGRAM_TOKEN valueFrom: diff --git a/helm/oncall/templates/plugin-provisioning.yaml b/helm/oncall/templates/plugin-provisioning.yaml new file mode 100644 index 0000000000..511a4a39fd --- /dev/null +++ b/helm/oncall/templates/plugin-provisioning.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: helm-testing-grafana-plugin-provisioning + labels: + app: {{ include "oncall.name" . }} +data: + grafana-oncall-app-provisioning.yaml: | + apps: + - type: grafana-oncall-app + name: grafana-oncall-app + disabled: false + jsonData: + stackId: 5 + orgId: 100 + onCallApiUrl: http://helm-testing-oncall-engine:8080 diff --git a/helm/oncall/tests/__snapshot__/integrations_deployment_test.yaml.snap b/helm/oncall/tests/__snapshot__/integrations_deployment_test.yaml.snap index 89efb16bdc..d055982f49 100644 --- a/helm/oncall/tests/__snapshot__/integrations_deployment_test.yaml.snap +++ b/helm/oncall/tests/__snapshot__/integrations_deployment_test.yaml.snap @@ -2,7 +2,7 @@ detached_integrations.enabled=true -> should create integrations deployment: 1: | - env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: diff --git a/helm/oncall/tests/__snapshot__/telegram_polling_deployment_test.yaml.snap b/helm/oncall/tests/__snapshot__/telegram_polling_deployment_test.yaml.snap index 341fa32d83..b3eb11b572 100644 --- a/helm/oncall/tests/__snapshot__/telegram_polling_deployment_test.yaml.snap +++ b/helm/oncall/tests/__snapshot__/telegram_polling_deployment_test.yaml.snap @@ -6,7 +6,7 @@ telegramPolling.enabled=true -> should create telegram polling deployment: - python manage.py start_telegram_polling env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: @@ -38,7 +38,7 @@ telegramPolling.enabled=true -> should create telegram polling deployment: - name: FEATURE_TELEGRAM_LONG_POLLING_ENABLED value: "True" - name: TELEGRAM_WEBHOOK_HOST - value: https://example.com + value: http://example.com - name: TELEGRAM_TOKEN value: "" - name: MYSQL_HOST diff --git a/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap b/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap index 2cee70e776..5c6e4adb7e 100644 --- a/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap +++ b/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap @@ -6,7 +6,7 @@ database.type=mysql -> should create initContainer for MySQL database (default): - until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: @@ -94,7 +94,7 @@ database.type=mysql -> should create initContainer for MySQL database (default): - until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: @@ -182,7 +182,7 @@ database.type=mysql -> should create initContainer for MySQL database (default): - until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: @@ -271,7 +271,7 @@ database.type=postgresql -> should create initContainer for PostgreSQL database: - until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: @@ -361,7 +361,7 @@ database.type=postgresql -> should create initContainer for PostgreSQL database: - until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: @@ -451,7 +451,7 @@ database.type=postgresql -> should create initContainer for PostgreSQL database: - until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done env: - name: BASE_URL - value: https://example.com + value: http://example.com - name: SECRET_KEY valueFrom: secretKeyRef: diff --git a/helm/oncall/tests/telegram_env_test.yaml b/helm/oncall/tests/telegram_env_test.yaml index 288d5ee65a..f45d019ccb 100644 --- a/helm/oncall/tests/telegram_env_test.yaml +++ b/helm/oncall/tests/telegram_env_test.yaml @@ -24,7 +24,7 @@ tests: set: oncall.telegram: enabled: true - webhookUrl: https://example.com + webhookUrl: http://example.com token: "abcd:123" asserts: - contains: @@ -36,7 +36,7 @@ tests: path: spec.template.spec.containers[0].env content: name: TELEGRAM_WEBHOOK_HOST - value: "https://example.com" + value: "http://example.com" - contains: path: spec.template.spec.containers[0].env content: diff --git a/helm/oncall/values.yaml b/helm/oncall/values.yaml index f7d4c30b1d..8ca59a2664 100644 --- a/helm/oncall/values.yaml +++ b/helm/oncall/values.yaml @@ -3,7 +3,7 @@ # Set the domain name Grafana OnCall will be installed on. # If you want to install grafana as a part of this release make sure to configure grafana.grafana.ini.server.domain too base_url: example.com -base_url_protocol: https +base_url_protocol: http ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. @@ -634,9 +634,11 @@ grafana: enabled: true grafana.ini: server: - domain: example.com - root_url: "%(protocol)s://%(domain)s/grafana" + domain: helm-testing-grafana + root_url: "%(protocol)s://%(domain)s/grafana/" serve_from_sub_path: true + feature_toggles: + enable: externalServiceAccounts persistence: enabled: true # Disable psp as PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+ @@ -644,6 +646,14 @@ grafana: pspEnabled: false plugins: - grafana-oncall-app + extraVolumes: + - name: provisioning + configMap: + name: helm-testing-grafana-plugin-provisioning + extraVolumeMounts: + - name: provisioning + mountPath: /etc/grafana/provisioning/plugins/grafana-oncall-app-provisioning.yaml + subPath: grafana-oncall-app-provisioning.yaml externalGrafana: # Example: https://grafana.mydomain.com diff --git a/helm/simple.yml b/helm/simple.yml index 219c7a11c6..0dd9da4b96 100644 --- a/helm/simple.yml +++ b/helm/simple.yml @@ -15,9 +15,9 @@ grafana: type: NodePort nodePort: 30002 detached_integrations: - enabled: true + enabled: false detached_integrations_service: - enabled: true + enabled: false type: NodePort port: 8080 nodePort: 30003