Skip to content

Commit

Permalink
fix: permissions inside Neve dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-ungureanu committed Sep 14, 2023
1 parent ddc8e6f commit 77a3851
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions assets/apps/dashboard/src/Components/Plugin/InstallActivate.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,40 @@ const InstallActivate = ({
const isProgress = (type) => progress === type;

const renderNoticeContent = () => {
const actionsAreDisabled =
(pluginData.slug === 'otter-blocks' && !isOtterProInstalled) ||
(!canInstallPlugins && currentState === 'install') ||
(!canActivatePlugins && currentState === 'activate') ||
pluginData.slug === 'otter-blocks' ||
false;
const isSuperAdmin = canInstallPlugins && canActivatePlugins;

const actionsAreDisabled = () => {
// Super admins can always perform actions
if (isSuperAdmin) {
return false;
}

// Prevent installing or activating plugins if not allowed
if (currentState === 'install' && !canInstallPlugins) {
return true;
}
if (currentState === 'activate' && !canActivatePlugins) {
return true;
}

// For non super admins, prevent installing specific plugins if Otter Pro is not installed
if (
(pluginData.slug === 'otter-blocks' ||
pluginData.slug === 'otter-pro') &&
!isOtterProInstalled
) {
return !canInstallPlugins;
}

return false;
};

const isButtonDisabled = () => {
if (progress) {
return true;
}

return actionsAreDisabled;
return actionsAreDisabled();
};

const buttonMap = {
Expand Down

0 comments on commit 77a3851

Please sign in to comment.