{
);
}
+ const showTable = apiKeysCount > 0;
return (
-
- {({}) => {
- const showTable = apiKeysCount > 0;
- return (
- <>
- {apiKeysCount !== 0 && }
- {apiKeysCount === 0 && (
-
- )}
- {showTable ? (
-
- ) : null}
- {showTable ? (
-
-
-
-
-
-
- ) : null}
- >
- );
- }}
-
+ <>
+
+ {showTable ? (
+
+ ) : null}
+ {showTable ? (
+
+
+
+
+
+
+ ) : null}
+ >
);
diff --git a/public/app/features/api-keys/MigrateToServiceAccountsCard.tsx b/public/app/features/api-keys/MigrateToServiceAccountsCard.tsx
index b76e470e913..0f1d7e107b2 100644
--- a/public/app/features/api-keys/MigrateToServiceAccountsCard.tsx
+++ b/public/app/features/api-keys/MigrateToServiceAccountsCard.tsx
@@ -6,10 +6,11 @@ import { Alert, Button, ConfirmModal, useStyles2 } from '@grafana/ui';
interface Props {
onMigrate: () => void;
+ apikeysCount: number;
disabled?: boolean;
}
-export const MigrateToServiceAccountsCard = ({ onMigrate, disabled }: Props): JSX.Element => {
+export const MigrateToServiceAccountsCard = ({ onMigrate, apikeysCount, disabled }: Props): JSX.Element => {
const [isModalOpen, setIsModalOpen] = useState(false);
const styles = useStyles2(getStyles);
@@ -23,30 +24,49 @@ export const MigrateToServiceAccountsCard = ({ onMigrate, disabled }: Props): JS
Find out more about the migration here.
);
- const migrationBoxDesc = Are you sure you want to migrate all API keys to service accounts? {docsLink} ;
+ const migrationBoxDesc = (
+
+ Are you sure you want to migrate all API keys to service accounts? {docsLink}
+ This hides the API keys tab.
+
+ );
return (
-
-
- We will soon deprecate API keys. Each API key will be migrated into a service account with a token and will
- continue to work as they were. We encourage you to migrate your API keys to service accounts now. {docsLink}
-
-
- setIsModalOpen(true)}>
- Migrate all service accounts
-
- setIsModalOpen(false)}
- confirmVariant="primary"
- confirmButtonVariant="primary"
- />
-
-
+ <>
+ {apikeysCount > 0 && (
+
+
+ We will soon deprecate API keys. Each API key will be migrated into a service account with a token and will
+ continue to work as they were. We encourage you to migrate your API keys to service accounts now. {docsLink}
+
+
+ setIsModalOpen(true)}>
+ Migrate all service accounts
+
+ setIsModalOpen(false)}
+ confirmVariant="primary"
+ confirmButtonVariant="primary"
+ />
+
+
+ )}
+ {apikeysCount === 0 && (
+ <>
+
+
+ No API keys were found. If you reload the browser, this tab will be not available. If any API keys are
+ created, this tab will appear again.
+
+
+ >
+ )}
+ >
);
};
diff --git a/public/app/features/api-keys/state/actions.ts b/public/app/features/api-keys/state/actions.ts
index 65f90b415cf..220fb770dd5 100644
--- a/public/app/features/api-keys/state/actions.ts
+++ b/public/app/features/api-keys/state/actions.ts
@@ -42,12 +42,6 @@ export function migrateAll(): ThunkResult {
};
}
-export function hideApiKeys(): ThunkResult {
- return async (dispatch) => {
- await getBackendSrv().post('/api/serviceaccounts/hideApiKeys');
- };
-}
-
export function toggleIncludeExpired(): ThunkResult {
return (dispatch) => {
dispatch(includeExpiredToggled());