Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(dashboards-v2): list tags, DSL search, per-user pinning & org-shared views (#11868)

Ashwin Bhatkalb2f048770e7a
diff --git a/frontend/src/components/TagKeyValueInput/TagKeyValueInput.module.scss b/frontend/src/components/TagKeyValueInput/TagKeyValueInput.module.scss
new file mode 100644
index 0000000000..626705c57f
--- /dev/null
+++ b/frontend/src/components/TagKeyValueInput/TagKeyValueInput.module.scss
@@ -0,0 +1,90 @@
+.container {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ width: 100%;
+}
+
+.field {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 6px;
+ padding: 6px 8px;
+ border-radius: 2px;
+ border: 1px solid var(--l2-border);
+}
+
+// Sienna chip — matches the dashboard list-row tag badge.
+.tag {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ max-width: 240px;
+ height: 24px;
+ padding: 2px 4px 2px 8px;
+ border-radius: 50px;
+ border: 1px solid color-mix(in srgb, var(--bg-sienna-500) 20%, transparent);
+ background: color-mix(in srgb, var(--bg-sienna-500) 10%, transparent);
+ color: var(--bg-sienna-400);
+ font-size: 13px;
+ font-weight: var(--font-weight-normal);
+ line-height: 20px;
+ cursor: text;
+}
+
+.tagLabel {
+ --button-height: auto;
+ --button-padding: 0;
+ --button-gap: 0;
+ --button-variant-ghost-background-color: transparent;
+ --button-variant-ghost-hover-background-color: transparent;
+ --button-variant-ghost-color: inherit;
+ --button-variant-ghost-hover-color: inherit;
+ overflow: hidden;
+ max-width: 200px;
+ font-size: 13px;
+ font-weight: var(--font-weight-normal);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ cursor: text;
+}
+
+.remove {
+ // Size overrides to fit the chip, plus a sienna-tinted hover — the Button's
+ // default ghost hover is a grey that clashes with the chip. Resting color is
+ // left at the Button default.
+ --button-height: 16px;
+ --button-padding: 0;
+ --button-border-radius: 50%;
+ --button-variant-ghost-hover-background-color: color-mix(
+ in srgb,
+ var(--bg-sienna-500) 22%,
+ transparent
+ );
+ --button-variant-ghost-hover-color: var(--bg-sienna-400);
+ width: 16px;
+ min-width: 16px;
+ flex: none;
+}
+
+.input {
+ flex: 1;
+ min-width: 120px;
+ border: none;
+ background: transparent;
+
+ &::placeholder {
+ color: var(--l3-foreground);
+ }
+}
+
+.editInput {
+ width: 160px;
+ height: 24px;
+}
+
+.error {
+ color: var(--bg-cherry-500);
+ font-size: 12px;
+}
diff --git a/frontend/src/components/TagKeyValueInput/TagKeyValueInput.tsx b/frontend/src/components/TagKeyValueInput/TagKeyValueInput.tsx
new file mode 100644
index 0000000000..4f5ae8c672
--- /dev/null
+++ b/frontend/src/components/TagKeyValueInput/TagKeyValueInput.tsx
@@ -0,0 +1,164 @@
+import { type ChangeEvent, type KeyboardEvent, useState } from 'react';
+import { Button } from '@signozhq/ui/button';
+import { Input } from '@signozhq/ui/input';
+import { Typography } from '@signozhq/ui/typography';
+import { X } from '@signozhq/icons';
+import cx from 'classnames';
+
+import { parseKeyValueTag } from './utils';
+
+import styles from './TagKeyValueInput.module.scss';
+
+interface TagKeyValueInputProps {
+ // Tags as `key:value` strings.
+ tags: string[];
+ onTagsChange: (tags: string[]) => void;
+ placeholder?: string;
+ // Override the outer container styling per host (e.g. the create modal).
+ className?: string;
+ testId?: string;
+}
+
+// Strict key:value tag editor. A tag is committed only on Enter and only when
+// it parses to a valid `key:value` pair — bare values are rejected with an
+// inline error. Existing chips can be edited inline (double-click), and removed.
+function TagKeyValueInput({
+ tags,
+ onTagsChange,
+ placeholder = 'key:value',
+ className,
+ testId = 'tag-key-value-input',
+}: TagKeyValueInputProps): JSX.Element {
+ const [inputValue, setInputValue] = useState('');
+ const [error, setError] = useState('');
+ const [editIndex, setEditIndex] = useState(-1);
+ const [editValue, setEditValue] = useState('');
+
+ const removeTag = (tag: string): void => {
+ onTagsChange(tags.filter((t) => t !== tag));
+ };
+
+ const commit = (): void => {
+ const raw = inputValue.trim();
+ if (!raw) {
+ return;
+ }
+ const normalized = parseKeyValueTag(raw);
+ if (!normalized) {
+ setError('Tags must be in key:value format (both sides required).');
+ return;
+ }
+ if (tags.includes(normalized)) {
+ setError('This tag already exists.');
+ return;
+ }
+ onTagsChange([...tags, normalized]);
+ setInputValue('');
+ setError('');
+ };
+
+ const handleChange = (e: ChangeEvent<HTMLInputElement>): void => {
+ setInputValue(e.target.value);
+ if (error) {
+ setError('');
+ }
+ };
+
+ const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>): void => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ commit();
+ }
+ };
+
+ const startEdit = (index: number): void => {
+ setEditIndex(index);
+ setEditValue(tags[index]);
+ setError('');
+ };
+
+ const cancelEdit = (): void => {
+ setEditIndex(-1);
+ setEditValue('');
+ };
+
+ const commitEdit = (): void => {
+ const normalized = parseKeyValueTag(editValue);
+ // Drop into a no-op (revert) on invalid or duplicate edits rather than
+ // stranding the user in an un-exitable edit box.
+ if (normalized && !tags.some((t, i) => t === normalized && i !== editIndex)) {
+ onTagsChange(tags.map((t, i) => (i === editIndex ? normalized : t)));
+ }
+ cancelEdit();
+ };
+
+ const handleEditKeyDown = (e: KeyboardEvent<HTMLInputElement>): void => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ commitEdit();
+ } else if (e.key === 'Escape') {
+ e.preventDefault();
+ cancelEdit();
+ }
+ };
+
+ return (
+ <div className={cx(styles.container, className)}>
+ <div className={styles.field}>
+ {tags.map((tag, index) =>
+ index === editIndex ? (
+ <Input
+ key={tag}
+ className={styles.editInput}
+ value={editValue}
+ autoFocus
+ testId={`${testId}-edit`}
+ onChange={(e: ChangeEvent<HTMLInputElement>): void =>
+ setEditValue(e.target.value)
+ }
+ onKeyDown={handleEditKeyDown}
+ onBlur={commitEdit}
+ />
+ ) : (
+ <div key={tag} className={styles.tag} data-testid={`${testId}-chip`}>
+ <Button
+ variant="ghost"
+ color="secondary"
+ className={styles.tagLabel}
+ title="Double-click to edit"
+ onDoubleClick={(): void => startEdit(index)}
+ >
+ {tag}
+ </Button>
+ <Button
+ variant="ghost"
+ color="secondary"
+ size="icon"
+ className={styles.remove}
+ aria-label={`Remove ${tag}`}
+ onClick={(): void => removeTag(tag)}
+ >
+ <X size={12} />
+ </Button>
+ </div>
+ ),
+ )}
+ <Input
+ className={styles.input}
+ value={inputValue}
+ placeholder={placeholder}
+ testId={testId}
+ onChange={handleChange}
+ onKeyDown={handleKeyDown}
+ />
+ </div>
+ {error && (
+ <Typography className={styles.error} data-testid={`${testId}-error`}>
+ {error}
+ </Typography>
+ )}
+ </div>
+ );
+}
+
+export default TagKeyValueInput;
diff --git a/frontend/src/components/TagKeyValueInput/utils.test.ts b/frontend/src/components/TagKeyValueInput/utils.test.ts
new file mode 100644
index 0000000000..62d06d6751
--- /dev/null
+++ b/frontend/src/components/TagKeyValueInput/utils.test.ts
@@ -0,0 +1,31 @@
+import { parseKeyValueTag } from './utils';
+
+describe('parseKeyValueTag', () => {
+ it('normalizes a valid key:value pair', () => {
+ expect(parseKeyValueTag('env:prod')).toBe('env:prod');
+ });
+
+ it('trims whitespace around key and value', () => {
+ expect(parseKeyValueTag(' env : prod ')).toBe('env:prod');
+ });
+
+ it('keeps colons inside the value', () => {
+ expect(parseKeyValueTag('url:http://x')).toBe('url:http://x');
+ });
+
+ it('rejects a bare value with no colon', () => {
+ expect(parseKeyValueTag('prod')).toBeNull();
+ });
+
+ it('rejects an empty key', () => {
+ expect(parseKeyValueTag(':prod')).toBeNull();
+ });
+
+ it('rejects an empty value', () => {
+ expect(parseKeyValueTag('env:')).toBeNull();
+ });
+
+ it('rejects blank input', () => {
+ expect(parseKeyValueTag(' ')).toBeNull();
+ });
+});
diff --git a/frontend/src/components/TagKeyValueInput/utils.ts b/frontend/src/components/TagKeyValueInput/utils.ts
new file mode 100644
index 0000000000..8872ccc381
--- /dev/null
+++ b/frontend/src/components/TagKeyValueInput/utils.ts
@@ -0,0 +1,17 @@
+// Tags are strictly key:value. Parse a raw input into a normalized `key:value`
+// string, or null if it isn't a valid pair (both sides non-empty). The first
+// colon separates key from value, so values may themselves contain colons
+// (e.g. `url:http://x`).
+export function parseKeyValueTag(raw: string): string | null {
+ const trimmed = raw.trim();
+ const idx = trimmed.indexOf(':');
+ if (idx <= 0) {
+ return null;
+ }
+ const key = trimmed.slice(0, idx).trim();
+ const value = trimmed.slice(idx + 1).trim();
+ if (!key || !value) {
+ return null;
+ }
+ return `${key}:${value}`;
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.module.scss
index c72191e975..9726bf5a8f 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.module.scss
@@ -68,13 +68,3 @@
border-radius: 2px;
border: 1px solid var(--l2-border);
}
-
-// the V1 tags input ships borderless; give the field a visible box to match
-.tagsField {
- display: flex;
- align-items: center;
- padding: 6px 8px;
- border-radius: 2px;
- border: 1px solid var(--l2-border);
- // background: var(--l3-background);
-}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.tsx
index bbfdd4f585..6d36a78c8f 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/DashboardInfoForm/DashboardInfoForm.tsx
@@ -9,7 +9,7 @@ import {
import { Typography } from '@signozhq/ui/typography';
// eslint-disable-next-line signoz/no-antd-components -- multiline TextArea has no @signozhq/ui equivalent yet
import { Input as AntdInput } from 'antd';
-import AddTags from 'container/DashboardContainer/DashboardSettings/General/AddBadges';
+import TagKeyValueInput from 'components/TagKeyValueInput/TagKeyValueInput';
import { Base64Icons } from '../utils';
import settingsStyles from '../../DashboardSettings.module.scss';
@@ -89,9 +89,7 @@ function DashboardInfoForm({
<div className={styles.infoItemContainer}>
<Typography className={styles.infoTitle}>Tags</Typography>
- <div className={styles.tagsField}>
- <AddTags tags={tags} setTags={onTagsChange} />
- </div>
+ <TagKeyValueInput tags={tags} onTagsChange={onTagsChange} />
</div>
</div>
</div>
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/utils.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/utils.ts
index 8c920ee86e..d99c6d113b 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/utils.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/utils.ts
@@ -1,6 +1,7 @@
import type { TagtypesPostableTagDTO } from 'api/generated/services/sigNoz.schemas';
export { Base64Icons } from 'container/DashboardContainer/DashboardSettings/General/utils';
+export { parseKeyValueTag } from 'components/TagKeyValueInput/utils';
// tag UX, a string with no ':' is round-tripped as `{key: x, value: x}` and
// collapsed back to just `x` for display.
diff --git a/frontend/src/pages/DashboardsListPageV2/DashboardsListPageV2.tsx b/frontend/src/pages/DashboardsListPageV2/DashboardsListPageV2.tsx
index bc64e62eb4..3ff6deb937 100644
--- a/frontend/src/pages/DashboardsListPageV2/DashboardsListPageV2.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/DashboardsListPageV2.tsx
@@ -1,5 +1,3 @@
-import { useState } from 'react';
-import { AnnouncementBanner } from '@signozhq/ui/announcement-banner';
import { LayoutGrid } from '@signozhq/icons';
import HeaderRightSection from 'components/HeaderRightSection/HeaderRightSection';
@@ -9,19 +7,8 @@ import styles from './DashboardsListPageV2.module.scss';
import { BreadcrumbLink } from '@signozhq/ui/breadcrumb';
function DashboardsListPageV2(): JSX.Element {
- const [showBanner, setShowBanner] = useState(true);
-
return (
<div className={styles.page}>
- {showBanner && (
- <AnnouncementBanner
- type="warning"
- onClose={(): void => setShowBanner(false)}
- >
- You&apos;re on the V2 dashboards page. If you landed here unintentionally,
- please reach out to Ashwin.
- </AnnouncementBanner>
- )}
<div className={styles.header}>
<div className={styles.headerLeft}>
<BreadcrumbLink icon={<LayoutGrid size={14} />}>Dashboard</BreadcrumbLink>
diff --git a/frontend/src/pages/DashboardsListPageV2/components/ActionsPopover/DeleteActionItem.tsx b/frontend/src/pages/DashboardsListPageV2/components/ActionsPopover/DeleteActionItem.tsx
index 209d38b454..e6028f7425 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/ActionsPopover/DeleteActionItem.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/ActionsPopover/DeleteActionItem.tsx
@@ -78,6 +78,11 @@ function DeleteActionItem({
runDelete(undefined, { onSettled: () => destroy() });
},
},
+ cancelButtonProps: {
+ onClick: (e): void => {
+ e.stopPropagation();
+ },
+ },
centered: true,
});
}, [modal, dashboardName, runDelete]);
diff --git a/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.module.scss b/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.module.scss
index 4cd5a592b5..292f7b3f69 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.module.scss
+++ b/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.module.scss
@@ -62,7 +62,7 @@
justify-content: flex-end;
}
-.favBtn {
+.pinBtn {
display: inline-flex;
align-items: center;
justify-content: center;
@@ -79,16 +79,16 @@
color 0.12s;
}
-.row:hover .favBtn {
+.row:hover .pinBtn {
color: var(--l3-foreground);
}
-.favBtn:hover {
+.pinBtn:hover {
background: var(--l1-background);
color: var(--bg-amber-500);
}
-.favBtnOn {
+.pinBtnOn {
color: var(--bg-amber-500);
svg {
diff --git a/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.tsx b/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.tsx
index e576fc612d..aa3833607c 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/DashboardRow/DashboardRow.tsx
@@ -1,7 +1,7 @@
import { Tooltip } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { Badge } from '@signozhq/ui/badge';
-import { CalendarClock, Star } from '@signozhq/icons';
+import { CalendarClock, Pin, PinOff } from '@signozhq/icons';
import cx from 'classnames';
import logEvent from 'api/common/logEvent';
import { generatePath } from 'react-router-dom';
@@ -12,9 +12,10 @@ import { useSafeNavigate } from 'hooks/useSafeNavigate';
import { useTimezone } from 'providers/Timezone';
import { isModifierKeyPressed } from 'utils/app';
+import { usePinDashboard } from '../../hooks/usePinDashboard';
import { useDashboardViewsStore } from '../../store/useDashboardViewsStore';
-import type { DashboardListItem } from '../../utils';
-import { lastUpdatedLabel, tagsToStrings } from '../../utils';
+import type { DashboardListItem } from '../../utils/helpers';
+import { lastUpdatedLabel, tagsToStrings } from '../../utils/helpers';
import ActionsPopover from '../ActionsPopover/ActionsPopover';
import styles from './DashboardRow.module.scss';
@@ -37,12 +38,10 @@ function DashboardRow({
const { safeNavigate } = useSafeNavigate();
const { formatTimezoneAdjustedTimestamp } = useTimezone();
- const isFavorite = useDashboardViewsStore((s) =>
- s.favorites.includes(dashboard.id),
- );
- const toggleFavorite = useDashboardViewsStore((s) => s.toggleFavorite);
const markViewed = useDashboardViewsStore((s) => s.markViewed);
+ const { togglePin, isUpdating } = usePinDashboard();
+ const isPinned = !!dashboard.pinned;
const id = dashboard.id;
const name = dashboard.spec?.display?.name ?? '';
const image = dashboard.image || Base64Icons[0];
@@ -69,9 +68,9 @@ function DashboardRow({
});
};
- const onToggleFavorite = (event: React.MouseEvent<HTMLElement>): void => {
+ const onTogglePin = (event: React.MouseEvent<HTMLElement>): void => {
event.stopPropagation();
- toggleFavorite(id);
+ togglePin(id, isPinned);
};
return (
@@ -105,7 +104,7 @@ function DashboardRow({
))}
{tags.length > 3 && (
<Badge className={styles.tag} key={tags[3]}>
- + <span> {tags.length - 3} </span>
+ + <Typography.Text> {tags.length - 3} </Typography.Text>
</Badge>
)}
</div>
@@ -114,13 +113,14 @@ function DashboardRow({
<button
type="button"
- className={cx(styles.favBtn, { [styles.favBtnOn]: isFavorite })}
- aria-label={isFavorite ? 'Remove from favorites' : 'Add to favorites'}
- title={isFavorite ? 'Remove from favorites' : 'Add to favorites'}
- data-testid={`dashboard-favorite-${index}`}
- onClick={onToggleFavorite}
+ className={cx(styles.pinBtn, { [styles.pinBtnOn]: isPinned })}
+ aria-label={isPinned ? 'Unpin dashboard' : 'Pin dashboard'}
+ title={isPinned ? 'Unpin dashboard' : 'Pin dashboard'}
+ data-testid={`dashboard-pin-${index}`}
+ disabled={isUpdating}
+ onClick={onTogglePin}
>
- <Star size={14} />
+ {isPinned ? <PinOff size={14} /> : <Pin size={14} />}
</button>
{canAct && (
diff --git a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx
index 328baa36d4..1ca86845cf 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import logEvent from 'api/common/logEvent';
-import { useListDashboardsV2 } from 'api/generated/services/dashboard';
+import { useListDashboardsForUserV2 } from 'api/generated/services/dashboard';
import {
DashboardtypesListOrderDTO,
DashboardtypesListSortDTO,
@@ -10,7 +10,8 @@ import { useGetTenantLicense } from 'hooks/useGetTenantLicense';
import { useAppContext } from 'providers/App/App';
import { toAPIError } from 'utils/errorUtils';
-import { combineQueries } from '../../filterQuery';
+import { combineQueries } from '../../utils/filterQuery';
+import { useAccumulatedTags } from '../../hooks/useAccumulatedTags';
import { useActiveView } from '../../hooks/useActiveView';
import { useDashboardFilters } from '../../hooks/useDashboardFilters';
import {
@@ -20,9 +21,10 @@ import {
} from '../../hooks/useDashboardsListQueryParams';
import { useDashboardViewsStore } from '../../store/useDashboardViewsStore';
import { useDashboardsListVisibleColumnsStore } from '../../store/useVisibleColumnsStore';
-import type { UpdatedWindow } from '../../types';
-import type { DashboardListItem } from '../../utils';
-import { applyClientView } from '../../views';
+import { BuiltinViewId } from '../../types';
+import type { SelectedTag, UpdatedWindow } from '../../types';
+import type { DashboardListItem } from '../../utils/helpers';
+import { applyClientView } from '../../utils/views';
import type { CreatorOption } from '../FilterZone/FilterChips';
import FilterZone from '../FilterZone/FilterZone';
import NewDashboardModal from '../NewDashboardModal/NewDashboardModal';
@@ -55,6 +57,7 @@ function DashboardsList(): JSX.Element {
setSearch,
setCreatedBy,
setUpdated,
+ setTags,
applyFilters,
clearAll,
} = useDashboardFilters();
@@ -66,6 +69,7 @@ function DashboardsList(): JSX.Element {
activeViewId,
builtinViews,
customViews,
+ customViewsLoading,
isCustomActive,
isModified,
viewQuery,
@@ -75,11 +79,18 @@ function DashboardsList(): JSX.Element {
saveActiveView,
resetView,
removeView,
- } = useActiveView({ filters, applyFilters, userEmail: user.email });
+ } = useActiveView({
+ filters,
+ applyFilters,
+ userEmail: user.email,
+ sortColumn,
+ sortOrder,
+ setSortColumn,
+ setSortOrder,
+ });
const railCollapsed = useDashboardViewsStore((s) => s.railCollapsed);
const setRailCollapsed = useDashboardViewsStore((s) => s.setRailCollapsed);
- const favorites = useDashboardViewsStore((s) => s.favorites);
const recent = useDashboardViewsStore((s) => s.recent);
// Any filter change resets to the first page so the user isn't stranded on a
@@ -105,6 +116,13 @@ function DashboardsList(): JSX.Element {
},
[setUpdated, setPage],
);
+ const handleTagsChange = useCallback(
+ (tags: SelectedTag[]): void => {
+ setTags(tags);
+ void setPage(1);
+ },
+ [setTags, setPage],
+ );
const handleClearAll = useCallback((): void => {
clearAll();
void setPage(1);
@@ -150,7 +168,9 @@ function DashboardsList(): JSX.Element {
isFetching,
error,
refetch,
- } = useListDashboardsV2(listParams, { query: { keepPreviousData: true } });
+ } = useListDashboardsForUserV2(listParams, {
+ query: { keepPreviousData: true },
+ });
const apiError = useMemo(
() => (error ? toAPIError(error) : undefined),
@@ -169,9 +189,9 @@ function DashboardsList(): JSX.Element {
const dashboards = useMemo<DashboardListItem[]>(
() =>
clientView
- ? applyClientView(rawDashboards, activeViewId, favorites, recent)
+ ? applyClientView(rawDashboards, activeViewId, recent)
: rawDashboards,
- [clientView, rawDashboards, activeViewId, favorites, recent],
+ [clientView, rawDashboards, activeViewId, recent],
);
const total = clientView ? dashboards.length : (response?.data?.total ?? 0);
@@ -194,6 +214,16 @@ function DashboardsList(): JSX.Element {
}));
}, [rawDashboards, user.email]);
+ // All key:value tags the API reports for the org's dashboards, powering the
+ // Tags filter chip and DSL key suggestions. Accumulated across refetches so
+ // previously-seen tags stay selectable even when a filtered page omits them.
+ const responseTags = useMemo<SelectedTag[]>(
+ () =>
+ (response?.data?.tags ?? []).map((t) => ({ key: t.key, value: t.value })),
+ [response],
+ );
+ const availableTags = useAccumulatedTags(responseTags);
+
const [isCreateOpen, setIsCreateOpen] = useState(false);
const visibleColumns = useDashboardsListVisibleColumnsStore(
(s) => s.visibleColumns,
@@ -239,7 +269,7 @@ function DashboardsList(): JSX.Element {
const showWorkspaceEmpty =
!error &&
dashboards.length === 0 &&
- activeViewId === 'all' &&
+ activeViewId === BuiltinViewId.All &&
filtersEmpty &&
page === 1;
@@ -251,6 +281,7 @@ function DashboardsList(): JSX.Element {
activeViewId={activeViewId}
builtinViews={builtinViews}
customViews={customViews}
+ customViewsLoading={customViewsLoading}
isCustomActive={isCustomActive}
isModified={isModified}
collapsed={railCollapsed}
@@ -281,11 +312,14 @@ function DashboardsList(): JSX.Element {
search={filters.search}
createdBy={filters.createdBy}
updated={filters.updated}
+ tags={filters.tags}
+ availableTags={availableTags}
creatorOptions={creatorOptions}
isEmpty={filtersEmpty}
onSearchChange={handleSearchChange}
onCreatedByChange={handleCreatedByChange}
onUpdatedChange={handleUpdatedChange}
+ onTagsChange={handleTagsChange}
onClearAll={handleClearAll}
/>
</div>
diff --git a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsListContent.tsx b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsListContent.tsx
index c6ba092118..5484c3eecc 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsListContent.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsListContent.tsx
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { Table } from 'antd';
import type { TableProps } from 'antd/lib';
-import type { DashboardListItem } from '../../utils';
+import type { DashboardListItem } from '../../utils/helpers';
import DashboardRow from '../DashboardRow/DashboardRow';
interface Props {
diff --git a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsResults.tsx b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsResults.tsx
index 9ea2be40c6..50d76873eb 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsResults.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsResults.tsx
@@ -3,8 +3,8 @@ import {
DashboardtypesListSortDTO,
} from 'api/generated/services/sigNoz.schemas';
-import type { DashboardListItem } from '../../utils';
-import { noResultsCopy } from '../../views';
+import type { DashboardListItem } from '../../utils/helpers';
+import { noResultsCopy } from '../../utils/views';
import ListHeader from '../ListHeader/ListHeader';
import ErrorState from '../states/ErrorState/ErrorState';
import LoadingState from '../states/LoadingState/LoadingState';
diff --git a/frontend/src/pages/DashboardsListPageV2/components/FilterZone/FilterZone.tsx b/frontend/src/pages/DashboardsListPageV2/components/FilterZone/FilterZone.tsx
index c0d34eb646..6f1748eb71 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/FilterZone/FilterZone.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/FilterZone/FilterZone.tsx
@@ -1,10 +1,19 @@
-import { type ReactNode, useCallback, useEffect, useState } from 'react';
+import {
+ type ReactNode,
+ useCallback,
+ useEffect,
+ useMemo,
+ useState,
+} from 'react';
import { Button } from '@signozhq/ui/button';
+import { Typography } from '@signozhq/ui/typography';
import { X } from '@signozhq/icons';
-import type { UpdatedWindow } from '../../types';
+import { buildSuggestionKeys } from '../../utils/dslSuggestions';
+import type { SelectedTag, UpdatedWindow } from '../../types';
import SearchBar from '../SearchBar/SearchBar';
import FilterChips, { type CreatorOption } from './FilterChips';
+import TagsFilterChip from './TagsFilterChip';
import styles from './FilterZone.module.scss';
@@ -12,11 +21,14 @@ interface Props {
search: string;
createdBy: string[];
updated: UpdatedWindow;
+ tags: SelectedTag[];
+ availableTags: SelectedTag[];
creatorOptions: CreatorOption[];
isEmpty: boolean;
onSearchChange: (value: string) => void;
onCreatedByChange: (emails: string[]) => void;
onUpdatedChange: (window: UpdatedWindow) => void;
+ onTagsChange: (tags: SelectedTag[]) => void;
onClearAll: () => void;
// Rendered at the end of the search row (e.g. the New Dashboard action).
rightSlot?: ReactNode;
@@ -29,16 +41,24 @@ function FilterZone({
search,
createdBy,
updated,
+ tags,
+ availableTags,
creatorOptions,
isEmpty,
onSearchChange,
onCreatedByChange,
onUpdatedChange,
+ onTagsChange,
onClearAll,
rightSlot,
}: Props): JSX.Element {
const [searchInput, setSearchInput] = useState(search);
+ const suggestionKeys = useMemo(
+ () => buildSuggestionKeys(availableTags),
+ [availableTags],
+ );
+
// Keep the local input in sync with external search changes (applying a view,
// clear-all, back/forward). User typing only mutates the local copy.
useEffect(() => {
@@ -58,7 +78,8 @@ function FilterZone({
<div className={styles.searchInput}>
<SearchBar
value={searchInput}
- placeholder="Search dashboards by name"
+ placeholder={`Search with DSL — e.g. name contains "prod" AND env = "staging"`}
+ suggestionKeys={suggestionKeys}
onChange={setSearchInput}
onSubmit={handleSubmit}
/>
@@ -66,7 +87,7 @@ function FilterZone({
{rightSlot}
</div>
<div className={styles.filtersRow}>
- <span className={styles.filtersLabel}>Filters</span>
+ <Typography.Text className={styles.filtersLabel}>Filters</Typography.Text>
<FilterChips
createdBy={createdBy}
updated={updated}
@@ -74,6 +95,11 @@ function FilterZone({
onCreatedByChange={onCreatedByChange}
onUpdatedChange={onUpdatedChange}
/>
+ <TagsFilterChip
+ availableTags={availableTags}
+ tags={tags}
+ onTagsChange={onTagsChange}
+ />
{!isEmpty && (
<Button
variant="ghost"
diff --git a/frontend/src/pages/DashboardsListPageV2/components/FilterZone/TagsFilterChip.tsx b/frontend/src/pages/DashboardsListPageV2/components/FilterZone/TagsFilterChip.tsx
new file mode 100644
index 0000000000..d17eacbdf5
--- /dev/null
+++ b/frontend/src/pages/DashboardsListPageV2/components/FilterZone/TagsFilterChip.tsx
@@ -0,0 +1,80 @@
+import { useMemo } from 'react';
+import { Button } from '@signozhq/ui/button';
+import { DropdownMenuSimple, type MenuItem } from '@signozhq/ui/dropdown-menu';
+import { ChevronDown, Tag } from '@signozhq/icons';
+import cx from 'classnames';
+
+import type { SelectedTag } from '../../types';
+
+import styles from './FilterZone.module.scss';
+
+interface Props {
+ // All key:value tags the list API reports across the org's dashboards.
+ availableTags: SelectedTag[];
+ tags: SelectedTag[];
+ onTagsChange: (tags: SelectedTag[]) => void;
+}
+
+const tagId = (tag: SelectedTag): string => `${tag.key}:${tag.value}`;
+
+function TagsFilterChip({
+ availableTags,
+ tags,
+ onTagsChange,
+}: Props): JSX.Element {
+ const selectedIds = useMemo(() => new Set(tags.map(tagId)), [tags]);
+
+ const label = useMemo((): string => {
+ if (tags.length === 0) {
+ return 'Any';
+ }
+ if (tags.length === 1) {
+ return tagId(tags[0]);
+ }
+ return `${tags.length} tags`;
+ }, [tags]);
+
+ const items = useMemo<MenuItem[]>(() => {
+ const options: MenuItem[] = availableTags.map((tag) => {
+ const id = tagId(tag);
+ return {
+ type: 'checkbox',
+ key: id,
+ label: id,
+ checked: selectedIds.has(id),
+ onCheckedChange: (checked: boolean): void =>
+ onTagsChange(
+ checked ? [...tags, tag] : tags.filter((t) => tagId(t) !== id),
+ ),
+ };
+ });
+ if (tags.length > 0) {
+ options.push({ type: 'divider', key: 'sep' });
+ options.push({
+ key: 'clear',
+ label: 'Clear selection',
+ onClick: (): void => onTagsChange([]),
+ });
+ }
+ return options;
+ }, [availableTags, selectedIds, tags, onTagsChange]);
+
+ return (
+ <DropdownMenuSimple menu={{ items }} align="start">
+ <Button
+ variant="outlined"
+ color="secondary"
+ size="sm"
+ prefix={<Tag size={12} />}
+ suffix={<ChevronDown size={12} />}
+ className={cx(styles.chip, { [styles.chipActive]: tags.length > 0 })}
+ disabled={availableTags.length === 0}
+ testId="dashboards-filter-tags"
+ >
+ Tags: {label}
+ </Button>
+ </DropdownMenuSimple>
+ );
+}
+
+export default TagsFilterChip;
diff --git a/frontend/src/pages/DashboardsListPageV2/components/ListHeader/ListHeader.tsx b/frontend/src/pages/DashboardsListPageV2/components/ListHeader/ListHeader.tsx
index 48295ee0d1..e08e6fc1fd 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/ListHeader/ListHeader.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/ListHeader/ListHeader.tsx
@@ -54,7 +54,7 @@ function ListHeader({
const metadataContent = (
<div className={styles.metaPanel}>
- <Typography.Text className={styles.sortHeading}>Metadata</Typography.Text>
+ <Typography.Text className={styles.sortHeading}>Columns</Typography.Text>
{METADATA_COLUMNS.map((col) => (
<div key={col.key} className={styles.metaRow}>
<Typography.Text className={styles.metaLabel}>{col.label}</Typography.Text>
@@ -171,7 +171,7 @@ function ListHeader({
)
}
>
- <span className={styles.sortPrefix}>Sort:</span>{' '}
+ <Typography.Text className={styles.sortPrefix}>Sort:</Typography.Text>{' '}
{SORT_LABELS[sortColumn]}{' '}
</Button>
</Popover>
@@ -183,13 +183,13 @@ function ListHeader({
placement="bottomRight"
arrow={false}
>
- <Tooltip title="Metadata">
+ <Tooltip title="Columns">
<Button
variant="ghost"
color="secondary"
size="icon"
- aria-label="Metadata"
- testId="configure-metadata-trigger"
+ aria-label="Columns"
+ testId="configure-columns-trigger"
>
<HdmiPort size={14} />
</Button>
diff --git a/frontend/src/pages/DashboardsListPageV2/components/NewDashboardModal/BlankDashboardPanel.tsx b/frontend/src/pages/DashboardsListPageV2/components/NewDashboardModal/BlankDashboardPanel.tsx
index 3a2411342e..00cd21ed7e 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/NewDashboardModal/BlankDashboardPanel.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/NewDashboardModal/BlankDashboardPanel.tsx
@@ -13,8 +13,9 @@ import ROUTES from 'constants/routes';
import { useSafeNavigate } from 'hooks/useSafeNavigate';
import { useErrorModal } from 'providers/ErrorModalProvider';
import APIError from 'types/api/error';
+import TagKeyValueInput from 'components/TagKeyValueInput/TagKeyValueInput';
-import { toPostableTags } from '../../utils';
+import { keyValueStringsToTags } from '../../utils/helpers';
import styles from './NewDashboardModal.module.scss';
@@ -30,7 +31,7 @@ function BlankDashboardPanel({ onClose }: Props): JSX.Element {
const [name, setName] = useState(DEFAULT_NAME);
const [description, setDescription] = useState('');
- const [tags, setTags] = useState('');
+ const [tags, setTags] = useState<string[]>([]);
const [submitting, setSubmitting] = useState(false);
const canSubmit = name.trim().length > 0 && !submitting;
@@ -42,7 +43,7 @@ function BlankDashboardPanel({ onClose }: Props): JSX.Element {
try {
setSubmitting(true);
logEvent('Dashboard List: Create dashboard clicked', {});
- const postableTags = toPostableTags(tags);
+ const postableTags = keyValueStringsToTags(tags);
const created = await createDashboardV2({
schemaVersion: 'v6',
generateName: true,
@@ -72,7 +73,7 @@ function BlankDashboardPanel({ onClose }: Props): JSX.Element {
<div className={styles.form}>
<div className={styles.field}>
<Typography.Text className={styles.label}>
- Title <span className={styles.required}>*</span>
+ Title <Typography.Text className={styles.required}>*</Typography.Text>
</Typography.Text>
<Input
value={name}
@@ -104,16 +105,14 @@ function BlankDashboardPanel({ onClose }: Props): JSX.Element {
<div className={styles.field}>
<Typography.Text className={styles.label}>Tags</Typography.Text>
- <Input
- value={tags}
- placeholder="team:jarvis, prod"
+ <TagKeyValueInput
+ tags={tags}
+ onTagsChange={setTags}
+ placeholder="team:jarvis (press Enter)"
testId="create-dashboard-tags"
- onChange={(e: ChangeEvent<HTMLInputElement>): void =>
- setTags(e.target.value)
- }
/>
<Typography.Text className={styles.hint}>
- Comma-separated. Use key:value (e.g. team:jarvis) or a single label.
+ Use key:value (e.g. team:jarvis) and press Enter to add.
</Typography.Text>
</div>
</div>
diff --git a/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.module.scss b/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.module.scss
index 8233fd141f..14a9924b71 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.module.scss
+++ b/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.module.scss
@@ -1,24 +1,58 @@
-.submit {
- display: inline-flex;
+.wrapper {
+ position: relative;
+ width: 100%;
+}
+
+.input::placeholder {
+ color: var(--l3-foreground);
+}
+
+// Flatten the input's bottom corners while the dropdown is attached below it.
+.inputOpen {
+ border-bottom-left-radius: 0;
+ border-bottom-right-radius: 0;
+}
+
+.suggestions {
+ position: absolute;
+ top: 100%;
+ left: 0;
+ right: 0;
+ z-index: 1000;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ max-height: 260px;
+ overflow-y: auto;
+ padding: 4px;
+ border: 1px solid var(--l2-border);
+ border-top: none;
+ border-radius: 0 0 6px 6px;
+ background: var(--l1-background);
+ /* stylelint-disable-next-line local/prefer-css-variables -- matches the V2 dashboard dropdown shadow */
+ box-shadow: 4px 10px 16px 2px rgba(0, 0, 0, 0.2);
+}
+
+.suggestion {
+ display: flex;
align-items: center;
- justify-content: center;
- width: 18px;
- height: 18px;
- padding: 0;
- background: transparent;
+ padding: 8px 10px;
border: none;
- border-radius: 3px;
- color: inherit;
+ border-radius: 4px;
+ background: transparent;
+ color: var(--l2-foreground);
+ font-family: 'Space Mono', monospace;
+ font-size: var(--font-size-sm);
+ text-align: left;
cursor: pointer;
- transition: background 120ms ease;
+ transition: background 0.1s;
+}
- &:hover,
- &:focus-visible {
- background: color-mix(in srgb, var(--l1-foreground) 12%, transparent);
- outline: none;
- }
+.suggestionActive {
+ background: var(--l2-background);
+ color: var(--l1-foreground);
+}
- &:active {
- background: color-mix(in srgb, var(--l1-foreground) 20%, transparent);
- }
+.submit {
+ color: var(--bg-vanilla-400);
}
diff --git a/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.tsx b/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.tsx
index 1ffa6078d3..3b59402b35 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/SearchBar/SearchBar.tsx
@@ -1,7 +1,21 @@
-import { ChangeEvent, KeyboardEvent, MouseEvent } from 'react';
+import {
+ ChangeEvent,
+ KeyboardEvent,
+ MouseEvent,
+ useMemo,
+ useState,
+} from 'react';
+import { Button } from '@signozhq/ui/button';
import { Input } from '@signozhq/ui/input';
import { Color } from '@signozhq/design-tokens';
import { CornerDownLeft, Search } from '@signozhq/icons';
+import cx from 'classnames';
+
+import {
+ applyKeySuggestion,
+ getActiveKeyToken,
+ matchKeys,
+} from '../../utils/dslSuggestions';
import styles from './SearchBar.module.scss';
@@ -10,6 +24,8 @@ interface Props {
onChange: (value: string) => void;
onSubmit: () => void;
placeholder?: string;
+ // Keys offered as you type (reserved DSL columns + tag keys from the API).
+ suggestionKeys?: string[];
}
function SearchBar({
@@ -17,38 +33,116 @@ function SearchBar({
onChange,
onSubmit,
placeholder = "Search with DSL (e.g. name CONTAINS 'foo')",
+ suggestionKeys = [],
}: Props): JSX.Element {
- return (
- <Input
- placeholder={placeholder}
- prefix={<Search size={12} color={Color.BG_VANILLA_400} />}
- suffix={
- <button
- type="button"
- className={styles.submit}
- aria-label="Run search"
- data-testid="dashboards-list-search-submit"
- onMouseDown={(e: MouseEvent<HTMLButtonElement>): void => {
- // Prevent the input's blur from firing first and double-submitting.
- e.preventDefault();
- }}
- onClick={onSubmit}
- >
- <CornerDownLeft size={12} color={Color.BG_VANILLA_400} />
- </button>
- }
- value={value}
- testId="dashboards-list-search"
- onChange={(e: ChangeEvent<HTMLInputElement>): void =>
- onChange(e.target.value)
+ const [focused, setFocused] = useState(false);
+ // -1 means nothing is highlighted, so Enter submits the typed query rather
+ // than picking a suggestion (arrow keys engage selection).
+ const [highlighted, setHighlighted] = useState(-1);
+
+ const active = useMemo(() => getActiveKeyToken(value), [value]);
+ const suggestions = useMemo(
+ () => (active ? matchKeys(suggestionKeys, active.token) : []),
+ [active, suggestionKeys],
+ );
+ const showSuggestions = focused && suggestions.length > 0;
+
+ const pickSuggestion = (key: string): void => {
+ if (active) {
+ onChange(applyKeySuggestion(value, active, key));
+ }
+ setHighlighted(-1);
+ };
+
+ const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>): void => {
+ if (showSuggestions && e.key === 'ArrowDown') {
+ e.preventDefault();
+ setHighlighted((h) => Math.min(h + 1, suggestions.length - 1));
+ return;
+ }
+ if (showSuggestions && e.key === 'ArrowUp') {
+ e.preventDefault();
+ setHighlighted((h) => Math.max(h - 1, 0));
+ return;
+ }
+ if (e.key === 'Enter') {
+ if (showSuggestions && highlighted >= 0) {
+ e.preventDefault();
+ pickSuggestion(suggestions[highlighted]);
+ } else {
+ onSubmit();
}
- onBlur={onSubmit}
- onKeyDown={(e: KeyboardEvent<HTMLInputElement>): void => {
- if (e.key === 'Enter') {
- onSubmit();
+ return;
+ }
+ if (e.key === 'Escape') {
+ setFocused(false);
+ setHighlighted(-1);
+ }
+ };
+
+ return (
+ <div className={styles.wrapper}>
+ <Input
+ className={cx(styles.input, { [styles.inputOpen]: showSuggestions })}
+ placeholder={placeholder}
+ prefix={<Search size={12} color={Color.BG_VANILLA_400} />}
+ suffix={
+ <Button
+ variant="ghost"
+ color="secondary"
+ size="icon"
+ className={styles.submit}
+ aria-label="Run search"
+ testId="dashboards-list-search-submit"
+ onMouseDown={(e: MouseEvent<HTMLButtonElement>): void => {
+ // Prevent the input's blur from firing first and double-submitting.
+ e.preventDefault();
+ }}
+ onClick={onSubmit}
+ >
+ <CornerDownLeft size={12} color={Color.BG_VANILLA_400} />
+ </Button>
}
- }}
- />
+ value={value}
+ testId="dashboards-list-search"
+ onChange={(e: ChangeEvent<HTMLInputElement>): void => {
+ onChange(e.target.value);
+ setHighlighted(-1);
+ }}
+ onFocus={(): void => setFocused(true)}
+ onBlur={(): void => {
+ setFocused(false);
+ setHighlighted(-1);
+ onSubmit();
+ }}
+ onKeyDown={handleKeyDown}
+ />
+ {showSuggestions && (
+ <div
+ className={styles.suggestions}
+ data-testid="dashboards-list-search-suggestions"
+ >
+ {suggestions.map((key, index) => (
+ <button
+ key={key}
+ type="button"
+ className={cx(styles.suggestion, {
+ [styles.suggestionActive]: index === highlighted,
+ })}
+ data-testid={`dashboards-list-search-suggestion-${key}`}
+ onMouseEnter={(): void => setHighlighted(index)}
+ onMouseDown={(e: MouseEvent<HTMLButtonElement>): void => {
+ // Keep focus on the input so blur doesn't submit before we update.
+ e.preventDefault();
+ }}
+ onClick={(): void => pickSuggestion(key)}
+ >
+ {key}
+ </button>
+ ))}
+ </div>
+ )}
+ </div>
);
}
diff --git a/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/SaveViewPopover.tsx b/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/SaveViewPopover.tsx
index 6874a91cc7..426acbdeef 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/SaveViewPopover.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/SaveViewPopover.tsx
@@ -2,21 +2,17 @@ import { type ChangeEvent, type ReactNode, useEffect, useState } from 'react';
import { Button } from '@signozhq/ui/button';
import { Input } from '@signozhq/ui/input';
import { PopoverSimple } from '@signozhq/ui/popover';
-import cx from 'classnames';
-
-import { VIEW_ICON_OPTIONS } from '../../views';
+import { Typography } from '@signozhq/ui/typography';
import styles from './ViewsRail.module.scss';
interface Props {
open: boolean;
onOpenChange: (open: boolean) => void;
- onSave: (name: string, icon: string) => void;
+ onSave: (name: string) => void;
trigger: ReactNode;
}
-const DEFAULT_ICON = VIEW_ICON_OPTIONS[0].name;
-
function SaveViewPopover({
open,
onOpenChange,
@@ -24,12 +20,10 @@ function SaveViewPopover({
trigger,
}: Props): JSX.Element {
const [name, setName] = useState('');
- const [icon, setIcon] = useState(DEFAULT_ICON);
useEffect(() => {
if (open) {
setName('');
- setIcon(DEFAULT_ICON);
}
}, [open]);
@@ -37,7 +31,7 @@ function SaveViewPopover({
const handleSave = (): void => {
if (canSave) {
- onSave(name, icon);
+ onSave(name);
onOpenChange(false);
}
};
@@ -51,7 +45,7 @@ function SaveViewPopover({
>
<div className={styles.savePopover}>
<div className={styles.saveTitle}>Save as view</div>
- <span className={styles.saveLabel}>Name</span>
+ <Typography.Text className={styles.saveLabel}>Name</Typography.Text>
<Input
value={name}
autoFocus
@@ -66,22 +60,6 @@ function SaveViewPopover({
}
}}
/>
- <span className={styles.saveLabel}>Icon</span>
- <div className={styles.iconGrid}>
- {VIEW_ICON_OPTIONS.map(({ name: iconName, Icon }) => (
- <button
- key={iconName}
- type="button"
- aria-label={iconName}
- className={cx(styles.iconCell, {
- [styles.iconCellOn]: icon === iconName,
- })}
- onClick={(): void => setIcon(iconName)}
- >
- <Icon size={14} />
- </button>
- ))}
- </div>
<div className={styles.saveActions}>
<Button
variant="ghost"
diff --git a/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.module.scss b/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.module.scss
index d773f7c5a0..da793a85df 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.module.scss
+++ b/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.module.scss
@@ -28,6 +28,7 @@
font-weight: var(--font-weight-semibold);
letter-spacing: -0.01em;
color: var(--l1-foreground);
+ text-align: left;
}
.search {
@@ -76,7 +77,13 @@
padding: 1px 6px;
}
+.deleteName {
+ color: var(--danger-background);
+ font-weight: var(--font-weight-medium);
+}
+
.row {
+ position: relative;
display: flex;
align-items: center;
margin: 3px 0;
@@ -92,27 +99,27 @@
background: var(--l2-background);
}
+// A left accent bar reads the active row more clearly than background alone.
+.rowActive::before {
+ content: '';
+ position: absolute;
+ left: 0;
+ top: 50%;
+ transform: translateY(-50%);
+ width: 3px;
+ height: 18px;
+ border-radius: 0 3px 3px 0;
+ background: var(--primary-background);
+}
+
.item {
- // Neutralise the signoz Button defaults so it reads as a full-width,
- // left-aligned list row; the row coordinates hover/active colours below.
--button-display: flex;
--button-justify-content: flex-start;
- --button-height: auto;
--button-padding: 9px 10px;
- --button-gap: 10px;
- --button-variant-ghost-background-color: transparent;
- --button-variant-ghost-hover-background-color: transparent;
- --button-variant-ghost-color: var(--l2-foreground);
- --button-variant-ghost-hover-color: var(--l1-foreground);
flex: 1;
min-width: 0;
width: 100%;
- font-size: var(--font-size-sm);
-}
-
-.row:hover .item,
-.rowActive .item {
- --button-variant-ghost-color: var(--l1-foreground);
+ font-size: var(--font-size-base);
}
.itemIcon {
@@ -125,7 +132,6 @@
}
.itemLabel {
- flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -140,24 +146,31 @@
}
.itemAction {
- // Square icon button that surfaces on row hover and turns red on its own
- // hover; colours flow through the signoz Button tokens.
- --button-height: auto;
+ // Blended ghost icon overlaid on the row's right edge — absolutely positioned
+ // so it never reserves layout space or affects the row height. Transparent so
+ // the row's hover background shows through; turns red only on its own hover.
+ position: absolute;
+ right: 6px;
+ top: 50%;
+ transform: translateY(-50%);
+ --button-height: 20px;
--button-padding: 0;
--button-border-radius: 4px;
- --button-variant-ghost-background-color: transparent;
--button-variant-ghost-color: var(--l3-foreground);
--button-variant-ghost-hover-background-color: var(--danger-background);
--button-variant-ghost-hover-color: var(--danger-color, #fff);
width: 20px;
height: 20px;
- margin-right: 8px;
opacity: 0;
+ // Hidden until row hover, and inert while hidden so it can't intercept clicks
+ // meant for the row.
+ pointer-events: none;
transition: opacity 0.1s;
}
.row:hover .itemAction {
opacity: 1;
+ pointer-events: auto;
}
.empty {
@@ -217,37 +230,6 @@
margin-top: 2px;
}
-.iconGrid {
- display: grid;
- grid-template-columns: repeat(5, 1fr);
- gap: 6px;
-}
-
-.iconCell {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 34px;
- border: 1px solid var(--l2-border);
- border-radius: 6px;
- background: var(--l2-background);
- color: var(--l2-foreground);
- cursor: pointer;
- transition:
- border-color 0.12s,
- color 0.12s;
-}
-
-.iconCell:hover {
- color: var(--l1-foreground);
- border-color: var(--l3-foreground);
-}
-
-.iconCellOn {
- border-color: var(--primary-background);
- color: var(--primary-background);
-}
-
.saveActions {
display: flex;
justify-content: flex-end;
diff --git a/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.tsx b/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.tsx
index 8ceb1e9ab9..3e1a60641d 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/ViewsRail/ViewsRail.tsx
@@ -3,11 +3,11 @@ import { Modal } from 'antd';
import { Button } from '@signozhq/ui/button';
import { Input } from '@signozhq/ui/input';
import { Typography } from '@signozhq/ui/typography';
-import { CircleAlert, Plus, Search, Trash2 } from '@signozhq/icons';
+import { Bookmark, CircleAlert, Plus, Search, Trash2 } from '@signozhq/icons';
import cx from 'classnames';
import type { SavedView } from '../../types';
-import { type BuiltinView, iconByName } from '../../views';
+import { type BuiltinView } from '../../utils/views';
import SaveViewPopover from './SaveViewPopover';
import styles from './ViewsRail.module.scss';
@@ -16,11 +16,12 @@ interface Props {
activeViewId: string;
builtinViews: BuiltinView[];
customViews: SavedView[];
+ customViewsLoading: boolean;
isCustomActive: boolean;
isModified: boolean;
collapsed?: boolean;
onSelect: (id: string) => void;
- onSave: (name: string, icon: string) => void;
+ onSave: (name: string) => void;
onSaveChanges: () => void;
onReset: () => void;
onClearFilters: () => void;
@@ -40,6 +41,7 @@ function ViewsRail({
activeViewId,
builtinViews,
customViews,
+ customViewsLoading,
isCustomActive,
isModified,
collapsed = false,
@@ -73,11 +75,8 @@ function ViewsRail({
const { destroy } = modal.confirm({
title: (
<Typography.Title level={5}>
- Delete the
- <span style={{ color: 'var(--danger-background)', fontWeight: 500 }}>
- {' '}
- {label}{' '}
- </span>
+ Delete the{' '}
+ <Typography.Text className={styles.deleteName}>{label}</Typography.Text>{' '}
view?
</Typography.Title>
),
@@ -116,12 +115,10 @@ function ViewsRail({
onClick={(): void => onSelect(row.id)}
testId={`dashboards-view-${row.id}`}
>
- <span className={styles.itemIcon}>
- <Icon size={14} />
- </span>
- <span className={styles.itemLabel}>{row.label}</span>
+ <Icon size={16} className={styles.itemIcon} />
+ <Typography.Text className={styles.itemLabel}>{row.label}</Typography.Text>
{active && isModified && (
- <span className={styles.dirtyDot} title="Unsaved changes" />
+ <div className={styles.dirtyDot} title="Unsaved changes" />
)}
</Button>
{row.deletable && (
@@ -132,7 +129,10 @@ function ViewsRail({
className={styles.itemAction}
aria-label="Delete view"
title="Delete view"
- onClick={(): void => confirmDelete(row.id, row.label)}
+ onClick={(e): void => {
+ e.stopPropagation();
+ confirmDelete(row.id, row.label);
+ }}
>
<Trash2 size={12} />
</Button>
@@ -166,7 +166,7 @@ function ViewsRail({
<div className={styles.search}>
<Input
value={query}
- placeholder="Search views"
+ placeholder="Filter views by name"
prefix={<Search size={12} />}
testId="dashboards-view-search"
onChange={(e: ChangeEvent<HTMLInputElement>): void =>
@@ -196,9 +196,13 @@ function ViewsRail({
<>
<div className={cx(styles.groupLabel, styles.groupLabelSpaced)}>
My views
- <span className={styles.groupCount}>{customViews.length}</span>
+ <Typography.Text className={styles.groupCount}>
+ {customViews.length}
+ </Typography.Text>
</div>
- {customViews.length === 0 ? (
+ {customViewsLoading ? (
+ <div className={styles.empty}>Loading views…</div>
+ ) : customViews.length === 0 ? (
<div className={styles.empty}>
No saved views yet. Filter the list, then save it as a view.
</div>
@@ -207,7 +211,7 @@ function ViewsRail({
renderItem({
id: v.id,
label: v.name,
- icon: iconByName(v.icon),
+ icon: Bookmark,
deletable: true,
}),
)
diff --git a/frontend/src/pages/DashboardsListPageV2/components/states/ErrorState/ErrorState.tsx b/frontend/src/pages/DashboardsListPageV2/components/states/ErrorState/ErrorState.tsx
index 75547a23d8..7f2075dd84 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/states/ErrorState/ErrorState.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/states/ErrorState/ErrorState.tsx
@@ -5,7 +5,7 @@ import { handleContactSupport } from 'container/Integrations/utils';
import awwSnapUrl from '@/assets/Icons/awwSnap.svg';
-import { formatQueryErrorMessage } from '../../../utils';
+import { formatQueryErrorMessage } from '../../../utils/helpers';
import styles from './ErrorState.module.scss';
interface Props {
diff --git a/frontend/src/pages/DashboardsListPageV2/hooks/useAccumulatedTags.ts b/frontend/src/pages/DashboardsListPageV2/hooks/useAccumulatedTags.ts
new file mode 100644
index 0000000000..53ac82c4d0
--- /dev/null
+++ b/frontend/src/pages/DashboardsListPageV2/hooks/useAccumulatedTags.ts
@@ -0,0 +1,32 @@
+import { useEffect, useState } from 'react';
+
+import type { SelectedTag } from '../types';
+
+const tagId = (tag: SelectedTag): string => `${tag.key}:${tag.value}`;
+
+// The list response only reports the tags present in the current (filtered) page,
+// so tags vanish from the filter options as results narrow. Accumulate every tag
+// we've ever seen so previously-surfaced tags stay selectable across refetches.
+export function useAccumulatedTags(responseTags: SelectedTag[]): SelectedTag[] {
+ const [tags, setTags] = useState<SelectedTag[]>([]);
+
+ useEffect(() => {
+ if (responseTags.length === 0) {
+ return;
+ }
+ setTags((prev) => {
+ const merged = new Map(prev.map((t) => [tagId(t), t]));
+ let changed = false;
+ responseTags.forEach((t) => {
+ const id = tagId(t);
+ if (!merged.has(id)) {
+ merged.set(id, t);
+ changed = true;
+ }
+ });
+ return changed ? Array.from(merged.values()) : prev;
+ });
+ }, [responseTags]);
+
+ return tags;
+}
diff --git a/frontend/src/pages/DashboardsListPageV2/hooks/useActiveView.ts b/frontend/src/pages/DashboardsListPageV2/hooks/useActiveView.ts
index 17fd7d4759..8c8bf45f14 100644
--- a/frontend/src/pages/DashboardsListPageV2/hooks/useActiveView.ts
+++ b/frontend/src/pages/DashboardsListPageV2/hooks/useActiveView.ts
@@ -1,8 +1,17 @@
import { useCallback, useMemo } from 'react';
import { parseAsString, useQueryState, type Options } from 'nuqs';
+import type {
+ DashboardtypesListOrderDTO,
+ DashboardtypesListSortDTO,
+} from 'api/generated/services/sigNoz.schemas';
-import { DEFAULT_FILTER_STATE, areFilterStatesEqual } from '../filterQuery';
-import { useDashboardViewsStore } from '../store/useDashboardViewsStore';
+import {
+ areFilterStatesEqual,
+ combineQueries,
+ DEFAULT_FILTER_STATE,
+ filterStateToQuery,
+} from '../utils/filterQuery';
+import { BuiltinViewId } from '../types';
import type { DashboardFilterState, SavedView } from '../types';
import {
BUILTIN_VIEWS,
@@ -10,7 +19,8 @@ import {
builtinViewSnapshot,
type BuiltinView,
isClientView,
-} from '../views';
+} from '../utils/views';
+import { useSavedViews } from './useSavedViews';
const opts: Options = { history: 'push' };
@@ -18,43 +28,62 @@ interface UseActiveViewArgs {
filters: DashboardFilterState;
applyFilters: (next: DashboardFilterState) => void;
userEmail: string;
+ sortColumn: DashboardtypesListSortDTO;
+ sortOrder: DashboardtypesListOrderDTO;
+ setSortColumn: (column: DashboardtypesListSortDTO) => void;
+ setSortOrder: (order: DashboardtypesListOrderDTO) => void;
}
export interface UseActiveViewResult {
activeViewId: string;
builtinViews: BuiltinView[];
customViews: SavedView[];
+ customViewsLoading: boolean;
isCustomActive: boolean;
// Current filters diverge from the active view's canonical snapshot.
isModified: boolean;
// Extra server-query fragment the active view contributes, and whether it
- // constrains the list client-side (favorites/recent).
+ // constrains the list client-side (pinned/recent).
viewQuery: string;
clientView: boolean;
selectView: (id: string) => void;
- saveView: (name: string, icon: string) => void;
+ saveView: (name: string) => void;
saveActiveView: () => void;
resetView: () => void;
removeView: (id: string) => void;
}
+// The canonical filter snapshot a saved view "is": the backend stores a flat
+// query, so a view folds entirely into the search box with empty chips.
+const customSnapshot = (view: SavedView): DashboardFilterState => ({
+ ...DEFAULT_FILTER_STATE,
+ search: view.query,
+});
+
// Orchestrates the active view: which view is selected (URL `view` param),
-// merging built-in + persisted custom views, applying a view's snapshot on
-// select, dirty detection, and save/reset/delete.
+// merging built-in + org-shared saved views, applying a view's snapshot on
+// select, dirty detection, and save/reset/delete via the Views API.
export function useActiveView({
filters,
applyFilters,
userEmail,
+ sortColumn,
+ sortOrder,
+ setSortColumn,
+ setSortOrder,
}: UseActiveViewArgs): UseActiveViewResult {
const [activeViewId, setActiveViewId] = useQueryState(
'view',
- parseAsString.withDefault('all').withOptions(opts),
+ parseAsString.withDefault(BuiltinViewId.All).withOptions(opts),
);
- const customViews = useDashboardViewsStore((s) => s.customViews);
- const addView = useDashboardViewsStore((s) => s.addView);
- const updateView = useDashboardViewsStore((s) => s.updateView);
- const deleteView = useDashboardViewsStore((s) => s.deleteView);
+ const {
+ views: customViews,
+ isLoading: customViewsLoading,
+ createView,
+ updateView,
+ deleteView,
+ } = useSavedViews();
const activeCustom = useMemo(
() => customViews.find((v) => v.id === activeViewId),
@@ -65,7 +94,7 @@ export function useActiveView({
const canonicalSnapshot = useMemo<DashboardFilterState | null>(
() =>
activeCustom
- ? activeCustom.filters
+ ? customSnapshot(activeCustom)
: builtinViewSnapshot(activeViewId, userEmail),
[activeCustom, activeViewId, userEmail],
);
@@ -78,47 +107,93 @@ export function useActiveView({
(id: string): void => {
void setActiveViewId(id);
const custom = customViews.find((v) => v.id === id);
- applyFilters(
- custom?.filters ??
- builtinViewSnapshot(id, userEmail) ??
- DEFAULT_FILTER_STATE,
- );
+ if (custom) {
+ applyFilters(customSnapshot(custom));
+ setSortColumn(custom.sort);
+ setSortOrder(custom.order);
+ return;
+ }
+ applyFilters(builtinViewSnapshot(id, userEmail) ?? DEFAULT_FILTER_STATE);
},
- [setActiveViewId, customViews, applyFilters, userEmail],
+ [
+ setActiveViewId,
+ customViews,
+ applyFilters,
+ userEmail,
+ setSortColumn,
+ setSortOrder,
+ ],
);
const saveView = useCallback(
- (name: string, icon: string): void => {
- const id = `cv_${Date.now()}`;
- addView({
- id,
- name: name.trim(),
- icon,
- filters: { ...filters },
- createdAt: Date.now(),
- });
- void setActiveViewId(id);
+ (name: string): void => {
+ // Fold the current built-in clause + chips into a single query string.
+ const query = combineQueries(
+ builtinViewQuery(activeViewId),
+ filterStateToQuery(filters),
+ );
+ void (async (): Promise<void> => {
+ const created = await createView({
+ name,
+ query,
+ sort: sortColumn,
+ order: sortOrder,
+ });
+ if (created) {
+ void setActiveViewId(created.id);
+ // Re-apply the folded representation so the new view isn't
+ // immediately flagged as modified.
+ applyFilters(customSnapshot(created));
+ }
+ })();
},
- [addView, filters, setActiveViewId],
+ [
+ activeViewId,
+ filters,
+ createView,
+ sortColumn,
+ sortOrder,
+ setActiveViewId,
+ applyFilters,
+ ],
);
const saveActiveView = useCallback((): void => {
- if (activeCustom) {
- updateView(activeCustom.id, { filters: { ...filters } });
+ if (!activeCustom) {
+ return;
}
- }, [activeCustom, updateView, filters]);
+ const query = filterStateToQuery(filters);
+ updateView(activeCustom.id, {
+ name: activeCustom.name,
+ query,
+ sort: sortColumn,
+ order: sortOrder,
+ });
+ applyFilters({ ...DEFAULT_FILTER_STATE, search: query });
+ }, [activeCustom, filters, updateView, sortColumn, sortOrder, applyFilters]);
const resetView = useCallback((): void => {
- if (canonicalSnapshot) {
- applyFilters(canonicalSnapshot);
+ if (!canonicalSnapshot) {
+ return;
+ }
+ applyFilters(canonicalSnapshot);
+ if (activeCustom) {
+ setSortColumn(activeCustom.sort);
+ setSortOrder(activeCustom.order);
}
- }, [canonicalSnapshot, applyFilters]);
+ }, [
+ canonicalSnapshot,
+ applyFilters,
+ activeCustom,
+ setSortColumn,
+ setSortOrder,
+ ]);
const removeView = useCallback(
(id: string): void => {
deleteView(id);
if (activeViewId === id) {
- void setActiveViewId('all');
+ void setActiveViewId(BuiltinViewId.All);
applyFilters(DEFAULT_FILTER_STATE);
}
},
@@ -129,6 +204,7 @@ export function useActiveView({
activeViewId,
builtinViews: BUILTIN_VIEWS,
customViews,
+ customViewsLoading,
isCustomActive: !!activeCustom,
isModified,
viewQuery: builtinViewQuery(activeViewId),
diff --git a/frontend/src/pages/DashboardsListPageV2/hooks/useDashboardFilters.ts b/frontend/src/pages/DashboardsListPageV2/hooks/useDashboardFilters.ts
index 0675ba33f8..7f8ff777d0 100644
--- a/frontend/src/pages/DashboardsListPageV2/hooks/useDashboardFilters.ts
+++ b/frontend/src/pages/DashboardsListPageV2/hooks/useDashboardFilters.ts
@@ -11,13 +11,28 @@ import {
DEFAULT_FILTER_STATE,
filterStateToQuery,
isFilterStateEmpty,
-} from '../filterQuery';
-import type { DashboardFilterState, UpdatedWindow } from '../types';
+} from '../utils/filterQuery';
+import type {
+ DashboardFilterState,
+ SelectedTag,
+ UpdatedWindow,
+} from '../types';
const UPDATED_WINDOWS: UpdatedWindow[] = ['any', 'today', '7d', '30d'];
const opts: Options = { history: 'push' };
+// Tags are carried in the URL as `key:value` strings; split on the first colon.
+const parseTag = (raw: string): SelectedTag | null => {
+ const idx = raw.indexOf(':');
+ if (idx <= 0) {
+ return null;
+ }
+ return { key: raw.slice(0, idx), value: raw.slice(idx + 1) };
+};
+
+const serializeTag = (tag: SelectedTag): string => `${tag.key}:${tag.value}`;
+
export interface UseDashboardFiltersResult {
filters: DashboardFilterState;
// The backend list-filter `query` string derived from the current filters.
@@ -26,6 +41,7 @@ export interface UseDashboardFiltersResult {
setSearch: (value: string) => void;
setCreatedBy: (emails: string[]) => void;
setUpdated: (window: UpdatedWindow) => void;
+ setTags: (tags: SelectedTag[]) => void;
// Replace the whole filter state at once — used when applying a saved view.
applyFilters: (next: DashboardFilterState) => void;
clearAll: () => void;
@@ -47,10 +63,19 @@ export function useDashboardFilters(): UseDashboardFiltersResult {
'updated',
parseAsStringLiteral(UPDATED_WINDOWS).withDefault('any').withOptions(opts),
);
+ const [tagStrings, setTagStringsState] = useQueryState(
+ 'tags',
+ parseAsArrayOf(parseAsString).withDefault([]).withOptions(opts),
+ );
+
+ const tags = useMemo<SelectedTag[]>(
+ () => tagStrings.map(parseTag).filter((t): t is SelectedTag => t !== null),
+ [tagStrings],
+ );
const filters = useMemo<DashboardFilterState>(
- () => ({ search, createdBy, updated }),
- [search, createdBy, updated],
+ () => ({ search, createdBy, updated, tags }),
+ [search, createdBy, updated, tags],
);
const query = useMemo(() => filterStateToQuery(filters), [filters]);
@@ -76,13 +101,23 @@ export function useDashboardFilters(): UseDashboardFiltersResult {
[setUpdatedState],
);
+ const setTags = useCallback(
+ (next: SelectedTag[]): void => {
+ void setTagStringsState(next.length ? next.map(serializeTag) : null);
+ },
+ [setTagStringsState],
+ );
+
const applyFilters = useCallback(
(next: DashboardFilterState): void => {
void setSearchState(next.search || null);
void setCreatedByState(next.createdBy.length ? next.createdBy : null);
void setUpdatedState(next.updated);
+ void setTagStringsState(
+ next.tags.length ? next.tags.map(serializeTag) : null,
+ );
},
- [setSearchState, setCreatedByState, setUpdatedState],
+ [setSearchState, setCreatedByState, setUpdatedState, setTagStringsState],
);
const clearAll = useCallback((): void => {
@@ -96,6 +131,7 @@ export function useDashboardFilters(): UseDashboardFiltersResult {
setSearch,
setCreatedBy,
setUpdated,
+ setTags,
applyFilters,
clearAll,
};
diff --git a/frontend/src/pages/DashboardsListPageV2/hooks/usePinDashboard.ts b/frontend/src/pages/DashboardsListPageV2/hooks/usePinDashboard.ts
new file mode 100644
index 0000000000..0d565866db
--- /dev/null
+++ b/frontend/src/pages/DashboardsListPageV2/hooks/usePinDashboard.ts
@@ -0,0 +1,63 @@
+import { useCallback } from 'react';
+import { useQueryClient } from 'react-query';
+import { toast } from '@signozhq/ui/sonner';
+import {
+ invalidateListDashboardsForUserV2,
+ usePinDashboardV2,
+ useUnpinDashboardV2,
+} from 'api/generated/services/dashboard';
+import { getHttpStatusCode } from 'utils/errorUtils';
+
+const PIN_LIMIT_MESSAGE =
+ 'You can pin up to 10 dashboards. Unpin one to add another.';
+
+export interface UsePinDashboardResult {
+ // Toggle the pin for a dashboard given its current pinned state.
+ togglePin: (id: string, pinned: boolean) => void;
+ isUpdating: boolean;
+}
+
+// Wraps the per-user pin/unpin mutations: refreshes the personalized list on
+// success and surfaces the 10-pin limit (HTTP 409) as a toast.
+export function usePinDashboard(): UsePinDashboardResult {
+ const queryClient = useQueryClient();
+
+ const invalidate = useCallback((): void => {
+ void invalidateListDashboardsForUserV2(queryClient);
+ }, [queryClient]);
+
+ const pin = usePinDashboardV2({
+ mutation: {
+ onSuccess: invalidate,
+ onError: (error): void => {
+ toast.error(
+ getHttpStatusCode(error) === 409
+ ? PIN_LIMIT_MESSAGE
+ : 'Failed to pin dashboard.',
+ );
+ },
+ },
+ });
+
+ const unpin = useUnpinDashboardV2({
+ mutation: {
+ onSuccess: invalidate,
+ onError: (): void => {
+ toast.error('Failed to unpin dashboard.');
+ },
+ },
+ });
+
+ const togglePin = useCallback(
+ (id: string, pinned: boolean): void => {
+ if (pinned) {
+ unpin.mutate({ pathParams: { id } });
+ } else {
+ pin.mutate({ pathParams: { id } });
+ }
+ },
+ [pin, unpin],
+ );
+
+ return { togglePin, isUpdating: pin.isLoading || unpin.isLoading };
+}
diff --git a/frontend/src/pages/DashboardsListPageV2/hooks/useSavedViews.ts b/frontend/src/pages/DashboardsListPageV2/hooks/useSavedViews.ts
new file mode 100644
index 0000000000..5362468c40
--- /dev/null
+++ b/frontend/src/pages/DashboardsListPageV2/hooks/useSavedViews.ts
@@ -0,0 +1,117 @@
+import { useCallback, useMemo } from 'react';
+import { useQueryClient } from 'react-query';
+import { toast } from '@signozhq/ui/sonner';
+import {
+ invalidateListDashboardViews,
+ useCreateDashboardView,
+ useDeleteDashboardView,
+ useListDashboardViews,
+ useUpdateDashboardView,
+} from 'api/generated/services/dashboard';
+import {
+ type DashboardtypesDashboardViewDTO,
+ DashboardtypesListOrderDTO,
+ DashboardtypesListSortDTO,
+} from 'api/generated/services/sigNoz.schemas';
+
+import type { SavedView, SavedViewInput } from '../types';
+
+// Schema version stamped on the view's data envelope (the backend requires it).
+const VIEW_DATA_VERSION = 'v1';
+
+const toSavedView = (dto: DashboardtypesDashboardViewDTO): SavedView => ({
+ id: dto.id,
+ name: dto.name,
+ query: dto.data.query ?? '',
+ sort: dto.data.sort ?? DashboardtypesListSortDTO.updated_at,
+ order: dto.data.order ?? DashboardtypesListOrderDTO.desc,
+});
+
+const toPostable = (
+ input: SavedViewInput,
+): { name: string; data: DashboardtypesDashboardViewDTO['data'] } => ({
+ name: input.name.trim(),
+ data: {
+ version: VIEW_DATA_VERSION,
+ query: input.query,
+ sort: input.sort,
+ order: input.order,
+ },
+});
+
+export interface UseSavedViewsResult {
+ views: SavedView[];
+ isLoading: boolean;
+ createView: (input: SavedViewInput) => Promise<SavedView | null>;
+ updateView: (id: string, input: SavedViewInput) => void;
+ deleteView: (id: string) => void;
+}
+
+// Org-shared saved views, backed by the Views API. Exposes the list plus
+// create/update/delete that invalidate the list on success.
+export function useSavedViews(): UseSavedViewsResult {
+ const queryClient = useQueryClient();
+ const { data, isLoading } = useListDashboardViews();
+
+ const views = useMemo<SavedView[]>(
+ () => (data?.data?.views ?? []).map(toSavedView),
+ [data],
+ );
+
+ const invalidate = useCallback((): void => {
+ void invalidateListDashboardViews(queryClient);
+ }, [queryClient]);
+
+ const createMutation = useCreateDashboardView({
+ mutation: {
+ onSuccess: invalidate,
+ onError: (): void => {
+ toast.error('Failed to save view.');
+ },
+ },
+ });
+ const updateMutation = useUpdateDashboardView({
+ mutation: {
+ onSuccess: invalidate,
+ onError: (): void => {
+ toast.error('Failed to update view.');
+ },
+ },
+ });
+ const deleteMutation = useDeleteDashboardView({
+ mutation: {
+ onSuccess: invalidate,
+ onError: (): void => {
+ toast.error('Failed to delete view.');
+ },
+ },
+ });
+
+ const createView = useCallback(
+ async (input: SavedViewInput): Promise<SavedView | null> => {
+ try {
+ const res = await createMutation.mutateAsync({ data: toPostable(input) });
+ return res?.data ? toSavedView(res.data) : null;
+ } catch {
+ return null;
+ }
+ },
+ [createMutation],
+ );
+
+ const updateView = useCallback(
+ (id: string, input: SavedViewInput): void => {
+ updateMutation.mutate({ pathParams: { id }, data: toPostable(input) });
+ },
+ [updateMutation],
+ );
+
+ const deleteView = useCallback(
+ (id: string): void => {
+ deleteMutation.mutate({ pathParams: { id } });
+ },
+ [deleteMutation],
+ );
+
+ return { views, isLoading, createView, updateView, deleteView };
+}
diff --git a/frontend/src/pages/DashboardsListPageV2/store/useDashboardViewsStore.ts b/frontend/src/pages/DashboardsListPageV2/store/useDashboardViewsStore.ts
index 750981650b..096c0f5693 100644
--- a/frontend/src/pages/DashboardsListPageV2/store/useDashboardViewsStore.ts
+++ b/frontend/src/pages/DashboardsListPageV2/store/useDashboardViewsStore.ts
@@ -2,30 +2,21 @@ import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { LOCALSTORAGE } from 'constants/localStorage';
-import type { SavedView } from '../types';
-
// Most-recently-viewed list is capped so it stays a useful shortlist.
const RECENT_LIMIT = 20;
-// Client-side persistence for everything the views feature owns until the views
-// API lands: user-saved views, favorite/recently-viewed dashboard ids, and the
-// rail collapse preference. Mirrors `useDashboardsListVisibleColumnsStore`.
+// Client-side persistence for the parts of the views feature that aren't backed
+// by an API: recently-viewed dashboard ids and the rail collapse preference.
+// (Saved views are org-shared via the Views API — see `useSavedViews`; pinning
+// is server-side per-user — see `usePinDashboard`.)
interface DashboardViewsState {
- customViews: SavedView[];
- favorites: string[]; // dashboard ids
recent: string[]; // dashboard ids, most-recent first
railCollapsed: boolean;
- addView: (view: SavedView) => void;
- updateView: (id: string, patch: Partial<Omit<SavedView, 'id'>>) => void;
- deleteView: (id: string) => void;
- toggleFavorite: (id: string) => void;
markViewed: (id: string) => void;
setRailCollapsed: (collapsed: boolean) => void;
}
const DEFAULT_STATE = {
- customViews: [] as SavedView[],
- favorites: [] as string[],
recent: [] as string[],
railCollapsed: false,
};
@@ -34,26 +25,6 @@ export const useDashboardViewsStore = create<DashboardViewsState>()(
persist(
(set) => ({
...DEFAULT_STATE,
- addView: (view): void => {
- set((s) => ({ customViews: [...s.customViews, view] }));
- },
- updateView: (id, patch): void => {
- set((s) => ({
- customViews: s.customViews.map((v) =>
- v.id === id ? { ...v, ...patch } : v,
- ),
- }));
- },
- deleteView: (id): void => {
- set((s) => ({ customViews: s.customViews.filter((v) => v.id !== id) }));
- },
- toggleFavorite: (id): void => {
- set((s) => ({
- favorites: s.favorites.includes(id)
- ? s.favorites.filter((f) => f !== id)
- : [...s.favorites, id],
- }));
- },
markViewed: (id): void => {
set((s) => ({
recent: [id, ...s.recent.filter((r) => r !== id)].slice(0, RECENT_LIMIT),
diff --git a/frontend/src/pages/DashboardsListPageV2/types.ts b/frontend/src/pages/DashboardsListPageV2/types.ts
index b5d1670838..de61964ba4 100644
--- a/frontend/src/pages/DashboardsListPageV2/types.ts
+++ b/frontend/src/pages/DashboardsListPageV2/types.ts
@@ -1,27 +1,52 @@
+import type {
+ DashboardtypesListOrderDTO,
+ DashboardtypesListSortDTO,
+} from 'api/generated/services/sigNoz.schemas';
+
// Relative "updated within" windows offered by the Updated filter chip.
export type UpdatedWindow = 'any' | 'today' | '7d' | '30d';
-// The user-controllable filter state a view captures. (Tags are intentionally
-// excluded for now — the tag filter UI is deferred.) Sort/order are handled
-// separately via URL query params and are not part of a view snapshot.
+// A tag selected in the Tags filter chip — a concrete key:value pair drawn from
+// the tags the list API reports across the org's dashboards.
+export interface SelectedTag {
+ key: string;
+ value: string;
+}
+
+// The user-controllable filter state a view captures. `search` is a raw filter
+// DSL fragment the user types; the structured chips (created-by, updated, tags)
+// are AND-ed onto it. Sort/order are handled separately via URL query params and
+// are not part of a view snapshot.
export interface DashboardFilterState {
search: string;
createdBy: string[]; // emails (created_by)
updated: UpdatedWindow;
+ tags: SelectedTag[];
}
-// A saved view: a named, iconed snapshot of filter state. Persisted client-side
-// (localStorage) until the views API lands.
+// A saved view: a named filter the org shares, persisted via the backend Views
+// API. The backend stores a flat `{ query, sort, order }` (no structured chips),
+// so a view captures the fully-combined DSL query plus the sort/order to apply.
export interface SavedView {
id: string;
name: string;
- icon: string; // @signozhq/icons icon name
- filters: DashboardFilterState;
- createdAt: number;
+ query: string;
+ sort: DashboardtypesListSortDTO;
+ order: DashboardtypesListOrderDTO;
}
+// The payload for creating or updating a saved view (everything but the id).
+export type SavedViewInput = Omit<SavedView, 'id'>;
+
// Built-in views rendered above the user's saved views. Their result set is
// derived (a fixed query fragment or a client-side id set), never persisted.
-export type BuiltinViewId = 'mine' | 'favorites' | 'recent' | 'all' | 'locked';
+// String values double as the URL `view` param, so they must stay stable.
+export enum BuiltinViewId {
+ Mine = 'mine',
+ Pinned = 'pinned',
+ Recent = 'recent',
+ All = 'all',
+ Locked = 'locked',
+}
export type ViewSection = 'personal' | 'system' | 'custom';
diff --git a/frontend/src/pages/DashboardsListPageV2/utils/dslSuggestions.test.ts b/frontend/src/pages/DashboardsListPageV2/utils/dslSuggestions.test.ts
new file mode 100644
index 0000000000..974bac287a
--- /dev/null
+++ b/frontend/src/pages/DashboardsListPageV2/utils/dslSuggestions.test.ts
@@ -0,0 +1,57 @@
+import {
+ applyKeySuggestion,
+ buildSuggestionKeys,
+ getActiveKeyToken,
+ matchKeys,
+ RESERVED_DSL_KEYS,
+} from './dslSuggestions';
+
+describe('getActiveKeyToken', () => {
+ it('returns the partial key at the start', () => {
+ expect(getActiveKeyToken('nam')).toStrictEqual({ token: 'nam', start: 0 });
+ });
+
+ it('returns the partial key after AND', () => {
+ const value = 'name = "x" AND en';
+ expect(getActiveKeyToken(value)).toStrictEqual({ token: 'en', start: 15 });
+ });
+
+ it('is null once an operator (space) has been typed', () => {
+ expect(getActiveKeyToken('name contains')).toBeNull();
+ });
+
+ it('is null for an empty trailing segment', () => {
+ expect(getActiveKeyToken('name = "x" AND ')).toBeNull();
+ });
+});
+
+describe('buildSuggestionKeys', () => {
+ it('lists reserved keys plus distinct tag keys', () => {
+ const keys = buildSuggestionKeys([
+ { key: 'env', value: 'prod' },
+ { key: 'env', value: 'dev' },
+ { key: 'team', value: 'core' },
+ ]);
+ expect(keys).toStrictEqual([...RESERVED_DSL_KEYS, 'env', 'team']);
+ });
+});
+
+describe('matchKeys', () => {
+ it('matches case-insensitively and excludes exact matches', () => {
+ expect(matchKeys(['name', 'created_by', 'env'], 'NAM')).toStrictEqual([
+ 'name',
+ ]);
+ expect(matchKeys(['name'], 'name')).toStrictEqual([]);
+ });
+});
+
+describe('applyKeySuggestion', () => {
+ it('replaces the partial key with the chosen key and a trailing space', () => {
+ const value = 'name = "x" AND en';
+ const active = getActiveKeyToken(value);
+ if (!active) {
+ throw new Error('expected an active key token');
+ }
+ expect(applyKeySuggestion(value, active, 'env')).toBe('name = "x" AND env ');
+ });
+});
diff --git a/frontend/src/pages/DashboardsListPageV2/utils/dslSuggestions.ts b/frontend/src/pages/DashboardsListPageV2/utils/dslSuggestions.ts
new file mode 100644
index 0000000000..1383b8fa5e
--- /dev/null
+++ b/frontend/src/pages/DashboardsListPageV2/utils/dslSuggestions.ts
@@ -0,0 +1,68 @@
+// Key-name suggestions for the dashboards-list DSL search box. The reserved keys
+// mirror the backend filter DSL (pkg/.../listfilter_visitor.go); any other key is
+// treated as a tag key, so we also surface the tag keys the list API reports.
+import type { SelectedTag } from '../types';
+
+// Reserved DSL keys the backend recognises as dashboard columns.
+export const RESERVED_DSL_KEYS: string[] = [
+ 'name',
+ 'description',
+ 'created_at',
+ 'updated_at',
+ 'created_by',
+ 'locked',
+ 'source',
+];
+
+export interface ActiveKeyToken {
+ token: string;
+ // Index in the value string where the partial key begins.
+ start: number;
+}
+
+// The partial key the user is currently typing: the trailing segment after the
+// last top-level AND/OR (or the start), provided it hasn't yet reached an
+// operator (no whitespace). Returns null once the key is complete.
+export const getActiveKeyToken = (value: string): ActiveKeyToken | null => {
+ const boundaryRe = /\b(?:AND|OR)\b/gi;
+ let lastEnd = 0;
+ let match = boundaryRe.exec(value);
+ while (match !== null) {
+ lastEnd = match.index + match[0].length;
+ match = boundaryRe.exec(value);
+ }
+ const segment = value.slice(lastEnd);
+ const leading = segment.length - segment.trimStart().length;
+ const partial = segment.slice(leading);
+ if (partial.length === 0 || /[\s(]/.test(partial)) {
+ return null;
+ }
+ return { token: partial, start: lastEnd + leading };
+};
+
+// Build the de-duplicated, ordered list of keys to offer: reserved columns plus
+// distinct tag keys from the list response.
+export const buildSuggestionKeys = (availableTags: SelectedTag[]): string[] => {
+ const tagKeys = availableTags.map((t) => t.key);
+ return Array.from(new Set([...RESERVED_DSL_KEYS, ...tagKeys]));
+};
+
+// Keys matching the partial token (case-insensitive), excluding an exact match.
+export const matchKeys = (
+ keys: string[],
+ token: string,
+ limit = 8,
+): string[] => {
+ const lower = token.toLowerCase();
+ return keys
+ .filter((k) => k.toLowerCase().includes(lower) && k.toLowerCase() !== lower)
+ .slice(0, limit);
+};
+
+// Replace the active partial key in `value` with the chosen key + a space, ready
+// for the user to type an operator.
+export const applyKeySuggestion = (
+ value: string,
+ active: ActiveKeyToken,
+ key: string,
+): string => `${value.slice(0, active.start)}${key} `;
diff --git a/frontend/src/pages/DashboardsListPageV2/utils/filterQuery.test.ts b/frontend/src/pages/DashboardsListPageV2/utils/filterQuery.test.ts
new file mode 100644
index 0000000000..fc60ee6629
--- /dev/null
+++ b/frontend/src/pages/DashboardsListPageV2/utils/filterQuery.test.ts
@@ -0,0 +1,109 @@
+import {
+ areFilterStatesEqual,
+ combineQueries,
+ DEFAULT_FILTER_STATE,
+ filterStateToQuery,
+ isFilterStateEmpty,
+} from './filterQuery';
+import type { DashboardFilterState } from '../types';
+
+const state = (patch: Partial<DashboardFilterState>): DashboardFilterState => ({
+ ...DEFAULT_FILTER_STATE,
+ ...patch,
+});
+
+describe('filterStateToQuery', () => {
+ it('passes the raw search through, wrapped in parentheses', () => {
+ expect(filterStateToQuery(state({ search: 'name contains "prod"' }))).toBe(
+ '(name contains "prod")',
+ );
+ });
+
+ it('emits an equality clause for a single creator', () => {
+ expect(filterStateToQuery(state({ createdBy: ['[email protected]'] }))).toBe(
+ "created_by = '[email protected]'",
+ );
+ });
+
+ it('emits an IN clause for multiple creators', () => {
+ expect(filterStateToQuery(state({ createdBy: ['[email protected]', '[email protected]'] }))).toBe(
+ "created_by IN ['[email protected]', '[email protected]']",
+ );
+ });
+
+ it('emits an exact equality clause per selected tag', () => {
+ expect(
+ filterStateToQuery(
+ state({
+ tags: [
+ { key: 'env', value: 'prod' },
+ { key: 'team', value: 'core' },
+ ],
+ }),
+ ),
+ ).toBe("env = 'prod' AND team = 'core'");
+ });
+
+ it('ANDs raw search with the structured chips', () => {
+ expect(
+ filterStateToQuery(
+ state({
+ search: 'name contains "x"',
+ createdBy: ['[email protected]'],
+ tags: [{ key: 'env', value: 'prod' }],
+ }),
+ ),
+ ).toBe("(name contains \"x\") AND created_by = '[email protected]' AND env = 'prod'");
+ });
+
+ it('returns an empty string for the default state', () => {
+ expect(filterStateToQuery(DEFAULT_FILTER_STATE)).toBe('');
+ });
+});
+
+describe('isFilterStateEmpty', () => {
+ it('is true for the default state', () => {
+ expect(isFilterStateEmpty(DEFAULT_FILTER_STATE)).toBe(true);
+ });
+
+ it('is false when any tag is selected', () => {
+ expect(
+ isFilterStateEmpty(state({ tags: [{ key: 'env', value: 'prod' }] })),
+ ).toBe(false);
+ });
+});
+
+describe('areFilterStatesEqual', () => {
+ it('ignores tag ordering', () => {
+ const a = state({
+ tags: [
+ { key: 'env', value: 'prod' },
+ { key: 'team', value: 'core' },
+ ],
+ });
+ const b = state({
+ tags: [
+ { key: 'team', value: 'core' },
+ { key: 'env', value: 'prod' },
+ ],
+ });
+ expect(areFilterStatesEqual(a, b)).toBe(true);
+ });
+
+ it('distinguishes differing tag selections', () => {
+ expect(
+ areFilterStatesEqual(
+ state({ tags: [{ key: 'env', value: 'prod' }] }),
+ state({ tags: [{ key: 'env', value: 'dev' }] }),
+ ),
+ ).toBe(false);
+ });
+});
+
+describe('combineQueries', () => {
+ it('drops empty fragments and ANDs the rest', () => {
+ expect(combineQueries('locked = true', '', undefined, 'name = "x"')).toBe(
+ 'locked = true AND name = "x"',
+ );
+ });
+});
diff --git a/frontend/src/pages/DashboardsListPageV2/filterQuery.ts b/frontend/src/pages/DashboardsListPageV2/utils/filterQuery.ts
similarity index 67%
rename from frontend/src/pages/DashboardsListPageV2/filterQuery.ts
rename to frontend/src/pages/DashboardsListPageV2/utils/filterQuery.ts
index 661a7a3214..d65471839c 100644
Binary files a/frontend/src/pages/DashboardsListPageV2/filterQuery.ts and b/frontend/src/pages/DashboardsListPageV2/utils/filterQuery.ts differ
diff --git a/frontend/src/pages/DashboardsListPageV2/utils.ts b/frontend/src/pages/DashboardsListPageV2/utils/helpers.ts
similarity index 68%
rename from frontend/src/pages/DashboardsListPageV2/utils.ts
rename to frontend/src/pages/DashboardsListPageV2/utils/helpers.ts
index eb3350353d..47b06bfc76 100644
--- a/frontend/src/pages/DashboardsListPageV2/utils.ts
+++ b/frontend/src/pages/DashboardsListPageV2/utils/helpers.ts
@@ -1,11 +1,12 @@
import dayjs from 'dayjs';
import { isEmpty } from 'lodash-es';
import type {
- DashboardtypesListedDashboardV2DTO,
+ DashboardtypesListedDashboardForUserV2DTO,
TagtypesPostableTagDTO,
} from 'api/generated/services/sigNoz.schemas';
-export type DashboardListItem = DashboardtypesListedDashboardV2DTO;
+// The list is fetched via the per-user endpoint, so every row carries `pinned`.
+export type DashboardListItem = DashboardtypesListedDashboardForUserV2DTO;
export const tagsToStrings = (
tags: { key: string; value: string }[] | null | undefined,
@@ -14,23 +15,23 @@ export const tagsToStrings = (
tag.key === tag.value ? tag.key : `${tag.key}:${tag.value}`,
);
-// Inverse of `tagsToStrings`: each comma-separated tag is "key:value" or a bare
-// label (key === value).
-export const toPostableTags = (raw: string): TagtypesPostableTagDTO[] =>
- raw
- .split(',')
- .map((label) => label.trim())
- .filter(Boolean)
- .map((label) => {
- const sep = label.indexOf(':');
- if (sep > 0) {
- return {
- key: label.slice(0, sep).trim(),
- value: label.slice(sep + 1).trim(),
- };
+// Convert validated `key:value` tag strings (from TagKeyValueInput) into the
+// postable tag DTO shape. The first colon separates key from value.
+export const keyValueStringsToTags = (
+ tags: string[],
+): TagtypesPostableTagDTO[] =>
+ tags
+ .map((tag) => {
+ const idx = tag.indexOf(':');
+ if (idx <= 0) {
+ return null;
}
- return { key: label, value: label };
- });
+ return {
+ key: tag.slice(0, idx).trim(),
+ value: tag.slice(idx + 1).trim(),
+ };
+ })
+ .filter((t): t is TagtypesPostableTagDTO => !!t?.key && !!t.value);
export const lastUpdatedLabel = (time: string | undefined): string => {
if (!time || isEmpty(time)) {
diff --git a/frontend/src/pages/DashboardsListPageV2/views.ts b/frontend/src/pages/DashboardsListPageV2/utils/views.ts
similarity index 57%
rename from frontend/src/pages/DashboardsListPageV2/views.ts
rename to frontend/src/pages/DashboardsListPageV2/utils/views.ts
index f6e0a4efde..8d73a4e07d 100644
--- a/frontend/src/pages/DashboardsListPageV2/views.ts
+++ b/frontend/src/pages/DashboardsListPageV2/utils/views.ts
@@ -3,26 +3,15 @@
// - snapshot: selecting applies a filter snapshot (All, My dashboards, custom)
// - query: contributes an extra server clause AND-ed with the chips (Locked)
// - client: constrains by a client-side id set (Favorites, Recently viewed)
-import {
- Activity,
- Bookmark,
- Clock,
- Code,
- Flag,
- Layers,
- Lock,
- Server,
- Star,
- Tag,
- User,
-} from '@signozhq/icons';
+import { Clock, Layers, Lock, Pin, User } from '@signozhq/icons';
import { DEFAULT_FILTER_STATE } from './filterQuery';
-import type { BuiltinViewId, DashboardFilterState, ViewSection } from './types';
-import type { DashboardListItem } from './utils';
+import { BuiltinViewId } from '../types';
+import type { DashboardFilterState, ViewSection } from '../types';
+import type { DashboardListItem } from './helpers';
// All @signozhq icons share this component type.
-export type ViewIcon = typeof Star;
+export type ViewIcon = typeof Pin;
export interface BuiltinView {
id: BuiltinViewId;
@@ -32,40 +21,37 @@ export interface BuiltinView {
}
export const BUILTIN_VIEWS: BuiltinView[] = [
- { id: 'mine', label: 'My dashboards', icon: User, section: 'personal' },
- { id: 'favorites', label: 'Favorites', icon: Star, section: 'personal' },
- { id: 'recent', label: 'Recently viewed', icon: Clock, section: 'personal' },
- { id: 'all', label: 'All dashboards', icon: Layers, section: 'system' },
- { id: 'locked', label: 'Locked', icon: Lock, section: 'system' },
+ {
+ id: BuiltinViewId.Mine,
+ label: 'My dashboards',
+ icon: User,
+ section: 'personal',
+ },
+ { id: BuiltinViewId.Pinned, label: 'Pinned', icon: Pin, section: 'personal' },
+ {
+ id: BuiltinViewId.Recent,
+ label: 'Recently viewed',
+ icon: Clock,
+ section: 'personal',
+ },
+ {
+ id: BuiltinViewId.All,
+ label: 'All dashboards',
+ icon: Layers,
+ section: 'system',
+ },
+ { id: BuiltinViewId.Locked, label: 'Locked', icon: Lock, section: 'system' },
];
-// Icons offered when naming a saved view; stored by name on the view.
-export const VIEW_ICON_OPTIONS: { name: string; Icon: ViewIcon }[] = [
- { name: 'bookmark', Icon: Bookmark },
- { name: 'star', Icon: Star },
- { name: 'layers', Icon: Layers },
- { name: 'activity', Icon: Activity },
- { name: 'server', Icon: Server },
- { name: 'code', Icon: Code },
- { name: 'flag', Icon: Flag },
- { name: 'tag', Icon: Tag },
- { name: 'lock', Icon: Lock },
- { name: 'clock', Icon: Clock },
-];
-
-const ICON_BY_NAME = new Map(VIEW_ICON_OPTIONS.map((o) => [o.name, o.Icon]));
-
-export const iconByName = (name: string): ViewIcon =>
- ICON_BY_NAME.get(name) ?? Bookmark;
-
-// Favorites/Recently-viewed constrain by a client-side id set — the backend has
-// no id filter, so these are filtered on the fetched rows.
+// Pinned/Recently-viewed constrain client-side — Pinned by the per-row `pinned`
+// flag, Recently-viewed by a localStorage id set — so they filter the fetched
+// rows rather than adding a server clause.
export const isClientView = (id: string): boolean =>
- id === 'favorites' || id === 'recent';
+ id === BuiltinViewId.Pinned || id === BuiltinViewId.Recent;
// Extra server query fragment a built-in view contributes (AND-ed with chips).
export const builtinViewQuery = (id: string): string =>
- id === 'locked' ? 'locked = true' : '';
+ id === BuiltinViewId.Locked ? 'locked = true' : '';
// The canonical filter snapshot a built-in view applies when selected. `null`
// for ids that aren't built-in (custom views carry their own snapshot).
@@ -74,15 +60,15 @@ export const builtinViewSnapshot = (
userEmail: string,
): DashboardFilterState | null => {
switch (id) {
- case 'mine':
+ case BuiltinViewId.Mine:
return {
...DEFAULT_FILTER_STATE,
createdBy: userEmail ? [userEmail] : [],
};
- case 'all':
- case 'favorites':
- case 'recent':
- case 'locked':
+ case BuiltinViewId.All:
+ case BuiltinViewId.Pinned:
+ case BuiltinViewId.Recent:
+ case BuiltinViewId.Locked:
return { ...DEFAULT_FILTER_STATE };
default:
return null;
@@ -109,22 +95,22 @@ export const noResultsCopy = (
};
}
switch (activeViewId) {
- case 'favorites':
+ case BuiltinViewId.Pinned:
return {
- title: 'No favorite dashboards yet',
- description: 'Star a dashboard to pin it here.',
+ title: 'No pinned dashboards yet',
+ description: 'Pin a dashboard to keep it handy here.',
};
- case 'recent':
+ case BuiltinViewId.Recent:
return {
title: 'No recently viewed dashboards',
description: 'Dashboards you open will appear here.',
};
- case 'locked':
+ case BuiltinViewId.Locked:
return {
title: 'No locked dashboards',
description: 'Dashboards locked for editing will appear here.',
};
- case 'mine':
+ case BuiltinViewId.Mine:
return {
title: "You haven't created any dashboards",
description: 'Dashboards you create will appear here.',
@@ -142,19 +128,18 @@ export const noResultsCopy = (
}
};
-// Apply a client-side view's id-set constraint to already-fetched rows.
-// Recently-viewed preserves visit order regardless of the active sort.
+// Apply a client-side view's constraint to already-fetched rows. Pinned filters
+// by the per-row `pinned` flag; Recently-viewed filters by a localStorage id set
+// and preserves visit order regardless of the active sort.
export const applyClientView = (
items: DashboardListItem[],
id: string,
- favorites: string[],
recent: string[],
): DashboardListItem[] => {
- if (id === 'favorites') {
- const set = new Set(favorites);
- return items.filter((d) => set.has(d.id));
+ if (id === BuiltinViewId.Pinned) {
+ return items.filter((d) => d.pinned);
}
- if (id === 'recent') {
+ if (id === BuiltinViewId.Recent) {
const order = new Map(recent.map((rid, index) => [rid, index]));
return items
.filter((d) => order.has(d.id))