Browse Source

fix: miscellaneous changes

pull/6616/head
Pranav C 1 year ago
parent
commit
92b41cac2f
  1. 32
      packages/nc-gui/components/dlg/share-and-collaborate/ShareBase.vue
  2. 13
      packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
  3. 2
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
  4. 2
      packages/nc-gui/composables/useGlobal/state.ts
  5. 7
      packages/nc-gui/middleware/auth.global.ts
  6. 36
      packages/nocodb/src/services/shared-bases.service.ts

32
packages/nc-gui/components/dlg/share-and-collaborate/ShareBase.vue

@ -1,5 +1,15 @@
<script setup lang="ts">
import { extractSdkResponseErrorMsg, message, onMounted, storeToRefs, useBase, useDashboard, useNuxtApp } from '#imports'
import {
extractSdkResponseErrorMsg,
message,
onMounted,
storeToRefs,
useBase,
useDashboard,
useGlobal,
useNuxtApp,
useWorkspace,
} from '#imports'
interface ShareBase {
uuid?: string
@ -20,9 +30,23 @@ const sharedBase = ref<null | ShareBase>(null)
const { base } = storeToRefs(useBase())
const url = computed(() =>
sharedBase.value && sharedBase.value.uuid ? `${dashboardUrl.value}#/base/${sharedBase.value.uuid}` : '',
)
const { getBaseUrl, appInfo } = useGlobal()
const workspaceStore = useWorkspace()
const url = computed(() => {
if (!sharedBase.value || !sharedBase.value.uuid) return ''
// get base url for workspace
const baseUrl = getBaseUrl(workspaceStore.activeWorkspaceId)
let dashboardUrl1 = dashboardUrl.value
if (baseUrl) {
dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}`
}
return encodeURI(`${dashboardUrl1}#/base/${sharedBase.value.uuid}`)
})
const loadBase = async () => {
try {

13
packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue

@ -6,6 +6,7 @@ import { useMetas } from '#imports'
const { view: _view, $api } = useSmartsheetStoreOrThrow()
const { $e } = useNuxtApp()
const { getBaseUrl, appInfo } = useGlobal()
const { dashboardUrl } = useDashboard()
@ -13,6 +14,8 @@ const viewStore = useViewsStore()
const { metas } = useMetas()
const workspaceStore = useWorkspace()
const isUpdating = ref({
public: false,
password: false,
@ -162,7 +165,15 @@ function sharedViewUrl() {
viewType = 'view'
}
return encodeURI(`${dashboardUrl?.value}#/nc/${viewType}/${activeView.value.uuid}`)
// get base url for workspace
const baseUrl = getBaseUrl(workspaceStore.activeWorkspaceId)
let dashboardUrl1 = dashboardUrl.value
if (baseUrl) {
dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}`
}
return encodeURI(`${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}`)
}
const toggleViewShare = async () => {

2
packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue

@ -3,6 +3,7 @@ import {
ActiveViewInj,
IsLockedInj,
computed,
iconMap,
inject,
ref,
useGlobal,
@ -10,7 +11,6 @@ import {
useSmartsheetStoreOrThrow,
useViewFilters,
watch,
iconMap,
} from '#imports'
const isLocked = inject(IsLockedInj, ref(false))

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

@ -18,7 +18,7 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
/** get the preferred languages of a user, according to browser settings */
const preferredLanguages = usePreferredLanguages()
/** todo: reimplement; get the preferred dark mode setting, according to browser settings */
// const prefersDarkMode = $(usePreferredDark())
// const prefersDarkMode = $(usePreferredDark())
const prefersDarkMode = false
/** reactive timestamp to check token expiry against */

7
packages/nc-gui/middleware/auth.global.ts

@ -1,6 +1,7 @@
import type { Api } from 'nocodb-sdk'
import type { Actions } from '~/composables/useGlobal/types'
import { defineNuxtRouteMiddleware, extractSdkResponseErrorMsg, message, navigateTo, useApi, useGlobal, useRoles } from '#imports'
import { defineNuxtRouteMiddleware, message, navigateTo, useApi, useGlobal, useRoles } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils'
/**
* Global auth middleware
@ -46,7 +47,9 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
}
/** if user isn't signed in and google auth is enabled, try to check if sign-in data is present */
if (!state.signedIn.value && state.appInfo.value.googleAuthEnabled) await tryGoogleAuth(api, state.signIn)
if (!state.signedIn.value && state.appInfo.value.googleAuthEnabled) {
await tryGoogleAuth(api, state.signIn)
}
/** if public allow all visitors */
if (to.meta.public) return

36
packages/nocodb/src/services/shared-bases.service.ts

@ -1,6 +1,8 @@
import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk';
import { v4 as uuidv4 } from 'uuid';
import { ConfigService } from '@nestjs/config';
import type { AppConfig } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -13,7 +15,10 @@ const config = {
@Injectable()
export class SharedBasesService {
constructor(private readonly appHooksService: AppHooksService) {}
constructor(
private readonly appHooksService: AppHooksService,
private configService: ConfigService<AppConfig>,
) {}
async createSharedBaseLink(param: {
baseId: string;
@ -42,7 +47,11 @@ export class SharedBasesService {
await Base.update(base.id, data);
data.url = `${param.siteUrl}${config.dashboardPath}#/nc/base/${data.uuid}`;
data.url = this.getUrl({
base,
siteUrl: param.siteUrl,
});
delete data.password;
this.appHooksService.emit(AppEvents.SHARED_BASE_GENERATE_LINK, {
@ -79,7 +88,11 @@ export class SharedBasesService {
await Base.update(base.id, data);
data.url = `${param.siteUrl}${config.dashboardPath}#/nc/base/${data.uuid}`;
data.url = this.getUrl({
base,
siteUrl: param.siteUrl,
});
delete data.password;
this.appHooksService.emit(AppEvents.SHARED_BASE_GENERATE_LINK, {
link: data.url,
@ -88,6 +101,21 @@ export class SharedBasesService {
return data;
}
private getUrl({ base, siteUrl: _siteUrl }: { base: Base; siteUrl: string }) {
let siteUrl = _siteUrl;
const baseDomain = process.env.NC_BASE_HOST_NAME;
const dashboardPath = this.configService.get('dashboardPath', {
infer: true,
});
if (baseDomain) {
siteUrl = `https://${base['fk_workspace_id']}.${baseDomain}${dashboardPath}`;
}
return `${siteUrl}${config.dashboardPath}#/base/${base.uuid}`;
}
async disableSharedBaseLink(param: { baseId: string }): Promise<any> {
const base = await Base.get(param.baseId);
@ -120,7 +148,7 @@ export class SharedBasesService {
roles: base.roles,
};
if (data.uuid)
data.url = `${param.siteUrl}${config.dashboardPath}#/nc/base/${data.shared_base_id}`;
data.url = `${param.siteUrl}${config.dashboardPath}#/base/${data.shared_base_id}`;
return data;
}

Loading…
Cancel
Save