@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.
- package/package.json +3 -3
- package/src/@types/custom.d.ts +8 -0
- package/src/scripts/dataset/mutations/__tests__/update-permissions.spec.jsx +2 -1
- package/src/scripts/dataset/mutations/update-permissions.tsx +1 -9
- package/src/scripts/routes.tsx +4 -0
- package/src/scripts/users/__tests__/user-account-view.spec.tsx +69 -0
- package/src/scripts/users/__tests__/user-card.spec.tsx +95 -0
- package/src/scripts/users/__tests__/user-query.spec.tsx +60 -0
- package/src/scripts/users/__tests__/user-routes.spec.tsx +71 -0
- package/src/scripts/users/__tests__/user-tabs.spec.tsx +87 -0
- package/src/scripts/users/components/close-button.tsx +20 -0
- package/src/scripts/users/components/edit-button.tsx +20 -0
- package/src/scripts/users/components/edit-list.tsx +79 -0
- package/src/scripts/users/components/edit-string.tsx +49 -0
- package/src/scripts/users/components/editable-content.tsx +63 -0
- package/src/scripts/users/scss/editable-content.scss +15 -0
- package/src/scripts/users/scss/user-meta-blocks.scss +14 -0
- package/src/scripts/users/scss/useraccountview.module.scss +20 -0
- package/src/scripts/users/scss/usercard.module.scss +24 -0
- package/src/scripts/users/scss/usercontainer.module.scss +38 -0
- package/src/scripts/users/scss/usertabs.module.scss +63 -0
- package/src/scripts/users/user-account-view.tsx +62 -0
- package/src/scripts/users/user-card.tsx +84 -0
- package/src/scripts/users/user-container.tsx +48 -0
- package/src/scripts/users/user-datasets-view.tsx +53 -0
- package/src/scripts/users/user-notifications-view.tsx +12 -0
- package/src/scripts/users/user-query.tsx +80 -0
- package/src/scripts/users/user-routes.tsx +45 -0
- package/src/scripts/users/user-tabs.tsx +70 -0
- 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
|
+
}
|