From 10ff04f39bfdbd5995d29cbfb6f58bd51214c7fd Mon Sep 17 00:00:00 2001 From: naumov Date: Tue, 29 Oct 2024 16:42:39 +0100 Subject: [PATCH] CB-5819 truncate titles --- webapp/packages/core-blocks/src/Link.module.css | 6 ++++++ webapp/packages/core-blocks/src/Link.tsx | 5 +++-- webapp/packages/core-blocks/src/Text.module.css | 12 ++++++++++++ webapp/packages/core-blocks/src/Text.tsx | 17 +++++++++++++++-- .../Users/Teams/TeamsTable/Team.tsx | 2 +- .../Users/Teams/TeamsTable/TeamEdit.tsx | 8 +++++--- .../Administration/Users/UsersTable/User.tsx | 2 +- .../Users/UsersTable/UserEdit.tsx | 7 +++++-- 8 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 webapp/packages/core-blocks/src/Text.module.css diff --git a/webapp/packages/core-blocks/src/Link.module.css b/webapp/packages/core-blocks/src/Link.module.css index e9a356eafb..da37b4afcc 100644 --- a/webapp/packages/core-blocks/src/Link.module.css +++ b/webapp/packages/core-blocks/src/Link.module.css @@ -10,6 +10,12 @@ display: inline; } + &.truncate { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + & a { position: relative; cursor: pointer; diff --git a/webapp/packages/core-blocks/src/Link.tsx b/webapp/packages/core-blocks/src/Link.tsx index c1c8c581b5..f4d4ab1a10 100644 --- a/webapp/packages/core-blocks/src/Link.tsx +++ b/webapp/packages/core-blocks/src/Link.tsx @@ -16,14 +16,15 @@ interface Props extends React.AnchorHTMLAttributes { wrapper?: boolean; indicator?: boolean; inline?: boolean; + truncate?: boolean; children?: React.ReactNode; } -export const Link = observer(function Link({ inline, wrapper, indicator, className, children, ...rest }) { +export const Link = observer(function Link({ inline, wrapper, indicator, truncate, className, children, ...rest }) { const styles = useS(style); return ( -
+
{indicator && } {children} diff --git a/webapp/packages/core-blocks/src/Text.module.css b/webapp/packages/core-blocks/src/Text.module.css new file mode 100644 index 0000000000..eafc194fc6 --- /dev/null +++ b/webapp/packages/core-blocks/src/Text.module.css @@ -0,0 +1,12 @@ +/* + * 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. + */ +.truncate { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} diff --git a/webapp/packages/core-blocks/src/Text.tsx b/webapp/packages/core-blocks/src/Text.tsx index 83b7e8b138..d0404bcdec 100644 --- a/webapp/packages/core-blocks/src/Text.tsx +++ b/webapp/packages/core-blocks/src/Text.tsx @@ -7,6 +7,19 @@ */ import { observer } from 'mobx-react-lite'; -export const Text: React.FC> = observer(function Text({ children, ...rest }) { - return
{children}
; +import { s } from './s.js'; +import classes from './Text.module.css'; +import { useS } from './useS.js'; + +interface Props extends React.HTMLAttributes { + truncate?: boolean; +} + +export const Text = observer(function Text({ truncate, children, className, ...rest }) { + const styles = useS(classes); + return ( +
+ {children} +
+ ); }); diff --git a/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/Team.tsx b/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/Team.tsx index 19ebfa994d..cd6db0813c 100644 --- a/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/Team.tsx +++ b/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/Team.tsx @@ -30,7 +30,7 @@ export const Team = observer(function Team({ team }) { teamsTableOptionsPanelService.open(team.teamId)}> - {team.teamId} + {team.teamId} {team.teamName || ''} diff --git a/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx b/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx index 566d31a3dc..23952f8c8a 100644 --- a/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx +++ b/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx @@ -8,7 +8,7 @@ import { observer } from 'mobx-react-lite'; import { TeamInfoMetaParametersResource, TeamsResource } from '@cloudbeaver/core-authentication'; -import { ColoredContainer, GroupBack, GroupTitle, useTranslate } from '@cloudbeaver/core-blocks'; +import { ColoredContainer, GroupBack, GroupTitle, Text, useTranslate } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { TeamForm } from '../TeamForm.js'; @@ -34,8 +34,10 @@ export const TeamEdit = observer(function TeamEdit({ item }) { - {translate('ui_edit')} - {data.config.teamName ? ` "${data.config.teamName}"` : ''} + + {translate('ui_edit')} + {data.config.teamName ? ` "${data.config.teamName}"` : ''} + diff --git a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/User.tsx b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/User.tsx index 51fa469d37..0b39dea5c1 100644 --- a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/User.tsx +++ b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/User.tsx @@ -67,7 +67,7 @@ export const User = observer(function User({ user, displayAuthRole, selec )} usersTableOptionsPanelService.open(user.userId)}> - {user.userId} + {user.userId} {displayAuthRole && ( diff --git a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx index 702b6b008e..f7de2e7db8 100644 --- a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx +++ b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx @@ -14,6 +14,7 @@ import { GroupTitle, Loader, type TableItemExpandProps, + Text, useExecutor, useTranslate, } from '@cloudbeaver/core-blocks'; @@ -55,8 +56,10 @@ export const UserEdit = observer>(function UserEdit - {translate('ui_edit')} - {state.state.userId ? ` "${state.state.userId}"` : ''} + + {translate('ui_edit')} + {state.state.userId ? ` "${state.state.userId}"` : ''} +