@unitedstatespowersquadrons/components 1.4.4 → 1.4.5-2
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/Admin/AdminLink.tsx +18 -16
- package/Admin/Impersonation.tsx +36 -42
- package/package.json +1 -1
package/Admin/AdminLink.tsx
CHANGED
|
@@ -3,7 +3,8 @@ import { createUseStyles } from "react-jss";
|
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import AdminItem from "./AdminItem";
|
|
5
5
|
import Colors, { ButtonColorName } from "../Colors";
|
|
6
|
-
import
|
|
6
|
+
import { FontAwesomeProps } from "../FontAwesomeIcon";
|
|
7
|
+
import IconButton from "../IconButton";
|
|
7
8
|
import Styles from "../Styles";
|
|
8
9
|
|
|
9
10
|
// Styles aren't tree-shaken, but keeping every color variant here means apps
|
|
@@ -48,13 +49,6 @@ const useStyles = createUseStyles({
|
|
|
48
49
|
cursor: "pointer",
|
|
49
50
|
},
|
|
50
51
|
left: { textAlign: "left" },
|
|
51
|
-
link: {
|
|
52
|
-
...Styles.flexRow,
|
|
53
|
-
color: "inherit",
|
|
54
|
-
flex: 1,
|
|
55
|
-
justifyContent: "left",
|
|
56
|
-
textDecoration: "none",
|
|
57
|
-
},
|
|
58
52
|
orange: {
|
|
59
53
|
"& button": { ...Styles.orange },
|
|
60
54
|
"&:hover": {
|
|
@@ -85,6 +79,12 @@ const useStyles = createUseStyles({
|
|
|
85
79
|
paddingLeft: "0",
|
|
86
80
|
paddingRight: "0",
|
|
87
81
|
},
|
|
82
|
+
subMenuLink: {
|
|
83
|
+
color: "inherit",
|
|
84
|
+
cursor: "pointer",
|
|
85
|
+
flex: 1,
|
|
86
|
+
textDecoration: "none",
|
|
87
|
+
},
|
|
88
88
|
subMenuText: {
|
|
89
89
|
animation: "fadeIn 100ms",
|
|
90
90
|
fontSize: "1.5em",
|
|
@@ -109,14 +109,16 @@ const AdminLink = (props: Props) => {
|
|
|
109
109
|
|
|
110
110
|
return(
|
|
111
111
|
<AdminItem className={classNames(classes.item, classes.left, colorClassName)}>
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
<IconButton
|
|
113
|
+
className={classNames(classes.subMenuIcon, className)}
|
|
114
|
+
fa={fa}
|
|
115
|
+
href={href}
|
|
116
|
+
icon={icon}
|
|
117
|
+
mode={mode}
|
|
118
|
+
style={style}
|
|
119
|
+
title={title}
|
|
120
|
+
/>
|
|
121
|
+
<a className={classes.subMenuLink} href={href} title={title}>
|
|
120
122
|
<span className={classNames(classes.subMenuText, className)}>{subMenu}</span>
|
|
121
123
|
</a>
|
|
122
124
|
</AdminItem>
|
package/Admin/Impersonation.tsx
CHANGED
|
@@ -1,45 +1,28 @@
|
|
|
1
|
-
import React, { useRef } from "react";
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
2
|
import { createUseStyles } from "react-jss";
|
|
3
|
-
import classNames from "classnames";
|
|
4
3
|
import AdminItem from "./AdminItem";
|
|
5
4
|
import { AdminAction, Impersonation as ImpersonationType } from "./types";
|
|
6
5
|
import ActionButton from "../ActionButton";
|
|
7
|
-
import FontAwesomeIcon from "../FontAwesomeIcon";
|
|
8
6
|
import IconButton from "../IconButton";
|
|
9
7
|
import Styles from "../Styles";
|
|
10
8
|
import { OnClickHandler, OnClickOrKeyboardHandler } from "../types";
|
|
11
9
|
|
|
12
10
|
const useStyles = createUseStyles({
|
|
13
11
|
button: { paddingRight: "0.75em !important" },
|
|
14
|
-
center: {
|
|
15
|
-
"& svg": { margin: "0 auto" },
|
|
16
|
-
justifyContent: "center",
|
|
17
|
-
},
|
|
18
12
|
gray: { ...Styles.gray },
|
|
19
13
|
impersonation: {
|
|
14
|
+
alignItems: "center",
|
|
20
15
|
animation: "300ms ease-in",
|
|
21
16
|
display: "flex",
|
|
22
17
|
flexDirection: "column",
|
|
23
18
|
gap: "0.25em",
|
|
24
19
|
paddingBottom: "0.5em",
|
|
20
|
+
width: "100%",
|
|
25
21
|
},
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
display: "none",
|
|
29
|
-
opacity: "0",
|
|
30
|
-
transition: "opacity 0.5s ease-in-out",
|
|
31
|
-
},
|
|
32
|
-
"& > svg": { display: "block" },
|
|
33
|
-
"&:hover > div": {
|
|
34
|
-
display: "flex",
|
|
35
|
-
opacity: "1",
|
|
36
|
-
},
|
|
37
|
-
"&:hover > svg": { display: "none" },
|
|
38
|
-
},
|
|
39
|
-
left: { textAlign: "left" },
|
|
40
|
-
viewAsIcon: {
|
|
22
|
+
triggerIcon: {
|
|
23
|
+
"&:hover": { ...Styles.hover.purple },
|
|
41
24
|
...Styles.purple,
|
|
42
|
-
fontSize: "2em",
|
|
25
|
+
fontSize: "2em !important",
|
|
43
26
|
},
|
|
44
27
|
viewingAsIcon: {
|
|
45
28
|
"&:hover": { ...Styles.hover.red },
|
|
@@ -62,6 +45,7 @@ const buildImpersonation = (hooks: Hooks) => {
|
|
|
62
45
|
const classes = useStyles();
|
|
63
46
|
|
|
64
47
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
48
|
+
const [expanded, setExpanded] = useState(false);
|
|
65
49
|
|
|
66
50
|
const handleImpersonate: OnClickOrKeyboardHandler = event => {
|
|
67
51
|
if ("key" in event && event.key !== "Enter") { return; }
|
|
@@ -73,10 +57,13 @@ const buildImpersonation = (hooks: Hooks) => {
|
|
|
73
57
|
dispatch({ certificate, type: "impersonate" });
|
|
74
58
|
};
|
|
75
59
|
|
|
76
|
-
const
|
|
60
|
+
const handleCancelImpersonation: OnClickHandler = () => {
|
|
77
61
|
dispatch({ type: "cancelImpersonation" });
|
|
78
62
|
};
|
|
79
63
|
|
|
64
|
+
const handleExpand: OnClickHandler = () => setExpanded(true);
|
|
65
|
+
const handleCollapse: OnClickHandler = () => setExpanded(false);
|
|
66
|
+
|
|
80
67
|
if (impersonation) {
|
|
81
68
|
const { certificate, name } = impersonation;
|
|
82
69
|
|
|
@@ -87,7 +74,7 @@ const buildImpersonation = (hooks: Hooks) => {
|
|
|
87
74
|
className={classes.viewingAsIcon}
|
|
88
75
|
icon="user-group"
|
|
89
76
|
mode="duotone"
|
|
90
|
-
onClick={
|
|
77
|
+
onClick={handleCancelImpersonation}
|
|
91
78
|
title="Cancel Impersonation"
|
|
92
79
|
/>
|
|
93
80
|
<div>{name}</div>
|
|
@@ -96,18 +83,32 @@ const buildImpersonation = (hooks: Hooks) => {
|
|
|
96
83
|
);
|
|
97
84
|
}
|
|
98
85
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
if (!expanded) {
|
|
87
|
+
return(
|
|
88
|
+
<AdminItem key="collapsed">
|
|
89
|
+
<IconButton
|
|
90
|
+
className={classes.triggerIcon}
|
|
91
|
+
color="purple"
|
|
92
|
+
icon="user-group"
|
|
93
|
+
mode="duotone"
|
|
94
|
+
onClick={handleExpand}
|
|
95
|
+
title="Impersonate Member"
|
|
96
|
+
/>
|
|
97
|
+
</AdminItem>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
106
100
|
|
|
107
|
-
|
|
108
|
-
<
|
|
101
|
+
return(
|
|
102
|
+
<AdminItem className={classes.impersonation} key="expanded">
|
|
109
103
|
<div className="bold">View As:</div>
|
|
110
|
-
<
|
|
104
|
+
<IconButton
|
|
105
|
+
className={classes.triggerIcon}
|
|
106
|
+
color="purple"
|
|
107
|
+
icon="user-group"
|
|
108
|
+
mode="duotone"
|
|
109
|
+
onClick={handleCollapse}
|
|
110
|
+
title="Collapse"
|
|
111
|
+
/>
|
|
111
112
|
<input
|
|
112
113
|
maxLength={7}
|
|
113
114
|
onKeyDown={handleImpersonate}
|
|
@@ -124,13 +125,6 @@ const buildImpersonation = (hooks: Hooks) => {
|
|
|
124
125
|
size="small"
|
|
125
126
|
text="Impersonate"
|
|
126
127
|
/>
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
return(
|
|
131
|
-
<AdminItem className={classes.inactive}>
|
|
132
|
-
{collapsed}
|
|
133
|
-
{expanded}
|
|
134
128
|
</AdminItem>
|
|
135
129
|
);
|
|
136
130
|
};
|