@openneuro/app 4.29.7 → 4.29.9

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.
Files changed (30) hide show
  1. package/package.json +3 -3
  2. package/src/@types/custom.d.ts +8 -0
  3. package/src/scripts/dataset/mutations/__tests__/update-permissions.spec.jsx +2 -1
  4. package/src/scripts/dataset/mutations/update-permissions.tsx +1 -9
  5. package/src/scripts/routes.tsx +4 -0
  6. package/src/scripts/users/__tests__/user-account-view.spec.tsx +69 -0
  7. package/src/scripts/users/__tests__/user-card.spec.tsx +95 -0
  8. package/src/scripts/users/__tests__/user-query.spec.tsx +60 -0
  9. package/src/scripts/users/__tests__/user-routes.spec.tsx +71 -0
  10. package/src/scripts/users/__tests__/user-tabs.spec.tsx +87 -0
  11. package/src/scripts/users/components/close-button.tsx +20 -0
  12. package/src/scripts/users/components/edit-button.tsx +20 -0
  13. package/src/scripts/users/components/edit-list.tsx +79 -0
  14. package/src/scripts/users/components/edit-string.tsx +49 -0
  15. package/src/scripts/users/components/editable-content.tsx +63 -0
  16. package/src/scripts/users/scss/editable-content.scss +15 -0
  17. package/src/scripts/users/scss/user-meta-blocks.scss +14 -0
  18. package/src/scripts/users/scss/useraccountview.module.scss +20 -0
  19. package/src/scripts/users/scss/usercard.module.scss +24 -0
  20. package/src/scripts/users/scss/usercontainer.module.scss +38 -0
  21. package/src/scripts/users/scss/usertabs.module.scss +63 -0
  22. package/src/scripts/users/user-account-view.tsx +62 -0
  23. package/src/scripts/users/user-card.tsx +84 -0
  24. package/src/scripts/users/user-container.tsx +48 -0
  25. package/src/scripts/users/user-datasets-view.tsx +53 -0
  26. package/src/scripts/users/user-notifications-view.tsx +12 -0
  27. package/src/scripts/users/user-query.tsx +80 -0
  28. package/src/scripts/users/user-routes.tsx +45 -0
  29. package/src/scripts/users/user-tabs.tsx +70 -0
  30. package/src/scripts/utils/validationUtils.ts +9 -0
@@ -0,0 +1,70 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { NavLink, useLocation } from "react-router-dom";
3
+ import styles from "./scss/usertabs.module.scss";
4
+
5
+ export interface UserAccountTabsProps {
6
+ hasEdit: boolean;
7
+ }
8
+
9
+ export const UserAccountTabs: React.FC<UserAccountTabsProps> = ({ hasEdit }) => {
10
+ const ulRef = useRef<HTMLUListElement>(null);
11
+ const [activePosition, setActivePosition] = useState<number>(0);
12
+ const [clicked, setClicked] = useState(false);
13
+ const location = useLocation();
14
+
15
+ useEffect(() => {
16
+ const activeLink = ulRef.current?.querySelector(`.${styles.active}`) as HTMLElement;
17
+ if (activeLink) {
18
+ const li = activeLink.parentElement as HTMLElement;
19
+ setActivePosition(li.offsetTop);
20
+ }
21
+ }, [location]);
22
+
23
+ const handleClick = () => {
24
+
25
+ setClicked(true);
26
+
27
+ };
28
+
29
+ if (!hasEdit) return null;
30
+
31
+ return (
32
+ <div className={styles.userAccountTabLinks}>
33
+ <ul
34
+ ref={ulRef}
35
+ className={`${clicked ? "clicked" : ""} ${styles.userAccountTabLinks}`}
36
+ style={{ "--active-offset": `${activePosition}px` } as React.CSSProperties}
37
+ >
38
+ <li>
39
+ <NavLink
40
+ to=""
41
+ end
42
+ className={({ isActive }) => (isActive ? styles.active : "")}
43
+ onClick={handleClick}
44
+ >
45
+ User Datasets
46
+ </NavLink>
47
+ </li>
48
+ <li>
49
+ <NavLink
50
+ data-testid="user-notifications-tab"
51
+ to="notifications"
52
+ className={({ isActive }) => (isActive ? styles.active : "")}
53
+ onClick={handleClick}
54
+ >
55
+ User Notifications
56
+ </NavLink>
57
+ </li>
58
+ <li>
59
+ <NavLink
60
+ to="account"
61
+ className={({ isActive }) => (isActive ? styles.active : "")}
62
+ onClick={handleClick}
63
+ >
64
+ Account Info
65
+ </NavLink>
66
+ </li>
67
+ </ul>
68
+ </div>
69
+ );
70
+ };
@@ -0,0 +1,9 @@
1
+
2
+ /**
3
+ * Validates an ORCID.
4
+ * @param orcid - The ORCID string to validate.
5
+ * @returns `true` if the ORCID is valid, `false` otherwise.
6
+ */
7
+ export function isValidOrcid(orcid: string): boolean {
8
+ return /^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]$/.test(orcid || '');
9
+ }