From 1ea56db61cd0cae62c35b8572b334220c88c7ef2 Mon Sep 17 00:00:00 2001 From: Denis Date: Sun, 28 Aug 2022 18:53:13 -0500 Subject: [PATCH 1/5] feat(gui-v2): customizable urls in shared views --- packages/nc-gui/components/cell/Url.vue | 39 ++++++++++++++++++- .../nc-gui/components/smartsheet/Grid.vue | 14 +++++++ packages/nc-gui/context/index.ts | 7 ++++ .../pages/[projectType]/view/[viewId].vue | 20 ++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/cell/Url.vue b/packages/nc-gui/components/cell/Url.vue index 2d9af3343b..ff7b1261ce 100644 --- a/packages/nc-gui/components/cell/Url.vue +++ b/packages/nc-gui/components/cell/Url.vue @@ -2,7 +2,7 @@ import type { VNodeRef } from '@vue/runtime-core' import { message } from 'ant-design-vue' import { useI18n } from 'vue-i18n' -import { ColumnInj, EditModeInj, computed, inject, isValidURL } from '#imports' +import { CellUrlConfigInj, CellUrlDisableOverlayInj, ColumnInj, EditModeInj, computed, inject, isValidURL, ref } from '#imports' import MiCircleWarning from '~icons/mi/circle-warning' const { modelValue: value } = defineProps() @@ -16,6 +16,8 @@ const column = inject(ColumnInj)! const editEnabled = inject(EditModeInj)! +const config = inject(CellUrlConfigInj, {}) +const disableOverlay = inject(CellUrlDisableOverlayInj) // Used in the logic of when to display error since we are not storing the url if its not valid const localState = ref(value) @@ -40,6 +42,17 @@ const url = computed(() => { return `https://${value}` }) +const urlOptions = computed(() => { + const { behavior, overlay, rules } = config + const options = { behavior, overlay } + if (rules && (!behavior || !overlay)) { + for (const [regex, value] of rules) { + if (url.value.match(regex)) return Object.assign(options, value) + } + } + return options +}) + const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus() watch( @@ -59,7 +72,20 @@ watch(
- {{ value }} + {{ value }} + + {{ urlOptions.overlay }} + {{ value }} @@ -74,6 +100,15 @@ watch(
+ +