Browse Source

Merge pull request #5137 from nocodb/feat/nc-disable-audit

feat: implement NC_DISABLE_AUDIT
refactor/icons-update
Raju Udava 2 years ago committed by GitHub
parent
commit
34aa7caa8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      packages/nc-gui/components/dashboard/settings/AuditTab.vue
  2. 1
      packages/nc-gui/composables/useGlobal/state.ts
  3. 1
      packages/nc-gui/composables/useGlobal/types.ts
  4. 3
      packages/noco-docs/content/en/getting-started/environment-variables.md
  5. 4
      packages/noco-docs/content/en/setup-and-usages/audit.md
  6. 3
      packages/nocodb/src/lib/meta/api/utilApis.ts
  7. 3
      packages/nocodb/src/lib/models/Audit.ts
  8. 11
      tests/playwright/tests/projectOperations.spec.ts

6
packages/nc-gui/components/dashboard/settings/AuditTab.vue

@ -1,7 +1,7 @@
<script setup lang="ts">
import { Tooltip as ATooltip, Empty } from 'ant-design-vue'
import type { AuditType } from 'nocodb-sdk'
import { h, onMounted, timeAgo, useI18n, useNuxtApp, useProject } from '#imports'
import { h, onMounted, timeAgo, useGlobal, useI18n, useNuxtApp, useProject } from '#imports'
const { $api } = useNuxtApp()
@ -16,8 +16,11 @@ let audits = $ref<null | Array<AuditType>>(null)
let totalRows = $ref(0)
const currentPage = $ref(1)
const currentLimit = $ref(25)
const { appInfo } = useGlobal()
async function loadAudits(page = currentPage, limit = currentLimit) {
try {
if (!project.value?.id) return
@ -86,6 +89,7 @@ const columns = [
<template>
<div class="flex flex-col gap-4 w-full">
<div v-if="!appInfo.auditEnabled" class="text-red-500">Audit logs are currently disabled by administrators.</div>
<div class="flex flex-row justify-between items-center">
<a-button class="self-start" @click="loadAudits">
<!-- Reload -->

1
packages/nc-gui/composables/useGlobal/state.ts

@ -94,6 +94,7 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
oneClick: false,
projectHasAdmin: false,
teleEnabled: true,
auditEnabled: true,
type: 'nocodb',
version: '0.0.0',
ncAttachmentFieldSize: 20,

1
packages/nc-gui/composables/useGlobal/types.ts

@ -16,6 +16,7 @@ export interface AppInfo {
oneClick: boolean
projectHasAdmin: boolean
teleEnabled: boolean
auditEnabled: boolean
type: string
version: string
ee?: boolean

3
packages/noco-docs/content/en/getting-started/environment-variables.md

@ -14,7 +14,7 @@ For production usecases, it is **recommended** to configure
- `NC_REDIS_URL`
| Variable | Comments | If absent | |
|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|---|
|---|---|---|---|
| NC_DB | See our database URLs | A local SQLite will be created in root folder if `NC_DB` is not provided | |
| NC_DB_JSON | Can be used instead of `NC_DB` and value should be valid knex connection JSON | | |
| NC_DB_JSON_FILE | Can be used instead of `NC_DB` and value should be a valid path to knex connection JSON | | |
@ -64,3 +64,4 @@ For production usecases, it is **recommended** to configure
| NC_ADMIN_PASSWORD | For updating/creating super admin with provided email and password. Your password should have at least 8 letters with one uppercase, one number and one special letter(Allowed special chars $&+,:;=?@#\|'.^*()%!_-" ) | | |
| NODE_OPTIONS | For passing Node.js [options](https://nodejs.org/api/cli.html#node_optionsoptions) to instance | | |
| NC_MINIMAL_DBS | Create a new SQLite file for each project. All the db files are stored in `nc_minimal_dbs` folder in current working directory. (This option restricts project creation on external sources) | | |
| NC_DISABLE_AUDIT | Disable Audit Log | `false` | |

4
packages/noco-docs/content/en/setup-and-usages/audit.md

@ -10,6 +10,10 @@ menuTitle: 'Team & Settings > Audit'
We are keeping all the user operation logs under Audit. To access it, click the down arrow button next to Project Name on the top left side, then select `Team & Settings`.
<alert>
We can disable audit logs by setting `NC_DISABLE_AUDIT` to `true`.
</alert>
<img width="322" alt="image" src="https://user-images.githubusercontent.com/35857179/194856648-67936db0-ee4d-4060-be3d-af9f86ef8fc6.png">
Then, under SETTINGS, click `Audit`.

3
packages/nocodb/src/lib/meta/api/utilApis.ts

@ -53,7 +53,8 @@ export async function appInfo(req: Request, res: Response) {
),
timezone: defaultConnectionConfig.timezone,
ncMin: !!process.env.NC_MIN,
teleEnabled: !process.env.NC_DISABLE_TELE,
teleEnabled: process.env.NC_DISABLE_TELE === 'true' ? false : true,
auditEnabled: process.env.NC_DISABLE_AUDIT === 'true' ? false : true,
ncSiteUrl: (req as any).ncSiteUrl,
ee: Noco.isEE(),
ncAttachmentFieldSize: NC_ATTACHMENT_FIELD_SIZE,

3
packages/nocodb/src/lib/models/Audit.ts

@ -44,6 +44,9 @@ export default class Audit implements AuditType {
forceAwait: process.env['TEST'] === 'true',
}
) {
if (process.env.NC_DISABLE_AUDIT === 'true') {
return;
}
const insertAudit = async () => {
if (!audit.project_id && audit.fk_model_id) {
audit.project_id = (

11
tests/playwright/tests/projectOperations.spec.ts

@ -19,15 +19,16 @@ test.describe('Project operations', () => {
test('rename, delete', async () => {
await dashboard.clickHome();
await projectPage.createProject({ name: 'project-1' });
await projectPage.createProject({ name: 'project-firstName', withoutPrefix: true });
await dashboard.clickHome();
await projectPage.renameProject({
title: 'project-1',
newTitle: 'project-new',
title: 'project-firstName',
newTitle: 'project-rename',
withoutPrefix: true,
});
await dashboard.clickHome();
await projectPage.openProject({ title: 'project-new' });
await projectPage.openProject({ title: 'project-rename', withoutPrefix: true });
await dashboard.clickHome();
await projectPage.deleteProject({ title: 'project-new' });
await projectPage.deleteProject({ title: 'project-rename', withoutPrefix: true });
});
});

Loading…
Cancel
Save