@@ -3,6 +3,7 @@ import { LayoutGrid } from '../../../../../shared/components/LayoutGrid/LayoutGr
33import { Button } from '../../../../../shared/defguard-ui/components/Button/Button' ;
44import { EmptyStateFlexible } from '../../../../../shared/defguard-ui/components/EmptyStateFlexible/EmptyStateFlexible' ;
55import { SizedBox } from '../../../../../shared/defguard-ui/components/SizedBox/SizedBox' ;
6+ import { Snackbar } from '../../../../../shared/defguard-ui/providers/snackbar/snackbar' ;
67import { ThemeSpacing } from '../../../../../shared/defguard-ui/types' ;
78import { openModal } from '../../../../../shared/hooks/modalControls/modalsSubjects' ;
89import { ModalName } from '../../../../../shared/hooks/modalControls/modalTypes' ;
@@ -44,8 +45,20 @@ export const ProfileApiTokensTab = ({ availability, isLoading }: Props) => {
4445
4546const AvailableProfileApiTokensTab = ( ) => {
4647 const username = useUserProfile ( ( s ) => s . user . username ) ;
48+ const isUserActive = useUserProfile ( ( s ) => s . user . is_active ) ;
4749 const apiTokens = useUserProfile ( ( s ) => s . apiTokens ) ;
4850
51+ const handleAddApiToken = ( ) => {
52+ if ( ! isUserActive ) {
53+ Snackbar . error ( m . modal_add_api_token_disabled_user_error ( ) ) ;
54+ return ;
55+ }
56+
57+ openModal ( ModalName . AddApiToken , {
58+ username,
59+ } ) ;
60+ } ;
61+
4962 return (
5063 < >
5164 { apiTokens . length === 0 && (
@@ -57,11 +70,7 @@ const AvailableProfileApiTokensTab = () => {
5770 iconLeft : 'add-token' ,
5871 testId : 'add-token' ,
5972 text : m . profile_api_tokens_add ( ) ,
60- onClick : ( ) => {
61- openModal ( ModalName . AddApiToken , {
62- username,
63- } ) ;
64- } ,
73+ onClick : handleAddApiToken ,
6574 } }
6675 />
6776 ) }
@@ -72,11 +81,7 @@ const AvailableProfileApiTokensTab = () => {
7281 < Button
7382 text = { m . profile_api_tokens_add ( ) }
7483 iconLeft = "add-token"
75- onClick = { ( ) => {
76- openModal ( ModalName . AddApiToken , {
77- username,
78- } ) ;
79- } }
84+ onClick = { handleAddApiToken }
8085 />
8186 </ ProfileTabHeader >
8287 < ProfileApiTokensTable />
0 commit comments