Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakdowns: Level, detected level, level_extracted, oh my! #685

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { getSortByPreference } from 'services/store';
import { GrotError } from '../../GrotError';
import { IndexScene } from '../../IndexScene/IndexScene';
import { CustomConstantVariable, CustomConstantVariableState } from '../../../services/CustomConstantVariable';
import { getLabelOptions } from '../../../services/filters';
import { getFieldOptions } from '../../../services/filters';
import { navigateToValueBreakdown } from '../../../services/navigate';
import { ValueSlugs } from '../../../services/routing';
import { areArraysEqual } from '../../../services/comparison';
Expand Down Expand Up @@ -118,7 +118,7 @@ export class FieldsBreakdownScene extends SceneObjectBase<FieldsBreakdownSceneSt

private updateFields(state: ServiceSceneState) {
const variable = this.getVariable();
const options = state.fields ? getLabelOptions(state.fields) : [];
const options = state.fields ? getFieldOptions(state.fields) : [];

variable.setState({
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class ServiceSelectionScene extends SceneObjectBase<ServiceSelectionScene
if (level === 'logs') {
level = '';
}
return `detected_level=\`${level}\``;
return `${LEVEL_VARIABLE_VALUE}=\`${level}\``;
});
return ` | ${filters.join(' or ')} `;
};
Expand Down
21 changes: 21 additions & 0 deletions src/services/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ export function getLabelOptions(labels: string[]) {
if (!labels.includes(LEVEL_VARIABLE_VALUE)) {
options.unshift(LEVEL_VARIABLE_VALUE);
}
const labelsIndex = options.indexOf('level');
if (labelsIndex !== -1) {
options.splice(labelsIndex, 1);
}

const labelOptions: VariableValueOption[] = options.map((label) => ({
label,
value: String(label),
}));

return [{ label: 'All', value: ALL_VARIABLE_VALUE }, ...labelOptions];
}

export function getFieldOptions(labels: string[]) {
const options = [...labels];

const labelsIndex = options.indexOf('level_extracted');
if (labelsIndex !== -1) {
options.splice(labelsIndex, 1);
}

const labelOptions: VariableValueOption[] = options.map((label) => ({
label,
value: String(label),
Expand Down
Loading