-
Notifications
You must be signed in to change notification settings - Fork 504
[CB] Remove tooltips from context menu #4033
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
Merged
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
93a598b
dbeaver/pro#7772 adds truncated tooltips for context menus
sergeyteleshev 285b6b7
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
sergeyteleshev e64ad4f
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
sergeyteleshev a7365de
dbeaver/pro#7772 adds " ... " for long labels
sergeyteleshev 178dfe8
adds unit tests
sergeyteleshev 8fa917c
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
sergeyteleshev e0e4162
Update webapp/packages/core-blocks/src/Menu/MenuItemElement.tsx
sergeyteleshev 6f02892
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
sergeyteleshev 9732955
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
dariamarutkina 67ad19b
adds binding for delete row
sergeyteleshev c8455bd
removes tooltips
sergeyteleshev f423efe
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
sergeyteleshev b2eb320
fixes tree filters clipping
sergeyteleshev 459dfab
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
sergeyteleshev cd3ee3d
clips only names, not whole labels
sergeyteleshev 1e01d04
clips only names, not whole labels [2]
sergeyteleshev f3c996d
reverts getBindingLabels + fixes the os specific keys to show it first
sergeyteleshev 34d1696
clips only names, not whole labels [3]
sergeyteleshev 8743624
dbeaver/pro#7772 simplifies keys helpers logic
sergeyteleshev 637f675
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
dariamarutkina a3c72c3
Merge branch 'devel' into 7772-cb-remove-tooltips-from-context-menu
dariamarutkina 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
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
104 changes: 104 additions & 0 deletions
104
webapp/packages/core-view/src/Menu/getMenuLabelClipped.test.ts
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,104 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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 { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { getMenuLabelClipped } from './getMenuLabelClipped.js'; | ||
|
|
||
| describe('getMenuLabelClipped', () => { | ||
| it('should return original label and no tooltip when label is shorter than limiter', () => { | ||
| const result = getMenuLabelClipped('Short label', 8, 30); | ||
| expect(result.clippedLabel).toBe('Short label'); | ||
| expect(result.tooltip).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should clip label and return tooltip when label exceeds limiter', () => { | ||
| const longLabel = 'This is a very long label that exceeds the limiter'; | ||
| const result = getMenuLabelClipped(longLabel, 8, 30); | ||
| expect(result.clippedLabel).not.toBe(longLabel); | ||
| expect(result.clippedLabel).toContain(' ... '); | ||
| expect(result.tooltip).toBe(longLabel); | ||
| }); | ||
|
|
||
| it('should use default sideLength of 8 when not provided', () => { | ||
| const longLabel = 'This is a very long label that exceeds the limiter'; | ||
| const result = getMenuLabelClipped(longLabel, undefined, 30); | ||
| expect(result.clippedLabel).toMatch(/^.{8} \.\.\. .{8}$/); | ||
| expect(result.tooltip).toBe(longLabel); | ||
| }); | ||
|
|
||
| it('should use default limiter of 30 when not provided', () => { | ||
| const label = '12345678901234567890123456789'; // exactly 29 characters | ||
| const result = getMenuLabelClipped(label, 8); | ||
| expect(result.clippedLabel).toBe(label); | ||
| expect(result.tooltip).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should use custom sideLength', () => { | ||
| const longLabel = 'This is a very long label that exceeds the limiter'; | ||
| const result = getMenuLabelClipped(longLabel, 5, 30); | ||
| expect(result.clippedLabel).toMatch(/^.{5} \.\.\. .{5}$/); | ||
| expect(result.tooltip).toBe(longLabel); | ||
| }); | ||
|
|
||
| it('should use custom limiter', () => { | ||
| const label = '1234567890123456789'; // exactly 19 characters | ||
| const result = getMenuLabelClipped(label, 8, 20); | ||
| expect(result.clippedLabel).toBe(label); | ||
| expect(result.tooltip).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should handle label exactly at limiter length', () => { | ||
| const label = '123456789012345678901234567890'; // exactly 30 characters | ||
| const result = getMenuLabelClipped(label, 8, 30); | ||
| expect(result.clippedLabel).toBe('12345678 ... 34567890'); | ||
| expect(result.tooltip).toBe(label); | ||
| }); | ||
|
|
||
| it('should handle label one character longer than limiter', () => { | ||
| const label = '1234567890123456789012345678901'; // 31 characters | ||
| const result = getMenuLabelClipped(label, 8, 30); | ||
| expect(result.clippedLabel).not.toBe(label); | ||
| expect(result.clippedLabel).toContain(' ... '); | ||
| expect(result.tooltip).toBe(label); | ||
| }); | ||
|
|
||
| it('should handle very long labels', () => { | ||
| const veryLongLabel = 'A'.repeat(100); | ||
| const result = getMenuLabelClipped(veryLongLabel, 8, 30); | ||
| expect(result.clippedLabel.length).toBeLessThan(veryLongLabel.length); | ||
| expect(result.clippedLabel).toContain(' ... '); | ||
| expect(result.tooltip).toBe(veryLongLabel); | ||
| }); | ||
|
|
||
| it('should handle empty string', () => { | ||
| const result = getMenuLabelClipped('', 8, 30); | ||
| expect(result.clippedLabel).toBe(''); | ||
| expect(result.tooltip).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should handle sideLength of 0', () => { | ||
| const longLabel = 'This is a very long label that exceeds the limiter'; | ||
| const result = getMenuLabelClipped(longLabel, 0, 30); | ||
| expect(result.clippedLabel).toContain(' ... '); | ||
| expect(result.tooltip).toBe(longLabel); | ||
| }); | ||
|
|
||
| it('should handle very small sideLength', () => { | ||
| const longLabel = 'This is a very long label that exceeds the limiter'; | ||
| const result = getMenuLabelClipped(longLabel, 2, 30); | ||
| expect(result.clippedLabel).toMatch(/^.{2} \.\.\. .{2}$/); | ||
| expect(result.tooltip).toBe(longLabel); | ||
| }); | ||
|
|
||
| it('should handle large sideLength', () => { | ||
| const longLabel = 'This is a very long label that exceeds the limiter'; | ||
| const result = getMenuLabelClipped(longLabel, 15, 30); | ||
| expect(result.clippedLabel).toMatch(/^.{15} \.\.\. .{15}$/); | ||
| expect(result.tooltip).toBe(longLabel); | ||
| }); | ||
| }); |
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,19 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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 { replaceMiddle } from '@cloudbeaver/core-utils'; | ||
|
|
||
| export function getMenuLabelClipped( | ||
| label: string, | ||
| sideLength: number = 8, | ||
| limiter: number = 30, | ||
| ): { clippedLabel: string; tooltip: string | undefined } { | ||
| const clippedLabel = replaceMiddle(label, ' ... ', sideLength, limiter); | ||
| const tooltip = clippedLabel !== label ? label : undefined; | ||
|
|
||
| return { clippedLabel, tooltip }; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.