Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): use props t fn instead of importing it

Ramesh Mane81191df33a65
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/AILongText.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/AILongText.ts
index 50f5bb449d..2b60d2c8ab 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/AILongText.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/AILongText.ts
@@ -1,4 +1,3 @@
-import { getI18n } from '../../../../../plugins/a.i18n'
import {
defaultOffscreen2DContext,
isBoxHovered,
@@ -272,7 +271,7 @@ export const AILongTextCellRenderer: CellRenderer = {
}
return false
},
- async handleHover({ row, column, mousePosition, getCellPosition }) {
+ async handleHover({ row, column, mousePosition, getCellPosition, t }) {
const { tryShowTooltip, hideTooltip } = useTooltipStore()
hideTooltip()
if (!row || !column?.id || !mousePosition || column?.isInvalidColumn?.isInvalid) return
@@ -280,7 +279,7 @@ export const AILongTextCellRenderer: CellRenderer = {
const { x, y, width } = getCellPosition(column, row.rowMeta.rowIndex!)
const expandIconBox = { x: x + width - 28, y: y + 7, width: 18, height: 18 }
const regenerateIconBox = { x: x + width - 52, y: y + 7, width: 18, height: 18 }
- tryShowTooltip({ text: getI18n().global.t('title.expand'), rect: expandIconBox, mousePosition })
+ tryShowTooltip({ text: t('title.expand'), rect: expandIconBox, mousePosition })
tryShowTooltip({ text: 'Re-generate', rect: regenerateIconBox, mousePosition })
},
async handleKeyDown(ctx) {
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Attachment.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Attachment.ts
index 5180588782..bcb37b1a13 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Attachment.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Attachment.ts
@@ -1,7 +1,6 @@
import { isBoxHovered, renderIconButton, roundedRect } from '../utils/canvas'
import { pxToRowHeight } from '../../../../../utils/cell'
import type { RenderRectangleProps } from '../utils/types'
-import { getI18n } from '../../../../../plugins/a.i18n'
interface Attachment {
mimetype?: string
@@ -279,7 +278,7 @@ export const AttachmentCellRenderer: CellRenderer = {
})
}
},
- async handleHover({ row, column, mousePosition, getCellPosition, value, selected, imageLoader }) {
+ async handleHover({ row, column, mousePosition, getCellPosition, value, selected, imageLoader, t }) {
const { tryShowTooltip, hideTooltip } = useTooltipStore()
hideTooltip()
if (!row || !column?.id || !mousePosition || !selected) return
@@ -322,7 +321,7 @@ export const AttachmentCellRenderer: CellRenderer = {
if (
tryShowTooltip({
rect: maximizeBox,
- text: `${getI18n().global.t('activity.viewAttachment')} '${getI18n().global.t('tooltip.shiftSpace')}'`,
+ text: `${t('activity.viewAttachment')} '${t('tooltip.shiftSpace')}'`,
mousePosition,
})
) {
@@ -332,7 +331,7 @@ export const AttachmentCellRenderer: CellRenderer = {
if (
tryShowTooltip({
rect: attachBox,
- text: getI18n().global.t('activity.addFiles'),
+ text: t('activity.addFiles'),
mousePosition,
})
) {
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Barcode.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Barcode.ts
index 6fd3df0c8f..fb916a77ea 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Barcode.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Barcode.ts
@@ -1,6 +1,5 @@
import { isBoxHovered, renderBarcode } from '../utils/canvas'
import { validateBarcode } from '../utils/cell'
-import { getI18n } from '../../../../../plugins/a.i18n'
export const BarcodeCellRenderer: CellRenderer = {
render: (ctx, props) => {
@@ -41,7 +40,7 @@ export const BarcodeCellRenderer: CellRenderer = {
return false
},
- async handleHover({ column, row, getCellPosition, value, mousePosition }) {
+ async handleHover({ column, row, getCellPosition, value, mousePosition, t }) {
const { x, y, width } = getCellPosition(column, row.rowMeta.rowIndex!)
const { tryShowTooltip } = useTooltipStore()
@@ -51,7 +50,7 @@ export const BarcodeCellRenderer: CellRenderer = {
const box = { x: x + width - 23, y: y + 9, width: 16, height: 16 }
tryShowTooltip({
rect: box,
- text: getI18n().global.t('msg.warning.barcode.renderError'),
+ text: t('msg.warning.barcode.renderError'),
mousePosition,
})
}
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Formula.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Formula.ts
index 66ddc4ca11..7b980924c5 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Formula.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Formula.ts
@@ -7,7 +7,6 @@ import {
renderSingleLineText,
} from '../utils/canvas'
import { showFieldEditWarning } from '../utils/cell'
-import { getI18n } from '../../../../../plugins/a.i18n'
import { CheckboxCellRenderer } from './Checkbox'
import { CurrencyRenderer } from './Currency'
import { DateCellRenderer } from './Date'
@@ -255,7 +254,7 @@ export const FormulaCellRenderer: CellRenderer = {
}
},
async handleHover(props) {
- const { mousePosition, getCellPosition, column, row, selected } = props
+ const { mousePosition, getCellPosition, column, row, selected, t } = props
const colObj = column.columnObj
const colMeta = parseProp(colObj.meta)
const error = parseProp(colObj.colOptions)?.error ?? ''
@@ -287,7 +286,7 @@ export const FormulaCellRenderer: CellRenderer = {
height: 18,
},
mousePosition,
- text: getI18n().global.t('tooltip.expandShiftSpace'),
+ text: t('tooltip.expandShiftSpace'),
})
}
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Json.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Json.ts
index aa7d7bc038..acf46e8acd 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Json.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Json.ts
@@ -1,4 +1,3 @@
-import { getI18n } from '../../../../../plugins/a.i18n'
import { isBoxHovered, renderIconButton, renderMultiLineText, renderTagLabel } from '../utils/canvas'
export const JsonCellRenderer: CellRenderer = {
@@ -107,13 +106,13 @@ export const JsonCellRenderer: CellRenderer = {
return false
},
- async handleHover({ row, column, mousePosition, getCellPosition, selected }) {
+ async handleHover({ row, column, mousePosition, getCellPosition, selected, t }) {
const { tryShowTooltip, hideTooltip } = useTooltipStore()
hideTooltip()
if (!row || !column?.id || !mousePosition || column?.isInvalidColumn?.isInvalid || !selected) return
const { x, y, width } = getCellPosition(column, row.rowMeta.rowIndex!)
const expandIconBox = { x: x + width - 28, y: y + 7, width: 18, height: 18 }
- tryShowTooltip({ text: getI18n().global.t('tooltip.expandShiftSpace'), rect: expandIconBox, mousePosition })
+ tryShowTooltip({ text: t('tooltip.expandShiftSpace'), rect: expandIconBox, mousePosition })
},
}
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/HasMany.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/HasMany.ts
index 397e6d03b6..9582a600a2 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/HasMany.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/HasMany.ts
@@ -2,7 +2,6 @@ import type { ColumnType, TableType } from 'nocodb-sdk'
import { isBoxHovered, renderIconButton, renderSingleLineText } from '../../utils/canvas'
import { PlainCellRenderer } from '../Plain'
import { renderAsCellLookupOrLtarValue } from '../../utils/cell'
-import { getI18n } from '../../../../../../plugins/a.i18n'
const ellipsisWidth = 15
const buttonSize = 24
@@ -306,7 +305,7 @@ export const HasManyCellRenderer: CellRenderer = {
return false
},
handleHover: async (props) => {
- const { row, column, mousePosition, getCellPosition } = props
+ const { row, column, mousePosition, getCellPosition, t } = props
const { tryShowTooltip, hideTooltip } = useTooltipStore()
hideTooltip()
@@ -316,6 +315,6 @@ export const HasManyCellRenderer: CellRenderer = {
const box = { x: x + width - 30, y: y + 4, width: buttonSize, height: buttonSize }
- tryShowTooltip({ rect: box, mousePosition, text: getI18n().global.t('tooltip.expandShiftSpace') })
+ tryShowTooltip({ rect: box, mousePosition, text: t('tooltip.expandShiftSpace') })
},
}
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/ManyToMany.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/ManyToMany.ts
index 22f016df6f..bb341695cd 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/ManyToMany.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/LTAR/ManyToMany.ts
@@ -2,7 +2,6 @@ import type { ColumnType, TableType } from 'nocodb-sdk'
import { isBoxHovered, renderIconButton, renderSingleLineText } from '../../utils/canvas'
import { PlainCellRenderer } from '../Plain'
import { renderAsCellLookupOrLtarValue } from '../../utils/cell'
-import { getI18n } from '../../../../../../plugins/a.i18n'
const ellipsisWidth = 15
const buttonSize = 20
@@ -309,7 +308,7 @@ export const ManyToManyCellRenderer: CellRenderer = {
return false
},
handleHover: async (props) => {
- const { row, column, mousePosition, getCellPosition, selected } = props
+ const { row, column, mousePosition, getCellPosition, selected, t } = props
if (!selected) return
@@ -321,6 +320,6 @@ export const ManyToManyCellRenderer: CellRenderer = {
const box = { x: x + width - 30, y: y + 4, width: buttonSize, height: buttonSize }
- tryShowTooltip({ rect: box, mousePosition, text: getI18n().global.t('tooltip.expandShiftSpace') })
+ tryShowTooltip({ rect: box, mousePosition, text: t('tooltip.expandShiftSpace') })
},
}
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/LongText.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/LongText.ts
index 5c01fc8c12..cec46e093f 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/LongText.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/LongText.ts
@@ -1,6 +1,5 @@
import { isAIPromptCol } from 'nocodb-sdk'
import { isBoxHovered, renderIconButton, renderMarkdown, renderMultiLineText, renderTagLabel } from '../utils/canvas'
-import { getI18n } from '../../../../../plugins/a.i18n'
import { AILongTextCellRenderer } from './AILongText'
export const LongTextCellRenderer: CellRenderer = {
@@ -183,7 +182,7 @@ export const LongTextCellRenderer: CellRenderer = {
return false
},
handleHover: async (props) => {
- const { row, column, value, mousePosition, getCellPosition, cellRenderStore, setCursor, selected } = props
+ const { row, column, value, mousePosition, getCellPosition, cellRenderStore, setCursor, selected, t } = props
if (!selected && !isAIPromptCol(column?.columnObj)) {
return
@@ -221,7 +220,7 @@ export const LongTextCellRenderer: CellRenderer = {
const { x, y, width } = getCellPosition(column, row.rowMeta.rowIndex!)
const box = { x: x + width - 28, y: y + 7, width: 18, height: 18 }
- tryShowTooltip({ rect: box, mousePosition, text: getI18n().global.t('tooltip.expandShiftSpace') })
+ tryShowTooltip({ rect: box, mousePosition, text: t('tooltip.expandShiftSpace') })
}
},
}
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Url.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Url.ts
index 3843f1dc3d..d68815bcc2 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Url.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Url.ts
@@ -1,4 +1,3 @@
-import { getI18n } from '../../../../../plugins/a.i18n'
import { defaultOffscreen2DContext, isBoxHovered, renderMultiLineText, renderTagLabel } from '../utils/canvas'
export const UrlCellRenderer: CellRenderer = {
@@ -62,7 +61,7 @@ export const UrlCellRenderer: CellRenderer = {
}
}
},
- async handleHover({ column, row, getCellPosition, value, mousePosition, selected }) {
+ async handleHover({ column, row, getCellPosition, value, mousePosition, selected, t }) {
const { x, y, width, height } = getCellPosition(column, row.rowMeta.rowIndex!)
const { tryShowTooltip, hideTooltip } = useTooltipStore()
@@ -98,7 +97,7 @@ export const UrlCellRenderer: CellRenderer = {
tryShowTooltip({
rect: box,
- text: getI18n().global.t('msg.error.invalidURL'),
+ text: t('msg.error.invalidURL'),
mousePosition,
})
}