2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 20:15:44 +00:00

Add config option to fully disable installing plugins (#6535)

* [FR] Add config option to fully disable installing plugins
Fixes #6531

* also restrict uninstalling

* Added test

* diff cleanup

* extend api to show if install was disabled

* PUI disable install buttons

* CUI disable install button if not available

* add config option

* Rephrase
This commit is contained in:
Matthias Mair
2024-02-26 12:44:31 +01:00
committed by GitHub
parent 85225538e6
commit 75c24fb8f4
14 changed files with 46 additions and 5 deletions

View File

@ -8,6 +8,7 @@ export const emptyServerAPI = {
worker_running: null,
worker_pending_tasks: null,
plugins_enabled: null,
plugins_install_disabled: null,
active_plugins: [],
email_configured: null,
debug_mode: null,

View File

@ -34,6 +34,7 @@ export interface ServerAPIProps {
worker_running: null | boolean;
worker_pending_tasks: null | number;
plugins_enabled: null | boolean;
plugins_install_disabled: null | boolean;
active_plugins: PluginProps[];
email_configured: null | boolean;
debug_mode: null | boolean;

View File

@ -14,6 +14,7 @@ export type RowAction = {
icon: ReactNode;
onClick?: () => void;
hidden?: boolean;
disabled?: boolean;
};
// Component for duplicating a row in a table
@ -129,6 +130,7 @@ export function RowActions({
setOpened(false);
}}
disabled={action.disabled || false}
>
{action.title}
</Menu.Item>

View File

@ -271,8 +271,11 @@ export default function PluginListTable() {
const navigate = useNavigate();
const user = useUserState();
const pluginsEnabled = useServerApiState(
(state) => state.server.plugins_enabled
const [pluginsEnabled, plugins_install_disabled] = useServerApiState(
(state) => [
state.server.plugins_enabled,
state.server.plugins_install_disabled
]
);
const pluginTableColumns: TableColumn[] = useMemo(
@ -457,7 +460,8 @@ export default function PluginListTable() {
onClick: () => {
setSelectedPlugin(record.pk);
uninstallPluginModal.open();
}
},
disabled: plugins_install_disabled || false
});
}
@ -592,6 +596,7 @@ export default function PluginListTable() {
setPluginPackage('');
installPluginModal.open();
}}
disabled={plugins_install_disabled || false}
/>
);
}