mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-09-14 19:02:35 +00:00
Notification toasts, nicer loading, add new user support
This commit is contained in:
@@ -4,15 +4,18 @@ import { intl } from "src/locale";
|
||||
|
||||
interface Props {
|
||||
tableInstance: ReactTable<any>;
|
||||
onNewUser?: () => void;
|
||||
}
|
||||
export default function Empty({ tableInstance }: Props) {
|
||||
export default function Empty({ tableInstance, onNewUser }: Props) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
|
||||
<div className="text-center my-4">
|
||||
<h2>{intl.formatMessage({ id: "proxy-hosts.empty" })}</h2>
|
||||
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
|
||||
<Button className="btn-lime my-3">{intl.formatMessage({ id: "proxy-hosts.add" })}</Button>
|
||||
<Button className="btn-lime my-3" onClick={onNewUser}>
|
||||
{intl.formatMessage({ id: "proxy-hosts.add" })}
|
||||
</Button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@@ -12,8 +12,9 @@ interface Props {
|
||||
isFetching?: boolean;
|
||||
currentUserId?: number;
|
||||
onEditUser?: (id: number) => void;
|
||||
onNewUser?: () => void;
|
||||
}
|
||||
export default function Table({ data, isFetching, currentUserId, onEditUser }: Props) {
|
||||
export default function Table({ data, isFetching, currentUserId, onEditUser, onNewUser }: Props) {
|
||||
const columnHelper = createColumnHelper<User>();
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
@@ -124,5 +125,10 @@ export default function Table({ data, isFetching, currentUserId, onEditUser }: P
|
||||
enableSortingRemoval: false,
|
||||
});
|
||||
|
||||
return <TableLayout tableInstance={tableInstance} emptyState={<Empty tableInstance={tableInstance} />} />;
|
||||
return (
|
||||
<TableLayout
|
||||
tableInstance={tableInstance}
|
||||
emptyState={<Empty tableInstance={tableInstance} onNewUser={onNewUser} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import { UserModal } from "src/modals";
|
||||
import Table from "./Table";
|
||||
|
||||
export default function TableWrapper() {
|
||||
const [editUserId, setEditUserId] = useState(0);
|
||||
const [editUserId, setEditUserId] = useState(0 as number | "new");
|
||||
const { isFetching, isLoading, isError, error, data } = useUsers(["permissions"]);
|
||||
const { data: currentUser } = useUser("me");
|
||||
|
||||
@@ -42,7 +42,7 @@ export default function TableWrapper() {
|
||||
autoComplete="off"
|
||||
/>
|
||||
</div>
|
||||
<Button size="sm" className="btn-orange">
|
||||
<Button size="sm" className="btn-orange" onClick={() => setEditUserId("new")}>
|
||||
{intl.formatMessage({ id: "users.add" })}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -54,6 +54,7 @@ export default function TableWrapper() {
|
||||
isFetching={isFetching}
|
||||
currentUserId={currentUser?.id}
|
||||
onEditUser={(id: number) => setEditUserId(id)}
|
||||
onNewUser={() => setEditUserId("new")}
|
||||
/>
|
||||
{editUserId ? <UserModal userId={editUserId} onClose={() => setEditUserId(0)} /> : null}
|
||||
</div>
|
||||
|
@@ -3,7 +3,7 @@ import TableWrapper from "./TableWrapper";
|
||||
|
||||
const Users = () => {
|
||||
return (
|
||||
<HasPermission permission="admin" type="manage">
|
||||
<HasPermission permission="admin" type="manage" pageLoading loadingNoLogo>
|
||||
<TableWrapper />
|
||||
</HasPermission>
|
||||
);
|
||||
|
Reference in New Issue
Block a user