[Workplace Search] Add download diagnostics button to source settings (#95726)
* Add routes * Add button to UI
This commit is contained in:
parent
01bf004193
commit
c6b37dec70
|
@ -106,4 +106,26 @@ describe('SourceSettings', () => {
|
|||
sourceConfigData.configuredFields.publicKey
|
||||
);
|
||||
});
|
||||
|
||||
describe('DownloadDiagnosticsButton', () => {
|
||||
it('renders for org with correct href', () => {
|
||||
const wrapper = shallow(<SourceSettings />);
|
||||
|
||||
expect(wrapper.find('[data-test-subj="DownloadDiagnosticsButton"]').prop('href')).toEqual(
|
||||
'/api/workplace_search/org/sources/123/download_diagnostics'
|
||||
);
|
||||
});
|
||||
|
||||
it('renders for account with correct href', () => {
|
||||
setMockValues({
|
||||
...mockValues,
|
||||
isOrganization: false,
|
||||
});
|
||||
const wrapper = shallow(<SourceSettings />);
|
||||
|
||||
expect(wrapper.find('[data-test-subj="DownloadDiagnosticsButton"]').prop('href')).toEqual(
|
||||
'/api/workplace_search/account/sources/123/download_diagnostics'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -44,6 +44,9 @@ import {
|
|||
SOURCE_CONFIG_LINK,
|
||||
SOURCE_REMOVE_TITLE,
|
||||
SOURCE_REMOVE_DESCRIPTION,
|
||||
SYNC_DIAGNOSTICS_TITLE,
|
||||
SYNC_DIAGNOSTICS_DESCRIPTION,
|
||||
SYNC_DIAGNOSTICS_BUTTON,
|
||||
} from '../constants';
|
||||
import { staticSourceData } from '../source_data';
|
||||
import { SourceLogic } from '../source_logic';
|
||||
|
@ -82,6 +85,10 @@ export const SourceSettings: React.FC = () => {
|
|||
|
||||
const { clientId, clientSecret, publicKey, consumerKey, baseUrl } = configuredFields || {};
|
||||
|
||||
const diagnosticsPath = isOrganization
|
||||
? `/api/workplace_search/org/sources/${id}/download_diagnostics`
|
||||
: `/api/workplace_search/account/sources/${id}/download_diagnostics`;
|
||||
|
||||
const handleNameChange = (e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value);
|
||||
|
||||
const submitNameChange = (e: FormEvent) => {
|
||||
|
@ -167,6 +174,17 @@ export const SourceSettings: React.FC = () => {
|
|||
</EuiFormRow>
|
||||
</ContentSection>
|
||||
)}
|
||||
<ContentSection title={SYNC_DIAGNOSTICS_TITLE} description={SYNC_DIAGNOSTICS_DESCRIPTION}>
|
||||
<EuiButton
|
||||
target="_blank"
|
||||
href={diagnosticsPath}
|
||||
isLoading={buttonLoading}
|
||||
data-test-subj="DownloadDiagnosticsButton"
|
||||
download
|
||||
>
|
||||
{SYNC_DIAGNOSTICS_BUTTON}
|
||||
</EuiButton>
|
||||
</ContentSection>
|
||||
<ContentSection title={SOURCE_REMOVE_TITLE} description={SOURCE_REMOVE_DESCRIPTION}>
|
||||
<EuiButton
|
||||
isLoading={buttonLoading}
|
||||
|
|
|
@ -306,6 +306,28 @@ export const SOURCE_REMOVE_DESCRIPTION = i18n.translate(
|
|||
}
|
||||
);
|
||||
|
||||
export const SYNC_DIAGNOSTICS_TITLE = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.sources.syncDiagnosticsTitle',
|
||||
{
|
||||
defaultMessage: 'Sync Diagnostics',
|
||||
}
|
||||
);
|
||||
|
||||
export const SYNC_DIAGNOSTICS_DESCRIPTION = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.sources.syncDiagnosticsDescription',
|
||||
{
|
||||
defaultMessage:
|
||||
'Retrieve relevant diagnostics data for troubleshooting active synchronization processes.',
|
||||
}
|
||||
);
|
||||
|
||||
export const SYNC_DIAGNOSTICS_BUTTON = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.sources.syncDiagnosticsButton',
|
||||
{
|
||||
defaultMessage: 'Download diagnostics data',
|
||||
}
|
||||
);
|
||||
|
||||
export const SOURCE_NAME_LABEL = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.sources.sourceName.label',
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
registerAccountSourceSchemasRoute,
|
||||
registerAccountSourceReindexJobRoute,
|
||||
registerAccountSourceReindexJobStatusRoute,
|
||||
registerAccountSourceDownloadDiagnosticsRoute,
|
||||
registerOrgSourcesRoute,
|
||||
registerOrgSourcesStatusRoute,
|
||||
registerOrgSourceRoute,
|
||||
|
@ -40,6 +41,7 @@ import {
|
|||
registerOrgSourceSchemasRoute,
|
||||
registerOrgSourceReindexJobRoute,
|
||||
registerOrgSourceReindexJobStatusRoute,
|
||||
registerOrgSourceDownloadDiagnosticsRoute,
|
||||
registerOrgSourceOauthConfigurationsRoute,
|
||||
registerOrgSourceOauthConfigurationRoute,
|
||||
registerOauthConnectorParamsRoute,
|
||||
|
@ -563,6 +565,29 @@ describe('sources routes', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('GET /api/workplace_search/account/sources/{sourceId}/download_diagnostics', () => {
|
||||
let mockRouter: MockRouter;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockRouter = new MockRouter({
|
||||
method: 'get',
|
||||
path: '/api/workplace_search/account/sources/{sourceId}/download_diagnostics',
|
||||
});
|
||||
|
||||
registerAccountSourceDownloadDiagnosticsRoute({
|
||||
...mockDependencies,
|
||||
router: mockRouter.router,
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a request handler', () => {
|
||||
expect(mockRequestHandler.createRequest).toHaveBeenCalledWith({
|
||||
path: '/ws/sources/:sourceId/download_diagnostics',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/workplace_search/org/sources', () => {
|
||||
let mockRouter: MockRouter;
|
||||
|
||||
|
@ -1061,6 +1086,29 @@ describe('sources routes', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('GET /api/workplace_search/org/sources/{sourceId}/download_diagnostics', () => {
|
||||
let mockRouter: MockRouter;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockRouter = new MockRouter({
|
||||
method: 'get',
|
||||
path: '/api/workplace_search/org/sources/{sourceId}/download_diagnostics',
|
||||
});
|
||||
|
||||
registerOrgSourceDownloadDiagnosticsRoute({
|
||||
...mockDependencies,
|
||||
router: mockRouter.router,
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a request handler', () => {
|
||||
expect(mockRequestHandler.createRequest).toHaveBeenCalledWith({
|
||||
path: '/ws/org/sources/:sourceId/download_diagnostics',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/workplace_search/org/settings/connectors', () => {
|
||||
let mockRouter: MockRouter;
|
||||
|
||||
|
|
|
@ -401,6 +401,25 @@ export function registerAccountSourceReindexJobStatusRoute({
|
|||
);
|
||||
}
|
||||
|
||||
export function registerAccountSourceDownloadDiagnosticsRoute({
|
||||
router,
|
||||
enterpriseSearchRequestHandler,
|
||||
}: RouteDependencies) {
|
||||
router.get(
|
||||
{
|
||||
path: '/api/workplace_search/account/sources/{sourceId}/download_diagnostics',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
sourceId: schema.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/ws/sources/:sourceId/download_diagnostics',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Org routes
|
||||
export function registerOrgSourcesRoute({
|
||||
router,
|
||||
|
@ -750,6 +769,25 @@ export function registerOrgSourceReindexJobStatusRoute({
|
|||
);
|
||||
}
|
||||
|
||||
export function registerOrgSourceDownloadDiagnosticsRoute({
|
||||
router,
|
||||
enterpriseSearchRequestHandler,
|
||||
}: RouteDependencies) {
|
||||
router.get(
|
||||
{
|
||||
path: '/api/workplace_search/org/sources/{sourceId}/download_diagnostics',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
sourceId: schema.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/ws/org/sources/:sourceId/download_diagnostics',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function registerOrgSourceOauthConfigurationsRoute({
|
||||
router,
|
||||
enterpriseSearchRequestHandler,
|
||||
|
@ -900,6 +938,7 @@ export const registerSourcesRoutes = (dependencies: RouteDependencies) => {
|
|||
registerAccountSourceSchemasRoute(dependencies);
|
||||
registerAccountSourceReindexJobRoute(dependencies);
|
||||
registerAccountSourceReindexJobStatusRoute(dependencies);
|
||||
registerAccountSourceDownloadDiagnosticsRoute(dependencies);
|
||||
registerOrgSourcesRoute(dependencies);
|
||||
registerOrgSourcesStatusRoute(dependencies);
|
||||
registerOrgSourceRoute(dependencies);
|
||||
|
@ -915,6 +954,7 @@ export const registerSourcesRoutes = (dependencies: RouteDependencies) => {
|
|||
registerOrgSourceSchemasRoute(dependencies);
|
||||
registerOrgSourceReindexJobRoute(dependencies);
|
||||
registerOrgSourceReindexJobStatusRoute(dependencies);
|
||||
registerOrgSourceDownloadDiagnosticsRoute(dependencies);
|
||||
registerOrgSourceOauthConfigurationsRoute(dependencies);
|
||||
registerOrgSourceOauthConfigurationRoute(dependencies);
|
||||
registerOauthConnectorParamsRoute(dependencies);
|
||||
|
|
Loading…
Reference in a new issue