-
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.
[Cloud] ES endpoint discovery (#167122)
- Loading branch information
Showing
36 changed files
with
663 additions
and
199 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
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,3 @@ | ||
# @kbn/cloud | ||
|
||
Empty package generated by @kbn/generate |
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,81 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiForm, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLink, | ||
EuiButtonEmpty, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { useDeploymentDetails } from './services'; | ||
import { DeploymentDetailsEsInput } from './deployment_details_es_input'; | ||
import { DeploymentDetailsCloudIdInput } from './deployment_details_cloudid_input'; | ||
|
||
const hasActiveModifierKey = (event: React.MouseEvent): boolean => { | ||
return event.metaKey || event.altKey || event.ctrlKey || event.shiftKey; | ||
}; | ||
|
||
export const DeploymentDetails = ({ closeModal }: { closeModal?: () => void }) => { | ||
const { cloudId, elasticsearchUrl, managementUrl, learnMoreUrl, navigateToUrl } = | ||
useDeploymentDetails(); | ||
const isInsideModal = !!closeModal; | ||
|
||
if (!cloudId) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<EuiForm component="div"> | ||
{/* Elastic endpoint */} | ||
{elasticsearchUrl && <DeploymentDetailsEsInput elasticsearchUrl={elasticsearchUrl} />} | ||
|
||
{/* Cloud ID */} | ||
<DeploymentDetailsCloudIdInput cloudId={cloudId} /> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
{managementUrl && ( | ||
<EuiFlexGroup gutterSize="m" justifyContent="spaceBetween" alignItems="center"> | ||
<EuiFlexItem grow={false}> | ||
{/* eslint-disable-next-line @elastic/eui/href-or-on-click */} | ||
<EuiButtonEmpty | ||
href={managementUrl} | ||
onClick={(e: React.MouseEvent) => { | ||
if (!hasActiveModifierKey(e)) { | ||
e.preventDefault(); | ||
navigateToUrl(managementUrl); | ||
} | ||
if (closeModal) { | ||
closeModal(); | ||
} | ||
}} | ||
flush="left" | ||
> | ||
{i18n.translate('cloud.deploymentDetails.createManageApiKeysButtonLabel', { | ||
defaultMessage: 'Create and manage API keys', | ||
})} | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
{!isInsideModal && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiLink external href={learnMoreUrl} target="_blank"> | ||
{i18n.translate('cloud.deploymentDetails.learnMoreButtonLabel', { | ||
defaultMessage: 'Learn more', | ||
})} | ||
</EuiLink> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
)} | ||
</EuiForm> | ||
); | ||
}; |
46 changes: 46 additions & 0 deletions
46
packages/cloud/deployment_details/deployment_details_cloudid_input.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,46 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import React, { type FC } from 'react'; | ||
import { | ||
EuiFormRow, | ||
EuiFieldText, | ||
EuiCopy, | ||
EuiButtonIcon, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const DeploymentDetailsCloudIdInput: FC<{ cloudId: string }> = ({ cloudId }) => { | ||
return ( | ||
<EuiFormRow | ||
label={i18n.translate('cloud.deploymentDetails.cloudIDLabel', { | ||
defaultMessage: 'Cloud ID', | ||
})} | ||
fullWidth | ||
> | ||
<EuiFlexGroup gutterSize="s"> | ||
<EuiFlexItem> | ||
<EuiFieldText | ||
value={cloudId} | ||
fullWidth | ||
disabled | ||
data-test-subj="deploymentDetailsCloudID" | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiCopy textToCopy={cloudId}> | ||
{(copy) => ( | ||
<EuiButtonIcon onClick={copy} iconType="copyClipboard" display="base" size="m" /> | ||
)} | ||
</EuiCopy> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFormRow> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
packages/cloud/deployment_details/deployment_details_es_input.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,48 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import React, { type FC } from 'react'; | ||
import { | ||
EuiFormRow, | ||
EuiFieldText, | ||
EuiCopy, | ||
EuiButtonIcon, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const DeploymentDetailsEsInput: FC<{ elasticsearchUrl: string }> = ({ | ||
elasticsearchUrl, | ||
}) => { | ||
return ( | ||
<EuiFormRow | ||
label={i18n.translate('cloud.deploymentDetails.elasticEndpointLabel', { | ||
defaultMessage: 'Elastic endpoint', | ||
})} | ||
fullWidth | ||
> | ||
<EuiFlexGroup gutterSize="s"> | ||
<EuiFlexItem> | ||
<EuiFieldText | ||
value={elasticsearchUrl} | ||
fullWidth | ||
disabled | ||
data-test-subj="deploymentDetailsEsEndpoint" | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiCopy textToCopy={elasticsearchUrl}> | ||
{(copy) => ( | ||
<EuiButtonIcon onClick={copy} iconType="copyClipboard" display="base" size="m" /> | ||
)} | ||
</EuiCopy> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFormRow> | ||
); | ||
}; |
69 changes: 69 additions & 0 deletions
69
packages/cloud/deployment_details/deployment_details_modal.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,69 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import React, { type FC } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
EuiButton, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLink, | ||
EuiModal, | ||
EuiModalBody, | ||
EuiModalFooter, | ||
EuiModalHeader, | ||
EuiModalHeaderTitle, | ||
} from '@elastic/eui'; | ||
import { useDeploymentDetails } from './services'; | ||
import { DeploymentDetails } from './deployment_details'; | ||
|
||
interface Props { | ||
closeModal: () => void; | ||
} | ||
|
||
export const DeploymentDetailsModal: FC<Props> = ({ closeModal }) => { | ||
const { learnMoreUrl } = useDeploymentDetails(); | ||
|
||
return ( | ||
<EuiModal | ||
onClose={() => { | ||
closeModal(); | ||
}} | ||
style={{ width: 600 }} | ||
data-test-subj="deploymentDetailsModal" | ||
> | ||
<EuiModalHeader> | ||
<EuiModalHeaderTitle> | ||
{i18n.translate('cloud.deploymentDetails.helpMenuLinks.endpoints', { | ||
defaultMessage: 'Endpoints', | ||
})} | ||
</EuiModalHeaderTitle> | ||
</EuiModalHeader> | ||
<EuiModalBody> | ||
<DeploymentDetails closeModal={closeModal} /> | ||
</EuiModalBody> | ||
<EuiModalFooter> | ||
<EuiFlexGroup alignItems="baseline" justifyContent="flexEnd"> | ||
<EuiFlexItem grow={false}> | ||
<EuiLink external href={learnMoreUrl} target="_blank"> | ||
{i18n.translate('cloud.deploymentDetails.modal.learnMoreButtonLabel', { | ||
defaultMessage: 'Learn more', | ||
})} | ||
</EuiLink> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton onClick={closeModal} fill> | ||
{i18n.translate('cloud.deploymentDetails.modal.closeButtonLabel', { | ||
defaultMessage: 'Close', | ||
})} | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiModalFooter> | ||
</EuiModal> | ||
); | ||
}; |
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,11 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { DeploymentDetailsKibanaProvider, DeploymentDetailsProvider } from './services'; | ||
export { DeploymentDetails } from './deployment_details'; | ||
export { DeploymentDetailsModal } from './deployment_details_modal'; |
Oops, something went wrong.