Browse Source

Merge pull request #8901 from nocodb/nc-fix/audit-related-fixes

Nc fix: Audit related fixes
pull/8950/head
Ramesh Mane 5 months ago committed by GitHub
parent
commit
bfbe3ff915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 25
      packages/nc-gui/components/smartsheet/expanded-form/Comments.vue
  2. 4
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  3. 13
      packages/nc-gui/components/smartsheet/toolbar/FieldListWithSearch.vue
  4. 16
      packages/nc-gui/components/workspace/AuditLogs.vue
  5. 4
      packages/nc-gui/composables/useExpandedFormStore.ts
  6. 2
      packages/nc-gui/composables/useMultiSelect/index.ts
  7. 873
      packages/nocodb/src/db/BaseModelSqlv2.ts
  8. 2
      packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts
  9. 2
      packages/nocodb/src/strategies/jwt.strategy.ts

25
packages/nc-gui/components/smartsheet/expanded-form/Comments.vue

@ -186,6 +186,18 @@ function scrollToComment(commentId: string) {
} }
} }
function scrollToAudit(auditId?: string) {
if (!auditId) return
const auditEl = commentsWrapperEl.value?.querySelector(`.nc-audit-item.${auditId}`)
if (auditEl) {
auditEl.scrollIntoView({
behavior: 'smooth',
block: 'center',
})
}
}
watch(commentsWrapperEl, () => { watch(commentsWrapperEl, () => {
setTimeout(() => { setTimeout(() => {
nextTick(() => { nextTick(() => {
@ -261,6 +273,17 @@ function handleResetHoverEffect() {
hoveredCommentId.value = null hoveredCommentId.value = null
} }
watch(
() => audits.value.length,
(auditCount) => {
nextTick(() => {
setTimeout(() => {
scrollToAudit(audits.value[auditCount - 1]?.id)
}, 100)
})
},
)
</script> </script>
<template> <template>
@ -530,7 +553,7 @@ function handleResetHoverEffect() {
</div> </div>
</template> </template>
<div v-for="audit of audits" :key="audit.id" class="nc-audit-item"> <div v-for="audit of audits" :key="audit.id" :class="`${audit.id}`" class="nc-audit-item">
<div class="group gap-3 overflow-hidden px-3 py-2 hover:bg-gray-100"> <div class="group gap-3 overflow-hidden px-3 py-2 hover:bg-gray-100">
<div class="flex items-start justify-between"> <div class="flex items-start justify-between">
<div class="flex items-start gap-3 flex-1 w-full"> <div class="flex items-start gap-3 flex-1 w-full">

4
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -315,7 +315,9 @@ const reloadHook = createEventHook()
reloadHook.on(() => { reloadHook.on(() => {
reloadParentRowHook?.trigger({ shouldShowLoading: false }) reloadParentRowHook?.trigger({ shouldShowLoading: false })
if (isNew.value) return if (isNew.value) return
_loadRow(null, true)
_loadRow(undefined, true)
loadAudits(rowId.value, false)
}) })
provide(ReloadRowDataHookInj, reloadHook) provide(ReloadRowDataHookInj, reloadHook)

13
packages/nc-gui/components/smartsheet/toolbar/FieldListWithSearch.vue

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { isSystemColumn, type ColumnType } from 'nocodb-sdk' import { type ColumnType, isSystemColumn } from 'nocodb-sdk'
const props = defineProps<{ const props = defineProps<{
// As we need to focus search box when the parent is opened // As we need to focus search box when the parent is opened
@ -13,21 +13,14 @@ const props = defineProps<{
const emits = defineEmits<{ selected: [ColumnType] }>() const emits = defineEmits<{ selected: [ColumnType] }>()
const { const { isParentOpen, toolbarMenu, searchInputPlaceholder, selectedOptionId, showSelectedOption } = toRefs(props)
isParentOpen,
toolbarMenu,
searchInputPlaceholder,
selectedOptionId,
options: _options,
showSelectedOption,
} = toRefs(props)
const { fieldsMap } = useViewColumnsOrThrow() const { fieldsMap } = useViewColumnsOrThrow()
const searchQuery = ref('') const searchQuery = ref('')
const options = computed(() => const options = computed(() =>
(_options.value || []) (props.options || [])
.map((c) => c) .map((c) => c)
.sort((field1, field2) => { .sort((field1, field2) => {
// sort by view column order and keep system columns at the end // sort by view column order and keep system columns at the end

16
packages/nc-gui/components/workspace/AuditLogs.vue

@ -476,7 +476,7 @@ useEventListener(tableWrapper, 'scroll', () => {
</div> </div>
</div> </div>
</template> </template>
<div v-if="selectedAudit" class="flex flex-col gap-4"> <div v-if="selectedAudit" class="nc-expanded-audit flex flex-col gap-4">
<div class="bg-gray-50 rounded-lg border-1 border-gray-200"> <div class="bg-gray-50 rounded-lg border-1 border-gray-200">
<div class="flex"> <div class="flex">
<div class="w-1/2 border-r border-gray-200 flex flex-col gap-2 px-4 py-3"> <div class="w-1/2 border-r border-gray-200 flex flex-col gap-2 px-4 py-3">
@ -548,7 +548,9 @@ useEventListener(tableWrapper, 'scroll', () => {
</div> </div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<div class="cell-header">{{ $t('labels.description') }}</div> <div class="cell-header">{{ $t('labels.description') }}</div>
<div class="text-small leading-[18px] text-gray-600">{{ selectedAudit?.description }}</div> <div>
<pre class="!text-small !leading-[18px] !text-gray-600 mb-0">{{ selectedAudit?.description }}</pre>
</div>
</div> </div>
</div> </div>
</NcModal> </NcModal>
@ -557,13 +559,9 @@ useEventListener(tableWrapper, 'scroll', () => {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.nc-audit-table pre { .nc-expanded-audit pre {
display: table; font-family: Manrope, 'Inter', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
table-layout: fixed; sans-serif;
width: 100%;
white-space: break-spaces;
font-size: unset;
font-family: unset;
} }
:deep(.nc-menu-item-inner) { :deep(.nc-menu-item-inner) {

4
packages/nc-gui/composables/useExpandedFormStore.ts

@ -173,7 +173,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
} }
} }
const loadAudits = async (_rowId?: string) => { const loadAudits = async (_rowId?: string, showLoading: boolean = true) => {
if (!isUIAllowed('auditListRow') || isEeUI || (!row.value && !_rowId)) return if (!isUIAllowed('auditListRow') || isEeUI || (!row.value && !_rowId)) return
const rowId = _rowId ?? extractPkFromRow(row.value.row, meta.value.columns as ColumnType[]) const rowId = _rowId ?? extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
@ -181,7 +181,9 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
if (!rowId) return if (!rowId) return
try { try {
if (showLoading) {
isAuditLoading.value = true isAuditLoading.value = true
}
const res = const res =
( (
await $api.utils.auditList({ await $api.utils.auditList({

2
packages/nc-gui/composables/useMultiSelect/index.ts

@ -1172,7 +1172,7 @@ export function useMultiSelect(
for (const col of cols) { for (const col of cols) {
if (!col.title || !isPasteable(row, col)) { if (!col.title || !isPasteable(row, col)) {
if ((isBt(col) || isOo(pasteCol) || isMm(col)) && !isInfoShown) { if ((isBt(col) || isOo(col) || isMm(col)) && !isInfoShown) {
message.info(t('msg.info.groupPasteIsNotSupportedOnLinksColumn')) message.info(t('msg.info.groupPasteIsNotSupportedOnLinksColumn'))
isInfoShown = true isInfoShown = true
} }

873
packages/nocodb/src/db/BaseModelSqlv2.ts

File diff suppressed because it is too large Load Diff

2
packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts

@ -44,6 +44,8 @@ export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') {
Object.assign(user, { Object.assign(user, {
id: dbUser.id, id: dbUser.id,
email: dbUser.email,
display_name: dbUser.display_name,
roles: extractRolesObj(dbUser.roles), roles: extractRolesObj(dbUser.roles),
base_roles: extractRolesObj(dbUser.base_roles), base_roles: extractRolesObj(dbUser.base_roles),
...(dbUser.workspace_roles ...(dbUser.workspace_roles

2
packages/nocodb/src/strategies/jwt.strategy.ts

@ -14,7 +14,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
} }
async validate(req, jwtPayload) { async validate(req, jwtPayload) {
if (!jwtPayload?.email) { if (!jwtPayload?.email || jwtPayload?.is_api_token) {
return jwtPayload; return jwtPayload;
} }

Loading…
Cancel
Save