tycho-components 0.23.4 → 0.23.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,5 @@ type Props = {
4
4
  mode: 'lexicon' | 'corpus' | 'parser';
5
5
  mobile?: boolean;
6
6
  };
7
- export default function HeaderNotifications({ uid, mode, mobile }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export default function HeaderNotifications({ uid, mode, mobile }: Props): import("react/jsx-runtime").JSX.Element | null;
8
8
  export {};
@@ -1,15 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { Trans, useTranslation } from 'react-i18next';
4
- import { useNavigate } from 'react-router-dom';
5
4
  import { Avatar, IconButton } from 'tycho-storybook';
6
5
  import DateUtils from '../../../functions/DateUtils';
7
6
  import CommentService from '../CommentService';
8
7
  import './style.scss';
9
8
  export default function HeaderNotifications({ uid, mode, mobile }) {
10
- const navigate = useNavigate();
11
9
  const { t } = useTranslation('comments');
12
10
  const [open, setOpen] = useState(false);
11
+ const [visible, setVisible] = useState(true);
13
12
  const [notifications, setNotifications] = useState();
14
13
  const [comments, setComments] = useState();
15
14
  const [tab, setTab] = useState('unread');
@@ -23,16 +22,22 @@ export default function HeaderNotifications({ uid, mode, mobile }) {
23
22
  const serviceMethod = tab === 'read'
24
23
  ? CommentService.findReadNotifications
25
24
  : CommentService.findNotifications;
26
- serviceMethod(uid, mode).then((r) => {
25
+ serviceMethod(uid, mode)
26
+ .then((r) => {
27
27
  if (tab !== 'read') {
28
28
  setComments(r.data);
29
29
  }
30
30
  setNotifications(r.data);
31
+ })
32
+ .catch(() => {
33
+ setVisible(false);
31
34
  });
32
35
  };
33
36
  useEffect(() => {
34
37
  load();
35
38
  }, [uid, tab]);
39
+ if (!visible)
40
+ return null;
36
41
  return (_jsxs("div", { className: "ds-dropdown-container notifications-container", children: [_jsx(IconButton, { name: "notifications_active", className: comments && comments.length > 0 ? 'shake' : '', size: "medium", onClick: () => setOpen(!open), mode: mobile ? 'outlined' : 'filled' }), open && (_jsx("div", { className: "ds-dropdown-list", children: _jsxs("div", { className: "notifications-panel", children: [_jsxs("div", { className: "header", children: [_jsx("span", { children: t('notification.title') }), _jsx(IconButton, { name: "close", size: "small", mode: "ghost", onClick: () => setOpen(false) })] }), _jsxs("div", { className: "tabs", children: [_jsxs("button", { className: tab === 'unread' ? 'active-tab' : '', onClick: () => setTab('unread'), children: [t('notification.unread'), " (", comments?.length || 0, ")"] }), _jsx("button", { className: tab === 'read' ? 'active-tab' : '', onClick: () => setTab('read'), children: t('notification.all') })] }), _jsxs("div", { className: "content", children: [notifications &&
37
42
  notifications.map((not, idx) => (_jsxs("div", { className: "item", onClick: () => handleOpen(not), children: [_jsx(Avatar, { src: not.picture, size: "small" }), _jsxs("div", { className: "message", children: [_jsx("span", { className: "text", children: _jsx(Trans, { t: t, i18nKey: "notification.text", values: {
38
43
  user: not.name,
@@ -3,5 +3,5 @@ import './style.scss';
3
3
  type Props = {
4
4
  document: Document;
5
5
  };
6
- export default function InconsistencyActions({ document }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export default function InconsistencyActions({ document }: Props): import("react/jsx-runtime").JSX.Element | null;
7
7
  export {};
@@ -11,6 +11,7 @@ export default function InconsistencyActions({ document }) {
11
11
  const { getCorpus, hasParameter } = useCorpusUtils();
12
12
  const [openInconsistency, setOpenInconsistency] = useState(false);
13
13
  const [loading, setLoading] = useState(true);
14
+ const [loadFailed, setLoadFailed] = useState(false);
14
15
  const [inconsistentData, setInconsistentData] = useState();
15
16
  const hasInconsistencies = (data) => {
16
17
  return Object.keys(data).some((d) => {
@@ -21,6 +22,7 @@ export default function InconsistencyActions({ document }) {
21
22
  };
22
23
  const checkInconsistency = () => {
23
24
  setLoading(true);
25
+ setLoadFailed(false);
24
26
  if (hasParameter(getCorpus(), 'useEditionTiers')) {
25
27
  InconsistencyService.verifyForDocument(document.uid)
26
28
  .then((r) => {
@@ -30,6 +32,10 @@ export default function InconsistencyActions({ document }) {
30
32
  else {
31
33
  setInconsistentData(undefined);
32
34
  }
35
+ })
36
+ .catch(() => {
37
+ setLoadFailed(true);
38
+ setInconsistentData(undefined);
33
39
  })
34
40
  .finally(() => {
35
41
  setLoading(false);
@@ -64,5 +70,8 @@ export default function InconsistencyActions({ document }) {
64
70
  title: t('label.consistent'),
65
71
  };
66
72
  }, [loading, inconsistentData, t]);
73
+ if (loadFailed) {
74
+ return null;
75
+ }
67
76
  return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "action-line", onClick: actionOption.onClick, role: actionOption.onClick ? 'button' : undefined, children: [_jsx("div", { className: "action-button", children: _jsx(Icon, { name: actionOption.iconName, size: "medium", className: actionOption.iconClassName }) }), _jsxs("div", { className: "action-desc", children: [_jsx("span", { className: "title", children: actionOption.title }), actionOption.description && _jsx("span", { children: actionOption.description })] })] }), openInconsistency && inconsistentData && (_jsx(Inconsistency, { data: inconsistentData, onClose: () => setOpenInconsistency(false) }))] }));
68
77
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.23.4",
4
+ "version": "0.23.6",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {