refactor(scripts): remove admin role checks from plugin API endpoints
- Eliminated admin role checks from the create, install, and delete plugin API endpoints to simplify access control. - Updated the ScriptsPage component to remove unnecessary user role checks, streamlining the installation process for all users. - Improved UI by consolidating the zip installation button, enhancing user experience during plugin management.
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
||||
useDuplicatePlugin,
|
||||
useForkScript,
|
||||
useInstallPlugin,
|
||||
useMe,
|
||||
useScripts,
|
||||
} from "../api/hooks.js";
|
||||
import { ConfirmDialog } from "../components/ConfirmDialog.jsx";
|
||||
@@ -46,8 +45,6 @@ export function ScriptsPage() {
|
||||
const fork = useForkScript();
|
||||
const duplicate = useDuplicatePlugin();
|
||||
const install = useInstallPlugin();
|
||||
const me = useMe();
|
||||
const isAdmin = me.data?.user?.role === "admin";
|
||||
const { notify } = useNotifications();
|
||||
const [pendingZip, setPendingZip] = useState(null);
|
||||
const [zipEncoding, setZipEncoding] = useState(false);
|
||||
@@ -144,23 +141,21 @@ export function ScriptsPage() {
|
||||
>
|
||||
Install example
|
||||
</button>
|
||||
{isAdmin ? (
|
||||
<label className={`btn btn-outline btn-sm ${zipBusy ? "btn-disabled" : ""}`}>
|
||||
{zipBusy ? (
|
||||
<span className="loading loading-spinner loading-xs" />
|
||||
) : (
|
||||
<LuUpload className="size-4" />
|
||||
)}
|
||||
Install from zip
|
||||
<input
|
||||
type="file"
|
||||
accept=".zip,application/zip"
|
||||
className="hidden"
|
||||
disabled={zipBusy}
|
||||
onChange={onPickZip}
|
||||
/>
|
||||
</label>
|
||||
) : null}
|
||||
<label className={`btn btn-outline btn-sm ${zipBusy ? "btn-disabled" : ""}`}>
|
||||
{zipBusy ? (
|
||||
<span className="loading loading-spinner loading-xs" />
|
||||
) : (
|
||||
<LuUpload className="size-4" />
|
||||
)}
|
||||
Install from zip
|
||||
<input
|
||||
type="file"
|
||||
accept=".zip,application/zip"
|
||||
className="hidden"
|
||||
disabled={zipBusy}
|
||||
onChange={onPickZip}
|
||||
/>
|
||||
</label>
|
||||
<Link to="/scripts/new" className="btn btn-primary btn-sm">
|
||||
<LuPlus className="size-4" />
|
||||
Add plugin
|
||||
|
||||
Reference in New Issue
Block a user