@unitedstatespowersquadrons/components 1.4.5-1 → 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/Impersonation.tsx +36 -42
- package/package.json +1 -1
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
|
};
|