Skip to content

Commit

Permalink
Partially i18n table editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jingsam committed Jul 10, 2024
1 parent 36a6bef commit 81a8aa7
Show file tree
Hide file tree
Showing 33 changed files with 180 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build studio multiarch image with buildx
on:
# run this action every day at 04:00 UTC (Singapore noon)
schedule:
- cron: '0 4 * * *'
- cron: '0 4 * * 1'
workflow_dispatch:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check Code with Prettier
on:
pull_request:
branches:
- 'master'
- 'foxgis'

# Cancel old builds on new commit for same workflow + branch/PR
concurrency:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/studio-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ name: Studio Unit Tests & Build Check

on:
push:
branches: [master, studio]
branches: [foxgis]
paths:
- 'apps/studio/**'
- 'package-lock.json'
pull_request:
branches: [master, studio]
branches: [foxgis]
paths:
- 'apps/studio/**'
- 'package-lock.json'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check code with TypeScript
on:
pull_request:
branches:
- 'master'
- 'foxgis'

# Cancel old builds on new commit for same workflow + branch/PR
concurrency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export const DropdownControl = ({
{options.map((x) => {
return (
<DropdownMenuItem key={x.value} onClick={() => onSelect(x.value)}>
<div className="flex items-center gap-2">
<div className="flex items-center gap-2 whitespace-nowrap">
{x.preLabel && <span className="grow text-foreground-lighter">{x.preLabel}</span>}
<span>{x.label}</span>
{x.postLabel && <span className="text-foreground-lighter">{x.postLabel}</span>}
{x.postLabel && <span className="text-foreground-lighter whitespace-nowrap">{x.postLabel}</span>}
</div>
</DropdownMenuItem>
)
Expand Down
12 changes: 6 additions & 6 deletions apps/studio/components/grid/components/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const Grid = memo(
)}
{isError && (
<div className="p-2 col-span-full">
<AlertError error={error} subject="Failed to retrieve rows from table" />
<AlertError error={error} subject="从表中获取数据失败" />
</div>
)}
{isSuccess && (
Expand All @@ -205,16 +205,16 @@ export const Grid = memo(
style={{ height: `calc(100% - 35px)` }}
className="flex flex-col items-center justify-center col-span-full"
>
<p className="text-sm text-light">This table is empty</p>
<p className="text-sm text-light">这张表是空的</p>
{onAddRow !== undefined && onImportData !== undefined && (
<>
<p className="text-sm text-light mt-1">
Add rows to your table to get started.
开始给这张表添加数据吧。
</p>
<div className="flex items-center space-x-2 mt-4">
{onAddRow !== undefined && onImportData !== undefined && (
<Button type="default" onClick={onImportData}>
Import data via CSV
通过 CSV 导入数据
</Button>
)}
</div>
Expand All @@ -227,11 +227,11 @@ export const Grid = memo(
className="flex flex-col items-center justify-center col-span-full"
>
<p className="text-sm text-light">
The filters applied has returned no results from this table
应用筛选条件后没有返回任何结果
</p>
<div className="flex items-center space-x-2 mt-4">
<Button type="default" onClick={() => removeAllFilters()}>
Remove all filters
移除所有的过滤条件
</Button>
</div>
</div>
Expand Down
36 changes: 18 additions & 18 deletions apps/studio/components/grid/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const DefaultHeader = ({ table, onAddColumn, onAddRow, onImportData }: DefaultHe
size="tiny"
icon={<ChevronDown strokeWidth={1.5} />}
>
Insert
插入
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="start">
Expand All @@ -143,9 +143,9 @@ const DefaultHeader = ({ table, onAddColumn, onAddRow, onImportData }: DefaultHe
/>
</div>
<div>
<p>Insert row</p>
<p>插入行</p>
<p className="text-foreground-light">
Insert a new row into {table.name}
{table.name} 插入新行
</p>
</div>
</DropdownMenuItem>,
Expand All @@ -169,9 +169,9 @@ const DefaultHeader = ({ table, onAddColumn, onAddRow, onImportData }: DefaultHe
/>
</div>
<div>
<p>Insert column</p>
<p>插入</p>
<p className="text-foreground-light">
Insert a new column into {table.name}
{table.name} 插入新列
</p>
</div>
</DropdownMenuItem>,
Expand Down Expand Up @@ -200,8 +200,8 @@ const DefaultHeader = ({ table, onAddColumn, onAddRow, onImportData }: DefaultHe
/>
</div>
<div>
<p>Import data from CSV</p>
<p className="text-foreground-light">Insert new rows from a CSV</p>
<p>导入 CSV</p>
<p className="text-foreground-light">通过 CSV 批量插入新行</p>
</div>
</DropdownMenuItem>,
]
Expand Down Expand Up @@ -288,13 +288,13 @@ const RowHeader = ({ table, sorts, filters }: RowHeaderProps) => {

if (allRowsSelected && totalRows > MAX_EXPORT_ROW_COUNT) {
toast.error(
`Sorry! We're unable to support exporting of CSV for row counts larger than ${MAX_EXPORT_ROW_COUNT.toLocaleString()} at the moment.`
`抱歉!我们暂时无法支持导出超过 ${MAX_EXPORT_ROW_COUNT.toLocaleString()} 行的 CSV。`
)
return setIsExporting(false)
}

if (!project) {
toast.error('Project is required')
toast.error('未找到项目')
return setIsExporting(false)
}

Expand Down Expand Up @@ -349,14 +349,14 @@ const RowHeader = ({ table, sorts, filters }: RowHeaderProps) => {
<Button type="default" className="px-1" icon={<X />} onClick={deselectRows} />
<span className="text-xs text-foreground">
{allRowsSelected
? `${totalRows} rows selected`
? `已选择了 ${totalRows} `
: selectedRows.size > 1
? `${selectedRows.size} rows selected`
: `${selectedRows.size} row selected`}
? `已选择了 ${selectedRows.size} `
: `已选择了 ${selectedRows.size} `}
</span>
{!allRowsSelected && totalRows > allRows.length && (
<Button type="link" onClick={() => onSelectAllRows()}>
Select all {totalRows} rows
选择所有 {totalRows}
</Button>
)}
</div>
Expand All @@ -370,7 +370,7 @@ const RowHeader = ({ table, sorts, filters }: RowHeaderProps) => {
disabled={isExporting}
onClick={onRowsExportCSV}
>
Export to CSV
导出为 CSV
</Button>
{editable && (
<Tooltip.Root delayDuration={0}>
Expand All @@ -383,10 +383,10 @@ const RowHeader = ({ table, sorts, filters }: RowHeaderProps) => {
disabled={allRowsSelected && isImpersonatingRole}
>
{allRowsSelected
? `Delete ${totalRows} rows`
? `删除 ${totalRows} `
: selectedRows.size > 1
? `Delete ${selectedRows.size} rows`
: `Delete ${selectedRows.size} row`}
? `删除 ${selectedRows.size} `
: `删除 ${selectedRows.size} `}
</Button>
</Tooltip.Trigger>

Expand All @@ -401,7 +401,7 @@ const RowHeader = ({ table, sorts, filters }: RowHeaderProps) => {
].join(' ')}
>
<span className="text-xs text-foreground">
Table truncation is not supported when impersonating a role
模拟角色不支持清空表操作
</span>
</div>
</Tooltip.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const RefreshButton = ({ table, isRefetching }: RefreshButtonProps) => {
icon={<RefreshCw className="text-foreground-muted" strokeWidth={1.5} />}
onClick={() => onClick()}
>
Refresh
刷新
</Button>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export const FilterOperatorOptions = [
{ value: '=', label: 'equals', preLabel: '[ = ]', abbrev: 'eq' },
{ value: '<>', label: 'not equal', preLabel: '[ <> ]', abbrev: 'neq' },
{ value: '>', label: 'greater than', preLabel: '[ > ]', abbrev: 'gt' },
{ value: '<', label: 'less than', preLabel: '[ < ]', abbrev: 'lt' },
{ value: '>=', label: 'greater than or equal', preLabel: '[ >= ]', abbrev: 'gte' },
{ value: '<=', label: 'less than or equal', preLabel: '[ <= ]', abbrev: 'lte' },
{ value: '~~', label: 'like operator', preLabel: '[ ~~ ]', abbrev: 'like' },
{ value: '~~*', label: 'ilike operator', preLabel: '[ ~~* ]', abbrev: 'ilike' },
{ value: 'in', label: 'one of a list of values', preLabel: '[ in ]', abbrev: 'in' },
{ value: '=', label: '等于', preLabel: '[ = ]', abbrev: 'eq' },
{ value: '<>', label: '不等于', preLabel: '[ <> ]', abbrev: 'neq' },
{ value: '>', label: '大于', preLabel: '[ > ]', abbrev: 'gt' },
{ value: '<', label: '小于', preLabel: '[ < ]', abbrev: 'lt' },
{ value: '>=', label: '大于等于', preLabel: '[ >= ]', abbrev: 'gte' },
{ value: '<=', label: '小于等于', preLabel: '[ <= ]', abbrev: 'lte' },
{ value: '~~', label: '模糊匹配', preLabel: '[ ~~ ]', abbrev: 'like' },
{ value: '~~*', label: '不区分大小写的模糊匹配', preLabel: '[ ~~* ]', abbrev: 'ilike' },
{ value: 'in', label: '属于', preLabel: '[ in ]', abbrev: 'in' },
{
value: 'is',
label: 'checking for (null,not null,true,false)',
label: '检查是否为(null, not null, true, false)',
preLabel: '[ is ]',
abbrev: 'is',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const FilterPopover = ({ table, filters, setParams }: FilterPopoverProps) => {

const btnText =
(filters || []).length > 0
? `Filtered by ${filters.length} rule${filters.length > 1 ? 's' : ''}`
: 'Filter'
? `已按${filters.length}个条件筛选`
: '筛选'

const onApplyFilters = (appliedFilters: Filter[]) => {
setParams((prevParams) => {
Expand Down Expand Up @@ -130,22 +130,26 @@ const FilterOverlay = ({ table, filters: filtersFromUrl, onApplyFilters }: Filte
))}
{filters.length == 0 && (
<div className="space-y-1 px-3">
<h5 className="text-sm text-foreground-light">No filters applied to this view</h5>
<p className="text-xs text-foreground-lighter">Add a column below to filter the view</p>
<h5 className="text-sm text-foreground-light">
此视图未应用任何筛选条件
</h5>
<p className="text-xs text-foreground-lighter">
请在下方添加列以筛选此视图
</p>
</div>
)}
</div>
<PopoverSeparator_Shadcn_ />
<div className="px-3 flex flex-row justify-between">
<Button icon={<Plus />} type="text" onClick={onAddFilter}>
Add filter
添加筛选条件
</Button>
<Button
disabled={isEqual(filters, initialFilters)}
type="default"
onClick={() => onApplyFilters(filters)}
>
Apply filter
应用筛选条件
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const FilterRow = ({ table, filter, filterIdx, onChange, onDelete, onKeyDown }:
? 'yyyy-mm-dd hh:mm:ss+zz'
: column?.format === 'timestamp'
? 'yyyy-mm-dd hh:mm:ss'
: 'Enter a value'
: '输入值'

return (
<div className="flex w-full items-center justify-between gap-x-1 px-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const SortPopover = ({ table, sorts, setParams }: SortPopoverProps) => {

const btnText =
(sorts || []).length > 0
? `Sorted by ${sorts.length} rule${sorts.length > 1 ? 's' : ''}`
: 'Sort'
? `已按${sorts.length}条规则排序`
: '排序'

const onApplySorts = (appliedSorts: Sort[]) => {
setParams((prevParams) => {
Expand Down Expand Up @@ -128,8 +128,8 @@ const SortOverlay = ({ table, sorts: sortsFromUrl, onApplySorts }: SortOverlayPr
))}
{sorts.length === 0 && (
<div className="space-y-1 px-3">
<h5 className="text-sm text-foreground-light">No sorts applied to this view</h5>
<p className="text-xs text-foreground-lighter">Add a column below to sort the view</p>
<h5 className="text-sm text-foreground-light">此视图未应用任何排序规则</h5>
<p className="text-xs text-foreground-lighter">在下方添加一列,对视图进行排序</p>
</div>
)}

Expand All @@ -149,19 +149,19 @@ const SortOverlay = ({ table, sorts: sortsFromUrl, onApplySorts }: SortOverlayPr
className="sb-grid-dropdown__item-trigger"
data-testid="table-editor-pick-column-to-sort-button"
>
<span>Pick {sorts.length > 1 ? 'another' : 'a'} column to sort by</span>
<span>选择{sorts.length > 1 ? '另一列' : '一列'}对视图进行排序</span>
</Button>
</DropdownControl>
) : (
<p className="text-sm text-foreground-light">All columns have been added</p>
<p className="text-sm text-foreground-light">所有列都已添加</p>
)}
<div className="flex items-center">
<Button
disabled={isEqual(sorts, initialSorts)}
type="default"
onClick={() => onApplySorts(sorts)}
>
Apply sorting
应用排序规则
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ const SortRow = ({ table, index, columnName, sort, onDelete, onToggle, onDrag }:
<div className="grow">
<span className="flex grow items-center gap-1 truncate text-sm text-foreground">
<span className="text-xs text-foreground-lighter">
{index > 0 ? 'then by' : 'sort by'}
{index > 0 ? '然后按' : '排序按'}
</span>
{column.name}
</span>
</div>
<div className="flex items-center gap-1">
<label className="text-xs text-foreground-lighter">ascending:</label>
<label className="text-xs text-foreground-lighter">升序:</label>
<Toggle
size="tiny"
layout="flex"
Expand Down
Loading

0 comments on commit 81a8aa7

Please sign in to comment.