import React, { useContext, useState } from "react"; import { Button, Popconfirm } from "antd"; import { ControlContext, SectionHeader, useAccount, notifyErrorHandler } from "@clusterio/web_ui"; import { SeedRolesRequest } from "../../messages"; /** Button on the roles page which creates the roles the scenario shipped with. */ export default function SeedRoles() { const control = useContext(ControlContext); const account = useAccount(); const [seeding, setSeeding] = useState(false); if (!account.hasPermission("core.role.create")) { return null; } return { setSeeding(true); control.send(new SeedRolesRequest()) .catch(notifyErrorHandler("Error seeding roles")) .finally(() => setSeeding(false)); }} > } />; }