use navId and subtitle on api keys page (#54247)
This commit is contained in:
@@ -2,7 +2,6 @@ import { render, screen, within } from '@testing-library/react';
|
|||||||
import userEvent, { PointerEventsCheckLevel } from '@testing-library/user-event';
|
import userEvent, { PointerEventsCheckLevel } from '@testing-library/user-event';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { NavModel } from '@grafana/data';
|
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { ApiKey, OrgRole } from 'app/types';
|
import { ApiKey, OrgRole } from 'app/types';
|
||||||
|
|
||||||
@@ -33,14 +32,6 @@ const setup = (propOverrides: Partial<Props>) => {
|
|||||||
const getApiKeysMigrationStatusMock = jest.fn();
|
const getApiKeysMigrationStatusMock = jest.fn();
|
||||||
const hideApiKeysMock = jest.fn();
|
const hideApiKeysMock = jest.fn();
|
||||||
const props: Props = {
|
const props: Props = {
|
||||||
navModel: {
|
|
||||||
main: {
|
|
||||||
text: 'Configuration',
|
|
||||||
},
|
|
||||||
node: {
|
|
||||||
text: 'Api Keys',
|
|
||||||
},
|
|
||||||
} as NavModel,
|
|
||||||
apiKeys: [] as ApiKey[],
|
apiKeys: [] as ApiKey[],
|
||||||
searchQuery: '',
|
searchQuery: '',
|
||||||
hasFetched: false,
|
hasFetched: false,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
|
|||||||
import { Page } from 'app/core/components/Page/Page';
|
import { Page } from 'app/core/components/Page/Page';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import { contextSrv } from 'app/core/core';
|
import { contextSrv } from 'app/core/core';
|
||||||
import { getNavModel } from 'app/core/selectors/navModel';
|
|
||||||
import { getTimeZone } from 'app/features/profile/state/selectors';
|
import { getTimeZone } from 'app/features/profile/state/selectors';
|
||||||
import { AccessControlAction, ApiKey, NewApiKey, StoreState } from 'app/types';
|
import { AccessControlAction, ApiKey, NewApiKey, StoreState } from 'app/types';
|
||||||
import { ShowModalReactEvent } from 'app/types/events';
|
import { ShowModalReactEvent } from 'app/types/events';
|
||||||
@@ -39,7 +38,6 @@ function mapStateToProps(state: StoreState) {
|
|||||||
const canCreate = contextSrv.hasAccess(AccessControlAction.ActionAPIKeysCreate, true);
|
const canCreate = contextSrv.hasAccess(AccessControlAction.ActionAPIKeysCreate, true);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
navModel: getNavModel(state.navIndex, 'apikeys'),
|
|
||||||
apiKeys: getApiKeys(state.apiKeys),
|
apiKeys: getApiKeys(state.apiKeys),
|
||||||
searchQuery: state.apiKeys.searchQuery,
|
searchQuery: state.apiKeys.searchQuery,
|
||||||
apiKeysCount: getApiKeysCount(state.apiKeys),
|
apiKeysCount: getApiKeysCount(state.apiKeys),
|
||||||
@@ -52,6 +50,11 @@ function mapStateToProps(state: StoreState) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultPageProps = {
|
||||||
|
navId: 'apikeys',
|
||||||
|
subTitle: 'Manage and create API keys that are used to interact with Grafana HTTP APIs.',
|
||||||
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
loadApiKeys,
|
loadApiKeys,
|
||||||
deleteApiKey,
|
deleteApiKey,
|
||||||
@@ -156,7 +159,6 @@ export class ApiKeysPageUnconnected extends PureComponent<Props, State> {
|
|||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
hasFetched,
|
hasFetched,
|
||||||
navModel,
|
|
||||||
apiKeysCount,
|
apiKeysCount,
|
||||||
apiKeys,
|
apiKeys,
|
||||||
searchQuery,
|
searchQuery,
|
||||||
@@ -169,14 +171,14 @@ export class ApiKeysPageUnconnected extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
if (!hasFetched) {
|
if (!hasFetched) {
|
||||||
return (
|
return (
|
||||||
<Page navModel={navModel}>
|
<Page {...defaultPageProps}>
|
||||||
<Page.Contents isLoading={true}>{}</Page.Contents>
|
<Page.Contents isLoading={true}>{}</Page.Contents>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page navModel={navModel}>
|
<Page {...defaultPageProps}>
|
||||||
<Page.Contents isLoading={false}>
|
<Page.Contents isLoading={false}>
|
||||||
<ApiKeysController>
|
<ApiKeysController>
|
||||||
{({ isAdding, toggleIsAdding }) => {
|
{({ isAdding, toggleIsAdding }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user