mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-11 03:52:59 +00:00
One edit user button per user
This commit is contained in:
@@ -10,6 +10,14 @@ import "./server-dashboard.css";
|
|||||||
import { timeSince } from "../../util/timeSince";
|
import { timeSince } from "../../util/timeSince";
|
||||||
import PaginationFooter from "../PaginationFooter/PaginationFooter";
|
import PaginationFooter from "../PaginationFooter/PaginationFooter";
|
||||||
|
|
||||||
|
const AccessServerButton = ({ userName, serverName }) => (
|
||||||
|
<a href={`/user/${userName}/${serverName || ""}`}>
|
||||||
|
<button className="btn btn-primary btn-xs" style={{ marginRight: 20 }}>
|
||||||
|
Access Server
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
|
||||||
const ServerDashboard = (props) => {
|
const ServerDashboard = (props) => {
|
||||||
// sort methods
|
// sort methods
|
||||||
var usernameDesc = (e) => e.sort((a, b) => (a.name > b.name ? 1 : -1)),
|
var usernameDesc = (e) => e.sort((a, b) => (a.name > b.name ? 1 : -1)),
|
||||||
@@ -145,6 +153,29 @@ const ServerDashboard = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const EditUserCell = ({ user, numServers, serverName }) => {
|
||||||
|
if (serverName) return null;
|
||||||
|
return (
|
||||||
|
<td rowspan={numServers}>
|
||||||
|
<button
|
||||||
|
className="btn btn-primary btn-xs"
|
||||||
|
style={{ marginRight: 20 }}
|
||||||
|
onClick={() =>
|
||||||
|
history.push({
|
||||||
|
pathname: "/edit-user",
|
||||||
|
state: {
|
||||||
|
username: user.name,
|
||||||
|
has_admin: user.admin,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Edit User
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container" data-testid="container">
|
<div className="container" data-testid="container">
|
||||||
{errorAlert != null ? (
|
{errorAlert != null ? (
|
||||||
@@ -354,18 +385,10 @@ const ServerDashboard = (props) => {
|
|||||||
serverName={server.name}
|
serverName={server.name}
|
||||||
userName={e.name}
|
userName={e.name}
|
||||||
/>
|
/>
|
||||||
<a
|
<AccessServerButton
|
||||||
href={`/user/${e.name}${
|
serverName={server.name}
|
||||||
server && server.name && "/" + server.name
|
userName={e.name}
|
||||||
}`}
|
/>
|
||||||
>
|
|
||||||
<button
|
|
||||||
className="btn btn-primary btn-xs"
|
|
||||||
style={{ marginRight: 20 }}
|
|
||||||
>
|
|
||||||
Access Server
|
|
||||||
</button>
|
|
||||||
</a>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
// Start Single-user server
|
// Start Single-user server
|
||||||
@@ -383,30 +406,17 @@ const ServerDashboard = (props) => {
|
|||||||
className="btn btn-secondary btn-xs"
|
className="btn btn-secondary btn-xs"
|
||||||
style={{ marginRight: 20 }}
|
style={{ marginRight: 20 }}
|
||||||
>
|
>
|
||||||
Spawn New
|
Spawn Page
|
||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<EditUserCell
|
||||||
{/* Edit User */}
|
user={e}
|
||||||
<button
|
numServers={userServers.length}
|
||||||
className="btn btn-primary btn-xs"
|
serverName={server.name}
|
||||||
style={{ marginRight: 20 }}
|
/>
|
||||||
onClick={() =>
|
|
||||||
history.push({
|
|
||||||
pathname: "/edit-user",
|
|
||||||
state: {
|
|
||||||
username: e.name,
|
|
||||||
has_admin: e.admin,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
edit user
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user