grafana/public/app/features/explore/state/selectors.ts
Andrej Ocenas b0bd242eda
Explore/Refactor: Simplify URL handling (#29173)
* Inline datasource actions into initialisation

* Simplify url handling

* Add comments

* Remove split property from state and split Explore.tsx to 2 components

* Add comments

* Simplify and fix splitOpen and splitClose actions

* Update public/app/features/explore/ExplorePaneContainer.tsx

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>

* Update public/app/features/explore/state/explorePane.test.ts

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>

* Update public/app/features/explore/Wrapper.tsx

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* Fix test

* Fix lint

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-02-12 21:33:26 +01:00

22 lines
947 B
TypeScript

import { createSelector } from 'reselect';
import { ExploreId, ExploreItemState, StoreState } from 'app/types';
import { filterLogLevels, dedupLogRows } from 'app/core/logs_model';
const logsRowsSelector = (state: ExploreItemState) => state.logsResult && state.logsResult.rows;
const hiddenLogLevelsSelector = (state: ExploreItemState) => state.hiddenLogLevels;
const dedupStrategySelector = (state: ExploreItemState) => state.dedupStrategy;
export const deduplicatedRowsSelector = createSelector(
logsRowsSelector,
hiddenLogLevelsSelector,
dedupStrategySelector,
function dedupRows(rows, hiddenLogLevels, dedupStrategy) {
if (!(rows && rows.length)) {
return rows;
}
const filteredRows = filterLogLevels(rows, new Set(hiddenLogLevels));
return dedupLogRows(filteredRows, dedupStrategy);
}
);
export const isSplit = (state: StoreState) => Boolean(state.explore[ExploreId.left] && state.explore[ExploreId.right]);