-
Notifications
You must be signed in to change notification settings - Fork 504
7855 cb add setting use the users os formatting for numbersdates #4020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Wroud
merged 21 commits into
devel
from
7855-cb-add-setting---use-the-users-os-formatting-for-numbersdates
Jan 13, 2026
Merged
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
95ff5eb
dbeaver/pro#7855 feat: Add setting to use the user's OS formatting fo…
SychevAndrey 880ff06
dbeaver/pro#7855 refactor: update OS formatting option value in DataG…
SychevAndrey 507f577
dbeaver/pro#7855 feat: implement OS formatting for date and time in D…
SychevAndrey cf92bab
dbeaver/pro#7855 feat: implement user-specific formatting for numbers…
SychevAndrey 96a044d
dbeaver/pro#7855 feat: add translations
SychevAndrey 94f5493
dbeaver/pro#7855 style: update date formatter
SychevAndrey 48b74d8
dbeaver/pro#7855 feat: add locale-specific formatting options for Dat…
SychevAndrey fa54ba5
dbeaver/pro#7855 feat: add support for locale-specific formatting wit…
SychevAndrey efdac7c
dbeaver/pro#7855 refactor: move date type detection to the grid level
SychevAndrey 27240c5
dbeaver/pro#7855 refactor: simplify cell formatter selection logic
SychevAndrey f391586
Merge branch 'devel' into 7855-cb-add-setting---use-the-users-os-form…
SychevAndrey 9902a6e
Merge branch '7855-cb-add-setting---use-the-users-os-formatting-for-n…
SychevAndrey 543c687
dbeaver/pro#7855 refactor: move formatting to a separate context
SychevAndrey 01b1054
dbeaver/pro#7855 refactor: optimize extended date kind retrieval logic
SychevAndrey 7ce2168
Merge branch 'devel' into 7855-cb-add-setting---use-the-users-os-form…
SychevAndrey bf3dc5e
dbeaver/pro#7855 fix: tw class names
SychevAndrey af2257b
Merge branch 'devel' into 7855-cb-add-setting---use-the-users-os-form…
SychevAndrey c3694e7
Merge branch 'devel' into 7855-cb-add-setting---use-the-users-os-form…
SychevAndrey 3966098
dbeaver/pro#7855 refactor: change caching mechanism and other improve…
SychevAndrey 167de1e
Merge branch 'devel' into 7855-cb-add-setting---use-the-users-os-form…
mr-anton-t 7c82e1a
Merge branch 'devel' into 7855-cb-add-setting---use-the-users-os-form…
mr-anton-t File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/DateTimeFormatter.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2024 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
|
|
||
| .dateFormatter { | ||
| display: flex; | ||
| align-items: center; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .dateFormatterValue { | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } |
59 changes: 59 additions & 0 deletions
59
.../plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/DateTimeFormatter.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2025 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
| import { observer } from 'mobx-react-lite'; | ||
| import { useContext } from 'react'; | ||
|
|
||
| import { getComputed, s, useS } from '@cloudbeaver/core-blocks'; | ||
| import { NullFormatter as GridNullFormatter } from '@cloudbeaver/plugin-data-grid'; | ||
|
|
||
| import { CellContext } from '../../CellRenderer/CellContext.js'; | ||
| import { TableDataContext } from '../../TableDataContext.js'; | ||
| import styles from './DateTimeFormatter.module.css'; | ||
| import type { ICellFormatterProps } from '../ICellFormatterProps.js'; | ||
|
|
||
| export const DateTimeFormatter = observer<ICellFormatterProps>(function DateTimeFormatter() { | ||
| const tableDataContext = useContext(TableDataContext); | ||
| const cellContext = useContext(CellContext); | ||
| const style = useS(styles); | ||
|
|
||
| if (!cellContext.cell) { | ||
| return null; | ||
| } | ||
|
|
||
| const formatter = tableDataContext.format; | ||
| const valueHolder = getComputed(() => formatter.get(cellContext.cell!)); | ||
| const nullValue = getComputed(() => formatter.isNull(valueHolder)); | ||
| const displayValue = getComputed(() => formatter.getDisplayString(valueHolder)); | ||
|
|
||
| if (nullValue) { | ||
| return <GridNullFormatter />; | ||
| } | ||
|
|
||
| let value = displayValue; | ||
|
|
||
| if (tableDataContext.useUserFormatting) { | ||
| const isDateOnly = /^\d{4}-\d{2}-\d{2}$/.test(displayValue); | ||
| const date = new Date(displayValue); | ||
|
|
||
| if (!isNaN(date.getTime())) { | ||
| let formatter = tableDataContext.useUserFormatting.dateTime; | ||
|
|
||
| if (isDateOnly) { | ||
| formatter = tableDataContext.useUserFormatting.dateOnly; | ||
| } | ||
|
|
||
| value = formatter.format(date); | ||
| } | ||
| } | ||
sergeyteleshev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return ( | ||
| <div className={s(style, { dateFormatter: true })}> | ||
| <div className={s(style, { dateFormatterValue: true })}>{value}</div> | ||
| </div> | ||
| ); | ||
| }); | ||
18 changes: 18 additions & 0 deletions
18
...in-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/NumberFormatter.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2024 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
|
|
||
| .numberFormatter { | ||
| display: flex; | ||
| align-items: center; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .numberFormatterValue { | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } | ||
Wroud marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
53 changes: 53 additions & 0 deletions
53
...es/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/NumberFormatter.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2025 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
| import { observer } from 'mobx-react-lite'; | ||
| import { useContext } from 'react'; | ||
|
|
||
| import { getComputed, s, useS } from '@cloudbeaver/core-blocks'; | ||
| import { NullFormatter as GridNullFormatter } from '@cloudbeaver/plugin-data-grid'; | ||
|
|
||
| import { CellContext } from '../../CellRenderer/CellContext.js'; | ||
| import { TableDataContext } from '../../TableDataContext.js'; | ||
| import type { ICellFormatterProps } from '../ICellFormatterProps.js'; | ||
|
|
||
| import styles from './NumberFormatter.module.css'; | ||
|
|
||
| export const NumberFormatter = observer<ICellFormatterProps>(function NumberFormatter() { | ||
| const tableDataContext = useContext(TableDataContext); | ||
| const cellContext = useContext(CellContext); | ||
| const style = useS(styles); | ||
|
|
||
| if (!cellContext.cell) { | ||
| return null; | ||
| } | ||
|
|
||
| const formatter = tableDataContext.format; | ||
| const valueHolder = getComputed(() => formatter.get(cellContext.cell!)); | ||
| const nullValue = getComputed(() => formatter.isNull(valueHolder)); | ||
| const displayValue = getComputed(() => formatter.getDisplayString(valueHolder)); | ||
|
|
||
| if (nullValue) { | ||
| return <GridNullFormatter />; | ||
| } | ||
|
|
||
| let value = displayValue; | ||
|
|
||
| if (tableDataContext.useUserFormatting) { | ||
| const numberValue = Number(displayValue); | ||
|
|
||
| if (!isNaN(numberValue) && displayValue.trim() !== '') { | ||
| value = tableDataContext.useUserFormatting.number.format(numberValue); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div className={s(style, { numberFormatter: true })}> | ||
| <div className={s(style, { numberFormatterValue: true })}>{value}</div> | ||
| </div> | ||
| ); | ||
| }); | ||
sergeyteleshev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isDateOnly = /^\d{4}-\d{2}-\d{2}$/.test(displayValue);Is it really required? This will hit performance in the grid noticeably, at least create a regex outside of the render function.
new Date()should be able to parse a date correctly without time. Maybe you can simplify the check by checking the resulting Date object (probably it will have some constant time)(or just use unified formatter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it's probably enough to check this format only once for one of the cells because they all will have the same format, or maybe you can check it by column type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can put it on the data context level and set something like "extended datakind" for every column with TIME/DATE/DATETIME values. In the cell we will just get the datakind of the column and use the according formatter. Do you want me refactor like that?
Unfortunately, we can't rely on new Date to check the shape, so testing by regex or splitting is required. However, if we do it only on the TableDataContext level it should be not a problem.