Skip to content
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

CB-5085 make errors focusable #2585

Merged
merged 6 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webapp/packages/core-blocks/src/DisplayError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const DisplayError = observer<Props>(function DisplayError({ root, childr
const stack = errorInfo?.componentStack || error?.stack;

return (
<div className={s(styles, { error: true, root }, className)}>
<div role="alert" tabIndex={0} className={s(styles, { error: true, root }, className)}>
<div className={s(styles, { errorInnerBlock: true })}>
<NotificationMark className={s(styles, { notificationMark: true })} type={ENotificationType.Error} />
<p>Something went wrong.</p>
Expand Down
12 changes: 7 additions & 5 deletions webapp/packages/core-blocks/src/ErrorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* you may not use this file except in compliance with the License.
*/
import { observer } from 'mobx-react-lite';

import { Button } from './Button';
import styles from './ErrorMessage.m.css';
import { IconOrImage } from './IconOrImage';
import { useTranslate } from './localization/useTranslate';
import { useS } from './useS';

import styles from './ErrorMessage.m.css';
import { s } from './s';
import { useS } from './useS';

interface Props {
hasDetails?: boolean;
Expand All @@ -26,9 +26,11 @@ export const ErrorMessage = observer<Props>(function ErrorMessage({ text, classN
const style = useS(styles);

return (
<div className={s(style, { message: true }, className)}>
<div role="status" tabIndex={0} aria-label={text} className={s(style, { message: true }, className)}>
<IconOrImage className={s(style, { errorIcon: true })} icon="/icons/error_icon_sm.svg" />
<div className={s(style, { messageBody: true })} title={text}>{text}</div>
<div className={s(style, { messageBody: true })} title={text}>
{text}
</div>
<div className={s(style, { messageActions: true })}>
{hasDetails && (
<Button type="button" mod={['outlined']} onClick={onShowDetails}>
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/core-blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,4 @@
export * from './usePasswordValidation';
export * from './manifest';
export * from './importLazyComponent';
export * from './Clickable';

Check warning on line 239 in webapp/packages/core-blocks/src/index.ts

View check run for this annotation

Jenkins-CI-integration / CheckStyle TypeScript Report

webapp/packages/core-blocks/src/index.ts#L239

Dont import/export .tsx files from .ts files directly, use React.lazy(). (@cloudbeaver/no-sync-component-import)
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ export const TableError = observer<Props>(function TableError({ model, loading,
}, [errorInfo, model.source.error]);

return (
<div className={s(style, { error: true, animated, collapsed: !errorInfo.display, errorHidden }, className)}>
<div
role="status"
aria-label={error.message}
tabIndex={0}
className={s(style, { error: true, animated, collapsed: !errorInfo.display, errorHidden }, className)}
>
<div className={s(style, { errorBody: true })}>
<IconOrImage className={s(style, { iconOrImage: true })} icon={icon} title={error.message} onClick={() => errorInfo.show()} />
<div className={s(style, { errorMessage: true })}>{error.message}</div>
Expand Down
11 changes: 8 additions & 3 deletions webapp/packages/plugin-user-profile/src/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { observer } from 'mobx-react-lite';

import { IconOrImage, s, useS, useTranslate } from '@cloudbeaver/core-blocks';
import { Clickable, IconOrImage, s, useS, useTranslate } from '@cloudbeaver/core-blocks';
import { useService } from '@cloudbeaver/core-di';
import type { UserInfo as IUserInfo } from '@cloudbeaver/core-sdk';

Expand All @@ -24,9 +24,14 @@ export const UserInfo = observer<Props>(function UserInfo({ info }) {
const style = useS(styles);

return (
<div className={s(style, { user: true })} title={translate('plugin_user_profile_menu')} onClick={() => userProfileOptionsPanelService.open()}>
<Clickable
as="div"
className={s(style, { user: true })}
title={translate('plugin_user_profile_menu')}
onClick={() => userProfileOptionsPanelService.open()}
>
<IconOrImage className={s(style, { iconOrImage: true })} icon="/icons/plugin_user_profile_m.svg" />
<div className={s(style, { userName: true })}>{info.displayName || info.userId}</div>
</div>
</Clickable>
);
});
Loading