I want to hide "Create Workspace" button at home page

Create workspace button hide at home page

1 Like

Hello @BHAVESH_MAHAVAR ,
i faced the same problem and i solved it writing this script in a custom.js file in my custom application

β€˜β€™β€™

$(document).ready(function () {
// Listen for route changes
frappe.router.on(β€˜change’, function(route) {

  // custom logic here
  //console.log('Route changed:', route);

  //Check if we are inside a workspace page cause we want to hide the page actions just for those pages 
  //Check the current route to determine the page or workspace
  var currentRoute = frappe.get_route();
  var currentPage = currentRoute[0];
  //window.alert(currentPage)
  
  // Check if the current route is a workspace page
  if (currentPage === 'Workspaces') {
    if (!userRoles.includes('Administrator')) {

      
      // Add a CSS rule to hide the navbar and the page actions
      var css = '<style type="text/css">.search-bar { display: none; } .page-actions { display: none; } </style>';
      
      //var css = '<style type="text/css"> .search-bar { display: none; } button[data-label="Create%20Workspace"] { display: none; }  button[data-label="Edit"] { display: none; }</style>';
  
    }
  }
  else{
    // If we are not inside any workspace hide just the navbar
    var css = '<style type="text/css">.search-bar { display: none; } </style>';
  }

  $('head').append(css);

  });
});

β€˜β€™β€™