-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-endpoint-logs
- Loading branch information
Showing
7 changed files
with
178 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
x-pack/plugins/serverless_search/public/application/components/connectors_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React from 'react'; | ||
import { | ||
EuiButton, | ||
EuiCallOut, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiIcon, | ||
EuiText, | ||
EuiToolTip, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
||
import { useConnectorTypes } from '../hooks/api/use_connector_types'; | ||
import { useCreateConnector } from '../hooks/api/use_create_connector'; | ||
|
||
const CONNECTOR_TYPES_DISPLAY = [ | ||
'azure_blob_storage', | ||
'sharepoint_online', | ||
's3', | ||
'mongodb', | ||
'google_cloud_storage', | ||
]; | ||
|
||
export const ConnectorsCallout = () => { | ||
const { data } = useConnectorTypes(); | ||
const { createConnector, isLoading } = useCreateConnector(); | ||
|
||
const allConnectorTypes = data?.connectors; | ||
const connectorTypes = allConnectorTypes | ||
? CONNECTOR_TYPES_DISPLAY.map( | ||
(type) => allConnectorTypes.find((connType) => connType.serviceType === type)! | ||
) | ||
: undefined; | ||
const showConnectors = connectorTypes && connectorTypes.length; | ||
return ( | ||
<EuiCallOut | ||
title={i18n.translate('xpack.serverlessSearch.selectClient.connectorsCallout.title', { | ||
defaultMessage: 'Sync your data using a connector client', | ||
})} | ||
size="m" | ||
iconType="iInCircle" | ||
> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.serverlessSearch.selectClient.connectorsCallout.description" | ||
defaultMessage="Sync a range of popular third-party data sources to Elasticsearch, by deploying open code Elastic connectors on your own infrastructure." | ||
/> | ||
</p> | ||
<EuiFlexGroup alignItems="center" gutterSize="m"> | ||
<EuiFlexItem grow={false}> | ||
<p> | ||
<EuiButton | ||
color="primary" | ||
fill | ||
data-test-subj="connectors-callout-cta" | ||
onClick={() => createConnector()} | ||
isLoading={isLoading} | ||
> | ||
{i18n.translate('xpack.serverlessSearch.selectClient.connectorsCallout.cta', { | ||
defaultMessage: 'Create a connector', | ||
})} | ||
</EuiButton> | ||
</p> | ||
</EuiFlexItem> | ||
<EuiFlexItem /> | ||
{showConnectors && | ||
connectorTypes.map((connectorType) => ( | ||
<EuiFlexItem grow={false} key={connectorType.serviceType}> | ||
<EuiToolTip content={connectorType.name}> | ||
<EuiIcon | ||
size="xxl" | ||
title={connectorType.name} | ||
id={connectorType.serviceType} | ||
type={connectorType.iconPath} | ||
/> | ||
</EuiToolTip> | ||
</EuiFlexItem> | ||
))} | ||
{showConnectors && ( | ||
<EuiFlexItem grow={false}> | ||
<p> | ||
<EuiText color="subdued" size="s"> | ||
<FormattedMessage | ||
id="xpack.serverlessSearch.selectClient.connectorsCallout.etc" | ||
defaultMessage="and more" | ||
/> | ||
</EuiText> | ||
</p> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
</EuiCallOut> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
x-pack/plugins/serverless_search/public/application/hooks/api/use_create_connector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { useEffect } from 'react'; | ||
import { generatePath } from 'react-router-dom'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { Connector } from '@kbn/search-connectors'; | ||
import { EDIT_CONNECTOR_PATH } from '../../components/connectors_router'; | ||
import { useKibanaServices } from '../use_kibana'; | ||
|
||
export const useCreateConnector = () => { | ||
const { | ||
application: { navigateToUrl }, | ||
http, | ||
} = useKibanaServices(); | ||
const { | ||
data: connector, | ||
isLoading, | ||
isSuccess, | ||
mutate, | ||
} = useMutation({ | ||
mutationFn: async () => { | ||
const result = await http.post<{ connector: Connector }>( | ||
'/internal/serverless_search/connectors' | ||
); | ||
return result.connector; | ||
}, | ||
}); | ||
|
||
useEffect(() => { | ||
if (isSuccess) { | ||
navigateToUrl(generatePath(EDIT_CONNECTOR_PATH, { id: connector?.id || '' })); | ||
} | ||
}, [connector, isSuccess, navigateToUrl]); | ||
|
||
const createConnector = () => mutate(); | ||
return { createConnector, isLoading }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters