mirror of
https://github.com/SigNoz/signoz.git
synced 2026-12-03 13:40:42 +00:00
Compare commits
23 Commits
feat/affec
...
split/1-lo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69c5a891f4 | ||
|
|
bef1303ace | ||
|
|
51828488b8 | ||
|
|
0346b0c04c | ||
|
|
3f539ce27a | ||
|
|
7f59d9031e | ||
|
|
8f0a24daa0 | ||
|
|
407138fdf1 | ||
|
|
b705b692b9 | ||
|
|
579e428cc9 | ||
|
|
fe93e8824c | ||
|
|
ec447e967a | ||
|
|
59e1e19cfb | ||
|
|
a6cb832e0d | ||
|
|
1afe45e043 | ||
|
|
d1f58e7e0f | ||
|
|
374683cbba | ||
|
|
d14703f229 | ||
|
|
c1cb330a22 | ||
|
|
fcf2cad196 | ||
|
|
1ae79f5586 | ||
|
|
5c2eb3e7a3 | ||
|
|
ebe97648bf |
36
.github/CODEOWNERS
vendored
36
.github/CODEOWNERS
vendored
@@ -113,21 +113,21 @@ go.mod @therealpandey
|
||||
/pkg/modules/role/ @therealpandey
|
||||
/pkg/types/coretypes/ @therealpandey @vikrantgupta25
|
||||
|
||||
/frontend/src/lib/authz/ @H4ad
|
||||
/frontend/src/container/RolesSettings/ @H4ad
|
||||
/frontend/src/components/RolesSelect/ @H4ad
|
||||
/frontend/src/pages/MembersSettings/ @H4ad
|
||||
/frontend/src/container/MembersSettings/ @H4ad
|
||||
/frontend/src/components/MembersTable/ @H4ad
|
||||
/frontend/src/components/EditMemberDrawer/ @H4ad
|
||||
/frontend/src/components/InviteMembersModal/ @H4ad
|
||||
/frontend/src/hooks/member/ @H4ad
|
||||
/frontend/src/pages/ServiceAccountsSettings/ @H4ad
|
||||
/frontend/src/container/ServiceAccountsSettings/ @H4ad
|
||||
/frontend/src/components/ServiceAccountsTable/ @H4ad
|
||||
/frontend/src/components/ServiceAccountDrawer/ @H4ad
|
||||
/frontend/src/components/CreateServiceAccountModal/ @H4ad
|
||||
/frontend/src/hooks/serviceAccount/ @H4ad
|
||||
/frontend/src/lib/authz/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/container/RolesSettings/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/components/RolesSelect/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/pages/MembersSettings/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/container/MembersSettings/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/components/MembersTable/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/components/EditMemberDrawer/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/components/InviteMembersModal/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/hooks/member/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/pages/ServiceAccountsSettings/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/container/ServiceAccountsSettings/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/components/ServiceAccountsTable/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/components/ServiceAccountDrawer/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/components/CreateServiceAccountModal/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/hooks/serviceAccount/ @SigNoz/frontend-maintainers
|
||||
|
||||
# IdentN Owners
|
||||
|
||||
@@ -308,9 +308,9 @@ go.mod @therealpandey
|
||||
/frontend/src/container/BottomStrip/ @aks07
|
||||
|
||||
## Storybook
|
||||
/frontend/.storybook/ @H4ad
|
||||
/frontend/src/storybook/ @H4ad
|
||||
/.claude/skills/signoz-page-story/ @H4ad
|
||||
/frontend/.storybook/ @SigNoz/frontend-maintainers
|
||||
/frontend/src/storybook/ @SigNoz/frontend-maintainers
|
||||
/.claude/skills/signoz-page-story/ @SigNoz/frontend-maintainers
|
||||
|
||||
## AI Assistant
|
||||
/frontend/src/container/AIAssistant/ @SigNoz/nerve @SigNoz/frontend-maintainers
|
||||
|
||||
@@ -138,6 +138,7 @@ func runGenerateAuthz(_ context.Context) error {
|
||||
coretypes.NewResourceRef(coretypes.ResourceMetaResourceRule).String(): true,
|
||||
coretypes.NewResourceRef(coretypes.ResourceMetaResourceRoutePolicy).String(): true,
|
||||
coretypes.NewResourceRef(coretypes.ResourceMetaResourcePlannedMaintenance).String(): true,
|
||||
coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceAuditLogs).String(): true,
|
||||
}
|
||||
|
||||
allowedTypes := map[string]bool{}
|
||||
|
||||
@@ -16319,15 +16319,15 @@ paths:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSignal'
|
||||
description: 'The signal to look up keys in: traces, logs or metrics. Empty
|
||||
searches every signal.'
|
||||
- description: The data source within the signal. Use meter for Cost Meter metrics;
|
||||
empty means the default source.
|
||||
- description: The data source within the signal. Use audit for audit logs or
|
||||
meter for Cost Meter metrics; empty means the default source.
|
||||
in: query
|
||||
name: source
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSource'
|
||||
description: The data source within the signal. Use meter for Cost Meter
|
||||
metrics; empty means the default source.
|
||||
description: The data source within the signal. Use audit for audit logs
|
||||
or meter for Cost Meter metrics; empty means the default source.
|
||||
- description: Maximum number of results per signal. Defaults to 1000 for keys
|
||||
and 50 for values. For keys, intrinsic and materialized fields are added
|
||||
on top, and an empty signal applies the limit to traces, logs and metrics
|
||||
@@ -16341,27 +16341,31 @@ paths:
|
||||
metrics separately, so the response can exceed it.
|
||||
type: integer
|
||||
- description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and
|
||||
log values apply it at calendar-day granularity; metric attribute values
|
||||
and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit for
|
||||
no lower bound.
|
||||
in: query
|
||||
name: startUnixMilli
|
||||
schema:
|
||||
description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace
|
||||
and log values apply it at calendar-day granularity; metric attribute
|
||||
values and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30
|
||||
day lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit
|
||||
for no lower bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: End of the lookup window in Unix milliseconds. Ignored for key
|
||||
lookups, trace and log value lookups and meter lookups; applied to metric
|
||||
attribute values and relatedValues. Omit for no upper bound.
|
||||
lookups, trace and log value lookups, audit lookups (fixed 30 day lookback)
|
||||
and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
in: query
|
||||
name: endUnixMilli
|
||||
schema:
|
||||
description: End of the lookup window in Unix milliseconds. Ignored for
|
||||
key lookups, trace and log value lookups and meter lookups; applied to
|
||||
metric attribute values and relatedValues. Omit for no upper bound.
|
||||
key lookups, trace and log value lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: 'Restricts keys to one context: resource, attribute, scope, span,
|
||||
@@ -16469,15 +16473,15 @@ paths:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSignal'
|
||||
description: 'The signal to look up keys in: traces, logs or metrics. Empty
|
||||
searches every signal.'
|
||||
- description: The data source within the signal. Use meter for Cost Meter metrics;
|
||||
empty means the default source.
|
||||
- description: The data source within the signal. Use audit for audit logs or
|
||||
meter for Cost Meter metrics; empty means the default source.
|
||||
in: query
|
||||
name: source
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSource'
|
||||
description: The data source within the signal. Use meter for Cost Meter
|
||||
metrics; empty means the default source.
|
||||
description: The data source within the signal. Use audit for audit logs
|
||||
or meter for Cost Meter metrics; empty means the default source.
|
||||
- description: Maximum number of results per signal. Defaults to 1000 for keys
|
||||
and 50 for values. For keys, intrinsic and materialized fields are added
|
||||
on top, and an empty signal applies the limit to traces, logs and metrics
|
||||
@@ -16491,27 +16495,31 @@ paths:
|
||||
metrics separately, so the response can exceed it.
|
||||
type: integer
|
||||
- description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and
|
||||
log values apply it at calendar-day granularity; metric attribute values
|
||||
and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit for
|
||||
no lower bound.
|
||||
in: query
|
||||
name: startUnixMilli
|
||||
schema:
|
||||
description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace
|
||||
and log values apply it at calendar-day granularity; metric attribute
|
||||
values and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30
|
||||
day lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit
|
||||
for no lower bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: End of the lookup window in Unix milliseconds. Ignored for key
|
||||
lookups, trace and log value lookups and meter lookups; applied to metric
|
||||
attribute values and relatedValues. Omit for no upper bound.
|
||||
lookups, trace and log value lookups, audit lookups (fixed 30 day lookback)
|
||||
and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
in: query
|
||||
name: endUnixMilli
|
||||
schema:
|
||||
description: End of the lookup window in Unix milliseconds. Ignored for
|
||||
key lookups, trace and log value lookups and meter lookups; applied to
|
||||
metric attribute values and relatedValues. Omit for no upper bound.
|
||||
key lookups, trace and log value lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: 'Restricts keys to one context: resource, attribute, scope, span,
|
||||
@@ -29598,15 +29606,15 @@ paths:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSignal'
|
||||
description: 'The signal to look up keys in: traces, logs or metrics. Empty
|
||||
searches every signal.'
|
||||
- description: The data source within the signal. Use meter for Cost Meter metrics;
|
||||
empty means the default source.
|
||||
- description: The data source within the signal. Use audit for audit logs or
|
||||
meter for Cost Meter metrics; empty means the default source.
|
||||
in: query
|
||||
name: source
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSource'
|
||||
description: The data source within the signal. Use meter for Cost Meter
|
||||
metrics; empty means the default source.
|
||||
description: The data source within the signal. Use audit for audit logs
|
||||
or meter for Cost Meter metrics; empty means the default source.
|
||||
- description: Maximum number of results per signal. Defaults to 1000 for keys
|
||||
and 50 for values. For keys, intrinsic and materialized fields are added
|
||||
on top, and an empty signal applies the limit to traces, logs and metrics
|
||||
@@ -29620,27 +29628,31 @@ paths:
|
||||
metrics separately, so the response can exceed it.
|
||||
type: integer
|
||||
- description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and
|
||||
log values apply it at calendar-day granularity; metric attribute values
|
||||
and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit for
|
||||
no lower bound.
|
||||
in: query
|
||||
name: startUnixMilli
|
||||
schema:
|
||||
description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace
|
||||
and log values apply it at calendar-day granularity; metric attribute
|
||||
values and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30
|
||||
day lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit
|
||||
for no lower bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: End of the lookup window in Unix milliseconds. Ignored for key
|
||||
lookups, trace and log value lookups and meter lookups; applied to metric
|
||||
attribute values and relatedValues. Omit for no upper bound.
|
||||
lookups, trace and log value lookups, audit lookups (fixed 30 day lookback)
|
||||
and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
in: query
|
||||
name: endUnixMilli
|
||||
schema:
|
||||
description: End of the lookup window in Unix milliseconds. Ignored for
|
||||
key lookups, trace and log value lookups and meter lookups; applied to
|
||||
metric attribute values and relatedValues. Omit for no upper bound.
|
||||
key lookups, trace and log value lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: 'Restricts keys to one context: resource, attribute, scope, span,
|
||||
@@ -29772,15 +29784,15 @@ paths:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSignal'
|
||||
description: 'The signal to look up keys in: traces, logs or metrics. Empty
|
||||
searches every signal.'
|
||||
- description: The data source within the signal. Use meter for Cost Meter metrics;
|
||||
empty means the default source.
|
||||
- description: The data source within the signal. Use audit for audit logs or
|
||||
meter for Cost Meter metrics; empty means the default source.
|
||||
in: query
|
||||
name: source
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/TelemetrytypesSource'
|
||||
description: The data source within the signal. Use meter for Cost Meter
|
||||
metrics; empty means the default source.
|
||||
description: The data source within the signal. Use audit for audit logs
|
||||
or meter for Cost Meter metrics; empty means the default source.
|
||||
- description: Maximum number of results per signal. Defaults to 1000 for keys
|
||||
and 50 for values. For keys, intrinsic and materialized fields are added
|
||||
on top, and an empty signal applies the limit to traces, logs and metrics
|
||||
@@ -29794,27 +29806,31 @@ paths:
|
||||
metrics separately, so the response can exceed it.
|
||||
type: integer
|
||||
- description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and
|
||||
log values apply it at calendar-day granularity; metric attribute values
|
||||
and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit for
|
||||
no lower bound.
|
||||
in: query
|
||||
name: startUnixMilli
|
||||
schema:
|
||||
description: Start of the lookup window in Unix milliseconds, rounded down
|
||||
to a 6 hour boundary. Ignored for key lookups and meter lookups; trace
|
||||
and log values apply it at calendar-day granularity; metric attribute
|
||||
values and relatedValues apply it. Omit for no lower bound.
|
||||
to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30
|
||||
day lookback) and meter lookups; trace and log values apply it at calendar-day
|
||||
granularity; metric attribute values and relatedValues apply it. Omit
|
||||
for no lower bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: End of the lookup window in Unix milliseconds. Ignored for key
|
||||
lookups, trace and log value lookups and meter lookups; applied to metric
|
||||
attribute values and relatedValues. Omit for no upper bound.
|
||||
lookups, trace and log value lookups, audit lookups (fixed 30 day lookback)
|
||||
and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
in: query
|
||||
name: endUnixMilli
|
||||
schema:
|
||||
description: End of the lookup window in Unix milliseconds. Ignored for
|
||||
key lookups, trace and log value lookups and meter lookups; applied to
|
||||
metric attribute values and relatedValues. Omit for no upper bound.
|
||||
key lookups, trace and log value lookups, audit lookups (fixed 30 day
|
||||
lookback) and meter lookups; applied to metric attribute values and relatedValues.
|
||||
Omit for no upper bound.
|
||||
format: int64
|
||||
type: integer
|
||||
- description: 'Restricts keys to one context: resource, attribute, scope, span,
|
||||
|
||||
@@ -190,6 +190,7 @@ const preview: Preview = {
|
||||
['Overview', 'Kafka', 'Kafka Detail', 'Celery'],
|
||||
'Onboarding',
|
||||
['Questionnaire', 'Add Data Source'],
|
||||
'Audit Logs',
|
||||
'Settings',
|
||||
[
|
||||
'Workspace',
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
"commitlint": "commitlint --edit $1",
|
||||
"test": "jest",
|
||||
"test:changedsince": "jest --changedSince=main --coverage --silent",
|
||||
"test:affected": "node scripts/affected-tests.mjs",
|
||||
"generate:api": "orval --config ./orval.config.ts && sh scripts/post-types-generation.sh",
|
||||
"generate:config:web-settings": "json2ts ./src/schemas/generated/webSettings.schema.json -o src/types/generated/webSettings.ts --style.useTabs --style.tabWidth=1 --style.singleQuote --bannerComment '/* AUTO GENERATED FILE - DO NOT EDIT - GENERATED FROM frontend/src/schemas/generated/webSettings.schema.json */'",
|
||||
"build:geo-outlines": "node scripts/geo-outlines/build.mjs"
|
||||
|
||||
@@ -61,5 +61,6 @@
|
||||
"AI_OBSERVABILITY_OVERVIEW": "SigNoz | AI Observability Overview",
|
||||
"AI_OBSERVABILITY_EXPLORER": "SigNoz | AI Observability Explorer",
|
||||
"AI_OBSERVABILITY_CONFIGURATION": "SigNoz | AI Observability Configuration",
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping"
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping",
|
||||
"AUDIT_LOGS": "SigNoz | Audit Logs"
|
||||
}
|
||||
@@ -82,5 +82,6 @@
|
||||
"AI_OBSERVABILITY_OVERVIEW": "SigNoz | AI Observability Overview",
|
||||
"AI_OBSERVABILITY_EXPLORER": "SigNoz | AI Observability Explorer",
|
||||
"AI_OBSERVABILITY_CONFIGURATION": "SigNoz | AI Observability Configuration",
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping"
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping",
|
||||
"AUDIT_LOGS": "SigNoz | Audit Logs"
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// Usage: node scripts/affected-tests.mjs [--suite unit|storybook|e2e|all] [--base <ref>] [--list] [-- <runner args>]
|
||||
import path from 'node:path';
|
||||
|
||||
import {
|
||||
E2E,
|
||||
e2eIndex,
|
||||
specsImporting,
|
||||
specsVisiting,
|
||||
} from './affected/e2e.mjs';
|
||||
import {
|
||||
REPO,
|
||||
changedFiles,
|
||||
changedPackages,
|
||||
git,
|
||||
importersOf,
|
||||
} from './affected/git.mjs';
|
||||
import { FRONTEND, pnpm, relatedFiles } from './affected/jestGraph.mjs';
|
||||
import { log } from './affected/log.mjs';
|
||||
import { SHELL_ENTRY, pageEntries } from './affected/routes.mjs';
|
||||
|
||||
const SHARED = String.raw`^frontend/(pnpm-lock\.yaml|pnpm-workspace\.yaml|tsconfig.*\.json)$`;
|
||||
|
||||
// Any change here can affect every test of the suite, so the import graph cannot narrow it.
|
||||
const RUN_ALL = {
|
||||
unit: [
|
||||
SHARED,
|
||||
String.raw`^frontend/(jest\.\w+\.\w+|babel\.config\.cjs)$`,
|
||||
'^frontend/(__mocks__|src/__tests__)/',
|
||||
],
|
||||
storybook: [
|
||||
SHARED,
|
||||
String.raw`^frontend/vite\.config\.ts$`,
|
||||
'^frontend/(\\.storybook|src/storybook/mocks|vite-plugins)/',
|
||||
],
|
||||
e2e: [
|
||||
SHARED,
|
||||
String.raw`^frontend/(vite\.config\.ts|index\.html)$`,
|
||||
'^frontend/vite-plugins/',
|
||||
String.raw`^tests/e2e/(package\.json|pnpm-lock\.yaml|playwright\.config\.ts|tsconfig\.json)$`,
|
||||
'^tests/e2e/bootstrap/',
|
||||
],
|
||||
};
|
||||
|
||||
const STORY_MATCH = [
|
||||
'<rootDir>/src/**/*.stories.ts',
|
||||
'<rootDir>/src/**/*.stories.tsx',
|
||||
];
|
||||
const SHELL_SPEC_DIRS = ['app-shell', 'routing'];
|
||||
|
||||
function parseArgs(argv) {
|
||||
const sep = argv.indexOf('--');
|
||||
const own = sep === -1 ? argv : argv.slice(0, sep);
|
||||
const opts = {
|
||||
base: 'origin/main',
|
||||
list: false,
|
||||
suite: 'unit',
|
||||
extra: sep === -1 ? [] : argv.slice(sep + 1),
|
||||
};
|
||||
for (let i = 0; i < own.length; i++) {
|
||||
if (own[i] === '--base') {
|
||||
opts.base = own[++i];
|
||||
} else if (own[i] === '--suite') {
|
||||
opts.suite = own[++i];
|
||||
} else if (own[i] === '--list') {
|
||||
opts.list = true;
|
||||
}
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
||||
// src/pages/DashboardPage/x/y.test.tsx -> pages/DashboardPage
|
||||
function srcFeature(file) {
|
||||
const parts = path.relative(path.join(FRONTEND, 'src'), file).split(path.sep);
|
||||
return parts.length > 2 ? `${parts[0]}/${parts[1]}` : parts[0];
|
||||
}
|
||||
|
||||
function printGroups(title, files, feature) {
|
||||
const groups = Object.entries(Object.groupBy(files, feature)).sort(
|
||||
(a, b) => b[1].length - a[1].length,
|
||||
);
|
||||
log(`\n[${title}] ${groups.length} features, ${files.length} files:`);
|
||||
groups.forEach(([name, list]) =>
|
||||
log(` ${String(list.length).padStart(4)} ${name}`),
|
||||
);
|
||||
}
|
||||
|
||||
// Swaps a dependency-only package.json bump for the source files that import the bumped packages.
|
||||
function expandBumps(files, mergeBase) {
|
||||
if (!files.includes('frontend/package.json')) {
|
||||
return { files };
|
||||
}
|
||||
const pkgs = changedPackages(mergeBase, 'frontend/package.json');
|
||||
if (!pkgs) {
|
||||
return {
|
||||
files,
|
||||
reason: 'frontend/package.json changed beyond dependency versions',
|
||||
};
|
||||
}
|
||||
log(`\nBumped packages: ${pkgs.join(', ')}`);
|
||||
const rest = files.filter(
|
||||
(f) => f !== 'frontend/package.json' && f !== 'frontend/pnpm-lock.yaml',
|
||||
);
|
||||
return {
|
||||
files: [
|
||||
...new Set([
|
||||
...rest,
|
||||
...pkgs.flatMap((p) => importersOf(p, 'frontend/src')),
|
||||
]),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const planners = {
|
||||
unit: (src) => ({ files: relatedFiles(src), feature: srcFeature }),
|
||||
storybook: (src) => ({
|
||||
files: relatedFiles(src, STORY_MATCH),
|
||||
feature: srcFeature,
|
||||
}),
|
||||
e2e: (src, changed) => {
|
||||
const pages = pageEntries();
|
||||
const hit = new Set(
|
||||
relatedFiles(src, [...pages.map((p) => p.file), SHELL_ENTRY]),
|
||||
);
|
||||
const routes = pages.filter((p) => hit.has(p.file)).flatMap((p) => p.paths);
|
||||
log(
|
||||
`\n[e2e] routes reached: ${routes.join(' ') || 'none'}${hit.has(SHELL_ENTRY) ? ' + app shell' : ''}`,
|
||||
);
|
||||
const index = e2eIndex(pages.flatMap((p) => p.paths));
|
||||
const shell = hit.has(SHELL_ENTRY)
|
||||
? index.specs.filter((s) => SHELL_SPEC_DIRS.includes(index.feature(s)))
|
||||
: [];
|
||||
const own = specsImporting(
|
||||
index,
|
||||
changed.filter((f) => f.startsWith('tests/e2e/')),
|
||||
);
|
||||
return {
|
||||
files: [...new Set([...specsVisiting(index, routes), ...own, ...shell])],
|
||||
feature: index.feature,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const runners = {
|
||||
unit: (files, extra) =>
|
||||
pnpm(
|
||||
['exec', 'jest', ...(files ? ['--runTestsByPath', ...files] : []), ...extra],
|
||||
FRONTEND,
|
||||
),
|
||||
storybook: (files, extra) =>
|
||||
pnpm(
|
||||
[
|
||||
'test:storybook',
|
||||
...(files ?? []).map((f) => path.relative(FRONTEND, f)),
|
||||
...extra,
|
||||
],
|
||||
FRONTEND,
|
||||
),
|
||||
e2e: (files, extra) =>
|
||||
pnpm(
|
||||
[
|
||||
'exec',
|
||||
'playwright',
|
||||
'test',
|
||||
...(files ?? []).map((f) => path.relative(E2E, f)),
|
||||
...extra,
|
||||
],
|
||||
E2E,
|
||||
),
|
||||
};
|
||||
|
||||
function runSuite(suite, changed, bumpReason, src, opts) {
|
||||
const trigger = changed.find((f) =>
|
||||
RUN_ALL[suite].some((re) => new RegExp(re).test(f)),
|
||||
);
|
||||
const reason = bumpReason ?? (trigger && `${trigger} affects every test`);
|
||||
if (reason) {
|
||||
log(`\n[${suite}] ${reason}; running the full suite.`);
|
||||
return opts.list ? 0 : runners[suite](null, opts.extra).status;
|
||||
}
|
||||
const { files, feature } = planners[suite](src, changed);
|
||||
printGroups(suite, files, feature);
|
||||
if (opts.list || !files.length) {
|
||||
return 0;
|
||||
}
|
||||
return runners[suite](files, opts.extra).status;
|
||||
}
|
||||
|
||||
const opts = parseArgs(process.argv.slice(2));
|
||||
const mergeBase = git('merge-base', opts.base, 'HEAD');
|
||||
const original = changedFiles(mergeBase);
|
||||
if (!original.length) {
|
||||
log(`No frontend or e2e changes since ${opts.base}.`);
|
||||
process.exit(0);
|
||||
}
|
||||
log(`Changed files since ${opts.base} (${original.length}):`);
|
||||
original.forEach((f) => log(` ${f}`));
|
||||
|
||||
const { files: changed, reason: bumpReason } = expandBumps(original, mergeBase);
|
||||
const src = changed
|
||||
.filter((f) => f.startsWith('frontend/'))
|
||||
.map((f) => path.join(REPO, f));
|
||||
const suites = opts.suite === 'all' ? Object.keys(planners) : [opts.suite];
|
||||
const failed = suites.filter(
|
||||
(s) => runSuite(s, changed, bumpReason, src, opts) !== 0,
|
||||
);
|
||||
if (failed.length) {
|
||||
log(`\nFailed: ${failed.join(', ')}`);
|
||||
}
|
||||
process.exit(failed.length ? 1 : 0);
|
||||
@@ -1,107 +0,0 @@
|
||||
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import { REPO } from './git.mjs';
|
||||
|
||||
export const E2E = path.join(REPO, 'tests/e2e');
|
||||
|
||||
// A driver used by this many features is infrastructure; its URLs say nothing about a spec's pages.
|
||||
const SHARED_FEATURE_COUNT = 5;
|
||||
|
||||
const feature = (spec) =>
|
||||
path.relative(path.join(E2E, 'tests'), spec).split(path.sep)[0];
|
||||
|
||||
function listSpecs(dir = path.join(E2E, 'tests')) {
|
||||
return readdirSync(dir, { withFileTypes: true }).flatMap((d) => {
|
||||
const full = path.join(dir, d.name);
|
||||
if (d.isDirectory()) {
|
||||
return listSpecs(full);
|
||||
}
|
||||
return d.name.endsWith('.spec.ts') ? [full] : [];
|
||||
});
|
||||
}
|
||||
|
||||
function localImports(file) {
|
||||
const body = readFileSync(file, 'utf8');
|
||||
return [...body.matchAll(/(?:from|import)\s+'(\.[^']+)'/g)]
|
||||
.map(([, spec]) => path.resolve(path.dirname(file), spec))
|
||||
.map((base) =>
|
||||
[base, `${base}.ts`, `${base}/index.ts`].find(
|
||||
(f) => f.endsWith('.ts') && existsSync(f),
|
||||
),
|
||||
)
|
||||
.filter((f) => f?.startsWith(E2E));
|
||||
}
|
||||
|
||||
function closure(spec) {
|
||||
const seen = new Set();
|
||||
const visit = (f) => {
|
||||
if (seen.has(f)) {
|
||||
return;
|
||||
}
|
||||
seen.add(f);
|
||||
localImports(f).forEach(visit);
|
||||
};
|
||||
visit(spec);
|
||||
return seen;
|
||||
}
|
||||
|
||||
function routeRegex(route, nested) {
|
||||
const body = route.replace(/\/$/, '').replace(/:[^/]+/g, '[^/]+');
|
||||
return new RegExp(`^${body}${nested ? '(/.*)?' : '/?'}$`);
|
||||
}
|
||||
|
||||
// The routes a URL literal from a spec lands on; `/dashboard/` comes from `/dashboard/${id}`.
|
||||
function routesFor(literal, routes) {
|
||||
const probe = literal.endsWith('/') ? `${literal}x` : literal;
|
||||
const exact = routes.filter((r) => routeRegex(r, false).test(probe));
|
||||
if (exact.length) {
|
||||
return exact;
|
||||
}
|
||||
const nested = routes.filter((r) => routeRegex(r, true).test(probe));
|
||||
return nested.sort((a, b) => b.length - a.length).slice(0, 1);
|
||||
}
|
||||
|
||||
export function e2eIndex(routes) {
|
||||
const specs = listSpecs();
|
||||
const deps = new Map(specs.map((s) => [s, closure(s)]));
|
||||
const users = new Map();
|
||||
for (const [spec, files] of deps) {
|
||||
files.forEach((f) =>
|
||||
users.set(f, new Set([...(users.get(f) ?? []), feature(spec)])),
|
||||
);
|
||||
}
|
||||
const shared = new Set(
|
||||
[...users]
|
||||
.filter(([, feats]) => feats.size >= SHARED_FEATURE_COUNT)
|
||||
.map(([f]) => f),
|
||||
);
|
||||
const specRoutes = new Map(
|
||||
specs.map((spec) => {
|
||||
const own = [...deps.get(spec)].filter((f) => f === spec || !shared.has(f));
|
||||
const literals = own.flatMap((f) =>
|
||||
[...readFileSync(f, 'utf8').matchAll(/['"`](\/[a-z][a-z0-9/_-]*)/gi)].map(
|
||||
([, l]) => l,
|
||||
),
|
||||
);
|
||||
const hit = literals
|
||||
.filter((l) => !l.startsWith('/api/'))
|
||||
.flatMap((l) => routesFor(l, routes));
|
||||
return [spec, new Set(hit)];
|
||||
}),
|
||||
);
|
||||
return { specs, deps, specRoutes, feature };
|
||||
}
|
||||
|
||||
export function specsImporting(index, files) {
|
||||
const abs = new Set(files.map((f) => path.join(REPO, f)));
|
||||
return index.specs.filter((s) =>
|
||||
[...index.deps.get(s)].some((f) => abs.has(f)),
|
||||
);
|
||||
}
|
||||
|
||||
export function specsVisiting(index, routes) {
|
||||
return index.specs.filter((s) =>
|
||||
routes.some((r) => index.specRoutes.get(s).has(r)),
|
||||
);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import { execFileSync, spawnSync } from 'node:child_process';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
export const REPO = execFileSync('git', ['rev-parse', '--show-toplevel'], {
|
||||
cwd: import.meta.dirname,
|
||||
encoding: 'utf8',
|
||||
}).trim();
|
||||
|
||||
const DEP_FIELDS = ['dependencies', 'devDependencies'];
|
||||
|
||||
export function git(...args) {
|
||||
return execFileSync('git', args, { cwd: REPO, encoding: 'utf8' }).trim();
|
||||
}
|
||||
|
||||
const lines = (out) => out.split('\n').filter(Boolean);
|
||||
|
||||
// Repo-relative paths under frontend/ and tests/e2e/ that differ from mergeBase, uncommitted included.
|
||||
export function changedFiles(mergeBase) {
|
||||
const scope = ['frontend', 'tests/e2e'];
|
||||
const tracked = lines(git('diff', '--name-only', mergeBase, '--', ...scope));
|
||||
const untracked = lines(
|
||||
git('ls-files', '--others', '--exclude-standard', '--', ...scope),
|
||||
);
|
||||
return [...new Set([...tracked, ...untracked])].filter((f) =>
|
||||
existsSync(path.join(REPO, f)),
|
||||
);
|
||||
}
|
||||
|
||||
// Changed package names, or null when anything besides dependency versions changed.
|
||||
export function changedPackages(mergeBase, pkgJson) {
|
||||
const before = JSON.parse(git('show', `${mergeBase}:${pkgJson}`));
|
||||
const after = JSON.parse(readFileSync(path.join(REPO, pkgJson), 'utf8'));
|
||||
const strip = (pkg) =>
|
||||
JSON.stringify({
|
||||
...pkg,
|
||||
...Object.fromEntries(DEP_FIELDS.map((k) => [k, null])),
|
||||
});
|
||||
if (strip(before) !== strip(after)) {
|
||||
return null;
|
||||
}
|
||||
const names = new Set(
|
||||
DEP_FIELDS.flatMap((k) => Object.keys({ ...before[k], ...after[k] })),
|
||||
);
|
||||
return [...names].filter((n) =>
|
||||
DEP_FIELDS.some((k) => before[k]?.[n] !== after[k]?.[n]),
|
||||
);
|
||||
}
|
||||
|
||||
export function importersOf(pkg, dir) {
|
||||
const out = spawnSync(
|
||||
'git',
|
||||
['grep', '-lE', `['"]${pkg}(/[^'"]*)?['"]`, '--', dir],
|
||||
{
|
||||
cwd: REPO,
|
||||
encoding: 'utf8',
|
||||
},
|
||||
).stdout;
|
||||
return lines(out);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
export const FRONTEND = path.resolve(import.meta.dirname, '../..');
|
||||
|
||||
export function pnpm(args, cwd, stdio = 'inherit') {
|
||||
return spawnSync('pnpm', args, {
|
||||
cwd,
|
||||
encoding: 'utf8',
|
||||
stdio,
|
||||
maxBuffer: 64 * 1024 * 1024,
|
||||
});
|
||||
}
|
||||
|
||||
// Absolute paths of files matching testMatch whose import graph reaches any of files.
|
||||
export function relatedFiles(files, testMatch) {
|
||||
if (!files.length) {
|
||||
return [];
|
||||
}
|
||||
const match = testMatch ? ['--testMatch', ...testMatch] : [];
|
||||
const res = pnpm(
|
||||
['exec', 'jest', '--listTests', '--findRelatedTests', ...files, ...match],
|
||||
FRONTEND,
|
||||
'pipe',
|
||||
);
|
||||
if (res.status !== 0) {
|
||||
throw new Error(`jest --listTests failed:\n${res.stderr}`);
|
||||
}
|
||||
return res.stdout.split('\n').filter((l) => l.startsWith('/'));
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export const log = (message) => process.stdout.write(`${message}\n`);
|
||||
@@ -1,57 +0,0 @@
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import { FRONTEND } from './jestGraph.mjs';
|
||||
|
||||
const SRC = path.join(FRONTEND, 'src');
|
||||
const read = (rel) => readFileSync(path.join(SRC, rel), 'utf8');
|
||||
|
||||
// Mounted around every page, so a change it reaches shows up as the shell, not as a page.
|
||||
export const SHELL_ENTRY = path.join(SRC, 'container/AppLayout/index.tsx');
|
||||
|
||||
function resolveModule(spec) {
|
||||
const base = path.join(SRC, spec);
|
||||
const candidates = ['.tsx', '.ts', '/index.tsx', '/index.ts'].map(
|
||||
(ext) => base + ext,
|
||||
);
|
||||
return candidates.find(existsSync);
|
||||
}
|
||||
|
||||
function routePaths() {
|
||||
const body = read('constants/routes.ts');
|
||||
return Object.fromEntries(
|
||||
[...body.matchAll(/^\s*(\w+):\s*'([^']+)'/gm)].map(([, k, v]) => [
|
||||
k,
|
||||
v.split('?')[0],
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
function componentModules() {
|
||||
const body = read('AppRoutes/pageComponents.ts');
|
||||
const re =
|
||||
/export const (\w+) = Loadable\(\s*\(\)\s*=>\s*import\(\s*(?:\/\*[\s\S]*?\*\/\s*)?'([^']+)'/g;
|
||||
return Object.fromEntries(
|
||||
[...body.matchAll(re)].map(([, name, spec]) => [name, resolveModule(spec)]),
|
||||
);
|
||||
}
|
||||
|
||||
// [{ file, paths }] for every page module the router mounts.
|
||||
export function pageEntries() {
|
||||
const paths = routePaths();
|
||||
const modules = componentModules();
|
||||
const byFile = new Map();
|
||||
for (const [block] of read('AppRoutes/routes.ts').matchAll(/\{[^{}]*\}/g)) {
|
||||
const component = block.match(/component:\s*(\w+)/)?.[1];
|
||||
const pathLine = block.match(/path:\s*([^\n]+)/)?.[1] ?? '';
|
||||
const file = modules[component];
|
||||
if (!file) {
|
||||
continue;
|
||||
}
|
||||
const routeKeys = [...pathLine.matchAll(/ROUTES\.(\w+)/g)]
|
||||
.map(([, k]) => paths[k])
|
||||
.filter(Boolean);
|
||||
byFile.set(file, [...(byFile.get(file) ?? []), ...routeKeys]);
|
||||
}
|
||||
return [...byFile].map(([file, p]) => ({ file, paths: [...new Set(p)] }));
|
||||
}
|
||||
@@ -1768,6 +1768,7 @@ describe('PrivateRoute', () => {
|
||||
deniedRoles: DENIED_ROLES,
|
||||
},
|
||||
BILLING: { path: ROUTES.BILLING, deniedRoles: DENIED_ROLES },
|
||||
AUDIT_LOGS: { path: ROUTES.AUDIT_LOGS, deniedRoles: DENIED_ROLES },
|
||||
};
|
||||
|
||||
const authzRouteRolePairs: [string, string, ROLES][] = Object.entries(
|
||||
|
||||
@@ -292,3 +292,10 @@ export const LLMObservabilityPage = Loadable(
|
||||
/* webpackChunkName: "LLM Observability Page" */ 'pages/LLMObservability'
|
||||
),
|
||||
);
|
||||
|
||||
export const AuditLogsPage = Loadable(
|
||||
() =>
|
||||
import(
|
||||
/* webpackChunkName: "Audit Logs Page" */ 'pages/AuditLogsModule/AuditLogsModule'
|
||||
),
|
||||
);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
AlertOverview,
|
||||
AllErrors,
|
||||
ApiMonitoring,
|
||||
AuditLogsPage,
|
||||
ChannelsEdit,
|
||||
ChannelsNew,
|
||||
CreateNewAlerts,
|
||||
@@ -408,6 +409,12 @@ const routes: AppRoutes[] = [
|
||||
key: 'AI_OBSERVABILITY_CONFIGURATION',
|
||||
isPrivate: true,
|
||||
},
|
||||
{
|
||||
path: ROUTES.AUDIT_LOGS,
|
||||
component: AuditLogsPage,
|
||||
key: 'AUDIT_LOGS',
|
||||
isPrivate: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const SUPPORT_ROUTE: AppRoutes = {
|
||||
|
||||
@@ -15821,7 +15821,7 @@ export type GetFieldsKeysParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -15832,13 +15832,13 @@ export type GetFieldsKeysParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
@@ -15880,7 +15880,7 @@ export type GetFieldsValuesParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -15891,13 +15891,13 @@ export type GetFieldsValuesParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
@@ -17626,7 +17626,7 @@ export type GetRuleHistoryFilterKeysParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -17637,13 +17637,13 @@ export type GetRuleHistoryFilterKeysParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
@@ -17688,7 +17688,7 @@ export type GetRuleHistoryFilterValuesParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -17699,13 +17699,13 @@ export type GetRuleHistoryFilterValuesParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
|
||||
@@ -396,16 +396,20 @@ describe('convertV5ResponseToLegacy', () => {
|
||||
meta: { rowsScanned: 0, bytesScanned: 0, durationMs: 0, stepIntervals: {} },
|
||||
} as unknown as QueryRangeResponseV5;
|
||||
|
||||
const baseSpec = {
|
||||
name: 'A',
|
||||
stepInterval: 60,
|
||||
disabled: false,
|
||||
aggregations: [],
|
||||
};
|
||||
|
||||
const params = makeBaseParams(type as RequestType, [
|
||||
{
|
||||
type: 'builder_query',
|
||||
spec: {
|
||||
name: 'A',
|
||||
signal: type === 'trace' ? 'traces' : 'logs',
|
||||
stepInterval: 60,
|
||||
disabled: false,
|
||||
aggregations: [],
|
||||
},
|
||||
spec:
|
||||
type === 'trace'
|
||||
? { ...baseSpec, signal: 'traces' }
|
||||
: { ...baseSpec, signal: 'logs' },
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -467,5 +471,34 @@ describe('convertV5ResponseToLegacy', () => {
|
||||
const data = (result.payload.data.result[0].list?.[0] as any)?.data ?? {};
|
||||
expect('body' in data).toBe(false);
|
||||
});
|
||||
|
||||
const getRowData = (
|
||||
result: ReturnType<typeof convertV5ResponseToLegacy>,
|
||||
): Record<string, unknown> =>
|
||||
(result.payload.data.result[0].list?.[0] as any)?.data ?? {};
|
||||
|
||||
it('lifts resource.attributes onto resource', () => {
|
||||
const result = makeRawResult([
|
||||
{
|
||||
timestamp: '2026-07-21T00:00:00Z',
|
||||
data: {
|
||||
resource: { attributes: { 'signoz.resource.kind': 'dashboard' } },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
expect(getRowData(result).resource).toStrictEqual({
|
||||
'signoz.resource.kind': 'dashboard',
|
||||
});
|
||||
});
|
||||
|
||||
it('leaves a flat resource unchanged', () => {
|
||||
const resource = { 'service.name': 'signoz' };
|
||||
const result = makeRawResult([
|
||||
{ timestamp: '2026-07-21T00:00:00Z', data: { resource } },
|
||||
]);
|
||||
|
||||
expect(getRowData(result).resource).toStrictEqual(resource);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { extractOnlyMessageBody } from 'lib/logs/logBody';
|
||||
import { cloneDeep, isEmpty } from 'lodash-es';
|
||||
import { cloneDeep, get, isEmpty, isPlainObject } from 'lodash-es';
|
||||
import { SuccessResponse, Warning } from 'types/api';
|
||||
import { MetricRangePayloadV3 } from 'types/api/metrics/getQueryRange';
|
||||
import {
|
||||
@@ -305,6 +305,12 @@ function convertRawData(
|
||||
data.body = extractOnlyMessageBody(row.data.body);
|
||||
}
|
||||
|
||||
// Audit rows nest resource keys under resource.attributes; lift them so resource is flat and FlatLogData flattens it.
|
||||
const resourceAttributes = get(row.data, ['resource', 'attributes']);
|
||||
if (isPlainObject(resourceAttributes)) {
|
||||
data.resource = resourceAttributes;
|
||||
}
|
||||
|
||||
return {
|
||||
timestamp: row.timestamp,
|
||||
data,
|
||||
|
||||
@@ -643,6 +643,28 @@ describe('prepareQueryRangePayloadV5', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('sends source audit on a logs query that targets audit', () => {
|
||||
const [envelope] = convertBuilderQueriesToV5(
|
||||
{
|
||||
A: baseBuilderQuery({ dataSource: DataSource.LOGS, source: 'audit' }),
|
||||
},
|
||||
'raw',
|
||||
);
|
||||
|
||||
expect(envelope.spec).toMatchObject({ signal: 'logs', source: 'audit' });
|
||||
});
|
||||
|
||||
it('sends no source on a plain logs query', () => {
|
||||
const [envelope] = convertBuilderQueriesToV5(
|
||||
{
|
||||
A: baseBuilderQuery({ dataSource: DataSource.LOGS, source: '' }),
|
||||
},
|
||||
'raw',
|
||||
);
|
||||
|
||||
expect(envelope.spec).not.toHaveProperty('source');
|
||||
});
|
||||
|
||||
it('builds payload for builder queries with filters array but no filter expression', () => {
|
||||
const props: GetQueryResultsProps = {
|
||||
query: {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
/* eslint-disable sonarjs/no-identical-functions */
|
||||
import { TelemetrytypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { convertFiltersToExpression } from 'components/QueryBuilderV2/utils';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
|
||||
@@ -341,6 +342,9 @@ export function convertBuilderQueriesToV5(
|
||||
spec = {
|
||||
name: queryName,
|
||||
signal: 'logs' as const,
|
||||
...(queryData.source === TelemetrytypesSourceDTO.audit && {
|
||||
source: TelemetrytypesSourceDTO.audit,
|
||||
}),
|
||||
...baseSpec,
|
||||
aggregations: aggregations as LogAggregation[],
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { Button } from '@signozhq/ui/button';
|
||||
import { ToggleGroup } from '@signozhq/ui/toggle-group';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import { Tooltip } from 'antd';
|
||||
import { SavedviewtypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import LogStateIndicator from 'components/Logs/LogStateIndicator/LogStateIndicator';
|
||||
@@ -20,22 +19,17 @@ import useInitialQuery from 'container/LogsExplorerContext/useInitialQuery';
|
||||
import { useOptionsMenu } from 'container/OptionsMenu';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import { useArrowKeyNavigation } from 'container/TracesExplorer/SpanDrawer/useArrowKeyNavigation';
|
||||
import { useCloseOnOutsideClick } from 'hooks/logs/useCloseOnOutsideClick';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { getBodyMessage } from 'lib/logs/logBody';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import {
|
||||
ArrowDown,
|
||||
ArrowUp,
|
||||
Filter,
|
||||
Histogram,
|
||||
Table,
|
||||
TextSelect,
|
||||
} from '@signozhq/icons';
|
||||
import { Filter, Histogram, Table, TextSelect } from '@signozhq/icons';
|
||||
import { Query, TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource, StringOperators } from 'types/common/queryBuilder';
|
||||
|
||||
import { RESOURCE_KEYS, VIEW_TYPES, VIEWS } from './constants';
|
||||
import { LogDetailBodyProps } from './LogDetail.interfaces';
|
||||
import { LogNavigationHint } from './LogNavigationHint/LogNavigationHint';
|
||||
import LogHighlights from './LogHighlights/LogHighlights';
|
||||
|
||||
/* eslint-disable-next-line sonarjs/cognitive-complexity */
|
||||
@@ -61,33 +55,7 @@ function LogDetailBody({
|
||||
const [isEdit, setIsEdit] = useState<boolean>(false);
|
||||
const { stagedQuery } = useQueryBuilder();
|
||||
|
||||
// Handle clicks outside to close drawer, except on explicitly ignored regions
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (e: MouseEvent): void => {
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
// Don't close if clicking on drawer content, overlays, or portal elements
|
||||
if (
|
||||
target.closest('[data-log-detail-ignore="true"]') ||
|
||||
target.closest('.cm-tooltip-autocomplete') ||
|
||||
target.closest('.drawer-popover') ||
|
||||
target.closest('.query-status-popover') ||
|
||||
target.closest('[data-radix-popper-content-wrapper]') ||
|
||||
target.closest('[data-base-ui-portal]')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Close the drawer for any other outside click
|
||||
onClose();
|
||||
};
|
||||
|
||||
document.addEventListener('mousedown', handleClickOutside);
|
||||
|
||||
return (): void => {
|
||||
document.removeEventListener('mousedown', handleClickOutside);
|
||||
};
|
||||
}, [onClose]);
|
||||
useCloseOnOutsideClick(true, onClose);
|
||||
|
||||
// Only listen in the OVERVIEW tab so we don't hijack arrow keys from the
|
||||
// JSON editor / context view.
|
||||
@@ -329,31 +297,7 @@ function LogDetailBody({
|
||||
|
||||
{selectedView === VIEW_TYPES.OVERVIEW && (
|
||||
<div className="log-detail-drawer__footer-hint">
|
||||
<div className="log-detail-drawer__footer-hint-content">
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
Use
|
||||
</Typography>
|
||||
<ArrowUp size={14} className="log-detail-drawer__footer-hint-icon" />
|
||||
<span>/</span>
|
||||
<ArrowDown size={14} className="log-detail-drawer__footer-hint-icon" />
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
to view previous/next log
|
||||
</Typography>
|
||||
</div>
|
||||
<LogNavigationHint />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -110,17 +110,5 @@
|
||||
color: var(--l3-foreground);
|
||||
background: var(--drawer-background);
|
||||
z-index: 10;
|
||||
|
||||
.log-detail-drawer__footer-hint-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.log-detail-drawer__footer-hint-icon {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
color: var(--l3-foreground);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import { act, renderHook } from 'tests/test-utils';
|
||||
|
||||
import { useLogNavigation } from '../useLogNavigation';
|
||||
|
||||
interface TestLog {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
const logs: TestLog[] = [
|
||||
{ id: 'a', label: 'first' },
|
||||
{ id: 'b', label: 'second' },
|
||||
{ id: 'c', label: 'third' },
|
||||
];
|
||||
|
||||
const onNavigateLog = jest.fn() as jest.MockedFunction<(log: TestLog) => void>;
|
||||
const onScrollToLog = jest.fn() as jest.MockedFunction<(id: string) => void>;
|
||||
|
||||
function renderNavigation(
|
||||
activeLogId: string,
|
||||
list: TestLog[] | undefined = logs,
|
||||
) {
|
||||
return renderHook(() =>
|
||||
useLogNavigation<TestLog>({
|
||||
logs: list,
|
||||
activeLogId,
|
||||
onNavigateLog,
|
||||
onScrollToLog,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('useLogNavigation', () => {
|
||||
it('disables previous on the first log', () => {
|
||||
const { result } = renderNavigation('a');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(true);
|
||||
expect(result.current.isNextDisabled).toBe(false);
|
||||
});
|
||||
|
||||
it('disables next on the last log', () => {
|
||||
const { result } = renderNavigation('c');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(false);
|
||||
expect(result.current.isNextDisabled).toBe(true);
|
||||
});
|
||||
|
||||
it('enables both in the middle', () => {
|
||||
const { result } = renderNavigation('b');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(false);
|
||||
expect(result.current.isNextDisabled).toBe(false);
|
||||
});
|
||||
|
||||
it('moves to the next log and scrolls to it', () => {
|
||||
const { result } = renderNavigation('b');
|
||||
|
||||
act(() => result.current.goToNext());
|
||||
|
||||
expect(onNavigateLog).toHaveBeenCalledWith(logs[2]);
|
||||
expect(onScrollToLog).toHaveBeenCalledWith('c');
|
||||
});
|
||||
|
||||
it('moves to the previous log and scrolls to it', () => {
|
||||
const { result } = renderNavigation('b');
|
||||
|
||||
act(() => result.current.goToPrev());
|
||||
|
||||
expect(onNavigateLog).toHaveBeenCalledWith(logs[0]);
|
||||
expect(onScrollToLog).toHaveBeenCalledWith('a');
|
||||
});
|
||||
|
||||
it('does nothing past the ends', () => {
|
||||
const { result } = renderNavigation('a');
|
||||
|
||||
act(() => result.current.goToPrev());
|
||||
|
||||
expect(onNavigateLog).not.toHaveBeenCalled();
|
||||
expect(onScrollToLog).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('disables both when the active log is not in the list', () => {
|
||||
const { result } = renderNavigation('missing');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(true);
|
||||
expect(result.current.isNextDisabled).toBe(true);
|
||||
});
|
||||
|
||||
it('disables both without logs', () => {
|
||||
const { result } = renderNavigation('a', []);
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(true);
|
||||
expect(result.current.isNextDisabled).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
import { LogWithId } from 'hooks/logs/types';
|
||||
|
||||
interface UseLogNavigationParams {
|
||||
logs?: ILog[];
|
||||
interface UseLogNavigationParams<T extends LogWithId> {
|
||||
logs?: T[];
|
||||
activeLogId: string;
|
||||
onNavigateLog?: (log: ILog) => void;
|
||||
onNavigateLog?: (log: T) => void;
|
||||
onScrollToLog?: (id: string) => void;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ interface UseLogNavigationReturn {
|
||||
isNextDisabled: boolean;
|
||||
}
|
||||
|
||||
export function useLogNavigation({
|
||||
export function useLogNavigation<T extends LogWithId>({
|
||||
logs,
|
||||
activeLogId,
|
||||
onNavigateLog,
|
||||
onScrollToLog,
|
||||
}: UseLogNavigationParams): UseLogNavigationReturn {
|
||||
}: UseLogNavigationParams<T>): UseLogNavigationReturn {
|
||||
const currentIndex = useMemo(
|
||||
() => logs?.findIndex((l) => l.id === activeLogId) ?? -1,
|
||||
[logs, activeLogId],
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-2);
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
color: var(--l3-foreground);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { ArrowDown, ArrowUp } from '@signozhq/icons';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
|
||||
import styles from './LogNavigationHint.module.scss';
|
||||
|
||||
export function LogNavigationHint(): JSX.Element {
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
Use
|
||||
</Typography>
|
||||
<ArrowUp size={14} className={styles.icon} />
|
||||
<span>/</span>
|
||||
<ArrowDown size={14} className={styles.icon} />
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
to view previous/next log
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -155,14 +155,6 @@
|
||||
background: var(--l2-background);
|
||||
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.context-btn {
|
||||
width: 50% !important;
|
||||
}
|
||||
.copy-link-btn {
|
||||
width: 50% !important;
|
||||
border-left: 1px solid var(--l1-border) !important;
|
||||
}
|
||||
|
||||
.ant-btn-default {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
|
||||
@@ -83,9 +83,3 @@ export const LogText = styled.div<LogTextProps>`
|
||||
: 'white-space: nowrap;'};
|
||||
};
|
||||
`;
|
||||
|
||||
export const SelectedLog = styled.div`
|
||||
display: flex;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
@@ -27,14 +27,3 @@
|
||||
border-color: var(--l1-border) !important;
|
||||
}
|
||||
}
|
||||
|
||||
// In table/column view, keep action buttons visible at the viewport's right edge
|
||||
.log-line-action-buttons.table-view-log-actions {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 8px;
|
||||
left: auto;
|
||||
transform: translateY(-50%);
|
||||
margin: 0;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import Spinner from 'components/Spinner';
|
||||
|
||||
export function LogsLoadingFooter(): JSX.Element {
|
||||
return <Spinner height={20} tip="Getting Logs" testId="logs-loading-footer" />;
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
import { blue } from '@ant-design/colors';
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
import Space from 'periscope/components/Space/Space';
|
||||
import Col from 'periscope/components/Col/Col';
|
||||
import Row from 'periscope/components/Row/Row';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import { Info } from '@signozhq/icons';
|
||||
@@ -73,12 +70,6 @@ export const InfoIconWrapper = styled(Info)`
|
||||
height: auto;
|
||||
`;
|
||||
|
||||
export const ExpandIconWrapper = styled(Col)`
|
||||
color: ${blue[6]};
|
||||
padding: 0.25rem 0.375rem;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
export const RawLogContent = styled.div<RawLogContentProps>`
|
||||
margin-bottom: 0;
|
||||
font-family: 'SF Mono', monospace;
|
||||
@@ -112,11 +103,3 @@ export const RawLogContent = styled.div<RawLogContentProps>`
|
||||
cursor: ${({ $isActiveLog, $isReadOnly }): string =>
|
||||
$isActiveLog || $isReadOnly ? 'initial' : 'pointer'};
|
||||
`;
|
||||
|
||||
export const ActionButtonsWrapper = styled(Space)`
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
top: 50%;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
@@ -187,177 +187,6 @@
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.add-new-column-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.add-new-column-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 8px;
|
||||
gap: 8px;
|
||||
|
||||
.back-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
}
|
||||
|
||||
.add-new-column-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
padding-bottom: 16px;
|
||||
|
||||
min-height: 240px;
|
||||
max-height: 400px;
|
||||
|
||||
.loading-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.column-format-new-options {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
.column-name {
|
||||
padding: 4px 8px;
|
||||
border-radius: 1px;
|
||||
color: var(--l2-foreground);
|
||||
|
||||
&.selected {
|
||||
background-color: var(--l3-background);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
height: 1rem;
|
||||
width: 0.2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.selected-item-content-container {
|
||||
.add-new-column-header {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: var(--l1-foreground);
|
||||
|
||||
margin-bottom: 12px;
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.lucide {
|
||||
color: var(--l2-foreground);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.horizontal-line {
|
||||
height: 1px;
|
||||
background: var(--l3-background);
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.item-content {
|
||||
padding: 12px;
|
||||
|
||||
.column-format,
|
||||
.column-format-new-options {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex-direction: column;
|
||||
margin-top: 12px;
|
||||
|
||||
.column-name {
|
||||
color: var(--l2-foreground);
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
&.default-column {
|
||||
color: var(--l2-foreground);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.no-columns-selected {
|
||||
color: var(--l3-foreground);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.add-new-column-btn {
|
||||
color: var(--l2-foreground);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.name {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
display: none;
|
||||
flex: 0 0 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.delete-btn {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
overflow-x: hidden;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
height: 1rem;
|
||||
width: 0.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.column-format {
|
||||
max-height: 150px;
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.column-format-new-options {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.column-divider {
|
||||
margin: 12px 0;
|
||||
border-top: 2px solid var(--l1-border);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
.nested-menu-container {
|
||||
backdrop-filter: blur(18px);
|
||||
@@ -368,26 +197,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.selected-item-content-container {
|
||||
width: 110%;
|
||||
margin-left: -5%;
|
||||
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--l1-border);
|
||||
background: linear-gradient(
|
||||
139deg,
|
||||
color-mix(in srgb, var(--surface-2) 80%, transparent) 0%,
|
||||
color-mix(in srgb, var(--surface-2) 90%, transparent) 98.68%
|
||||
);
|
||||
|
||||
box-shadow: 4px 10px 16px 2px rgba(0, 0, 0, 0.2);
|
||||
backdrop-filter: blur(20px);
|
||||
|
||||
.column-format {
|
||||
margin-top: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ function OptionsMenu({
|
||||
type="button"
|
||||
className="periscope-btn"
|
||||
aria-label="Fewer lines per row"
|
||||
data-testid="max-lines-fewer"
|
||||
onClick={(): void => handleLinesPerRowChange(maxLinesPerRow - 1)}
|
||||
>
|
||||
<Minus size={12} />
|
||||
@@ -211,6 +212,7 @@ function OptionsMenu({
|
||||
type="button"
|
||||
className="periscope-btn"
|
||||
aria-label="More lines per row"
|
||||
data-testid="max-lines-more"
|
||||
onClick={(): void => handleLinesPerRowChange(maxLinesPerRow + 1)}
|
||||
>
|
||||
<Plus size={12} />
|
||||
|
||||
@@ -26,9 +26,3 @@
|
||||
width: max-content;
|
||||
}
|
||||
}
|
||||
|
||||
.select-label-with-coming-soon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
@@ -1,39 +1,8 @@
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
import { Tooltip } from 'antd';
|
||||
import type { DefaultOptionType } from 'antd/es/select';
|
||||
import { Info } from '@signozhq/icons';
|
||||
|
||||
import './MQCommon.styles.scss';
|
||||
|
||||
export function ComingSoon(): JSX.Element {
|
||||
return (
|
||||
<Tooltip
|
||||
title={
|
||||
<div>
|
||||
Join our Slack community for more details:{' '}
|
||||
<a
|
||||
href="https://signoz.io/slack"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
onClick={(e): void => e.stopPropagation()}
|
||||
>
|
||||
SigNoz Community
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
placement="top"
|
||||
overlayClassName="tooltip-overlay"
|
||||
>
|
||||
<div className="coming-soon">
|
||||
<div className="coming-soon__text">Coming Soon</div>
|
||||
<div className="coming-soon__icon">
|
||||
<Info size={10} color={Color.BG_SIENNA_400} />
|
||||
</div>
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export function SelectMaxTagPlaceholder(
|
||||
omittedValues: Partial<DefaultOptionType>[],
|
||||
): JSX.Element {
|
||||
@@ -43,15 +12,3 @@ export function SelectMaxTagPlaceholder(
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export function SelectLabelWithComingSoon({
|
||||
label,
|
||||
}: {
|
||||
label: string;
|
||||
}): JSX.Element {
|
||||
return (
|
||||
<div className="select-label-with-coming-soon">
|
||||
{label} <ComingSoon />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useCallback } from 'react';
|
||||
import { Button } from '@signozhq/ui/button';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import ROUTES from 'constants/routes';
|
||||
@@ -22,6 +23,10 @@ function NotificationChannelsNotFound({
|
||||
}: NotificationChannelsNotFoundProps): JSX.Element {
|
||||
const { isGranted, isLoading, error } = useAuthZ(CREATE_CHECKS);
|
||||
const canCreate = !!error || isGranted(NotificationChannelCreatePermission);
|
||||
const openCreateChannel = useCallback(
|
||||
(): void => openInNewTab(ROUTES.CHANNELS_NEW),
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
@@ -43,7 +48,7 @@ function NotificationChannelsNotFound({
|
||||
color="primary"
|
||||
size="sm"
|
||||
testId="channels-not-found-create"
|
||||
onClick={(): void => openInNewTab(ROUTES.CHANNELS_NEW)}
|
||||
onClick={openCreateChannel}
|
||||
>
|
||||
Create one here.
|
||||
</Button>
|
||||
|
||||
@@ -238,7 +238,7 @@ export const QueryBuilderV2 = memo(function QueryBuilderV2({
|
||||
queryVariant={config?.queryVariant || 'dropdown'}
|
||||
showOnlyWhereClause={showOnlyWhereClause}
|
||||
isRawQuery={isRawQuery}
|
||||
signalSource={activeBuilder.queryData[0].source as 'meter' | ''}
|
||||
signalSource={activeBuilder.queryData[0].source}
|
||||
onSignalSourceChange={onSignalSourceChange || ((): void => {})}
|
||||
signalSourceChangeEnabled={signalSourceChangeEnabled}
|
||||
queriesCount={1}
|
||||
@@ -260,7 +260,7 @@ export const QueryBuilderV2 = memo(function QueryBuilderV2({
|
||||
queryVariant={config?.queryVariant || 'dropdown'}
|
||||
showOnlyWhereClause={showOnlyWhereClause}
|
||||
isRawQuery={isRawQuery}
|
||||
signalSource={query.source as 'meter' | ''}
|
||||
signalSource={query.source}
|
||||
onSignalSourceChange={onSignalSourceChange || ((): void => {})}
|
||||
signalSourceChangeEnabled={signalSourceChangeEnabled}
|
||||
queriesCount={activeBuilder.queryData.length}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useMemo } from 'react';
|
||||
import { TelemetrytypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { FieldValuesConfig } from 'api/querySuggestions/types';
|
||||
import { QUICK_FILTER_SOURCE_TO_SIGNAL } from 'components/QuickFilters/constants';
|
||||
import {
|
||||
QUICK_FILTER_SOURCE_TO_SIGNAL,
|
||||
QUICK_FILTER_SOURCE_TO_SOURCE,
|
||||
} from 'components/QuickFilters/constants';
|
||||
import {
|
||||
IQuickFiltersConfig,
|
||||
QuickFiltersSource,
|
||||
@@ -27,12 +29,6 @@ interface UseFieldValuesReturn {
|
||||
isFetching: boolean;
|
||||
}
|
||||
|
||||
const QUICK_FILTERS_SOURCE_TO_SOURCE: Partial<
|
||||
Record<QuickFiltersSource, TelemetrytypesSourceDTO>
|
||||
> = {
|
||||
[QuickFiltersSource.METER_EXPLORER]: TelemetrytypesSourceDTO.meter,
|
||||
};
|
||||
|
||||
export function useFieldValues({
|
||||
filter,
|
||||
searchText,
|
||||
@@ -65,7 +61,7 @@ export function useFieldValues({
|
||||
searchText,
|
||||
existingQuery,
|
||||
metricNamespace,
|
||||
source: QUICK_FILTERS_SOURCE_TO_SOURCE[quickFilterSource],
|
||||
source: QUICK_FILTER_SOURCE_TO_SOURCE[quickFilterSource],
|
||||
startUnixMilli,
|
||||
// This field does not affect the backend but I wanted to keep it here
|
||||
// in case we add the support in the future
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { useMemo } from 'react';
|
||||
import { Button, Skeleton } from 'antd';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import {
|
||||
QuickfiltertypesSourceDTO,
|
||||
TelemetrytypesSourceDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { QuickfiltertypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { FieldKeysConfig } from 'api/querySuggestions/types';
|
||||
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
|
||||
import { QUICK_FILTER_SOURCE_TO_SIGNAL } from 'components/QuickFilters/constants';
|
||||
import {
|
||||
QUICK_FILTER_SOURCE_TO_SIGNAL,
|
||||
QUICK_FILTER_SOURCE_TO_SOURCE,
|
||||
} from 'components/QuickFilters/constants';
|
||||
import { buildCompositeKey } from 'container/OptionsMenu/utils';
|
||||
import { useFieldKeysSuggestion } from 'hooks/querySuggestions/useFieldKeysSuggestion';
|
||||
import {
|
||||
@@ -44,8 +44,6 @@ function OtherFilters({
|
||||
addedFilters: TelemetryFieldKey[];
|
||||
setAddedFilters: React.Dispatch<React.SetStateAction<TelemetryFieldKey[]>>;
|
||||
}): JSX.Element {
|
||||
const isMeterDataSource =
|
||||
savedFiltersSource === QuickfiltertypesSourceDTO.meter;
|
||||
const isAIObservability =
|
||||
savedFiltersSource === QuickfiltertypesSourceDTO.ai_observability;
|
||||
|
||||
@@ -58,7 +56,7 @@ function OtherFilters({
|
||||
: {
|
||||
searchText: inputValue,
|
||||
signal: QUICK_FILTER_SOURCE_TO_SIGNAL[savedFiltersSource],
|
||||
source: isMeterDataSource ? TelemetrytypesSourceDTO.meter : undefined,
|
||||
source: QUICK_FILTER_SOURCE_TO_SOURCE[savedFiltersSource],
|
||||
};
|
||||
|
||||
const { data: fetchedKeys, isFetching } = useFieldKeysSuggestion(
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import {
|
||||
TelemetrytypesSignalDTO,
|
||||
TelemetrytypesSourceDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import { QuickFiltersSource } from './types';
|
||||
|
||||
@@ -15,3 +18,17 @@ export const QUICK_FILTER_SOURCE_TO_SIGNAL: Record<
|
||||
[QuickFiltersSource.INFRA_MONITORING]: TelemetrytypesSignalDTO.metrics,
|
||||
[QuickFiltersSource.AUDIT_LOGS]: TelemetrytypesSignalDTO.logs,
|
||||
};
|
||||
|
||||
export const QUICK_FILTER_SOURCE_TO_SOURCE: Record<
|
||||
QuickFiltersSource,
|
||||
TelemetrytypesSourceDTO | undefined
|
||||
> = {
|
||||
[QuickFiltersSource.LOGS_EXPLORER]: undefined,
|
||||
[QuickFiltersSource.TRACES_EXPLORER]: undefined,
|
||||
[QuickFiltersSource.EXCEPTIONS]: undefined,
|
||||
[QuickFiltersSource.API_MONITORING]: undefined,
|
||||
[QuickFiltersSource.AI_OBSERVABILITY]: undefined,
|
||||
[QuickFiltersSource.METER_EXPLORER]: TelemetrytypesSourceDTO.meter,
|
||||
[QuickFiltersSource.INFRA_MONITORING]: undefined,
|
||||
[QuickFiltersSource.AUDIT_LOGS]: TelemetrytypesSourceDTO.audit,
|
||||
};
|
||||
|
||||
@@ -48,4 +48,5 @@ export enum LOCALSTORAGE {
|
||||
ALERT_RULES_LIST_VIEWS = 'ALERT_RULES_LIST_VIEWS',
|
||||
DASHBOARD_V2_PANEL_COLUMN_WIDTHS = 'DASHBOARD_V2_PANEL_COLUMN_WIDTHS',
|
||||
LLM_ATTRIBUTE_MAPPING_TEST_SPAN = 'LLM_ATTRIBUTE_MAPPING_TEST_SPAN',
|
||||
AUDIT_LOGS_OPTIONS = 'AUDIT_LOGS_OPTIONS',
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export const REACT_QUERY_KEY = {
|
||||
GET_PUBLIC_DASHBOARD_WIDGET_DATA: 'GET_PUBLIC_DASHBOARD_WIDGET_DATA',
|
||||
GET_ALL_LICENCES: 'GET_ALL_LICENCES',
|
||||
GET_QUERY_RANGE: 'GET_QUERY_RANGE',
|
||||
GET_AUDIT_LOGS: 'GET_AUDIT_LOGS',
|
||||
GET_ALL_DASHBOARDS: 'GET_ALL_DASHBOARDS',
|
||||
GET_TRIGGERED_ALERTS: 'GET_TRIGGERED_ALERTS',
|
||||
DASHBOARD_BY_ID: 'DASHBOARD_BY_ID',
|
||||
|
||||
@@ -41,6 +41,7 @@ const ROUTES = {
|
||||
LOGS_PIPELINES: '/logs/pipelines',
|
||||
PASSWORD_RESET: '/password-reset',
|
||||
LIST_LICENSES: '/licenses',
|
||||
AUDIT_LOGS: '/audit-logs',
|
||||
LOGS_INDEX_FIELDS: '/logs-explorer/index-fields',
|
||||
TRACE_EXPLORER: '/trace-explorer',
|
||||
BILLING: '/settings/billing',
|
||||
|
||||
@@ -1,51 +1,3 @@
|
||||
export const MOCK_USE_QUERIES_DATA = [
|
||||
{
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
error: null,
|
||||
data: {
|
||||
statusCode: 200,
|
||||
payload: [
|
||||
{
|
||||
exceptionType: '*errors.errorString',
|
||||
exceptionMessage: 'redis timeout',
|
||||
exceptionCount: 2510,
|
||||
lastSeen: '2025-04-14T18:27:57.797616374Z',
|
||||
firstSeen: '2025-04-14T17:58:00.262775497Z',
|
||||
serviceName: 'redis-manual',
|
||||
groupID: '511b9c91a92b9c5166ecb77235f5743b',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
status: 'success',
|
||||
isLoading: false,
|
||||
isSuccess: true,
|
||||
isError: false,
|
||||
isIdle: false,
|
||||
data: {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
payload: 525,
|
||||
},
|
||||
dataUpdatedAt: 1744661020341,
|
||||
error: null,
|
||||
errorUpdatedAt: 0,
|
||||
failureCount: 0,
|
||||
errorUpdateCount: 0,
|
||||
isFetched: true,
|
||||
isFetchedAfterMount: true,
|
||||
isFetching: false,
|
||||
isRefetching: false,
|
||||
isLoadingError: false,
|
||||
isPlaceholderData: false,
|
||||
isPreviousData: false,
|
||||
isRefetchError: false,
|
||||
isStale: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const INIT_URL_WITH_COMMON_QUERY =
|
||||
'/exceptions?compositeQuery=%257B%2522queryType%2522%253A%2522builder%2522%252C%2522builder%2522%253A%257B%2522queryData%2522%253A%255B%257B%2522dataSource%2522%253A%2522traces%2522%252C%2522queryName%2522%253A%2522A%2522%252C%2522aggregateOperator%2522%253A%2522noop%2522%252C%2522aggregateAttribute%2522%253A%257B%2522id%2522%253A%2522----resource--false%2522%252C%2522dataType%2522%253A%2522%2522%252C%2522key%2522%253A%2522%2522%252C%2522isColumn%2522%253Afalse%252C%2522type%2522%253A%2522resource%2522%252C%2522isJSON%2522%253Afalse%257D%252C%2522timeAggregation%2522%253A%2522rate%2522%252C%2522spaceAggregation%2522%253A%2522sum%2522%252C%2522functions%2522%253A%255B%255D%252C%2522filters%2522%253A%257B%2522items%2522%253A%255B%257B%2522id%2522%253A%2522db118ac7-9313-4adb-963f-f31b5b32c496%2522%252C%2522op%2522%253A%2522in%2522%252C%2522key%2522%253A%257B%2522key%2522%253A%2522deployment.environment%2522%252C%2522dataType%2522%253A%2522string%2522%252C%2522type%2522%253A%2522resource%2522%252C%2522isColumn%2522%253Afalse%252C%2522isJSON%2522%253Afalse%257D%252C%2522value%2522%253A%2522mq-kafka%2522%257D%255D%252C%2522op%2522%253A%2522AND%2522%257D%252C%2522expression%2522%253A%2522A%2522%252C%2522disabled%2522%253Afalse%252C%2522stepInterval%2522%253A60%252C%2522having%2522%253A%255B%255D%252C%2522limit%2522%253Anull%252C%2522orderBy%2522%253A%255B%255D%252C%2522groupBy%2522%253A%255B%255D%252C%2522legend%2522%253A%2522%2522%252C%2522reduceTo%2522%253A%2522avg%2522%257D%255D%252C%2522queryFormulas%2522%253A%255B%255D%257D%252C%2522promql%2522%253A%255B%257B%2522name%2522%253A%2522A%2522%252C%2522query%2522%253A%2522%2522%252C%2522legend%2522%253A%2522%2522%252C%2522disabled%2522%253Afalse%257D%255D%252C%2522clickhouse_sql%2522%253A%255B%257B%2522name%2522%253A%2522A%2522%252C%2522legend%2522%253A%2522%2522%252C%2522disabled%2522%253Afalse%252C%2522query%2522%253A%2522%2522%257D%255D%252C%2522id%2522%253A%2522dd576d04-0822-476d-b0c2-807a7af2e5e7%2522%257D';
|
||||
|
||||
|
||||
@@ -50,16 +50,6 @@
|
||||
font-family: var(--code-base-500-font-family);
|
||||
}
|
||||
|
||||
.radio-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: var(--padding-1);
|
||||
border: 1px solid var(--l1-border);
|
||||
background: var(--l3-background);
|
||||
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.round-metric-tag {
|
||||
display: inline-flex;
|
||||
padding: 2px 8px;
|
||||
@@ -783,80 +773,5 @@
|
||||
gap: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.no-dependent-services-message-container {
|
||||
height: 30vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.no-dependent-services-message-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
|
||||
width: fit-content;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.no-dependent-services-message {
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.end-point-details-zero-state-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
height: 100%;
|
||||
|
||||
.end-point-details-zero-state-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.end-point-details-zero-state-content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 12px;
|
||||
|
||||
.end-point-details-zero-state-text-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
|
||||
.title {
|
||||
color: var(--l1-foreground);
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
}
|
||||
|
||||
.ant-select {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-select-item,
|
||||
.ant-select-item-option-content {
|
||||
flex: auto;
|
||||
white-space: normal;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,13 +69,6 @@ jest.mock('antd', () => {
|
||||
))}
|
||||
</div>
|
||||
)),
|
||||
Typography: {
|
||||
Text: jest
|
||||
.fn()
|
||||
.mockImplementation(({ children }) => (
|
||||
<div data-testid="typography-text">{children}</div>
|
||||
)),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -130,13 +130,6 @@ jest.mock('antd', () => {
|
||||
{children}
|
||||
</div>
|
||||
)),
|
||||
Typography: {
|
||||
Text: jest
|
||||
.fn()
|
||||
.mockImplementation(({ children }) => (
|
||||
<div data-testid="typography-text">{children}</div>
|
||||
)),
|
||||
},
|
||||
Button: {
|
||||
...originalModule.Button,
|
||||
Group: jest.fn().mockImplementation(({ children, className }) => (
|
||||
|
||||
@@ -46,13 +46,6 @@ jest.mock('antd', () => {
|
||||
)}
|
||||
</div>
|
||||
)),
|
||||
Typography: {
|
||||
Text: jest.fn().mockImplementation(({ children, className }) => (
|
||||
<div data-testid="typography-text" className={className}>
|
||||
{children}
|
||||
</div>
|
||||
)),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
import { domainNameKey } from './constants';
|
||||
|
||||
export interface APIMonitoringResponseRow {
|
||||
data: {
|
||||
endpoints: number | string;
|
||||
error_rate: number | string;
|
||||
lastseen: number | string;
|
||||
[domainNameKey]: string;
|
||||
p99: number | string;
|
||||
rps: number | string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface APIMonitoringResponseColumn {
|
||||
name: string;
|
||||
signal: string;
|
||||
@@ -22,12 +9,6 @@ export interface APIMonitoringResponseColumn {
|
||||
columnType: string;
|
||||
}
|
||||
|
||||
export interface EndPointsResponseRow {
|
||||
data: {
|
||||
[key: string]: string | number | undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export interface APIDomainsRowData {
|
||||
key: string;
|
||||
domainName: string;
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { TableColumnType as ColumnType, Tooltip } from 'antd';
|
||||
import { Progress } from '@signozhq/ui/progress';
|
||||
import { Badge } from '@signozhq/ui/badge';
|
||||
import { combineInitialAndUserExpression } from 'components/QueryBuilderV2/QueryV2/QuerySearch/utils';
|
||||
import { formatValueForExpression } from 'components/QueryBuilderV2/utils';
|
||||
import {
|
||||
FiltersType,
|
||||
IQuickFiltersConfig,
|
||||
} from 'components/QuickFilters/types';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import { GraphClickMetaData } from 'container/WidgetCard/hooks/useNavigateToExplorerPages';
|
||||
import { getWidgetQueryBuilder } from 'container/MetricsApplication/MetricsApplication.factory';
|
||||
import { convertNanoToMilliseconds } from 'container/MetricsExplorer/Summary/utils';
|
||||
import dayjs from 'dayjs';
|
||||
import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { ArrowUpDown, ChevronDown, ChevronRight, Info } from '@signozhq/icons';
|
||||
import { ArrowUpDown, Info } from '@signozhq/icons';
|
||||
import { getWidgetQuery } from 'pages/MessagingQueues/MQDetails/MetricPage/MetricPageUtil';
|
||||
import { Widgets } from 'types/api/widgets/widget';
|
||||
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
DataTypes,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import {
|
||||
IBuilderQuery,
|
||||
OrderByPayload,
|
||||
TagFilterItem,
|
||||
} from 'types/api/queryBuilder/queryBuilderData';
|
||||
import {
|
||||
@@ -41,11 +33,7 @@ import { v4 } from 'uuid';
|
||||
|
||||
import { domainNameKey } from './constants';
|
||||
import { SPAN_ATTRIBUTES } from './Explorer/Domains/DomainDetails/constants';
|
||||
import {
|
||||
APIDomainsRowData,
|
||||
APIMonitoringResponseColumn,
|
||||
EndPointsResponseRow,
|
||||
} from './types';
|
||||
import { APIDomainsRowData, APIMonitoringResponseColumn } from './types';
|
||||
|
||||
function metricProgressColor(
|
||||
percent: number,
|
||||
@@ -91,40 +79,6 @@ export const getDomainScopeExpression = (
|
||||
.filter(Boolean)
|
||||
.join(' AND ');
|
||||
|
||||
export const ApiMonitoringQuickFiltersConfig: IQuickFiltersConfig[] = [
|
||||
{
|
||||
type: FiltersType.CHECKBOX,
|
||||
title: 'Environment',
|
||||
|
||||
attributeKey: {
|
||||
key: 'deployment.environment',
|
||||
dataType: DataTypes.String,
|
||||
type: 'resource',
|
||||
},
|
||||
defaultOpen: true,
|
||||
},
|
||||
{
|
||||
type: FiltersType.CHECKBOX,
|
||||
title: 'Service Name',
|
||||
attributeKey: {
|
||||
key: 'service.name',
|
||||
dataType: DataTypes.String,
|
||||
type: 'resource',
|
||||
},
|
||||
defaultOpen: true,
|
||||
},
|
||||
{
|
||||
type: FiltersType.CHECKBOX,
|
||||
title: 'RPC Method',
|
||||
attributeKey: {
|
||||
key: 'rpc.method',
|
||||
dataType: DataTypes.String,
|
||||
type: 'tag',
|
||||
},
|
||||
defaultOpen: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const getLastUsedRelativeTime = (lastRefresh: number): string => {
|
||||
const currentTime = dayjs();
|
||||
|
||||
@@ -571,258 +525,6 @@ const defaultGroupBy = [
|
||||
// },
|
||||
];
|
||||
|
||||
export const getEndPointsQueryPayload = (
|
||||
groupBy: BaseAutocompleteData[],
|
||||
domainName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
): GetQueryResultsProps[] => {
|
||||
const isGroupedByAttribute = groupBy.length > 0;
|
||||
return [
|
||||
{
|
||||
selectedTime: 'GLOBAL_TIME',
|
||||
graphType: PANEL_TYPES.TABLE,
|
||||
query: {
|
||||
builder: {
|
||||
queryData: [
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.String,
|
||||
key: 'span_id',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'count',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: false,
|
||||
expression: 'A',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: 'ec316e57',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'A',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'count',
|
||||
},
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.Float64,
|
||||
key: 'duration_nano',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'p99',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: false,
|
||||
expression: 'B',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: '46d57857',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'B',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'p99',
|
||||
},
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.String,
|
||||
id: 'timestamp------false',
|
||||
key: 'timestamp',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'max',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: false,
|
||||
expression: 'C',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: '4a237616',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'C',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'max',
|
||||
},
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.String,
|
||||
key: 'span_id',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'count',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: true,
|
||||
expression: 'D',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: 'f162de1e',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '3df0ac1d',
|
||||
key: {
|
||||
dataType: DataTypes.bool,
|
||||
key: 'has_error',
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'true',
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'D',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'count',
|
||||
},
|
||||
],
|
||||
queryFormulas: [
|
||||
{
|
||||
queryName: 'F1',
|
||||
expression: '(D/A)*100',
|
||||
disabled: false,
|
||||
legend: 'error percentage',
|
||||
},
|
||||
],
|
||||
queryTraceOperator: [],
|
||||
},
|
||||
clickhouse_sql: [
|
||||
{
|
||||
disabled: false,
|
||||
legend: '',
|
||||
name: 'A',
|
||||
query: '',
|
||||
},
|
||||
],
|
||||
id: '315b15fa-ff0c-442f-89f8-2bf4fb1af2f2',
|
||||
promql: [
|
||||
{
|
||||
disabled: false,
|
||||
legend: '',
|
||||
name: 'A',
|
||||
query: '',
|
||||
},
|
||||
],
|
||||
queryType: EQueryType.QUERY_BUILDER,
|
||||
},
|
||||
variables: {},
|
||||
formatForWeb: true,
|
||||
start,
|
||||
end,
|
||||
step: 60,
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
function buildFilterExpression(
|
||||
domainName: string,
|
||||
filterExpression: string,
|
||||
@@ -907,16 +609,6 @@ export const getTopErrorsQueryPayload = (
|
||||
};
|
||||
};
|
||||
|
||||
export interface EndPointsTableRowData {
|
||||
key: string;
|
||||
endpointName: string;
|
||||
callCount: number | string;
|
||||
latency: number | string;
|
||||
errorRate: number | string;
|
||||
lastUsed: string | number;
|
||||
groupedByMeta?: Record<string, string | number>;
|
||||
}
|
||||
|
||||
export const extractPortAndEndpoint = (
|
||||
url: string,
|
||||
): { port: string; endpoint: string } => {
|
||||
@@ -937,258 +629,6 @@ export const extractPortAndEndpoint = (
|
||||
}
|
||||
};
|
||||
|
||||
export const getEndPointsColumnsConfig = (
|
||||
isGroupedByAttribute: boolean,
|
||||
expandedRowKeys: React.Key[],
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
): ColumnType<EndPointsTableRowData>[] => [
|
||||
{
|
||||
title: (
|
||||
<div className="endpoint-name-header">
|
||||
{isGroupedByAttribute ? 'Endpoint group' : 'Endpoint'}
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'endpointName',
|
||||
key: 'endpointName',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
sorter: false,
|
||||
className: 'column',
|
||||
render: (text: string, record: EndPointsTableRowData): React.ReactNode => {
|
||||
const endPointName = isGroupedByAttribute
|
||||
? text
|
||||
: extractPortAndEndpoint(record.endpointName).endpoint;
|
||||
return (
|
||||
<div className="endpoint-name-value">
|
||||
{((): React.ReactNode => {
|
||||
if (!isGroupedByAttribute) {
|
||||
return null;
|
||||
}
|
||||
return expandedRowKeys.includes(record.key) ? (
|
||||
<ChevronDown size={14} />
|
||||
) : (
|
||||
<ChevronRight size={14} />
|
||||
);
|
||||
})()}
|
||||
{isGroupedByAttribute
|
||||
? text.split(',').map((value) => (
|
||||
<Badge
|
||||
textTransform="none"
|
||||
variant="solid"
|
||||
key={value}
|
||||
color="secondary"
|
||||
>
|
||||
{value === '' ? '<no-value>' : value}
|
||||
</Badge>
|
||||
))
|
||||
: endPointName}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: <div className="column-header">Port</div>,
|
||||
dataIndex: 'port',
|
||||
key: 'port',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
sorter: false,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<div className="column-header">
|
||||
Num of calls <ArrowUpDown size={14} />
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'callCount',
|
||||
key: 'callCount',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<div>
|
||||
Error <span className="round-metric-tag">%</span>
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'errorRate',
|
||||
key: 'errorRate',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
render: (errorRate: number | string): React.ReactNode => (
|
||||
<div className="progress-bar error-rate">
|
||||
<Progress
|
||||
percent={Number(
|
||||
(
|
||||
(errorRate === 'n/a' || errorRate === '-' ? 0 : errorRate) as number
|
||||
).toFixed(1),
|
||||
)}
|
||||
showInfo
|
||||
color={metricProgressColor(
|
||||
Number(
|
||||
(
|
||||
(errorRate === 'n/a' || errorRate === '-' ? 0 : errorRate) as number
|
||||
).toFixed(1),
|
||||
),
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<div>
|
||||
Latency <span className="round-metric-tag">ms</span>
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'latency',
|
||||
key: 'latency',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
},
|
||||
{
|
||||
title: <div>Last used</div>,
|
||||
dataIndex: 'lastUsed',
|
||||
key: 'lastUsed',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||
render: (lastUsed: string): string =>
|
||||
lastUsed === 'n/a' || lastUsed === '-'
|
||||
? '-'
|
||||
: getLastUsedRelativeTime(new Date(lastUsed).getTime()),
|
||||
},
|
||||
];
|
||||
|
||||
export const formatEndPointsDataForTable = (
|
||||
data: EndPointsResponseRow[] | undefined,
|
||||
groupBy: BaseAutocompleteData[],
|
||||
orderBy?: OrderByPayload | null,
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
): EndPointsTableRowData[] => {
|
||||
if (!data) {
|
||||
return [];
|
||||
}
|
||||
const isGroupedByAttribute = groupBy.length > 0;
|
||||
|
||||
let formattedData: EndPointsTableRowData[] = [];
|
||||
|
||||
if (!isGroupedByAttribute) {
|
||||
formattedData = data?.map((endpoint) => {
|
||||
const { port } = extractPortAndEndpoint(
|
||||
(endpoint.data[SPAN_ATTRIBUTES.HTTP_URL] as string) || '',
|
||||
);
|
||||
return {
|
||||
key: v4(),
|
||||
endpointName: (endpoint.data[SPAN_ATTRIBUTES.HTTP_URL] as string) || '-',
|
||||
port,
|
||||
callCount:
|
||||
endpoint.data.A === 'n/a' || endpoint.data.A === undefined
|
||||
? '-'
|
||||
: endpoint.data.A,
|
||||
latency:
|
||||
endpoint.data.B === 'n/a' || endpoint.data.B === undefined
|
||||
? '-'
|
||||
: Math.round(Number(endpoint.data.B) / 1000000), // Convert from nanoseconds to milliseconds
|
||||
lastUsed:
|
||||
endpoint.data.C === 'n/a' || endpoint.data.C === undefined
|
||||
? '-'
|
||||
: new Date(Math.floor(Number(endpoint.data.C) / 1000000)).toISOString(), // Convert from nanoseconds to milliseconds
|
||||
|
||||
errorRate:
|
||||
endpoint.data.F1 === undefined || endpoint.data.F1 === 'n/a'
|
||||
? 0
|
||||
: Number(endpoint.data.F1),
|
||||
};
|
||||
});
|
||||
} else {
|
||||
const groupedByAttributeData = groupBy.map((attribute) => attribute.key);
|
||||
|
||||
formattedData = data?.map((endpoint) => {
|
||||
const newEndpointName = groupedByAttributeData
|
||||
.map((attribute) => endpoint.data[attribute])
|
||||
.join(',');
|
||||
return {
|
||||
key: v4(),
|
||||
endpointName: newEndpointName,
|
||||
callCount:
|
||||
endpoint.data.A === 'n/a' || endpoint.data.A === undefined
|
||||
? '-'
|
||||
: endpoint.data.A,
|
||||
latency:
|
||||
endpoint.data.B === 'n/a' || endpoint.data.B === undefined
|
||||
? '-'
|
||||
: Math.round(Number(endpoint.data.B) / 1000000), // Convert from nanoseconds to milliseconds
|
||||
lastUsed:
|
||||
endpoint.data.C === 'n/a' || endpoint.data.C === undefined
|
||||
? '-'
|
||||
: getLastUsedRelativeTime(Math.floor(Number(endpoint.data.C) / 1000000)), // Convert from nanoseconds to milliseconds
|
||||
errorRate:
|
||||
endpoint.data.D === 'n/a' || endpoint.data.D === undefined
|
||||
? 0
|
||||
: Number(endpoint.data.D),
|
||||
groupedByMeta: groupedByAttributeData.reduce(
|
||||
(acc, attribute) => {
|
||||
acc[attribute] = endpoint.data[attribute] || '';
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string | number>,
|
||||
),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if orderBy is provided
|
||||
if (orderBy) {
|
||||
formattedData.sort((a, b) => {
|
||||
let valueA: number | string = a[
|
||||
orderBy.columnName as keyof EndPointsTableRowData
|
||||
] as number | string;
|
||||
let valueB: number | string = b[
|
||||
orderBy.columnName as keyof EndPointsTableRowData
|
||||
] as number | string;
|
||||
|
||||
// Handle special cases for each column type
|
||||
if (
|
||||
orderBy.columnName === 'callCount' ||
|
||||
orderBy.columnName === 'latency' ||
|
||||
orderBy.columnName === 'errorRate'
|
||||
) {
|
||||
valueA = valueA === '-' || valueA === 'n/a' ? 0 : Number(valueA);
|
||||
valueB = valueB === '-' || valueB === 'n/a' ? 0 : Number(valueB);
|
||||
} else if (orderBy.columnName === 'lastUsed') {
|
||||
// confirm once the implication of this
|
||||
valueA =
|
||||
valueA === '-' || valueA === 'n/a'
|
||||
? new Date(0).getTime()
|
||||
: new Date(valueA as string).getTime();
|
||||
valueB =
|
||||
valueB === '-' || valueB === 'n/a'
|
||||
? new Date(0).getTime()
|
||||
: new Date(valueB as string).getTime();
|
||||
}
|
||||
|
||||
// Apply sort direction
|
||||
if (orderBy.order === 'asc') {
|
||||
return valueA > valueB ? 1 : -1;
|
||||
}
|
||||
return valueA < valueB ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
return formattedData;
|
||||
};
|
||||
|
||||
export type TopErrorsResponseRow = ScalarData;
|
||||
|
||||
export interface TopErrorsTableRowData {
|
||||
@@ -1333,37 +773,6 @@ export const getTopErrorsColumnsConfig =
|
||||
},
|
||||
];
|
||||
|
||||
export const createFiltersForSelectedRowData = (
|
||||
selectedRowData: EndPointsTableRowData,
|
||||
currentFilters?: IBuilderQuery['filters'],
|
||||
): IBuilderQuery['filters'] => {
|
||||
const baseFilters: IBuilderQuery['filters'] = {
|
||||
items: [...(currentFilters?.items || [])],
|
||||
op: 'and',
|
||||
};
|
||||
|
||||
if (!selectedRowData) {
|
||||
return baseFilters;
|
||||
}
|
||||
|
||||
const { groupedByMeta = {} } = selectedRowData;
|
||||
|
||||
// Replace for...of with Object.keys().map()
|
||||
baseFilters.items.push(
|
||||
...Object.keys(groupedByMeta).map((key) => ({
|
||||
key: {
|
||||
key,
|
||||
type: null,
|
||||
},
|
||||
op: '=',
|
||||
value: groupedByMeta[key] || '',
|
||||
id: key,
|
||||
})),
|
||||
);
|
||||
|
||||
return baseFilters;
|
||||
};
|
||||
|
||||
// First query payload for endpoint metrics
|
||||
// Second query payload for endpoint status code table
|
||||
// Third query payload for endpoint dependant services
|
||||
@@ -2465,21 +1874,6 @@ export const dependentServicesColumns: ColumnType<DependentServicesData>[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const getFormattedChartData = (
|
||||
data: MetricRangePayloadProps,
|
||||
newLegendArray: string[],
|
||||
): MetricRangePayloadProps => {
|
||||
const result = cloneDeep(data);
|
||||
if (result?.data?.result) {
|
||||
result.data.result = result?.data?.result?.map((series, index) => ({
|
||||
...series,
|
||||
legend: newLegendArray[index],
|
||||
}));
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const getStatusCodeClass = (statusCode: string): string => {
|
||||
const code = parseInt(statusCode, 10);
|
||||
|
||||
@@ -3100,40 +2494,6 @@ const getStartAndEndStatusCode = (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates filter items for bar chart based on group by fields and request data
|
||||
* Used specifically for filtering status code ranges in bar charts
|
||||
* @param groupBy Array of group by fields to create filters for
|
||||
* @param requestData Data from graph click containing values to filter on
|
||||
* @returns Array of TagFilterItems with >= and < operators for status code ranges
|
||||
*/
|
||||
export const createGroupByFiltersForBarChart = (
|
||||
groupBy: BaseAutocompleteData[],
|
||||
requestData: GraphClickMetaData,
|
||||
): TagFilterItem[] =>
|
||||
groupBy
|
||||
.map((gb) => {
|
||||
const value = requestData[gb.key];
|
||||
const [startStatusCode, endStatusCode] = getStartAndEndStatusCode(value);
|
||||
return value
|
||||
? [
|
||||
{
|
||||
id: v4(),
|
||||
key: gb,
|
||||
op: '>=',
|
||||
value: startStatusCode,
|
||||
},
|
||||
{
|
||||
id: v4(),
|
||||
key: gb,
|
||||
op: '<=',
|
||||
value: endStatusCode,
|
||||
},
|
||||
]
|
||||
: [];
|
||||
})
|
||||
.flat();
|
||||
|
||||
export const getCustomFiltersForBarChart = (
|
||||
metric:
|
||||
| {
|
||||
|
||||
@@ -191,7 +191,6 @@ function ThresholdItem({
|
||||
updateThreshold(threshold.id, 'channels', value)
|
||||
}
|
||||
data-testid="threshold-notification-channel-select"
|
||||
popupMatchSelectWidth={false}
|
||||
style={{ width: 350 }}
|
||||
options={channelOptions}
|
||||
onDropdownVisibleChange={onPickerVisibleChange}
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
NotificationChannelCreatePermission,
|
||||
} from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';
|
||||
import { buildRuleDetachPermission } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import type { UseAuthZResult } from 'lib/authz/hooks/useAuthZ/types';
|
||||
import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';
|
||||
import { formatPermission } from 'lib/authz/hooks/useAuthZ/utils';
|
||||
import {
|
||||
@@ -532,7 +531,7 @@ describe('ThresholdItem', () => {
|
||||
...mockUseAuthZDeny()([]),
|
||||
isLoading: true,
|
||||
permissions: null,
|
||||
} as UseAuthZResult);
|
||||
});
|
||||
renderThresholdItem();
|
||||
await openPicker();
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ export function useAlertRuleSaveChecks(): UseAlertRuleSaveChecksReturn {
|
||||
useCreateAlertState();
|
||||
const { data: channels, isLoading } = useChannelOptions();
|
||||
|
||||
const selectedChannels = useMemo(
|
||||
const selectedChannelNames = useMemo(
|
||||
() => thresholdState.thresholds.flatMap((threshold) => threshold.channels),
|
||||
[thresholdState.thresholds],
|
||||
);
|
||||
|
||||
return useMemo(() => {
|
||||
const selectedChannelIds = getChannelIds(channels, selectedChannels);
|
||||
const selectedChannelIds = getChannelIds(channels, selectedChannelNames);
|
||||
|
||||
return {
|
||||
saveChecks: getRuleSaveChecks({
|
||||
@@ -38,11 +38,12 @@ export function useAlertRuleSaveChecks(): UseAlertRuleSaveChecksReturn {
|
||||
}),
|
||||
testChecks: getRuleCreateChecks(selectedChannelIds),
|
||||
isResolvingChannels:
|
||||
isLoading && (selectedChannels.length > 0 || savedChannelNames.length > 0),
|
||||
isLoading &&
|
||||
(selectedChannelNames.length > 0 || savedChannelNames.length > 0),
|
||||
};
|
||||
}, [
|
||||
channels,
|
||||
selectedChannels,
|
||||
selectedChannelNames,
|
||||
savedChannelNames,
|
||||
isEditMode,
|
||||
ruleId,
|
||||
|
||||
@@ -13,11 +13,6 @@ export const DashedContainer = styled.div`
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
export const ButtonContainer = styled.div`
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
`;
|
||||
|
||||
export const EventContainer = styled.div`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -14,8 +14,8 @@ import Card from 'periscope/components/Card/Card';
|
||||
import { isModifierKeyPressed } from 'utils/app';
|
||||
import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';
|
||||
import {
|
||||
RuleCreatePermission,
|
||||
RuleListPermission,
|
||||
RuleCreateChecks,
|
||||
RuleListChecks,
|
||||
} from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { withAuthZContent } from 'lib/authz/components/withAuthZ/withAuthZContent';
|
||||
|
||||
@@ -26,9 +26,6 @@ import AlertRulesDenied from './AlertRulesDenied';
|
||||
import AlertRulesLoading from './AlertRulesLoading';
|
||||
import { useHomeAlertRules } from './useHomeAlertRules';
|
||||
|
||||
const LIST_CHECKS = [RuleListPermission];
|
||||
const CREATE_CHECKS = [RuleCreatePermission];
|
||||
|
||||
function AlertRules({
|
||||
onUpdateChecklistDoneItem,
|
||||
loadingUserPreferences,
|
||||
@@ -73,7 +70,7 @@ function AlertRules({
|
||||
|
||||
<div className="empty-actions-container">
|
||||
<AuthZButton
|
||||
checks={CREATE_CHECKS}
|
||||
checks={RuleCreateChecks}
|
||||
size="md"
|
||||
variant="solid"
|
||||
color="secondary"
|
||||
@@ -224,8 +221,8 @@ function AlertRules({
|
||||
}
|
||||
|
||||
export default withAuthZContent(AlertRules, {
|
||||
checks: LIST_CHECKS,
|
||||
preloadChecks: CREATE_CHECKS,
|
||||
checks: RuleListChecks,
|
||||
preloadChecks: RuleCreateChecks,
|
||||
fallback: ({ deniedPermissions }) => (
|
||||
<AlertRulesDenied deniedPermissions={deniedPermissions} />
|
||||
),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Typography } from '@signozhq/ui/typography';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import ROUTES from 'constants/routes';
|
||||
import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';
|
||||
import { RuleCreatePermission } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { RuleCreateChecks } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { useSafeNavigate } from 'hooks/useSafeNavigate';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { isModifierKeyPressed } from 'utils/app';
|
||||
@@ -32,8 +32,6 @@ const alertLogEvents = (
|
||||
void logEvent(title, dataSource ? { ...attributes, dataSource } : attributes);
|
||||
};
|
||||
|
||||
const CREATE_CHECKS = [RuleCreatePermission];
|
||||
|
||||
interface AlertsEmptyStateProps {
|
||||
onRefresh?: () => void;
|
||||
}
|
||||
@@ -91,7 +89,7 @@ export function AlertsEmptyState({
|
||||
<div className={styles.actionContainer}>
|
||||
<div className={styles.buttonGroup}>
|
||||
<AuthZButton
|
||||
checks={CREATE_CHECKS}
|
||||
checks={RuleCreateChecks}
|
||||
size="md"
|
||||
variant="solid"
|
||||
color="primary"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { AllTheProviders, renderHook } from 'tests/test-utils';
|
||||
|
||||
import { useRuleViews } from '../useRuleViews';
|
||||
|
||||
describe('useRuleViews', () => {
|
||||
it('reports loading while the views query is held', () => {
|
||||
const { result } = renderHook(() => useRuleViews({ enabled: false }), {
|
||||
wrapper: AllTheProviders,
|
||||
});
|
||||
|
||||
expect(result.current.isLoading).toBe(true);
|
||||
expect(result.current.views).toStrictEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -4,14 +4,12 @@ import { ColumnSelector } from 'components/TanStackTableView';
|
||||
import type { TableColumnDef } from 'components/TanStackTableView';
|
||||
import TextToolTip from 'components/TextToolTip';
|
||||
import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';
|
||||
import { RuleCreatePermission } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { RuleCreateChecks } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
|
||||
import type { AlertRule } from '../types';
|
||||
|
||||
import styles from './AlertRulesHeaderActions.module.scss';
|
||||
|
||||
const CREATE_CHECKS = [RuleCreatePermission];
|
||||
|
||||
interface Props {
|
||||
columns: TableColumnDef<AlertRule>[];
|
||||
/** False on the empty list, whose own button creates the first rule. */
|
||||
@@ -33,7 +31,7 @@ function AlertRulesHeaderActions({
|
||||
/>
|
||||
{showNewAlert && (
|
||||
<AuthZButton
|
||||
checks={CREATE_CHECKS}
|
||||
checks={RuleCreateChecks}
|
||||
variant="solid"
|
||||
size="sm"
|
||||
prefix={<Plus size={14} />}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useTableParams } from 'components/TanStackTableView/useTableParams';
|
||||
import { useGetTenantLicense } from 'hooks/useGetTenantLicense';
|
||||
import { AuthZGuardContent } from 'lib/authz/components/AuthZGuard/AuthZGuardContent';
|
||||
import PermissionDeniedCallout from 'lib/authz/components/PermissionDeniedCallout/PermissionDeniedCallout';
|
||||
import { RuleListPermission } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { RuleListChecks } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';
|
||||
import { useAppContext } from 'providers/App/App';
|
||||
import { useTimezone } from 'providers/Timezone';
|
||||
@@ -51,7 +51,6 @@ const CLIENT_VIEW_LIMIT = 200;
|
||||
|
||||
const DEFAULT_PAGE = 1;
|
||||
const DEFAULT_LIMIT = 10;
|
||||
const RULE_LIST_CHECKS = [RuleListPermission];
|
||||
|
||||
function ListAlertRules(): JSX.Element {
|
||||
const { user } = useAppContext();
|
||||
@@ -76,7 +75,7 @@ function ListAlertRules(): JSX.Element {
|
||||
const { filter, applyFilter, submitQuery, changeStates, changeSort } =
|
||||
useAlertRulesListFilter({ orderBy, setOrderBy, setPage });
|
||||
|
||||
const listAccess = useAuthZ(RULE_LIST_CHECKS);
|
||||
const listAccess = useAuthZ(RuleListChecks);
|
||||
const ruleViews = useAlertRuleViews({
|
||||
filter,
|
||||
applyFilter,
|
||||
@@ -91,7 +90,7 @@ function ListAlertRules(): JSX.Element {
|
||||
}, [setRailCollapsed, railCollapsed]);
|
||||
const guardViewsRail = useCallback(
|
||||
(content: ReactElement): ReactElement => (
|
||||
<ViewsRailGuard checks={RULE_LIST_CHECKS} shouldRenderUntilDenied>
|
||||
<ViewsRailGuard checks={RuleListChecks} shouldRenderUntilDenied>
|
||||
{content}
|
||||
</ViewsRailGuard>
|
||||
),
|
||||
@@ -295,7 +294,7 @@ function ListAlertRules(): JSX.Element {
|
||||
|
||||
<div ref={containerRef} className={styles.tableContainer}>
|
||||
<AuthZGuardContent
|
||||
checks={RULE_LIST_CHECKS}
|
||||
checks={RuleListChecks}
|
||||
fallback={({ deniedPermissions }): JSX.Element => (
|
||||
<PermissionDeniedCallout
|
||||
deniedPermissions={deniedPermissions}
|
||||
|
||||
@@ -21,8 +21,7 @@ export interface UseAlertRuleViewsResult extends UseListViewsResult<RuleListFilt
|
||||
}
|
||||
|
||||
// A link carrying only `view=<custom id>` gets that view's filter applied once
|
||||
// the views load; a link carrying its own filter params keeps them. A held
|
||||
// query reports no loading, so the link also waits for `enabled`.
|
||||
// the views load; a link carrying its own filter params keeps them.
|
||||
export function useAlertRuleViews({
|
||||
filter,
|
||||
applyFilter,
|
||||
@@ -51,7 +50,7 @@ export function useAlertRuleViews({
|
||||
const hasResolvedLinkedView = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (hasResolvedLinkedView.current || !enabled || api.isLoading) {
|
||||
if (hasResolvedLinkedView.current || api.isLoading) {
|
||||
return;
|
||||
}
|
||||
hasResolvedLinkedView.current = true;
|
||||
@@ -62,7 +61,7 @@ export function useAlertRuleViews({
|
||||
) {
|
||||
applyFilter(activeView.filter);
|
||||
}
|
||||
}, [enabled, api.isLoading, activeView, applyFilter, filter]);
|
||||
}, [api.isLoading, activeView, applyFilter, filter]);
|
||||
|
||||
return { ...views, customViewsLoading: api.isLoading };
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export function useRuleViews({
|
||||
enabled,
|
||||
}: UseRuleViewsArgs): SavedListViewsApi<RuleListFilter> {
|
||||
const queryClient = useQueryClient();
|
||||
const { data, isLoading } = useListRuleViews({ query: { enabled } });
|
||||
const { data, isLoading, isIdle } = useListRuleViews({ query: { enabled } });
|
||||
|
||||
const views = useMemo<RuleView[]>(
|
||||
() => (data?.data?.views ?? []).map(toRuleView),
|
||||
@@ -147,5 +147,11 @@ export function useRuleViews({
|
||||
[deleteMutation],
|
||||
);
|
||||
|
||||
return { views, isLoading, createView, updateView, deleteView };
|
||||
return {
|
||||
views,
|
||||
isLoading: isLoading || isIdle,
|
||||
createView,
|
||||
updateView,
|
||||
deleteView,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,10 +42,6 @@
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
|
||||
.ant-typography {
|
||||
color: var(--l1-foreground);
|
||||
}
|
||||
|
||||
.loading-gif {
|
||||
height: 72px;
|
||||
margin-left: -24px;
|
||||
|
||||
@@ -3,10 +3,6 @@ import {
|
||||
initialQueryBuilderFormValuesMap,
|
||||
} from 'constants/queryBuilder';
|
||||
import { ORDERBY_FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
DataTypes,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { IBuilderQuery, Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { LogsAggregatorOperator } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -44,9 +40,3 @@ export const liveLogsCompositeQuery = constructCompositeQuery({
|
||||
initialQueryData: initialQueryBuilderFormValuesMap.logs,
|
||||
customQueryData: defaultLiveQueryDataConfig,
|
||||
});
|
||||
|
||||
export const idObject: BaseAutocompleteData = {
|
||||
key: 'id',
|
||||
type: '',
|
||||
dataType: DataTypes.String,
|
||||
};
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
.json-view-container {
|
||||
border-radius: 3px;
|
||||
border: 1px solid var(--l1-border);
|
||||
padding-top: 16px;
|
||||
|
||||
.json-view-footer {
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1px solid var(--l1-border);
|
||||
}
|
||||
|
||||
.log-switch {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.wrap-word-switch {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-left: var(--margin-3);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-switch-btn {
|
||||
border: 1px solid var(--l1-border);
|
||||
background-color: var(--l2-background);
|
||||
width: 40px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,6 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.wrap-word-switch {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-left: var(--margin-3);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-switch-btn {
|
||||
border: 1px solid var(--l1-border);
|
||||
background-color: var(--l2-background);
|
||||
@@ -53,74 +46,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
.attribute-table {
|
||||
margin-top: var(--margin-1);
|
||||
}
|
||||
|
||||
.ant-collapse {
|
||||
border: 1px solid var(--l1-border);
|
||||
}
|
||||
|
||||
.collapse-content {
|
||||
border-bottom: 1px solid var(--l1-border);
|
||||
|
||||
.ant-collapse-header {
|
||||
align-items: center;
|
||||
border-radius: 2px;
|
||||
background-color: var(--l3-background);
|
||||
border: 1px solid var(--l3-border);
|
||||
|
||||
padding: 8px;
|
||||
|
||||
.ant-collapse-extra {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.action-btn {
|
||||
display: flex;
|
||||
|
||||
.ant-btn {
|
||||
background: color-mix(in srgb, var(--bg-robin-400) 8%, transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-collapse-content {
|
||||
padding: 0;
|
||||
background: var(--l2-background);
|
||||
border-top: 1px solid var(--l1-border);
|
||||
|
||||
.ant-collapse-content-box {
|
||||
padding: var(--padding-2) 0 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-body-content {
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
[data-slot='badge'] {
|
||||
border-radius: 2px;
|
||||
background: color-mix(in srgb, var(--bg-robin-400) 8%, transparent);
|
||||
}
|
||||
|
||||
.attribute-collapse {
|
||||
.ant-collapse-content {
|
||||
.ant-collapse-content-box {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-wrapper .ant-table-cell {
|
||||
padding: 14px 14px;
|
||||
}
|
||||
|
||||
.attribute-tab-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export const DROPDOWN_KEY = {
|
||||
FILTER_IN: 'filterIn',
|
||||
FILTER_OUT: 'filterOut',
|
||||
GROUP_BY: 'groupBy',
|
||||
};
|
||||
@@ -76,9 +76,6 @@ export const generateFieldKeyForArray = (
|
||||
return `body.${newResultNodeKey}`;
|
||||
};
|
||||
|
||||
export const removeObjectFromString = (str: string): string =>
|
||||
str.replace(/\[object Object\]./g, '');
|
||||
|
||||
// Split `str` on the first occurrence of `delimiter`
|
||||
// For example, will return `['a', 'b.c']` when splitting `'a.b.c'` at dots
|
||||
const splitOnce = (str: string, delimiter: string): string[] => {
|
||||
@@ -303,30 +300,6 @@ export const unescapeString = (str: string): string =>
|
||||
String.fromCharCode(parseInt(hex, 16)),
|
||||
); // Replaces Unicode escape sequences
|
||||
|
||||
export function findKeyPath(
|
||||
obj: AnyObject,
|
||||
targetKey: string,
|
||||
currentPath = '',
|
||||
): string | null {
|
||||
let finalPath = null;
|
||||
Object.keys(obj).forEach((key) => {
|
||||
const value = obj[key];
|
||||
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
||||
|
||||
if (key === targetKey) {
|
||||
finalPath = newPath;
|
||||
}
|
||||
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
const result = findKeyPath(value, targetKey, newPath);
|
||||
if (result) {
|
||||
finalPath = result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return finalPath;
|
||||
}
|
||||
|
||||
export const getSanitizedLogBody = (
|
||||
text: string,
|
||||
options: { shouldEscapeHtml?: boolean } = {},
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
.qb-search-view-container {
|
||||
padding: 8px 16px;
|
||||
|
||||
.ant-select-selector {
|
||||
border-radius: 2px;
|
||||
border: 1px solid var(--l1-border) !important;
|
||||
background-color: var(--l1-background) !important;
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import { useShareBuilderUrl } from 'hooks/queryBuilder/useShareBuilderUrl';
|
||||
import { ExplorerViews } from 'pages/LogsExplorer/utils';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import './LogsExplorerQuerySection.styles.scss';
|
||||
|
||||
function LogExplorerQuerySection({
|
||||
selectedView,
|
||||
}: {
|
||||
|
||||
@@ -62,16 +62,6 @@ const SEVERITY_VARIANT_COLORS: Record<string, string> = {
|
||||
PANIC: Color.BG_SAKURA_600,
|
||||
};
|
||||
|
||||
// Simple function to get severity color for any component
|
||||
export function getSeverityColor(severityText: string): string {
|
||||
const variantColor = SEVERITY_VARIANT_COLORS[severityText.trim()];
|
||||
if (variantColor) {
|
||||
return variantColor;
|
||||
}
|
||||
|
||||
return Color.BG_ROBIN_500; // Default fallback
|
||||
}
|
||||
|
||||
export function getColorsForSeverityLabels(
|
||||
label: string,
|
||||
index: number,
|
||||
|
||||
@@ -7,252 +7,6 @@
|
||||
letter-spacing: -0.005em;
|
||||
text-align: left;
|
||||
min-height: 0;
|
||||
|
||||
.logs-list-table-view-container {
|
||||
.data-table-container {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
table {
|
||||
thead {
|
||||
tr {
|
||||
th {
|
||||
font-size: 12px;
|
||||
color: white !important;
|
||||
|
||||
.cursor-col-resize {
|
||||
width: 24px !important;
|
||||
cursor: col-resize !important;
|
||||
opacity: 1 !important;
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
|
||||
&:hover {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
border-bottom: 1px solid var(--l1-border) !important;
|
||||
}
|
||||
|
||||
border-bottom: 1px solid var(--l1-border) !important;
|
||||
background-color: var(--l2-background) !important;
|
||||
|
||||
tr {
|
||||
&:hover {
|
||||
background-color: var(--l2-background) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
font-size: 12px;
|
||||
padding: 4px !important;
|
||||
|
||||
white-space: pre-wrap !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: var(--l1-border) !important;
|
||||
}
|
||||
|
||||
border-bottom: 1px solid var(--l1-border) !important;
|
||||
}
|
||||
|
||||
tr:has(.active-log) {
|
||||
background-color: rgba(78, 116, 248, 0.5) !important; // same as bg-robin-500
|
||||
color: var(--l1-foreground) !important;
|
||||
}
|
||||
}
|
||||
|
||||
thead {
|
||||
z-index: 2 !important;
|
||||
}
|
||||
|
||||
.log-state-indicator {
|
||||
padding-left: 0 !important;
|
||||
|
||||
.line {
|
||||
margin: 0 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sticky-header-table-container {
|
||||
&::-webkit-scrollbar {
|
||||
width: 0.4rem;
|
||||
height: 0.4rem;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--l3-background);
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--l3-background);
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='1'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='2'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='3'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='4'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 4;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='5'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 5;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='6'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 6;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='7'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 7;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='8'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 8;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='9'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 9;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='10'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 10;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-linked-row td {
|
||||
|
||||
@@ -16,7 +16,7 @@ import { getLogIndicatorType } from 'components/Logs/LogStateIndicator/utils';
|
||||
import RawLogView from 'components/Logs/RawLogView';
|
||||
import { useLogsTableColumns } from 'components/Logs/TableView/useLogsTableColumns';
|
||||
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
|
||||
import Spinner from 'components/Spinner';
|
||||
import { LogsLoadingFooter } from 'components/Logs/LogsLoadingFooter/LogsLoadingFooter';
|
||||
import type { TanStackTableHandle } from 'components/TanStackTableView';
|
||||
import TanStackTable from 'components/TanStackTableView';
|
||||
import type { TableColumnDef } from 'components/TanStackTableView/types';
|
||||
@@ -51,9 +51,6 @@ import {
|
||||
import styles from './LogsExplorerList.module.scss';
|
||||
import './LogsExplorerList.style.scss';
|
||||
|
||||
function Footer(): JSX.Element {
|
||||
return <Spinner height={20} tip="Getting Logs" />;
|
||||
}
|
||||
function LogsExplorerList({
|
||||
isLoading,
|
||||
isFetching,
|
||||
@@ -195,7 +192,7 @@ function LogsExplorerList({
|
||||
const renderContent = useMemo(() => {
|
||||
const components = isLoading
|
||||
? {
|
||||
Footer,
|
||||
Footer: LogsLoadingFooter,
|
||||
}
|
||||
: {};
|
||||
|
||||
|
||||
@@ -132,16 +132,6 @@
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.order-by-select {
|
||||
width: 100px;
|
||||
|
||||
.ant-select-selector {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,6 @@
|
||||
font-weight: 400;
|
||||
line-height: 18px;
|
||||
font-family: Inter;
|
||||
|
||||
.ant-typography {
|
||||
background-color: transparent;
|
||||
color: var(--l1-foreground);
|
||||
margin-bottom: 0;
|
||||
font-size: 13px;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 18px;
|
||||
font-family: Inter;
|
||||
}
|
||||
padding: 14px 8px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -29,15 +29,6 @@ export const ProcessorTypeContainer = styled.div`
|
||||
gap: 0.313rem;
|
||||
`;
|
||||
|
||||
export const Container = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
padding: 0rem;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
export const FormWrapper = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
.sample-logs-notice-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { Badge } from '@signozhq/ui/badge';
|
||||
|
||||
function Tags({ tags }: TagsProps): JSX.Element {
|
||||
return (
|
||||
<span>
|
||||
{tags?.map((tag) => (
|
||||
<Badge
|
||||
textTransform="none"
|
||||
variant="solid"
|
||||
color="highlight-danger"
|
||||
key={tag}
|
||||
>
|
||||
{tag}
|
||||
</Badge>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
interface TagsProps {
|
||||
tags: Array<string>;
|
||||
}
|
||||
|
||||
export default Tags;
|
||||
@@ -2,8 +2,6 @@ import { Pipeline, PipelineData } from 'types/api/pipeline/def';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
export const configurationVersion = '1.0';
|
||||
|
||||
export function mockPipelineFilter(
|
||||
key: string,
|
||||
op: string,
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import Tags from 'container/PipelinePage/PipelineListsView/TableComponents/Tags';
|
||||
import { render } from 'tests/test-utils';
|
||||
|
||||
const tags = ['server', 'app'];
|
||||
|
||||
describe('PipelinePage container test', () => {
|
||||
it('should render Tags section', () => {
|
||||
const { asFragment } = render(<Tags tags={tags} />);
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@@ -1,42 +0,0 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`PipelinePage container test should render Tags section 1`] = `
|
||||
<DocumentFragment>
|
||||
<span>
|
||||
<span
|
||||
class="_badge_1wurm_1"
|
||||
data-color="highlight-danger"
|
||||
data-slot="badge"
|
||||
data-text-overflow="ellipsis"
|
||||
data-text-transform="none"
|
||||
data-trigger-disabled=""
|
||||
data-variant="solid"
|
||||
id="base-ui-:r1:"
|
||||
>
|
||||
<span
|
||||
class="_badge__label_1wurm_141"
|
||||
data-slot="badge-label"
|
||||
>
|
||||
server
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="_badge_1wurm_1"
|
||||
data-color="highlight-danger"
|
||||
data-slot="badge"
|
||||
data-text-overflow="ellipsis"
|
||||
data-text-transform="none"
|
||||
data-trigger-disabled=""
|
||||
data-variant="solid"
|
||||
id="base-ui-:r3:"
|
||||
>
|
||||
<span
|
||||
class="_badge__label_1wurm_141"
|
||||
data-slot="badge-label"
|
||||
>
|
||||
app
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
@@ -1,10 +1,4 @@
|
||||
import React, {
|
||||
type ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Check, Info } from '@signozhq/icons';
|
||||
import {
|
||||
DatePicker,
|
||||
@@ -37,14 +31,8 @@ import dayjs from 'dayjs';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { useNotifications } from 'hooks/useNotifications';
|
||||
import { formatDeniedMessage } from 'lib/authz/components/formatDeniedMessage';
|
||||
import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';
|
||||
import { RuleListPermission } from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { useAppContext } from 'providers/App/App';
|
||||
import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';
|
||||
import AuthZSelect from 'lib/authz/components/AuthZSelect/AuthZSelect';
|
||||
import type { AuthZSelectOption } from 'lib/authz/components/AuthZSelect/types';
|
||||
import { deniedReason } from 'lib/authz/components/deniedTooltip';
|
||||
import { defaultTo, isEmpty } from 'lodash-es';
|
||||
import { useErrorModal } from 'providers/ErrorModalProvider';
|
||||
import APIError from 'types/api/error';
|
||||
@@ -84,9 +72,6 @@ const TZ_OPTIONS: DefaultOptionType[] = ALL_TIME_ZONES.map(
|
||||
|
||||
type AlertRuleScope = 'all' | 'specific';
|
||||
|
||||
// Module-level so the useQueries identity stays stable across renders.
|
||||
const RULE_LIST_CHECKS = [RuleListPermission];
|
||||
|
||||
interface PlannedDowntimeFormData {
|
||||
name: string;
|
||||
startTime: dayjs.Dayjs | null;
|
||||
@@ -159,7 +144,9 @@ export function PlannedDowntimeForm(
|
||||
isReadOnly,
|
||||
readOnlyReason,
|
||||
saveChecks,
|
||||
getRuleAccess,
|
||||
ruleOptions,
|
||||
getRuleLockReason,
|
||||
ruleListDenial,
|
||||
onPickerVisibleChange,
|
||||
} = usePlannedDowntimeFormPermissions({
|
||||
initialValues,
|
||||
@@ -169,36 +156,6 @@ export function PlannedDowntimeForm(
|
||||
selectedRules: selectedTags,
|
||||
});
|
||||
|
||||
const { user } = useAppContext();
|
||||
const ruleList = useAuthZ(RULE_LIST_CHECKS);
|
||||
const isRuleListDenied =
|
||||
!ruleList.isLoading &&
|
||||
!ruleList.error &&
|
||||
!ruleList.isGranted(RuleListPermission);
|
||||
|
||||
const gatedAlertOptions = useMemo(
|
||||
() =>
|
||||
alertOptions.map((option): AuthZSelectOption => ({
|
||||
...getRuleAccess(String(option.value)),
|
||||
value: String(option.value),
|
||||
label:
|
||||
typeof option.label === 'string' ? option.label : String(option.value),
|
||||
testId: `downtime-rule-option-${option.value}`,
|
||||
})),
|
||||
[alertOptions, getRuleAccess],
|
||||
);
|
||||
|
||||
const getRuleLockReason = useCallback(
|
||||
(ruleId: string): ReactNode => {
|
||||
const { disabled, reason, denied } = getRuleAccess(ruleId);
|
||||
if (!disabled || !reason) {
|
||||
return undefined;
|
||||
}
|
||||
return denied ? deniedReason(reason) : reason;
|
||||
},
|
||||
[getRuleAccess],
|
||||
);
|
||||
|
||||
const requiredFieldRule = [{ required: true }];
|
||||
|
||||
const datePickerFooter = (mode: string): JSX.Element | null =>
|
||||
@@ -600,14 +557,12 @@ export function PlannedDowntimeForm(
|
||||
tagRender={noTagRenderer}
|
||||
onChange={handleAlertRulesChange}
|
||||
showSearch
|
||||
options={gatedAlertOptions}
|
||||
options={ruleOptions}
|
||||
data-testid="downtime-alert-rules"
|
||||
onDropdownVisibleChange={onPickerVisibleChange}
|
||||
notFoundContent={
|
||||
isRuleListDenied ? (
|
||||
<span data-testid="downtime-rules-denied">
|
||||
{formatDeniedMessage([RuleListPermission], user.id)}
|
||||
</span>
|
||||
ruleListDenial ? (
|
||||
<span data-testid="downtime-rules-denied">{ruleListDenial}</span>
|
||||
) : isLoading ? (
|
||||
<span>
|
||||
<Spin size="small" /> Loading...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type ReactNode, useMemo } from 'react';
|
||||
import { type ReactNode, useCallback, useMemo } from 'react';
|
||||
import type { DefaultOptionType } from 'antd/es/select';
|
||||
import type { AlertmanagertypesPlannedMaintenanceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import {
|
||||
@@ -9,12 +9,20 @@ import {
|
||||
import {
|
||||
buildRuleAttachPermission,
|
||||
buildRuleDetachPermission,
|
||||
RuleListChecks,
|
||||
RuleListPermission,
|
||||
} from 'lib/authz/hooks/useAuthZ/permissions/rule.permissions';
|
||||
import { deniedTooltip } from 'lib/authz/components/deniedTooltip';
|
||||
import type { AuthZSelectOption } from 'lib/authz/components/AuthZSelect/types';
|
||||
import {
|
||||
deniedReason,
|
||||
deniedTooltip,
|
||||
} from 'lib/authz/components/deniedTooltip';
|
||||
import { formatDeniedMessage } from 'lib/authz/components/formatDeniedMessage';
|
||||
import type { BrandedPermission } from 'lib/authz/hooks/useAuthZ/types';
|
||||
import type {
|
||||
LinkAccess,
|
||||
LinkPermissions,
|
||||
import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';
|
||||
import {
|
||||
type LinkPermissions,
|
||||
LinkAccessState,
|
||||
} from 'lib/authz/hooks/useLinkPickerAccess/types';
|
||||
import { useLinkPickerAccess } from 'lib/authz/hooks/useLinkPickerAccess/useLinkPickerAccess';
|
||||
import { useAppContext } from 'providers/App/App';
|
||||
@@ -35,8 +43,12 @@ export interface UsePlannedDowntimeFormPermissionsReturn {
|
||||
/** The denial a read-only control shows; set whenever editing, so a control keeps its tooltip. */
|
||||
readOnlyReason?: ReactNode;
|
||||
saveChecks: BrandedPermission[];
|
||||
/** Whether a rule can be added or, if the schedule already has it, removed. */
|
||||
getRuleAccess: (ruleId: string) => LinkAccess;
|
||||
/** The rule picker's options, each disabled with the reason when locked. */
|
||||
ruleOptions: AuthZSelectOption[];
|
||||
/** Why a selected rule's tag cannot be removed; undefined when it can. */
|
||||
getRuleLockReason: (ruleId: string) => ReactNode;
|
||||
/** The `rule:list` denial, shown in place of an empty picker. */
|
||||
ruleListDenial?: string;
|
||||
/** Starts the `attach` checks on unsilenced rules once the picker opens. */
|
||||
onPickerVisibleChange: (open: boolean) => void;
|
||||
}
|
||||
@@ -116,6 +128,37 @@ export function usePlannedDowntimeFormPermissions({
|
||||
[scheduleId, storedIds, incomingIds],
|
||||
);
|
||||
|
||||
const ruleOptions = useMemo(
|
||||
() =>
|
||||
alertOptions.map((option): AuthZSelectOption => ({
|
||||
...getAccess(String(option.value)),
|
||||
value: String(option.value),
|
||||
label:
|
||||
typeof option.label === 'string' ? option.label : String(option.value),
|
||||
testId: `downtime-rule-option-${option.value}`,
|
||||
})),
|
||||
[alertOptions, getAccess],
|
||||
);
|
||||
|
||||
const getRuleLockReason = useCallback(
|
||||
(ruleId: string): ReactNode => {
|
||||
const access = getAccess(ruleId);
|
||||
if (access.state === LinkAccessState.Allowed) {
|
||||
return undefined;
|
||||
}
|
||||
return access.state === LinkAccessState.Denied
|
||||
? deniedReason(access.reason)
|
||||
: access.reason;
|
||||
},
|
||||
[getAccess],
|
||||
);
|
||||
|
||||
const ruleList = useAuthZ(RuleListChecks);
|
||||
const isRuleListDenied =
|
||||
!ruleList.isLoading &&
|
||||
!ruleList.error &&
|
||||
!ruleList.isGranted(RuleListPermission);
|
||||
|
||||
const readOnlyReason = useMemo(
|
||||
() => (update ? deniedTooltip([update], user.id) : undefined),
|
||||
[update, user.id],
|
||||
@@ -125,7 +168,11 @@ export function usePlannedDowntimeFormPermissions({
|
||||
isReadOnly: !!update && isOwnerDenied(update),
|
||||
readOnlyReason,
|
||||
saveChecks,
|
||||
getRuleAccess: getAccess,
|
||||
ruleOptions,
|
||||
getRuleLockReason,
|
||||
ruleListDenial: isRuleListDenied
|
||||
? formatDeniedMessage(RuleListChecks, user.id)
|
||||
: undefined,
|
||||
onPickerVisibleChange,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,3 +34,11 @@ describe('ingestion permissions in the roles editor', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('audit-logs permissions in the roles editor', () => {
|
||||
it('lists audit-logs with read-only verb', () => {
|
||||
expect(RESOURCE_ORDER).toContain('audit-logs');
|
||||
expect(getResourcePanel('audit-logs').label).toBe('Audit Logs');
|
||||
expect([...getResourceVerbs('audit-logs')]).toStrictEqual(['read']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -329,10 +329,11 @@ describe('transformTransactionGroupsToResourcePermissions', () => {
|
||||
it('returns all resources from RESOURCE_ORDER even with empty transaction groups', () => {
|
||||
const result = transformTransactionGroupsToResourcePermissions([]);
|
||||
|
||||
expect(result).toHaveLength(22);
|
||||
expect(result).toHaveLength(23);
|
||||
expect(result.map((r) => r.resourceKind)).toStrictEqual([
|
||||
'rule',
|
||||
'factor-api-key',
|
||||
'audit-logs',
|
||||
'auth-domain',
|
||||
'dashboard',
|
||||
'ingestion-key',
|
||||
@@ -433,10 +434,11 @@ describe('createEmptyRolePermissions', () => {
|
||||
it('creates permissions for all resources in RESOURCE_ORDER', () => {
|
||||
const result = createEmptyRolePermissions();
|
||||
|
||||
expect(result).toHaveLength(22);
|
||||
expect(result).toHaveLength(23);
|
||||
expect(result.map((r) => r.resourceKind)).toStrictEqual([
|
||||
'rule',
|
||||
'factor-api-key',
|
||||
'audit-logs',
|
||||
'auth-domain',
|
||||
'dashboard',
|
||||
'ingestion-key',
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
ChartLine,
|
||||
DraftingCompass,
|
||||
FileKey,
|
||||
FileLock,
|
||||
Gauge,
|
||||
Grid3X3,
|
||||
Key,
|
||||
@@ -145,6 +146,15 @@ export const RESOURCE_PANELS: Record<AuthZResource, ResourcePanelConfig> = {
|
||||
'Type routing policy ID, separate multiple with comma or space',
|
||||
docsAnchor: 'route-policy',
|
||||
},
|
||||
'audit-logs': {
|
||||
label: 'Audit Logs',
|
||||
description: 'Audit log events recorded across the workspace.',
|
||||
icon: FileLock,
|
||||
selectorPlaceholder:
|
||||
'Enter selector as <query-type>/<key>/<value> or <query-type>/* or use wizard...',
|
||||
docsAnchor: 'audit-logs',
|
||||
selectorType: 'telemetryBuilder',
|
||||
},
|
||||
logs: {
|
||||
label: 'Logs',
|
||||
description: 'Log data collected across the workspace.',
|
||||
|
||||
@@ -186,7 +186,6 @@ function RoutingPolicyDetails({
|
||||
>
|
||||
<AuthZSelect
|
||||
options={channelOptions}
|
||||
popupMatchSelectWidth={false}
|
||||
onDropdownVisibleChange={onPickerVisibleChange}
|
||||
placeholder="Select notification channels"
|
||||
aria-label="Notification Channels"
|
||||
|
||||
@@ -169,8 +169,6 @@ describe('RoutingPolicyDetails', () => {
|
||||
await waitFor(() => expect(option).toHaveAttribute('aria-disabled', 'false'));
|
||||
await user.click(option);
|
||||
|
||||
await user.click(screen.getByTestId(SAVE_BUTTON));
|
||||
|
||||
await waitForSaveEnabled();
|
||||
await user.click(screen.getByTestId(SAVE_BUTTON));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export function useRoutingPolicyFormPermissions(
|
||||
): UseRoutingPolicyFormPermissionsReturn {
|
||||
const policyId = mode === 'edit' ? routingPolicy?.id : undefined;
|
||||
|
||||
const update = useMemo(
|
||||
const updatePermission = useMemo(
|
||||
() => (policyId ? buildRoutePolicyUpdatePermission(policyId) : undefined),
|
||||
[policyId],
|
||||
);
|
||||
@@ -50,7 +50,10 @@ export function useRoutingPolicyFormPermissions(
|
||||
: undefined,
|
||||
[policyId],
|
||||
);
|
||||
const ownerChecks = useMemo(() => (update ? [update] : []), [update]);
|
||||
const ownerChecks = useMemo(
|
||||
() => (updatePermission ? [updatePermission] : []),
|
||||
[updatePermission],
|
||||
);
|
||||
|
||||
const {
|
||||
options: channelOptions,
|
||||
@@ -67,12 +70,12 @@ export function useRoutingPolicyFormPermissions(
|
||||
});
|
||||
|
||||
const saveChecks = useMemo(
|
||||
() => (update ? [update] : RoutePolicyCreateChecks),
|
||||
[update],
|
||||
() => (updatePermission ? [updatePermission] : RoutePolicyCreateChecks),
|
||||
[updatePermission],
|
||||
);
|
||||
|
||||
return {
|
||||
isReadOnly: !!update && isOwnerDenied(update),
|
||||
isReadOnly: !!updatePermission && isOwnerDenied(updatePermission),
|
||||
saveChecks,
|
||||
channelOptions,
|
||||
onPickerVisibleChange,
|
||||
|
||||
@@ -82,6 +82,7 @@ import {
|
||||
aiAssistantMenuItem,
|
||||
USER_SETTINGS_MENU_LABELS,
|
||||
type UserSettingsMenuKey,
|
||||
auditLogsMenuItem,
|
||||
} from './menuItems';
|
||||
import NavItem from './NavItem/NavItem';
|
||||
import {
|
||||
@@ -958,6 +959,8 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
|
||||
onSelect: handleSettingsMenuItemClick,
|
||||
});
|
||||
|
||||
const isAuditLogsEnabled = isCloudUser || isEnterpriseSelfHostedUser;
|
||||
|
||||
return (
|
||||
<div className={cx('sidenav-container', isPinned && 'pinned')}>
|
||||
<div
|
||||
@@ -1198,6 +1201,8 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
|
||||
<div className="secondary-nav-items">
|
||||
{isAIAssistantEnabled && renderNavItems([aiAssistantMenuItem], false)}
|
||||
|
||||
{isAuditLogsEnabled && renderNavItems([auditLogsMenuItem], false)}
|
||||
|
||||
<div className="nav-dropdown-item">
|
||||
<Dropdown
|
||||
items={helpSupportItems}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { useGetTenantLicense } from 'hooks/useGetTenantLicense';
|
||||
import { render, screen } from 'tests/test-utils';
|
||||
import { USER_ROLES } from 'types/roles';
|
||||
|
||||
import SideNav from '../SideNav';
|
||||
|
||||
jest.mock('hooks/useGetTenantLicense');
|
||||
|
||||
jest.mock('providers/cmdKProvider', () => ({
|
||||
useCmdK: (): { openCmdK: jest.Mock } => ({ openCmdK: jest.fn() }),
|
||||
}));
|
||||
|
||||
jest.mock('hooks/hotkeys/useKeyboardHotkeys', () => ({
|
||||
useKeyboardHotkeys: (): Record<string, jest.Mock> => ({
|
||||
registerShortcut: jest.fn(),
|
||||
deregisterShortcut: jest.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
type TenantLicense = ReturnType<typeof useGetTenantLicense>;
|
||||
|
||||
const NO_LICENSE: TenantLicense = {
|
||||
isCloudUser: false,
|
||||
isEnterpriseSelfHostedUser: false,
|
||||
isCommunityUser: false,
|
||||
isCommunityEnterpriseUser: false,
|
||||
};
|
||||
|
||||
const AUDIT_LOGS_NAV_ITEM = 'nav-item-audit-logs';
|
||||
|
||||
describe('SideNav audit logs entry', () => {
|
||||
it.each([
|
||||
['cloud', { ...NO_LICENSE, isCloudUser: true }],
|
||||
[
|
||||
'enterprise self-hosted',
|
||||
{ ...NO_LICENSE, isEnterpriseSelfHostedUser: true },
|
||||
],
|
||||
])('shows the entry on %s', (_, license) => {
|
||||
jest.mocked(useGetTenantLicense).mockReturnValue(license);
|
||||
|
||||
render(<SideNav isPinned />, undefined, { role: USER_ROLES.ADMIN });
|
||||
|
||||
expect(screen.getByTestId(AUDIT_LOGS_NAV_ITEM)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it.each([USER_ROLES.EDITOR, USER_ROLES.VIEWER])(
|
||||
'shows the entry to a %s',
|
||||
(role) => {
|
||||
jest
|
||||
.mocked(useGetTenantLicense)
|
||||
.mockReturnValue({ ...NO_LICENSE, isCloudUser: true });
|
||||
|
||||
render(<SideNav isPinned />, undefined, { role });
|
||||
|
||||
expect(screen.getByTestId(AUDIT_LOGS_NAV_ITEM)).toBeInTheDocument();
|
||||
},
|
||||
);
|
||||
|
||||
it('hides the entry from an admin on a community install', () => {
|
||||
jest
|
||||
.mocked(useGetTenantLicense)
|
||||
.mockReturnValue({ ...NO_LICENSE, isCommunityUser: true });
|
||||
|
||||
render(<SideNav isPinned />, undefined, { role: USER_ROLES.ADMIN });
|
||||
|
||||
expect(screen.queryByTestId(AUDIT_LOGS_NAV_ITEM)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
ChartArea,
|
||||
Cloudy,
|
||||
DraftingCompass,
|
||||
FileClock,
|
||||
FileKey2,
|
||||
Github,
|
||||
HardDrive,
|
||||
@@ -81,6 +82,15 @@ export const helpSupportMenuItem = {
|
||||
icon: <MessageSquareText size={16} />,
|
||||
};
|
||||
|
||||
export const auditLogsMenuItem = {
|
||||
key: ROUTES.AUDIT_LOGS,
|
||||
label: 'Audit Logs',
|
||||
icon: <FileClock size={16} />,
|
||||
isEnabled: true,
|
||||
isBeta: true,
|
||||
itemKey: 'audit-logs',
|
||||
};
|
||||
|
||||
// The AI Assistant route is parameterized as `/ai-assistant/:conversationId`.
|
||||
// Sending the user to `/ai-assistant/new` triggers the page's fallback that
|
||||
// spawns a fresh conversation and replaces the URL with the real id, so
|
||||
|
||||
@@ -201,6 +201,7 @@ export const routesToSkip = [
|
||||
ROUTES.AI_OBSERVABILITY_CONFIGURATION,
|
||||
ROUTES.AI_OBSERVABILITY_ATTRIBUTE_MAPPING,
|
||||
ROUTES.AI_OBSERVABILITY_EXPLORER,
|
||||
ROUTES.AUDIT_LOGS,
|
||||
];
|
||||
|
||||
export const routesToDisable = [ROUTES.LOGS_EXPLORER];
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import { CSSProperties } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
export const tableStyles: CSSProperties = {
|
||||
cursor: 'unset',
|
||||
};
|
||||
|
||||
export const Container = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
--typography-color: var(--l1-foreground);
|
||||
`;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import {
|
||||
NO_DELAY_USER_EVENT,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { useCloseOnOutsideClick } from '../useCloseOnOutsideClick';
|
||||
|
||||
function Harness({
|
||||
enabled,
|
||||
onClose,
|
||||
}: {
|
||||
enabled: boolean;
|
||||
onClose: () => void;
|
||||
}): JSX.Element {
|
||||
useCloseOnOutsideClick(enabled, onClose);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button type="button" data-testid="outside">
|
||||
outside
|
||||
</button>
|
||||
<div data-log-detail-ignore="true">
|
||||
<button type="button" data-testid="ignored-list">
|
||||
list
|
||||
</button>
|
||||
</div>
|
||||
<div className="drawer-popover">
|
||||
<button type="button" data-testid="ignored-popover">
|
||||
popover
|
||||
</button>
|
||||
</div>
|
||||
<div data-base-ui-portal>
|
||||
<button type="button" data-testid="ignored-portal">
|
||||
portal
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
describe('useCloseOnOutsideClick', () => {
|
||||
it('closes on a click outside', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn() as jest.MockedFunction<() => void>;
|
||||
render(<Harness enabled onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId('outside'));
|
||||
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it.each(['ignored-list', 'ignored-popover', 'ignored-portal'])(
|
||||
'does not close on a click inside %s',
|
||||
async (testId) => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn() as jest.MockedFunction<() => void>;
|
||||
render(<Harness enabled onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId(testId));
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
it('does nothing while disabled', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn() as jest.MockedFunction<() => void>;
|
||||
render(<Harness enabled={false} onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId('outside'));
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('stops listening after it is disabled', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn() as jest.MockedFunction<() => void>;
|
||||
const { rerender } = render(<Harness enabled onClose={onClose} />);
|
||||
rerender(<Harness enabled={false} onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId('outside'));
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -3,11 +3,6 @@ import { ScalarFieldValue } from 'utils/stringUtils';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
|
||||
export type LogTimeRange = {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
|
||||
export type UseCopyLogLink = {
|
||||
isHighlighted: boolean;
|
||||
isLogsExplorerPage: boolean;
|
||||
@@ -16,9 +11,11 @@ export type UseCopyLogLink = {
|
||||
onClearActiveLog: () => void;
|
||||
};
|
||||
|
||||
export type UseActiveLog = {
|
||||
activeLog: ILog | null;
|
||||
onSetActiveLog: (log: ILog) => void;
|
||||
export type LogWithId = { id: string };
|
||||
|
||||
export type UseActiveLog<T extends LogWithId = ILog> = {
|
||||
activeLog: T | null;
|
||||
onSetActiveLog: (log: T) => void;
|
||||
onClearActiveLog: () => void;
|
||||
onAddToQuery: (
|
||||
fieldKey: string,
|
||||
|
||||
@@ -8,12 +8,12 @@ import { ILog } from 'types/api/logs/log';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import { UseActiveLog } from './types';
|
||||
import { LogWithId, UseActiveLog } from './types';
|
||||
|
||||
export const useActiveLog = (): UseActiveLog => {
|
||||
export const useActiveLog = <T extends LogWithId = ILog>(): UseActiveLog<T> => {
|
||||
const { currentQuery, redirectWithQueryBuilderData } = useQueryBuilder();
|
||||
|
||||
const [activeLog, setActiveLog] = useState<ILog | null>(null);
|
||||
const [activeLog, setActiveLog] = useState<T | null>(null);
|
||||
|
||||
// Close drawer/clear active log when query in URL changes
|
||||
const urlQuery = useUrlQuery();
|
||||
@@ -29,7 +29,7 @@ export const useActiveLog = (): UseActiveLog => {
|
||||
prevQueryRef.current = compositeQuery;
|
||||
}, [compositeQuery]);
|
||||
|
||||
const onSetActiveLog = useCallback((nextActiveLog: ILog): void => {
|
||||
const onSetActiveLog = useCallback((nextActiveLog: T): void => {
|
||||
setActiveLog(nextActiveLog);
|
||||
}, []);
|
||||
|
||||
|
||||
32
frontend/src/hooks/logs/useCloseOnOutsideClick.ts
Normal file
32
frontend/src/hooks/logs/useCloseOnOutsideClick.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const IGNORED_TARGETS = [
|
||||
'[data-log-detail-ignore="true"]',
|
||||
'.cm-tooltip-autocomplete',
|
||||
'.drawer-popover',
|
||||
'.query-status-popover',
|
||||
'[data-base-ui-portal]',
|
||||
].join(',');
|
||||
|
||||
export function useCloseOnOutsideClick(
|
||||
enabled: boolean,
|
||||
onClose: () => void,
|
||||
): void {
|
||||
useEffect(() => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const handleMouseDown = (e: MouseEvent): void => {
|
||||
if (e.target instanceof Element && e.target.closest(IGNORED_TARGETS)) {
|
||||
return;
|
||||
}
|
||||
onClose();
|
||||
};
|
||||
|
||||
document.addEventListener('mousedown', handleMouseDown);
|
||||
return (): void => {
|
||||
document.removeEventListener('mousedown', handleMouseDown);
|
||||
};
|
||||
}, [enabled, onClose]);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { server } from 'mocks-server/server';
|
||||
import { act, AllTheProviders, renderHook, waitFor } from 'tests/test-utils';
|
||||
import { buildNotificationChannelAttachPermission } from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';
|
||||
import { formatPermission } from 'lib/authz/hooks/useAuthZ/utils';
|
||||
import { LinkAccessState } from 'lib/authz/hooks/useLinkPickerAccess/types';
|
||||
import { setupAuthzDeny } from 'lib/authz/utils/authz-test-utils';
|
||||
|
||||
import { useChannelPickerAccess } from '../useChannelPickerAccess';
|
||||
@@ -31,16 +32,18 @@ describe('useChannelPickerAccess', () => {
|
||||
act(() => result.current.onPickerVisibleChange(true));
|
||||
|
||||
await waitFor(() =>
|
||||
expect(result.current.options[1].reason).toContain(formatPermission(denied)),
|
||||
expect(result.current.options[1].state).toBe(LinkAccessState.Denied),
|
||||
);
|
||||
const [open, locked] = result.current.options;
|
||||
expect(open).toMatchObject({
|
||||
value: 'ops-slack',
|
||||
label: 'ops-slack',
|
||||
disabled: false,
|
||||
state: LinkAccessState.Allowed,
|
||||
testId: 'picker-option-c1',
|
||||
});
|
||||
expect(locked).toMatchObject({ disabled: true, denied: true });
|
||||
expect(locked.reason).toContain(formatPermission(denied));
|
||||
expect(locked).toMatchObject({
|
||||
state: LinkAccessState.Denied,
|
||||
reason: expect.stringContaining(formatPermission(denied)),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { LinkPermissions } from 'lib/authz/hooks/useLinkPickerAccess/types'
|
||||
import { useLinkPickerAccess } from 'lib/authz/hooks/useLinkPickerAccess/useLinkPickerAccess';
|
||||
|
||||
import type { ChannelOption } from './useChannelOptions';
|
||||
import { getChannelIds } from './utils';
|
||||
|
||||
interface UseChannelPickerAccessArgs {
|
||||
/** The `attach`/`detach` of the rule or policy being edited; absent when new. */
|
||||
@@ -44,14 +45,14 @@ export function useChannelPickerAccess({
|
||||
channels,
|
||||
testIdPrefix,
|
||||
}: UseChannelPickerAccessArgs): UseChannelPickerAccessReturn {
|
||||
const linkedIds = useMemo(() => {
|
||||
const saved = new Set(savedChannelNames);
|
||||
return channels.filter((c) => saved.has(c.name)).map((c) => c.id);
|
||||
}, [savedChannelNames, channels]);
|
||||
const exemptIds = useMemo(() => {
|
||||
const exempt = new Set(exemptChannelNames);
|
||||
return channels.filter((c) => exempt.has(c.name)).map((c) => c.id);
|
||||
}, [exemptChannelNames, channels]);
|
||||
const linkedIds = useMemo(
|
||||
() => getChannelIds(channels, savedChannelNames),
|
||||
[channels, savedChannelNames],
|
||||
);
|
||||
const exemptIds = useMemo(
|
||||
() => getChannelIds(channels, exemptChannelNames),
|
||||
[channels, exemptChannelNames],
|
||||
);
|
||||
const optionIds = useMemo(() => channels.map((c) => c.id), [channels]);
|
||||
|
||||
const { getAccess, onPickerVisibleChange, isOwnerDenied } =
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user