SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
refactor(authz): use new authz components for service accounts (#12007)
Vinicius Lourençob5567d155032
diff --git a/frontend/src/components/CreateServiceAccountModal/CreateServiceAccountModal.tsx b/frontend/src/components/CreateServiceAccountModal/CreateServiceAccountModal.tsxindex 3d0b542f6c..db64a3a060 100644--- a/frontend/src/components/CreateServiceAccountModal/CreateServiceAccountModal.tsx+++ b/frontend/src/components/CreateServiceAccountModal/CreateServiceAccountModal.tsx@@ -2,7 +2,7 @@ import { Controller, useForm } from 'react-hook-form';import { useQueryClient } from 'react-query';import { X } from '@signozhq/icons';import { Button } from '@signozhq/ui/button';-import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';import { SACreatePermission } from 'lib/authz/hooks/useAuthZ/permissions/service-account.permissions';import { DialogFooter, DialogWrapper } from '@signozhq/ui/dialog';import { Input } from '@signozhq/ui/input';@@ -134,18 +134,17 @@ function CreateServiceAccountModal(): JSX.Element {Cancel</Button>- <AuthZTooltip checks={[SACreatePermission]}>- <Button- type="submit"- form="create-sa-form"- variant="solid"- color="primary"- loading={isSubmitting}- disabled={!isValid}- >- Create Service Account- </Button>- </AuthZTooltip>+ <AuthZButton+ checks={[SACreatePermission]}+ type="submit"+ form="create-sa-form"+ variant="solid"+ color="primary"+ loading={isSubmitting}+ disabled={!isValid}+ >+ Create Service Account+ </AuthZButton></DialogFooter></DialogWrapper>);diff --git a/frontend/src/components/ServiceAccountDrawer/AddKeyModal/KeyFormPhase.tsx b/frontend/src/components/ServiceAccountDrawer/AddKeyModal/KeyFormPhase.tsxindex 179890d735..6e31db1684 100644--- a/frontend/src/components/ServiceAccountDrawer/AddKeyModal/KeyFormPhase.tsx+++ b/frontend/src/components/ServiceAccountDrawer/AddKeyModal/KeyFormPhase.tsx@@ -4,7 +4,7 @@ import { Button } from '@signozhq/ui/button';import { Input } from '@signozhq/ui/input';import { ToggleGroupSimple } from '@signozhq/ui/toggle-group';import { DatePicker } from 'antd';-import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';import {APIKeyCreatePermission,buildSAAttachPermission,@@ -109,24 +109,21 @@ function KeyFormPhase({<Button variant="solid" color="secondary" onClick={onClose}>Cancel</Button>- <AuthZTooltip+ <AuthZButtonchecks={[APIKeyCreatePermission,buildSAAttachPermission(accountId ?? ''),]}- enabled={!!accountId}+ authZEnabled={!!accountId}+ type="submit"+ form={FORM_ID}+ variant="solid"+ color="primary"+ loading={isSubmitting}+ disabled={!isValid}>- <Button- type="submit"- form={FORM_ID}- variant="solid"- color="primary"- loading={isSubmitting}- disabled={!isValid}- >- Create Key- </Button>- </AuthZTooltip>+ Create Key+ </AuthZButton></div></div></>diff --git a/frontend/src/components/ServiceAccountDrawer/DeleteAccountModal.tsx b/frontend/src/components/ServiceAccountDrawer/DeleteAccountModal.tsxindex 1b265b266f..a8c6b8c443 100644--- a/frontend/src/components/ServiceAccountDrawer/DeleteAccountModal.tsx+++ b/frontend/src/components/ServiceAccountDrawer/DeleteAccountModal.tsx@@ -1,7 +1,7 @@import { useQueryClient } from 'react-query';import { Trash2, X } from '@signozhq/icons';import { Button } from '@signozhq/ui/button';-import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';import { buildSADeletePermission } from 'lib/authz/hooks/useAuthZ/permissions/service-account.permissions';import { DialogWrapper } from '@signozhq/ui/dialog';import { toast } from '@signozhq/ui/sonner';@@ -84,20 +84,17 @@ function DeleteAccountModal(): JSX.Element {<X size={12} />Cancel</Button>- <AuthZTooltip+ <AuthZButtonchecks={[buildSADeletePermission(accountId ?? '')]}- enabled={!!accountId}+ authZEnabled={!!accountId}+ variant="solid"+ color="destructive"+ loading={isDeleting}+ onClick={handleConfirm}>- <Button- variant="solid"- color="destructive"- loading={isDeleting}- onClick={handleConfirm}- >- <Trash2 size={12} />- Delete- </Button>- </AuthZTooltip>+ <Trash2 size={12} />+ Delete+ </AuthZButton></div>);diff --git a/frontend/src/components/ServiceAccountDrawer/EditKeyModal/EditKeyForm.tsx b/frontend/src/components/ServiceAccountDrawer/EditKeyModal/EditKeyForm.tsxindex 7ebc67bafc..dd84da6590 100644--- a/frontend/src/components/ServiceAccountDrawer/EditKeyModal/EditKeyForm.tsx+++ b/frontend/src/components/ServiceAccountDrawer/EditKeyModal/EditKeyForm.tsx@@ -7,6 +7,7 @@ import { Input } from '@signozhq/ui/input';import { ToggleGroupSimple } from '@signozhq/ui/toggle-group';import { DatePicker } from 'antd';import type { ServiceaccounttypesGettableFactorAPIKeyDTO } from 'api/generated/services/sigNoz.schemas';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';import {buildAPIKeyDeletePermission,@@ -158,38 +159,36 @@ function EditKeyForm({</form><div className="edit-key-modal__footer">- <AuthZTooltip+ <AuthZButtonchecks={[buildAPIKeyDeletePermission(keyItem?.id ?? ''),buildSADetachPermission(accountId ?? ''),]}- enabled={!!accountId && !!keyItem?.id}+ authZEnabled={!!accountId && !!keyItem?.id}+ variant="link"+ color="destructive"+ onClick={onRevokeClick}>- <Button variant="link" color="destructive" onClick={onRevokeClick}>- <Trash2 size={12} />- Revoke Key- </Button>- </AuthZTooltip>+ <Trash2 size={12} />+ Revoke Key+ </AuthZButton><div className="edit-key-modal__footer-right"><Button variant="solid" color="secondary" onClick={onClose}><X size={12} />Cancel</Button>- <AuthZTooltip+ <AuthZButtonchecks={[buildAPIKeyUpdatePermission(keyItem?.id ?? '')]}- enabled={!!accountId && !!keyItem?.id}+ authZEnabled={!!accountId && !!keyItem?.id}+ type="submit"+ form={FORM_ID}+ variant="solid"+ color="primary"+ loading={isSaving}+ disabled={!isDirty}>- <Button- type="submit"- form={FORM_ID}- variant="solid"- color="primary"- loading={isSaving}- disabled={!isDirty}- >- Save Changes- </Button>- </AuthZTooltip>+ Save Changes+ </AuthZButton></div></div></>diff --git a/frontend/src/components/ServiceAccountDrawer/KeysTab.tsx b/frontend/src/components/ServiceAccountDrawer/KeysTab.tsxindex d6d3ed349b..fd4fe04b08 100644--- a/frontend/src/components/ServiceAccountDrawer/KeysTab.tsx+++ b/frontend/src/components/ServiceAccountDrawer/KeysTab.tsx@@ -1,12 +1,13 @@import React, { useCallback, useMemo } from 'react';import { KeyRound, X } from '@signozhq/icons';-import { Button } from '@signozhq/ui/button';-import { Skeleton, Table, Tooltip } from 'antd';+import { Pagination, Skeleton, Table, Tooltip } from 'antd';import type { ColumnsType } from 'antd/es/table/interface';import type { ServiceaccounttypesGettableFactorAPIKeyDTO } from 'api/generated/services/sigNoz.schemas';-import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';+import { withAuthZContent } from 'lib/authz/components/withAuthZ/withAuthZContent';import {APIKeyCreatePermission,+ APIKeyListPermission,buildAPIKeyDeletePermission,buildSAAttachPermission,buildSADetachPermission,@@ -24,10 +25,10 @@ interface KeysTabProps {keys: ServiceaccounttypesGettableFactorAPIKeyDTO[];isLoading: boolean;isDisabled?: boolean;- canUpdate?: boolean;accountId?: string;currentPage: number;pageSize: number;+ onPageChange: (page: number) => void;}interface BuildColumnsParams {@@ -113,29 +114,26 @@ function buildColumns({render: (_, record): JSX.Element => {const tooltipTitle = isDisabled ? 'Service account disabled' : 'Revoke Key';return (- <AuthZTooltip- checks={[- buildAPIKeyDeletePermission(record.id),- buildSADetachPermission(accountId),- ]}- enabled={!isDisabled && !!accountId}- >- <Tooltip title={tooltipTitle}>- <Button- variant="ghost"- size="sm"- color="destructive"- disabled={isDisabled}- onClick={(e): void => {- e.stopPropagation();- onRevokeClick(record.id);- }}- className="keys-tab__revoke-btn"- >- <X size={12} />- </Button>- </Tooltip>- </AuthZTooltip>+ <Tooltip title={tooltipTitle}>+ <AuthZButton+ checks={[+ buildAPIKeyDeletePermission(record.id),+ buildSADetachPermission(accountId),+ ]}+ authZEnabled={!isDisabled && !!accountId}+ variant="ghost"+ size="sm"+ color="destructive"+ disabled={isDisabled}+ onClick={(e): void => {+ e.stopPropagation();+ onRevokeClick(record.id);+ }}+ className="keys-tab__revoke-btn"+ >+ <X size={12} />+ </AuthZButton>+ </Tooltip>);},},@@ -149,6 +147,7 @@ function KeysTab({accountId = '',currentPage,pageSize,+ onPageChange,}: KeysTabProps): JSX.Element {const [, setIsAddKeyOpen] = useQueryState('add-key',@@ -212,21 +211,18 @@ function KeysTab({Learn more</a></p>- <AuthZTooltip+ <AuthZButtonchecks={[APIKeyCreatePermission, buildSAAttachPermission(accountId)]}- enabled={!isDisabled && !!accountId}+ authZEnabled={!isDisabled && !!accountId}+ variant="link"+ color="primary"+ onClick={async (): Promise<void> => {+ await setIsAddKeyOpen(true);+ }}+ disabled={isDisabled}>- <Button- variant="link"- color="primary"- onClick={async (): Promise<void> => {- await setIsAddKeyOpen(true);- }}- disabled={isDisabled}- >- + Add your first key- </Button>- </AuthZTooltip>+ + Add your first key+ </AuthZButton></div>);}@@ -278,6 +274,24 @@ function KeysTab({})}/>+ <Pagination+ current={currentPage}+ pageSize={pageSize}+ total={keys.length}+ showTotal={(total: number, range: number[]): JSX.Element => (+ <>+ <span className="sa-drawer__pagination-range">+ {range[0]} — {range[1]}+ </span>+ <span className="sa-drawer__pagination-total"> of {total}</span>+ </>+ )}+ showSizeChanger={false}+ hideOnSinglePage+ onChange={onPageChange}+ className="sa-drawer__keys-pagination"+ />+<EditKeyModal keyItem={editKey} /><RevokeKeyModal />@@ -285,4 +299,7 @@ function KeysTab({);}-export default KeysTab;+export default withAuthZContent(KeysTab, {+ checks: [APIKeyListPermission],+ fallbackOnLoading: <Skeleton active paragraph={{ rows: 6 }} />,+});diff --git a/frontend/src/components/ServiceAccountDrawer/OverviewTab.tsx b/frontend/src/components/ServiceAccountDrawer/OverviewTab.tsxindex ef7f651361..949cbc03aa 100644--- a/frontend/src/components/ServiceAccountDrawer/OverviewTab.tsx+++ b/frontend/src/components/ServiceAccountDrawer/OverviewTab.tsx@@ -6,15 +6,20 @@ import { Input } from '@signozhq/ui/input';import { useCopyToClipboard } from 'react-use';import type { AuthtypesRoleDTO } from 'api/generated/services/sigNoz.schemas';import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import { withAuthZContent } from 'lib/authz/components/withAuthZ/withAuthZContent';import RolesSelect from 'components/RolesSelect';import { DATE_TIME_FORMATS } from 'constants/dateTimeFormats';import { ServiceAccountRow } from 'container/ServiceAccountsSettings/utils';-import { buildSAUpdatePermission } from 'lib/authz/hooks/useAuthZ/permissions/service-account.permissions';+import {+ buildSAReadPermission,+ buildSAUpdatePermission,+} from 'lib/authz/hooks/useAuthZ/permissions/service-account.permissions';import { useTimezone } from 'providers/Timezone';import APIError from 'types/api/error';import SaveErrorItem from './SaveErrorItem';import type { SaveError } from './utils';+import { Skeleton } from 'antd';interface OverviewTabProps {account: ServiceAccountRow;@@ -23,7 +28,6 @@ interface OverviewTabProps {localRoles: string[];onRolesChange: (v: string[]) => void;isDisabled: boolean;- canUpdate?: boolean;availableRoles: AuthtypesRoleDTO[];rolesLoading?: boolean;rolesError?: boolean;@@ -39,7 +43,6 @@ function OverviewTab({localRoles,onRolesChange,isDisabled,- canUpdate = true,availableRoles,rolesLoading,rolesError,@@ -86,23 +89,22 @@ function OverviewTab({<label className="sa-drawer__label" htmlFor="sa-name">Name</label>- {isDisabled || !canUpdate ? (- <AuthZTooltip- checks={[buildSAUpdatePermission(account.id)]}- enabled={!isDisabled && !canUpdate}- >+ {isDisabled ? (+ <AuthZTooltip checks={[buildSAUpdatePermission(account.id)]}><div className="sa-drawer__input-wrapper sa-drawer__input-wrapper--disabled"><span className="sa-drawer__input-text">{localName || '—'}</span><LockKeyhole size={14} className="sa-drawer__lock-icon" /></div></AuthZTooltip>) : (- <Input- id="sa-name"- value={localName}- onChange={(e): void => onNameChange(e.target.value)}- placeholder="Enter name"- />+ <AuthZTooltip checks={[buildSAUpdatePermission(account.id)]}>+ <Input+ id="sa-name"+ value={localName}+ onChange={(e): void => onNameChange(e.target.value)}+ placeholder="Enter name"+ />+ </AuthZTooltip>)}</div>@@ -220,4 +222,9 @@ function OverviewTab({);}-export default OverviewTab;+export default withAuthZContent(OverviewTab, {+ checks: (props): ReturnType<typeof buildSAReadPermission>[] => [+ buildSAReadPermission(props.account.id),+ ],+ fallbackOnLoading: <Skeleton active paragraph={{ rows: 6 }} />,+});diff --git a/frontend/src/components/ServiceAccountDrawer/RevokeKeyModal.tsx b/frontend/src/components/ServiceAccountDrawer/RevokeKeyModal.tsxindex fa5ffc1554..714db05e1b 100644--- a/frontend/src/components/ServiceAccountDrawer/RevokeKeyModal.tsx+++ b/frontend/src/components/ServiceAccountDrawer/RevokeKeyModal.tsx@@ -1,7 +1,7 @@import { useQueryClient } from 'react-query';import { Trash2, X } from '@signozhq/icons';import { Button } from '@signozhq/ui/button';-import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';import {buildAPIKeyDeletePermission,buildSADetachPermission,@@ -45,23 +45,20 @@ export function RevokeKeyFooter({<X size={12} />Cancel</Button>- <AuthZTooltip+ <AuthZButtonchecks={[buildAPIKeyDeletePermission(keyId ?? ''),buildSADetachPermission(accountId ?? ''),]}- enabled={!!accountId && !!keyId}+ authZEnabled={!!accountId && !!keyId}+ variant="solid"+ color="destructive"+ loading={isRevoking}+ onClick={onConfirm}>- <Button- variant="solid"- color="destructive"- loading={isRevoking}- onClick={onConfirm}- >- <Trash2 size={12} />- Revoke Key- </Button>- </AuthZTooltip>+ <Trash2 size={12} />+ Revoke Key+ </AuthZButton></>);}@@ -111,7 +108,7 @@ function RevokeKeyModal(): JSX.Element {}function handleCancel(): void {- setRevokeKeyId(null);+ void setRevokeKeyId(null);}return (diff --git a/frontend/src/components/ServiceAccountDrawer/ServiceAccountDrawer.tsx b/frontend/src/components/ServiceAccountDrawer/ServiceAccountDrawer.tsxindex 440147c6ba..a0a5157d9a 100644--- a/frontend/src/components/ServiceAccountDrawer/ServiceAccountDrawer.tsx+++ b/frontend/src/components/ServiceAccountDrawer/ServiceAccountDrawer.tsx@@ -1,11 +1,17 @@-import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import React, {+ useCallback,+ useEffect,+ useMemo,+ useRef,+ useState,+} from 'react';import { useQueryClient } from 'react-query';import { Key, LayoutGrid, Plus, Trash2, X } from '@signozhq/icons';import { Button } from '@signozhq/ui/button';import { DrawerWrapper } from '@signozhq/ui/drawer';import { toast } from '@signozhq/ui/sonner';import { ToggleGroupSimple } from '@signozhq/ui/toggle-group';-import { Pagination, Skeleton } from 'antd';+import { Skeleton } from 'antd';import { convertToApiError } from 'api/ErrorResponseHandlerForGeneratedAPIs';import {getListServiceAccountsQueryKey,@@ -16,7 +22,6 @@ import {import type { RenderErrorResponseDTO } from 'api/generated/services/sigNoz.schemas';import { AxiosError } from 'axios';import ErrorInPlace from 'components/ErrorInPlace/ErrorInPlace';-import PermissionDeniedCallout from 'lib/authz/components/PermissionDeniedCallout/PermissionDeniedCallout';import { useRoles } from 'components/RolesSelect';import { SA_QUERY_PARAMS } from 'container/ServiceAccountsSettings/constants';import {@@ -28,15 +33,13 @@ import {RoleUpdateFailure,useServiceAccountRoleManager,} from 'hooks/serviceAccount/useServiceAccountRoleManager';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';import {APIKeyCreatePermission,- APIKeyListPermission,buildSAAttachPermission,buildSADeletePermission,- buildSAReadPermission,buildSAUpdatePermission,} from 'lib/authz/hooks/useAuthZ/permissions/service-account.permissions';-import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';import {parseAsBoolean,parseAsInteger,@@ -47,7 +50,6 @@ import {import APIError from 'types/api/error';import { toAPIError } from 'utils/errorUtils';-import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';import AddKeyModal from './AddKeyModal';import DeleteAccountModal from './DeleteAccountModal';import KeysTab from './KeysTab';@@ -70,14 +72,12 @@ function toSaveApiError(err: unknown): APIError {);}-// eslint-disable-next-line sonarjs/cognitive-complexityfunction ServiceAccountDrawer({onSuccess,}: ServiceAccountDrawerProps): JSX.Element {const [selectedAccountId, setSelectedAccountId] = useQueryState(SA_QUERY_PARAMS.ACCOUNT,);- const open = !!selectedAccountId;const [activeTab, setActiveTab] = useQueryState(SA_QUERY_PARAMS.TAB,parseAsStringEnum<ServiceAccountDrawerTab>(@@ -100,28 +100,14 @@ function ServiceAccountDrawer({SA_QUERY_PARAMS.DELETE_SA,parseAsBoolean.withDefault(false),);+const [localName, setLocalName] = useState('');const [localRoles, setLocalRoles] = useState<string[]>([]);const [isSaving, setIsSaving] = useState(false);const [saveErrors, setSaveErrors] = useState<SaveError[]>([]);const queryClient = useQueryClient();-- const { permissions: drawerPermissions, isLoading: isAuthZLoading } = useAuthZ(- selectedAccountId- ? [- buildSAReadPermission(selectedAccountId),- buildSAUpdatePermission(selectedAccountId),- buildSADeletePermission(selectedAccountId),- APIKeyListPermission,- ]- : [],- { enabled: !!selectedAccountId },- );-- const canRead =- drawerPermissions?.[buildSAReadPermission(selectedAccountId ?? '')]- ?.isGranted ?? false;+ const open = !!selectedAccountId;const {data: accountData,@@ -131,7 +117,7 @@ function ServiceAccountDrawer({refetch: refetchAccount,} = useGetServiceAccount({ id: selectedAccountId ?? '' },- { query: { enabled: canRead && !!selectedAccountId } },+ { query: { enabled: !!selectedAccountId } },);const account = useMemo(@@ -145,7 +131,7 @@ function ServiceAccountDrawer({isLoading: isRolesLoading,applyDiff,} = useServiceAccountRoleManager(selectedAccountId ?? '', {- enabled: canRead && !!selectedAccountId,+ enabled: !!selectedAccountId,});const roleSessionRef = useRef<string | null>(null);@@ -194,16 +180,9 @@ function ServiceAccountDrawer({refetch: refetchRoles,} = useRoles();- const canListKeys =- drawerPermissions?.[APIKeyListPermission]?.isGranted ?? false;-- const canUpdate =- drawerPermissions?.[buildSAUpdatePermission(selectedAccountId ?? '')]- ?.isGranted ?? true;-const { data: keysData, isLoading: keysLoading } = useListServiceAccountKeys({ id: selectedAccountId ?? '' },- { query: { enabled: !!selectedAccountId && canListKeys } },+ { query: { enabled: !!selectedAccountId } },);const keys = keysData?.data ?? [];@@ -217,7 +196,6 @@ function ServiceAccountDrawer({}}, [keysLoading, keys.length, keysPage, setKeysPage]);- // the retry for this mutation is safe due to the api being idempotent on backendconst { mutateAsync: updateMutateAsync } = useUpdateServiceAccount();const retryNameUpdate = useCallback(async (): Promise<void> => {@@ -375,23 +353,71 @@ function ServiceAccountDrawer({]);const handleClose = useCallback((): void => {- void setIsDeleteOpen(null);- void setIsAddKeyOpen(null);- void setSelectedAccountId(null);+ setSaveErrors([]);void setActiveTab(null);void setKeysPage(null);void setEditKeyId(null);- setSaveErrors([]);+ void setIsAddKeyOpen(null);+ void setIsDeleteOpen(null);+ void setSelectedAccountId(null);}, [- setSelectedAccountId,setActiveTab,setKeysPage,setEditKeyId,setIsAddKeyOpen,setIsDeleteOpen,+ setSelectedAccountId,]);- const drawerContent = (+ const footer = useMemo(+ () =>+ activeTab === ServiceAccountDrawerTab.Overview && !isDeleted && open ? (+ <div className="sa-drawer__footer">+ <AuthZButton+ checks={[buildSADeletePermission(selectedAccountId ?? '')]}+ authZEnabled={!!selectedAccountId}+ variant="link"+ color="destructive"+ onClick={(): void => {+ void setIsDeleteOpen(true);+ }}+ >+ <Trash2 size={12} />+ Delete Service Account+ </AuthZButton>+ <div className="sa-drawer__footer-right">+ <Button variant="outlined" color="secondary" onClick={handleClose}>+ <X size={14} />+ Cancel+ </Button>+ <AuthZButton+ checks={[buildSAUpdatePermission(selectedAccountId ?? '')]}+ authZEnabled={!!selectedAccountId}+ variant="solid"+ color="primary"+ loading={isSaving}+ disabled={!isDirty}+ onClick={handleSave}+ >+ Save Changes+ </AuthZButton>+ </div>+ </div>+ ) : null,+ [+ activeTab,+ isDeleted,+ open,+ selectedAccountId,+ isSaving,+ isDirty,+ handleClose,+ handleSave,+ setIsDeleteOpen,+ ],+ );++ const body = (<div className="sa-drawer__layout"><div className="sa-drawer__tabs"><ToggleGroupSimple@@ -433,26 +459,23 @@ function ServiceAccountDrawer({]}/>{activeTab === ServiceAccountDrawerTab.Keys && (- <AuthZTooltip+ <AuthZButtonchecks={[APIKeyCreatePermission,buildSAAttachPermission(selectedAccountId ?? ''),]}- enabled={!isDeleted && !!selectedAccountId}+ authZEnabled={!isDeleted && !!selectedAccountId}+ variant="outlined"+ size="sm"+ color="secondary"+ disabled={isDeleted}+ onClick={(): void => {+ void setIsAddKeyOpen(true);+ }}>- <Button- variant="outlined"- size="sm"- color="secondary"- disabled={isDeleted}- onClick={(): void => {- void setIsAddKeyOpen(true);- }}- >- <Plus size={12} />- Add Key- </Button>- </AuthZTooltip>+ <Plus size={12} />+ Add Key+ </AuthZButton>)}</div>@@ -461,9 +484,7 @@ function ServiceAccountDrawer({activeTab === ServiceAccountDrawerTab.Keys ? ' sa-drawer__body--keys' : ''}`}>- {(isAuthZLoading || isAccountLoading) && (- <Skeleton active paragraph={{ rows: 6 }} />- )}+ {isAccountLoading && <Skeleton active paragraph={{ rows: 6 }} />}{isAccountError && (<ErrorInPlaceerror={toAPIError(@@ -472,141 +493,73 @@ function ServiceAccountDrawer({)}/>)}- {!isAuthZLoading &&- !isAccountLoading &&- !isAccountError &&- selectedAccountId && (- <>- {activeTab === ServiceAccountDrawerTab.Overview &&- (canRead && account ? (- <OverviewTab- account={account}- localName={localName}- onNameChange={handleNameChange}- localRoles={localRoles}- onRolesChange={(roles): void => {- setLocalRoles(roles);- clearRoleErrors();- }}- isDisabled={isDeleted}- canUpdate={canUpdate}- availableRoles={availableRoles}- rolesLoading={rolesLoading}- rolesError={rolesError}- rolesErrorObj={rolesErrorObj}- onRefetchRoles={refetchRoles}- saveErrors={saveErrors}- />- ) : (- <PermissionDeniedCallout permissionName="serviceaccount:read" />- ))}- {activeTab === ServiceAccountDrawerTab.Keys &&- (canListKeys ? (- <KeysTab- keys={keys}- isLoading={keysLoading}- isDisabled={isDeleted}- canUpdate={canUpdate}- accountId={selectedAccountId}- currentPage={keysPage}- pageSize={PAGE_SIZE}- />- ) : (- <PermissionDeniedCallout permissionName="factor-api-key:list" />- ))}- </>- )}+ {!isAccountLoading && !isAccountError && (+ <>+ {activeTab === ServiceAccountDrawerTab.Overview &&+ (account ? (+ <OverviewTab+ account={account}+ localName={localName}+ onNameChange={handleNameChange}+ localRoles={localRoles}+ onRolesChange={(roles): void => {+ setLocalRoles(roles);+ clearRoleErrors();+ }}+ isDisabled={isDeleted}+ availableRoles={availableRoles}+ rolesLoading={rolesLoading}+ rolesError={rolesError}+ rolesErrorObj={rolesErrorObj}+ onRefetchRoles={refetchRoles}+ saveErrors={saveErrors}+ />+ ) : (+ <Skeleton active />+ ))}+ {activeTab === ServiceAccountDrawerTab.Keys && (+ <KeysTab+ keys={keys}+ isLoading={keysLoading}+ isDisabled={isDeleted}+ accountId={selectedAccountId ?? ''}+ currentPage={keysPage}+ pageSize={PAGE_SIZE}+ onPageChange={(page): void => {+ void setKeysPage(page);+ }}+ />+ )}+ </>+ )}</div></div>);- const footer = (- <div className="sa-drawer__footer">- {activeTab === ServiceAccountDrawerTab.Keys ? (- <Pagination- current={keysPage}- pageSize={PAGE_SIZE}- total={keys.length}- showTotal={(total: number, range: number[]): JSX.Element => (- <>- <span className="sa-drawer__pagination-range">- {range[0]} — {range[1]}- </span>- <span className="sa-drawer__pagination-total"> of {total}</span>- </>- )}- showSizeChanger={false}- hideOnSinglePage- onChange={(page): void => {- void setKeysPage(page);- }}- className="sa-drawer__keys-pagination"- />- ) : (+ return (+ <DrawerWrapper+ open={open}+ onOpenChange={(isOpen): void => {+ if (!isOpen) {+ handleClose();+ }+ }}+ direction="right"+ showCloseButton+ showOverlay={false}+ title="Service Account Details"+ className="sa-drawer"+ width="wide"+ footer={footer}+ >+ {open && (<>- {!isDeleted && (- <AuthZTooltip- checks={[buildSADeletePermission(selectedAccountId ?? '')]}- enabled={!!selectedAccountId}- >- <Button- variant="link"- color="destructive"- onClick={(): void => {- void setIsDeleteOpen(true);- }}- >- <Trash2 size={12} />- Delete Service Account- </Button>- </AuthZTooltip>- )}- {!isDeleted && (- <div className="sa-drawer__footer-right">- <Button variant="outlined" color="secondary" onClick={handleClose}>- <X size={14} />- Cancel- </Button>- <Button- variant="solid"- color="primary"- loading={isSaving}- disabled={!isDirty}- onClick={handleSave}- >- Save Changes- </Button>- </div>- )}+ {body}+ <DeleteAccountModal />+ <AddKeyModal /></>)}- </div>- );-- return (- <>- <DrawerWrapper- open={open}- onOpenChange={(isOpen): void => {- if (!isOpen) {- handleClose();- }- }}- direction="right"- showCloseButton- showOverlay={false}- title="Service Account Details"- className="sa-drawer"- width="wide"- footer={footer}- >- {drawerContent}- </DrawerWrapper>-- <DeleteAccountModal />-- <AddKeyModal />- </>+ </DrawerWrapper>);}diff --git a/frontend/src/components/ServiceAccountDrawer/__tests__/AddKeyModal.test.tsx b/frontend/src/components/ServiceAccountDrawer/__tests__/AddKeyModal.test.tsxindex e9a7d9b02b..92641fd481 100644--- a/frontend/src/components/ServiceAccountDrawer/__tests__/AddKeyModal.test.tsx+++ b/frontend/src/components/ServiceAccountDrawer/__tests__/AddKeyModal.test.tsx@@ -1,4 +1,5 @@import { toast } from '@signozhq/ui/sonner';+import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';import { rest, server } from 'mocks-server/server';import { NuqsTestingAdapter } from 'nuqs/adapters/testing';import {@@ -59,6 +60,7 @@ describe('AddKeyModal', () => {rest.post(SA_KEYS_ENDPOINT, (_, res, ctx) =>res(ctx.status(201), ctx.json(createdKeyResponse)),),+ setupAuthzAdmin(),);});diff --git a/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsx b/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsxindex 566052a4f2..5e0cc7bd96 100644--- a/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsx+++ b/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsx@@ -1,5 +1,6 @@import { toast } from '@signozhq/ui/sonner';import type { ServiceaccounttypesGettableFactorAPIKeyDTO } from 'api/generated/services/sigNoz.schemas';+import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';import { rest, server } from 'mocks-server/server';import { NuqsTestingAdapter } from 'nuqs/adapters/testing';import { render, screen, userEvent, waitFor } from 'tests/test-utils';@@ -61,6 +62,7 @@ describe('EditKeyModal (URL-controlled)', () => {rest.delete(SA_KEY_ENDPOINT, (_, res, ctx) =>res(ctx.status(200), ctx.json({ status: 'success', data: {} })),),+ setupAuthzAdmin(),);});diff --git a/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsx b/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsxindex f50ce3050a..e88db848f9 100644--- a/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsx+++ b/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsx@@ -1,5 +1,6 @@import { toast } from '@signozhq/ui/sonner';import { ServiceaccounttypesGettableFactorAPIKeyDTO } from 'api/generated/services/sigNoz.schemas';+import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';import { rest, server } from 'mocks-server/server';import { NuqsTestingAdapter } from 'nuqs/adapters/testing';import { render, screen, userEvent, waitFor } from 'tests/test-utils';@@ -35,7 +36,7 @@ const keys: ServiceaccounttypesGettableFactorAPIKeyDTO[] = [{id: 'key-2',name: 'Staging Key',- expiresAt: 1924905600, // 2030-12-31+ expiresAt: 1924948800, // 2030-12-31 12:00 UTC (noon to avoid timezone issues)lastObservedAt: '2026-03-10T10:00:00Z',serviceAccountId: 'sa-1',},@@ -47,6 +48,7 @@ const defaultProps = {isDisabled: false,currentPage: 1,pageSize: 10,+ onPageChange: jest.fn(),};function renderKeysTab(@@ -67,6 +69,7 @@ describe('KeysTab', () => {rest.delete(SA_KEY_ENDPOINT, (_, res, ctx) =>res(ctx.status(200), ctx.json({ status: 'success', data: {} })),),+ setupAuthzAdmin(),);});@@ -74,9 +77,12 @@ describe('KeysTab', () => {server.resetHandlers();});- it('renders loading state', () => {+ it('renders loading state', async () => {renderKeysTab({ isLoading: true });- expect(document.querySelector('.ant-skeleton')).toBeInTheDocument();+ // Wait for authz to complete, then check for skeleton+ await waitFor(() => {+ expect(document.querySelector('.ant-skeleton')).toBeInTheDocument();+ });});it('renders empty state when no keys and clicking add sets add-key param', async () => {@@ -91,9 +97,9 @@ describe('KeysTab', () => {</NuqsTestingAdapter>,);- expect(- screen.getByText(/No keys. Start by creating one./i),- ).toBeInTheDocument();+ await expect(+ screen.findByText(/No keys. Start by creating one./i),+ ).resolves.toBeInTheDocument();const addBtn = screen.getByRole('button', { name: /\+ Add your first key/i });await user.click(addBtn);expect(onUrlUpdate).toHaveBeenCalledWith(@@ -103,10 +109,12 @@ describe('KeysTab', () => {);});- it('renders table with keys', () => {+ it('renders table with keys', async () => {renderKeysTab();- expect(screen.getByText('Production Key')).toBeInTheDocument();+ await expect(+ screen.findByText('Production Key'),+ ).resolves.toBeInTheDocument();expect(screen.getByText('Staging Key')).toBeInTheDocument();expect(screen.getByText('Never')).toBeInTheDocument();expect(screen.getByText('Dec 31, 2030')).toBeInTheDocument();@@ -122,7 +130,7 @@ describe('KeysTab', () => {</NuqsTestingAdapter>,);- const row = screen.getByText('Production Key').closest('tr');+ const row = (await screen.findByText('Production Key')).closest('tr');if (!row) {throw new Error('Row not found');}@@ -146,6 +154,8 @@ describe('KeysTab', () => {</NuqsTestingAdapter>,);+ // Wait for authz to complete and table to render+ await screen.findByText('Production Key');const revokeBtns = screen.getAllByRole('button').filter((btn) => btn.className.includes('keys-tab__revoke-btn'));@@ -163,7 +173,8 @@ describe('KeysTab', () => {renderKeysTab();- // Seed the keys cache so RevokeKeyModal can read the key name+ // Wait for authz to complete and table to render+ await screen.findByText('Production Key');const revokeBtns = screen.getAllByRole('button').filter((btn) => btn.className.includes('keys-tab__revoke-btn'));@@ -177,9 +188,11 @@ describe('KeysTab', () => {});});- it('disables actions when isDisabled is true', () => {+ it('disables actions when isDisabled is true', async () => {renderKeysTab({ isDisabled: true });+ // Wait for authz to complete and table to render+ await screen.findByText('Production Key');const revokeBtns = screen.getAllByRole('button').filter((btn) => btn.className.includes('keys-tab__revoke-btn'));diff --git a/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.authz.test.tsx b/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.authz.test.tsxindex 71b84bfa42..c02622ddab 100644--- a/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.authz.test.tsx+++ b/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.authz.test.tsx@@ -1,4 +1,3 @@-import type { ReactNode } from 'react';import { listRolesSuccessResponse } from 'mocks-server/__mockdata__/roles';import { rest, server } from 'mocks-server/server';import { NuqsTestingAdapter } from 'nuqs/adapters/testing';@@ -32,30 +31,6 @@ const activeAccountResponse = {updatedAt: '2026-01-02T00:00:00Z',};-jest.mock('@signozhq/ui/drawer', () => ({- ...jest.requireActual('@signozhq/ui/drawer'),- DrawerWrapper: ({- children,- footer,- open,- }: {- children?: ReactNode;- footer?: ReactNode;- open: boolean;- }): JSX.Element | null =>- open ? (- <div>- {children}- {footer}- </div>- ) : null,-}));--jest.mock('@signozhq/ui/sonner', () => ({- ...jest.requireActual('@signozhq/ui/sonner'),- toast: { success: jest.fn(), error: jest.fn() },-}));-function renderDrawer(searchParams: Record<string, string> = { account: 'sa-1' },): ReturnType<typeof render> {@@ -118,7 +93,7 @@ describe('ServiceAccountDrawer — permissions', () => {renderDrawer();await waitFor(() => {- expect(screen.getByText(/serviceaccount:read/)).toBeInTheDocument();+ expect(screen.getByText(/read:serviceaccount/)).toBeInTheDocument();});});@@ -140,7 +115,7 @@ describe('ServiceAccountDrawer — permissions', () => {fireEvent.click(screen.getByRole('radio', { name: /keys/i }));await waitFor(() => {- expect(screen.getByText(/factor-api-key:list/)).toBeInTheDocument();+ expect(screen.getByText(/list:factor-api-key/)).toBeInTheDocument();});});diff --git a/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.test.tsx b/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.test.tsxindex 2c3212ac6a..ad24f7ea60 100644--- a/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.test.tsx+++ b/frontend/src/components/ServiceAccountDrawer/__tests__/ServiceAccountDrawer.test.tsx@@ -1,4 +1,3 @@-import type { ReactNode } from 'react';import { listRolesSuccessResponse } from 'mocks-server/__mockdata__/roles';import { rest, server } from 'mocks-server/server';import { NuqsTestingAdapter } from 'nuqs/adapters/testing';@@ -7,30 +6,6 @@ import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';import ServiceAccountDrawer from '../ServiceAccountDrawer';-jest.mock('@signozhq/ui/drawer', () => ({- ...jest.requireActual('@signozhq/ui/drawer'),- DrawerWrapper: ({- children,- footer,- open,- }: {- children?: ReactNode;- footer?: ReactNode;- open: boolean;- }): JSX.Element | null =>- open ? (- <div>- {children}- {footer}- </div>- ) : null,-}));--jest.mock('@signozhq/ui/sonner', () => ({- ...jest.requireActual('@signozhq/ui/sonner'),- toast: { success: jest.fn(), error: jest.fn() },-}));-const ROLES_ENDPOINT = '*/api/v1/roles';const SA_KEYS_ENDPOINT = '*/api/v1/service_accounts/:id/keys';const SA_ENDPOINT = '*/api/v1/service_accounts/sa-1';diff --git a/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.authz.test.tsx b/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.authz.test.tsxindex 66d2c2add9..56f7a8a810 100644--- a/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.authz.test.tsx+++ b/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.authz.test.tsx@@ -28,7 +28,7 @@ describe('ServiceAccountsSettings — FGA', () => {);});- it('shows PermissionDeniedFullPage when list permission is denied', async () => {+ it('shows denied callout when list permission is denied', async () => {server.use(rest.post(AUTHZ_CHECK_URL, async (req, res, ctx) => {const payload = await req.json();@@ -47,14 +47,40 @@ describe('ServiceAccountsSettings — FGA', () => {renderPage();await waitFor(() => {- expect(- screen.getByText('Uh-oh! You are not authorized'),- ).toBeInTheDocument();+ expect(screen.getByText(/is not authorized to perform/)).toBeInTheDocument();});expect(screen.queryByRole('table')).not.toBeInTheDocument();});+ it('shows page header and disables search when list permission is denied', async () => {+ server.use(+ rest.post(AUTHZ_CHECK_URL, async (req, res, ctx) => {+ const payload = await req.json();+ return res(+ ctx.status(200),+ ctx.json(+ authzMockResponse(+ payload,+ payload.map(() => false),+ ),+ ),+ );+ }),+ );++ renderPage();++ await waitFor(() => {+ expect(screen.getByText(/is not authorized to perform/)).toBeInTheDocument();+ });++ expect(screen.getByText('Service Accounts')).toBeInTheDocument();+ expect(+ screen.getByPlaceholderText('Search by name or email...'),+ ).toBeDisabled();+ });+it('shows table when list permission is granted', async () => {server.use(rest.post(AUTHZ_CHECK_URL, async (req, res, ctx) => {@@ -78,7 +104,7 @@ describe('ServiceAccountsSettings — FGA', () => {});expect(- screen.queryByText('Uh-oh! You are not authorized'),+ screen.queryByText(/is not authorized to perform/),).not.toBeInTheDocument();});diff --git a/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.styles.scss b/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.styles.scssindex eb4e001da2..fde7418912 100644--- a/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.styles.scss+++ b/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.styles.scss@@ -44,6 +44,7 @@display: flex;align-items: center;gap: var(--spacing-4);+ padding-bottom: var(--spacing-6);}&__search {diff --git a/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.tsx b/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.tsxindex 909ed3a250..189311976b 100644--- a/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.tsx+++ b/frontend/src/container/ServiceAccountsSettings/ServiceAccountsSettings.tsx@@ -1,14 +1,17 @@import { useCallback, useEffect, useMemo } from 'react';+import { useQueryClient } from 'react-query';import { Check, ChevronDown, Plus } from '@signozhq/icons';import { Button } from '@signozhq/ui/button';import { DropdownMenuSimple, type MenuItem } from '@signozhq/ui/dropdown-menu';import { Input } from '@signozhq/ui/input';import { useListServiceAccounts } from 'api/generated/services/serviceaccount';+import { invalidateListServiceAccounts } from 'api/generated/services/serviceaccount';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';+import { AuthZGuardContent } from 'lib/authz/components/AuthZGuard/AuthZGuardContent';import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';import CreateServiceAccountModal from 'components/CreateServiceAccountModal/CreateServiceAccountModal';import ErrorInPlace from 'components/ErrorInPlace/ErrorInPlace';-import PermissionDeniedFullPage from 'lib/authz/components/PermissionDeniedFullPage/PermissionDeniedFullPage';-import Spinner from 'components/Spinner';import ServiceAccountDrawer from 'components/ServiceAccountDrawer/ServiceAccountDrawer';import ServiceAccountsTable, {PAGE_SIZE,@@ -17,7 +20,6 @@ import {SACreatePermission,SAListPermission,} from 'lib/authz/hooks/useAuthZ/permissions/service-account.permissions';-import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';import {parseAsBoolean,parseAsInteger,@@ -38,6 +40,13 @@ import {import './ServiceAccountsSettings.styles.scss';function ServiceAccountsSettings(): JSX.Element {+ const queryClient = useQueryClient();+ const { permissions: authzPermissions, isLoading: isAuthZLoading } = useAuthZ([+ SAListPermission,+ ]);+ const canListServiceAccounts =+ authzPermissions?.[SAListPermission]?.isGranted ?? false;+ const [, setSelectedAccountId] = useQueryState(SA_QUERY_PARAMS.ACCOUNT);const [currentPage, setPage] = useQueryState(SA_QUERY_PARAMS.PAGE,parseAsInteger.withDefault(1),@@ -52,25 +61,19 @@ function ServiceAccountsSettings(): JSX.Element {FilterMode.All,),);- const [, setSelectedAccountId] = useQueryState(SA_QUERY_PARAMS.ACCOUNT);const [, setIsCreateModalOpen] = useQueryState(SA_QUERY_PARAMS.CREATE_SA,parseAsBoolean.withDefault(false),);- const { permissions: listPerms, isLoading: isAuthZLoading } = useAuthZ([- SAListPermission,- ]);-- const hasListPermission = listPerms?.[SAListPermission]?.isGranted ?? false;-const {data: serviceAccountsData,isLoading,isError,error,- refetch: handleCreateSuccess,- } = useListServiceAccounts({ query: { enabled: hasListPermission } });+ } = useListServiceAccounts({ query: { enabled: canListServiceAccounts } });++ const controlsDisabled = isAuthZLoading || !canListServiceAccounts;const allAccounts = useMemo((): ServiceAccountRow[] =>@@ -199,9 +202,9 @@ function ServiceAccountsSettings(): JSX.Element {if (options?.closeDrawer) {void setSelectedAccountId(null);}- void handleCreateSuccess();+ void invalidateListServiceAccounts(queryClient);},- [handleCreateSuccess, setSelectedAccountId],+ [queryClient, setSelectedAccountId],);return (@@ -223,31 +226,32 @@ function ServiceAccountsSettings(): JSX.Element {</div></div>- {isAuthZLoading || isLoading ? (- <Spinner height="50vh" />- ) : !hasListPermission ? (- <PermissionDeniedFullPage permissionName="serviceaccount:list" />- ) : (- <div className="sa-settings__list-section">- <div className="sa-settings__controls">- <DropdownMenuSimple- menu={{ items: filterMenuItems }}- className="sa-settings-filter-dropdown"- >- <Button- variant="solid"- color="secondary"- className="sa-settings-filter-trigger"+ <div className="sa-settings__list-section">+ <div className="sa-settings__controls">+ <AuthZTooltip checks={[SAListPermission]}>+ <span>+ <DropdownMenuSimple+ menu={{ items: filterMenuItems }}+ className="sa-settings-filter-dropdown">- <span>{filterLabel}</span>- <ChevronDown- size={12}- className="sa-settings-filter-trigger__chevron"- />- </Button>- </DropdownMenuSimple>+ <Button+ variant="solid"+ color="secondary"+ className="sa-settings-filter-trigger"+ disabled={controlsDisabled}+ >+ <span>{filterLabel}</span>+ <ChevronDown+ size={12}+ className="sa-settings-filter-trigger__chevron"+ />+ </Button>+ </DropdownMenuSimple>+ </span>+ </AuthZTooltip>- <div className="sa-settings__search">+ <div className="sa-settings__search">+ <AuthZTooltip checks={[SAListPermission]}><Inputtype="search"name="service-accounts-search"@@ -258,23 +262,25 @@ function ServiceAccountsSettings(): JSX.Element {void setPage(1);}}className="sa-settings-search-input"+ disabled={controlsDisabled}/>- </div>-- <AuthZTooltip checks={[SACreatePermission]}>- <Button- variant="solid"- color="primary"- onClick={async (): Promise<void> => {- await setIsCreateModalOpen(true);- }}- >- <Plus size={12} />- New Service Account- </Button></AuthZTooltip></div>+ <AuthZButton+ checks={[SACreatePermission]}+ variant="solid"+ color="primary"+ onClick={async (): Promise<void> => {+ await setIsCreateModalOpen(true);+ }}+ >+ <Plus size={12} />+ New Service Account+ </AuthZButton>+ </div>++ <AuthZGuardContent checks={[SAListPermission]}>{isError ? (<ErrorInPlaceerror={toAPIError(@@ -289,8 +295,8 @@ function ServiceAccountsSettings(): JSX.Element {onRowClick={handleRowClick}/>)}- </div>- )}+ </AuthZGuardContent>+ </div><CreateServiceAccountModal />diff --git a/frontend/src/container/ServiceAccountsSettings/__tests__/ServiceAccountsSettings.authz.integration.test.tsx b/frontend/src/container/ServiceAccountsSettings/__tests__/ServiceAccountsSettings.authz.integration.test.tsxindex 6ea08b713e..3946ee1e7b 100644--- a/frontend/src/container/ServiceAccountsSettings/__tests__/ServiceAccountsSettings.authz.integration.test.tsx+++ b/frontend/src/container/ServiceAccountsSettings/__tests__/ServiceAccountsSettings.authz.integration.test.tsx@@ -1,4 +1,3 @@-import type { ReactNode } from 'react';import userEvent from '@testing-library/user-event';import { listRolesSuccessResponse } from 'mocks-server/__mockdata__/roles';import { rest, server } from 'mocks-server/server';@@ -14,46 +13,6 @@ const SA_KEYS_ENDPOINT = '*/api/v1/service_accounts/:id/keys';const SA_ROLES_ENDPOINT = '*/api/v1/service_accounts/:id/roles';const ROLES_ENDPOINT = '*/api/v1/roles';-jest.mock('@signozhq/ui/drawer', () => ({- ...jest.requireActual('@signozhq/ui/drawer'),- DrawerWrapper: ({- children,- footer,- open,- }: {- children?: ReactNode;- footer?: ReactNode;- open: boolean;- }): JSX.Element | null =>- open ? (- <div>- {children}- {footer}- </div>- ) : null,-}));--jest.mock('@signozhq/ui/dialog', () => ({- ...jest.requireActual('@signozhq/ui/dialog'),- DialogWrapper: ({- children,- open,- title,- }: {- children?: ReactNode;- open: boolean;- title?: string;- }): JSX.Element | null =>- open ? (- <div role="dialog" aria-label={title}>- {children}- </div>- ) : null,- DialogFooter: ({ children }: { children?: ReactNode }): JSX.Element => (- <div>{children}</div>- ),-}));-const mockServiceAccountsAPI = [{id: 'sa-1',@@ -173,11 +132,11 @@ describe('ServiceAccountsSettings (integration)', () => {</NuqsTestingAdapter>,);- fireEvent.click(- await screen.findByRole('button', {- name: /View service account CI Bot/i,- }),- );+ const viewButton = await screen.findByRole('button', {+ name: /View service account CI Bot/i,+ });++ fireEvent.click(viewButton);await expect(screen.findByRole('button', { name: /Delete Service Account/i }),