@visns-studio/visns-components 5.12.11 → 5.12.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -87,7 +87,7 @@
87
87
  "react-dom": "^17.0.0 || ^18.0.0"
88
88
  },
89
89
  "name": "@visns-studio/visns-components",
90
- "version": "5.12.11",
90
+ "version": "5.12.13",
91
91
  "description": "Various packages to assist in the development of our Custom Applications.",
92
92
  "main": "src/index.js",
93
93
  "files": [
@@ -1928,6 +1928,20 @@ const DataGrid = forwardRef(
1928
1928
  let iconStyle = {};
1929
1929
  let allow = true;
1930
1930
 
1931
+ // Check role-based permissions if roles are specified
1932
+ if (s.roles && Array.isArray(s.roles) && s.roles.length > 0) {
1933
+ // Check if user has any of the required roles
1934
+ const hasRequiredRole = s.roles.some((requiredRole) =>
1935
+ userProfile?.roles?.some(
1936
+ (userRole) => userRole.name === requiredRole
1937
+ )
1938
+ );
1939
+
1940
+ if (!hasRequiredRole) {
1941
+ allow = false;
1942
+ }
1943
+ }
1944
+
1931
1945
  if (s.active) {
1932
1946
  // Helper function to get nested values for main active condition (searches for target value)
1933
1947
  const getNestedValueForMain = (data, path, targetValue) => {
@@ -2836,7 +2850,25 @@ const DataGrid = forwardRef(
2836
2850
 
2837
2851
  const newColumns = columns.map(renderColumn);
2838
2852
 
2839
- if (settings.length > 0) {
2853
+ // Function to check if any settings would be visible for any row
2854
+ const hasVisibleSettings = () => {
2855
+ if (settings.length === 0) return false;
2856
+
2857
+ // Check if any setting would be visible based on role permissions
2858
+ return settings.some(setting => {
2859
+ // Check role-based permissions
2860
+ if (setting.roles && Array.isArray(setting.roles) && setting.roles.length > 0) {
2861
+ const hasRequiredRole = setting.roles.some(requiredRole =>
2862
+ userProfile?.roles?.some(userRole => userRole.name === requiredRole)
2863
+ );
2864
+ return hasRequiredRole;
2865
+ }
2866
+ // If no roles specified, setting is visible
2867
+ return true;
2868
+ });
2869
+ };
2870
+
2871
+ if (hasVisibleSettings()) {
2840
2872
  newColumns.push({
2841
2873
  name: 'setting',
2842
2874
  header: 'Action',