+ )
+ }
/>
);
}
diff --git a/app/react/docker/secrets/ListView/.keep b/app/react/docker/secrets/ListView/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/app/react/docker/secrets/ListView/SecretsDatatable.tsx b/app/react/docker/secrets/ListView/SecretsDatatable.tsx
index 36d87b35e..81343a4e1 100644
--- a/app/react/docker/secrets/ListView/SecretsDatatable.tsx
+++ b/app/react/docker/secrets/ListView/SecretsDatatable.tsx
@@ -3,6 +3,7 @@ import { Lock, Plus, Trash2 } from 'lucide-react';
import { SecretViewModel } from '@/docker/models/secret';
import { isoDate } from '@/portainer/filters/filters';
+import { Authorized, useAuthorizations } from '@/react/hooks/useUser';
import { buildNameColumn } from '@@/datatables/buildNameColumn';
import { Datatable, TableSettingsMenu } from '@@/datatables';
@@ -53,6 +54,11 @@ export function SecretsDatatable({
const tableState = useTableState(store, storageKey);
useRepeater(tableState.autoRefreshRate, onRefresh);
+ const hasWriteAccessQuery = useAuthorizations([
+ 'DockerSecretCreate',
+ 'DockerSecretDelete',
+ ]);
+
return (
(
-
- )}
+ renderTableActions={(selectedItems) =>
+ hasWriteAccessQuery.authorized && (
+
+ )
+ }
renderTableSettings={() => (
-
+
+
+
-
+
+
+
);
}
diff --git a/app/react/hooks/useUser.tsx b/app/react/hooks/useUser.tsx
index 04df8f195..7fdbbb881 100644
--- a/app/react/hooks/useUser.tsx
+++ b/app/react/hooks/useUser.tsx
@@ -88,6 +88,14 @@ export function useIsEdgeAdmin({
};
}
+/**
+ * Check if the user has some of the authorizations
+ *
+ * @param authorizations a list of authorizations to check
+ * @param forceEnvironmentId to force the environment id, used where the environment id can't be loaded from the router, like sidebar
+ * @param adminOnlyCE if true, will return false if the user is not an admin in CE
+ * @returns query result with isLoading and authorized - authorized is true if the user has some of the authorizations
+ */
export function useAuthorizations(
authorizations: string | string[],
forceEnvironmentId?: EnvironmentId,
@@ -137,7 +145,7 @@ export function useIsEnvironmentAdmin({
}
/**
- * will return true if the user has the authorizations. assumes the user is authenticated and not an admin
+ * will return true if the user has some of the authorizations. assumes the user is authenticated and not an admin
*
* @private Please use `useAuthorizations` instead. Exported only for angular's authentication service app/portainer/services/authentication.js:154
*/