Loki: Move convertToWebSocketUrl from Explore to Loki (#78542)

* Move convertToWebSocketUrl to Loki

* Add tests

* Fix test
This commit is contained in:
Ivana Huckova
2023-11-23 10:43:48 +01:00
committed by GitHub
parent 5dd5ed9b30
commit fd5f66083c
4 changed files with 56 additions and 14 deletions

View File

@@ -28,8 +28,6 @@ import store from 'app/core/store';
import { ExpressionDatasourceUID } from 'app/features/expressions/types';
import { QueryOptions, QueryTransaction } from 'app/types/explore';
import { config } from '../config';
import { getNextRefIdChar } from './query';
export const DEFAULT_UI_STATE = {
@@ -329,15 +327,6 @@ export const getTimeRange = (timeZone: TimeZone, rawRange: RawTimeRange, fiscalY
export const refreshIntervalToSortOrder = (refreshInterval?: string) =>
RefreshPicker.isLive(refreshInterval) ? LogsSortOrder.Ascending : LogsSortOrder.Descending;
export const convertToWebSocketUrl = (url: string) => {
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
let backend = `${protocol}${window.location.host}${config.appSubUrl}`;
if (backend.endsWith('/')) {
backend = backend.slice(0, -1);
}
return `${backend}${url}`;
};
export const stopQueryState = (querySubscription: Unsubscribable | undefined) => {
if (querySubscription) {
querySubscription.unsubscribe();