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