Merge pull request #9864 from Budibase/fix/audit-log-fixes
Audit logs fixes
This commit is contained in:
commit
857742c419
|
@ -1,6 +1,6 @@
|
|||
import { getAppClient } from "../redis/init"
|
||||
import { doWithDB, DocumentType } from "../db"
|
||||
import { Database } from "@budibase/types"
|
||||
import { Database, App } from "@budibase/types"
|
||||
|
||||
const AppState = {
|
||||
INVALID: "invalid",
|
||||
|
@ -65,7 +65,7 @@ export async function getAppMetadata(appId: string) {
|
|||
if (isInvalid(metadata)) {
|
||||
throw { status: 404, message: "No app metadata found" }
|
||||
}
|
||||
return metadata
|
||||
return metadata as App
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
HostInfo,
|
||||
} from "@budibase/types"
|
||||
import { EventProcessor } from "./types"
|
||||
import { getAppId, doInTenant } from "../../context"
|
||||
import { getAppId, doInTenant, getTenantId } from "../../context"
|
||||
import BullQueue from "bull"
|
||||
import { createQueue, JobQueue } from "../../queue"
|
||||
import { isAudited } from "../../utils"
|
||||
|
@ -74,7 +74,7 @@ export default class AuditLogsProcessor implements EventProcessor {
|
|||
appId: getAppId(),
|
||||
hostInfo: identity.hostInfo,
|
||||
},
|
||||
tenantId: identity.tenantId!,
|
||||
tenantId: getTenantId(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
export let sort = false
|
||||
export let autoWidth = false
|
||||
export let fetchTerm = null
|
||||
export let useFetch = false
|
||||
export let customPopoverHeight
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
@ -86,6 +87,7 @@
|
|||
isPlaceholder={!value?.length}
|
||||
{autocomplete}
|
||||
bind:fetchTerm
|
||||
{useFetch}
|
||||
{isOptionSelected}
|
||||
{getOptionLabel}
|
||||
{getOptionValue}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
export let autocomplete = false
|
||||
export let sort = false
|
||||
export let fetchTerm = null
|
||||
export let useFetch = false
|
||||
export let customPopoverHeight
|
||||
export let align = "left"
|
||||
export let footer = null
|
||||
|
@ -150,9 +151,9 @@
|
|||
>
|
||||
{#if autocomplete}
|
||||
<Search
|
||||
value={fetchTerm ? fetchTerm : searchTerm}
|
||||
value={useFetch ? fetchTerm : searchTerm}
|
||||
on:change={event =>
|
||||
fetchTerm ? (fetchTerm = event.detail) : (searchTerm = event.detail)}
|
||||
useFetch ? (fetchTerm = event.detail) : (searchTerm = event.detail)}
|
||||
{disabled}
|
||||
placeholder="Search"
|
||||
/>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
export let autoWidth = false
|
||||
export let autocomplete = false
|
||||
export let fetchTerm = null
|
||||
export let useFetch = false
|
||||
export let customPopoverHeight
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
@ -41,6 +42,7 @@
|
|||
{autocomplete}
|
||||
{customPopoverHeight}
|
||||
bind:fetchTerm
|
||||
{useFetch}
|
||||
on:change={onChange}
|
||||
on:click
|
||||
/>
|
||||
|
|
|
@ -12,18 +12,20 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
{#if row?.user?.email}
|
||||
<div
|
||||
class="container"
|
||||
on:mouseover={() => (showTooltip = true)}
|
||||
on:focus={() => (showTooltip = true)}
|
||||
on:mouseleave={() => (showTooltip = false)}
|
||||
>
|
||||
<Avatar size="M" initials={getInitials(row?.user)} />
|
||||
</div>
|
||||
{#if showTooltip}
|
||||
<div class="tooltip">
|
||||
<Tooltip textWrapping text={row?.user.email} direction="bottom" />
|
||||
>
|
||||
<Avatar size="M" initials={getInitials(row.user)} />
|
||||
</div>
|
||||
{#if showTooltip}
|
||||
<div class="tooltip">
|
||||
<Tooltip textWrapping text={row.user.email} direction="bottom" />
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
|
|
|
@ -257,6 +257,7 @@
|
|||
<div class="select">
|
||||
<Multiselect
|
||||
bind:fetchTerm={userSearchTerm}
|
||||
useFetch
|
||||
placeholder="All users"
|
||||
label="Users"
|
||||
autocomplete
|
||||
|
|
|
@ -26,9 +26,16 @@ export enum AuditLogResourceStatus {
|
|||
DELETED = "deleted",
|
||||
}
|
||||
|
||||
export type DeletedResourceInfo = {
|
||||
_id: string
|
||||
status: AuditLogResourceStatus
|
||||
email?: string
|
||||
name?: string
|
||||
}
|
||||
|
||||
export interface AuditLogEnriched {
|
||||
app?: App | { _id: string; status: AuditLogResourceStatus }
|
||||
user: User | { _id: string; status: AuditLogResourceStatus }
|
||||
app?: App | DeletedResourceInfo
|
||||
user: User | DeletedResourceInfo
|
||||
event: Event
|
||||
timestamp: string
|
||||
name: string
|
||||
|
|
|
@ -3,6 +3,11 @@ import { Event } from "../../sdk"
|
|||
|
||||
export const AuditLogSystemUser = "SYSTEM"
|
||||
|
||||
export type FallbackInfo = {
|
||||
appName?: string
|
||||
email?: string
|
||||
}
|
||||
|
||||
export interface AuditLogDoc extends Document {
|
||||
appId?: string
|
||||
event: Event
|
||||
|
@ -10,4 +15,5 @@ export interface AuditLogDoc extends Document {
|
|||
timestamp: string
|
||||
metadata: any
|
||||
name: string
|
||||
fallback?: FallbackInfo
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue