mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
refactor(dashboard): drop the scope-keyed placeholder from the logs view
The logs view remounts under a key per scope, so its queries start with no previous result to carry over and the scope check never had anything to refuse. The key is the one guard, and the tenant-switch tests fail without it. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
1 parent
4be80657be
commit
7eff63b028
2 files changed
+1
-13
No files matched your search
+1
-4
@@ -14,7 +14,6 @@ import {
|
||||
import {
|
||||
fieldValues,
|
||||
isScopeWide,
|
||||
keepWithinScope,
|
||||
logsRoot,
|
||||
queryLogs,
|
||||
type ObservabilityScope,
|
||||
@@ -81,7 +80,7 @@ function placeholderFor({ follow, stopped, loading, failed, longestRange, retry
|
||||
return <EmptyState tone="dark" title="No log lines for this range and filter." hint={longestRange ? "Try a broader filter." : "Try a longer range or a broader filter."} />
|
||||
}
|
||||
|
||||
// Filter, pod and container belong to one scope; a new tenant or application starts clean.
|
||||
// Filter, pod, container and the lines already read belong to one scope; a new tenant or application starts clean.
|
||||
export function LogsView({ scope }: { scope: ObservabilityScope }) {
|
||||
const root = logsRoot(scope)
|
||||
return <ScopedLogsView key={root} root={root} />
|
||||
@@ -107,7 +106,6 @@ function ScopedLogsView({ root }: { root: string }) {
|
||||
query: buildLogsQuery({ filter: "", pod: narrowTo }),
|
||||
...windowFor(range),
|
||||
}, signal),
|
||||
placeholderData: keepWithinScope(root),
|
||||
retry: false,
|
||||
})
|
||||
const pods = useQuery(pickerQuery(POD_FIELD))
|
||||
@@ -117,7 +115,6 @@ function ScopedLogsView({ root }: { root: string }) {
|
||||
queryKey: ["observability", "logs", root, query, range],
|
||||
queryFn: ({ signal }) => queryLogs(client, root, { query, limit: HISTORY_LIMIT, ...windowFor(range) }, signal),
|
||||
enabled: !follow,
|
||||
placeholderData: keepWithinScope(root),
|
||||
retry: false,
|
||||
})
|
||||
const tail = useLogTail(root, query, followRun, { cap: FOLLOW_CAP })
|
||||
|
||||
@@ -20,15 +20,6 @@ export function logsRoot(scope: ObservabilityScope): string {
|
||||
return app ? `${app}/log/` : `/apis/cozystack.io/v1alpha1/namespaces/${scope.namespace}/logs/`
|
||||
}
|
||||
|
||||
// The provider's default keeps a useQuery's previous result while its key
|
||||
// changes; across scopes that would show one tenant's or application's data
|
||||
// under another. (useQueries starts a new observer per key, so it never does.)
|
||||
// Every observability query key carries its root at index 2.
|
||||
export function keepWithinScope(root: string) {
|
||||
return <T,>(previous: T | undefined, previousQuery?: { queryKey: readonly unknown[] }): T | undefined =>
|
||||
previousQuery?.queryKey[2] === root ? previous : undefined
|
||||
}
|
||||
|
||||
export type ProxyErrorKind =
|
||||
| "bad-request"
|
||||
| "unauthorized"
|
||||
|
||||
Reference in new issue
Block a user