Browse Source

feat: user field record type

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/7202/head
mertmit 11 months ago
parent
commit
5ee7a195b7
  1. 13
      packages/nc-gui/components/cell/User.vue
  2. 4
      packages/nc-gui/components/project/AccessSettings.vue
  3. 4
      packages/nc-gui/composables/useMultiSelect/index.ts
  4. 13
      packages/nocodb-sdk/src/lib/Api.ts
  5. 2
      packages/nocodb/src/meta/meta.service.ts
  6. 21
      packages/nocodb/src/schema/swagger.json

13
packages/nc-gui/components/cell/User.vue

@ -2,6 +2,7 @@
import { onUnmounted } from '@vue/runtime-core' import { onUnmounted } from '@vue/runtime-core'
import tinycolor from 'tinycolor2' import tinycolor from 'tinycolor2'
import type { Select as AntSelect } from 'ant-design-vue' import type { Select as AntSelect } from 'ant-design-vue'
import type { UserFieldRecordType } from 'nocodb-sdk'
import { import {
ActiveCellInj, ActiveCellInj,
CellClickHookInj, CellClickHookInj,
@ -25,7 +26,7 @@ import {
import MdiCloseCircle from '~icons/mdi/close-circle' import MdiCloseCircle from '~icons/mdi/close-circle'
interface Props { interface Props {
modelValue?: { id: string; email: string; display_name: string }[] | string | null modelValue?: UserFieldRecordType[] | string | null
rowIndex?: number rowIndex?: number
location?: 'cell' | 'filter' location?: 'cell' | 'filter'
forceMulti?: boolean forceMulti?: boolean
@ -75,14 +76,15 @@ const searchVal = ref<string | null>()
const { isUIAllowed } = useRoles() const { isUIAllowed } = useRoles()
const options = computed<{ id: string; email: string; display_name: string }[]>(() => { const options = computed<UserFieldRecordType[]>(() => {
const collaborators: { id: string; email: string; display_name: string }[] = [] const collaborators: UserFieldRecordType[] = []
collaborators.push( collaborators.push(
...(baseUsers.value?.map((user: any) => ({ ...(baseUsers.value?.map((user: any) => ({
id: user.id, id: user.id,
email: user.email, email: user.email,
display_name: user.display_name, display_name: user.display_name,
deleted: user.deleted,
})) || []), })) || []),
) )
return collaborators return collaborators
@ -309,9 +311,9 @@ const filterOption = (input: string, option: any) => {
<template #suffixIcon> <template #suffixIcon>
<GeneralIcon icon="arrowDown" class="text-gray-700 nc-select-expand-btn" /> <GeneralIcon icon="arrowDown" class="text-gray-700 nc-select-expand-btn" />
</template> </template>
<template v-for="op of options" :key="op.id || op.email">
<a-select-option <a-select-option
v-for="op of options" v-if="!op.deleted"
:key="op.id || op.email"
:value="op.id" :value="op.id"
:data-testid="`select-option-${column.title}-${location === 'filter' ? 'filter' : rowIndex}`" :data-testid="`select-option-${column.title}-${location === 'filter' ? 'filter' : rowIndex}`"
:class="`nc-select-option-${column.title}-${op.email}`" :class="`nc-select-option-${column.title}-${op.email}`"
@ -331,6 +333,7 @@ const filterOption = (input: string, option: any) => {
</span> </span>
</a-tag> </a-tag>
</a-select-option> </a-select-option>
</template>
<template #tagRender="{ label, value: val, onClose }"> <template #tagRender="{ label, value: val, onClose }">
<a-tag <a-tag

4
packages/nc-gui/components/project/AccessSettings.vue

@ -44,7 +44,9 @@ const loadCollaborators = async () => {
totalCollaborators.value = totalRows totalCollaborators.value = totalRows
collaborators.value = [ collaborators.value = [
...users.map((user: any) => ({ ...users
.filter((u: any) => !u?.deleted)
.map((user: any) => ({
...user, ...user,
base_roles: user.roles, base_roles: user.roles,
roles: extractRolesObj(user.main_roles)?.[OrgUserRoles.SUPER_ADMIN] roles: extractRolesObj(user.main_roles)?.[OrgUserRoles.SUPER_ADMIN]

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

@ -2,7 +2,7 @@ import { computed } from 'vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import type { MaybeRef } from '@vueuse/core' import type { MaybeRef } from '@vueuse/core'
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType, TableType, UserFieldRecordType } from 'nocodb-sdk'
import { RelationTypes, UITypes, dateFormats, isDateMonthFormat, isSystemColumn, isVirtualCol, timeFormats } from 'nocodb-sdk' import { RelationTypes, UITypes, dateFormats, isDateMonthFormat, isSystemColumn, isVirtualCol, timeFormats } from 'nocodb-sdk'
import { parse } from 'papaparse' import { parse } from 'papaparse'
import type { Cell } from './cellRange' import type { Cell } from './cellRange'
@ -115,7 +115,7 @@ export function useMultiSelect(
if (columnObj.uidt === UITypes.User) { if (columnObj.uidt === UITypes.User) {
if (textToCopy && Array.isArray(textToCopy)) { if (textToCopy && Array.isArray(textToCopy)) {
textToCopy = textToCopy textToCopy = textToCopy
.map((user: { id: string; email: string; display_name: string }) => { .map((user: UserFieldRecordType) => {
return user.email return user.email
}) })
.join(', ') .join(', ')

13
packages/nocodb-sdk/src/lib/Api.ts

@ -2763,6 +2763,13 @@ export interface NotificationUpdateType {
is_read?: boolean; is_read?: boolean;
} }
export interface UserFieldRecordType {
id: string;
display_name?: string;
email: string;
deleted?: boolean;
}
import type { import type {
AxiosInstance, AxiosInstance,
AxiosRequestConfig, AxiosRequestConfig,
@ -3343,7 +3350,7 @@ export class Api<
}), }),
/** /**
* @description Regenerate user refresh token * @description Creates a new refresh token and JWT auth token for the user. The refresh token is sent as a cookie, while the JWT auth token is included in the response body.
* *
* @tags Auth * @tags Auth
* @name TokenRefresh * @name TokenRefresh
@ -3351,7 +3358,7 @@ export class Api<
* @request POST:/api/v1/auth/token/refresh * @request POST:/api/v1/auth/token/refresh
* @response `200` `{ * @response `200` `{
\** \**
* New access token for user * New JWT auth token for user
* @example 96751db2d53fb834382b682268874a2ea9ee610e4d904e688d1513f11d3c30d62d36d9e05dec0d63 * @example 96751db2d53fb834382b682268874a2ea9ee610e4d904e688d1513f11d3c30d62d36d9e05dec0d63
*\ *\
token?: string, token?: string,
@ -3367,7 +3374,7 @@ export class Api<
this.request< this.request<
{ {
/** /**
* New access token for user * New JWT auth token for user
* @example 96751db2d53fb834382b682268874a2ea9ee610e4d904e688d1513f11d3c30d62d36d9e05dec0d63 * @example 96751db2d53fb834382b682268874a2ea9ee610e4d904e688d1513f11d3c30d62d36d9e05dec0d63
*/ */
token?: string; token?: string;

2
packages/nocodb/src/meta/meta.service.ts

@ -912,7 +912,7 @@ export class MetaService {
); );
} }
private now(): any { public now(): any {
return dayjs() return dayjs()
.utc() .utc()
.format(this.isMySQL() ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'); .format(this.isMySQL() ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ');

21
packages/nocodb/src/schema/swagger.json

@ -23864,6 +23864,27 @@
"type": "boolean" "type": "boolean"
} }
} }
},
"UserFieldRecord": {
"type": "object",
"properties": {
"id": {
"type": "string",
"required": true
},
"display_name": {
"type": "string",
"required": false
},
"email": {
"type": "string",
"required": true
},
"deleted": {
"type": "boolean",
"required": false
}
}
} }
}, },
"responses": { "responses": {

Loading…
Cancel
Save