-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Code] Code Integrator Component #47180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -31,3 +31,6 @@ | |
| border-radius: $euiSizeXS $euiSizeXS 0 0; | ||
| } | ||
|
|
||
| .referencesPanel__code-block { | ||
| margin-bottom: $euiSizeXL; | ||
| } | ||
56 changes: 56 additions & 0 deletions
56
x-pack/legacy/plugins/code/public/components/integrations/code_integrator.tsx
This file contains hidden or 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,56 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React, { useState } from 'react'; | ||
| import { EuiButtonEmpty, EuiPopover, EuiText } from '@elastic/eui'; | ||
|
|
||
| import { RepoSelector } from './repo_selector'; | ||
|
|
||
| interface Props { | ||
| onRepoSelect: (repo: string) => void; | ||
| onImportSuccess: (repo: string) => void; | ||
| repos: string[]; | ||
| } | ||
|
|
||
| export const CodeIntegrator = ({ onRepoSelect, onImportSuccess, repos }: Props) => { | ||
| const [showSelector, setShowSelector] = useState(false); | ||
|
|
||
| const handleClick = () => setShowSelector(true); | ||
|
|
||
| const handleSelect = (codeId: string) => { | ||
| onRepoSelect(codeId); | ||
| setShowSelector(false); | ||
| // TODO: show success | ||
| }; | ||
|
|
||
| const link = ( | ||
| <EuiButtonEmpty | ||
| className="codeIntegrations__link--external" | ||
| iconType="codeApp" | ||
| onClick={handleClick} | ||
| > | ||
| <EuiText size="s">View in Code</EuiText> | ||
| </EuiButtonEmpty> | ||
| ); | ||
|
|
||
| return ( | ||
| <EuiPopover | ||
| anchorPosition="leftCenter" | ||
| button={link} | ||
| isOpen={showSelector} | ||
| closePopover={() => setShowSelector(false)} | ||
| > | ||
| <EuiText size="s" className="codeIntegrations__popover"> | ||
| <h3>No repository mapping found</h3> | ||
| <p> | ||
| We can't find the mapping between service and the source code. Select the repository or | ||
| import a new one. | ||
| </p> | ||
| </EuiText> | ||
| <RepoSelector onSelect={handleSelect} onImport={onImportSuccess} repos={repos} /> | ||
| </EuiPopover> | ||
| ); | ||
| }; | ||
This file contains hidden or 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
100 changes: 100 additions & 0 deletions
100
x-pack/legacy/plugins/code/public/components/integrations/import_modal.tsx
This file contains hidden or 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,100 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React, { ChangeEvent } from 'react'; | ||
|
|
||
| import { | ||
| EuiButton, | ||
| EuiButtonEmpty, | ||
| EuiFieldText, | ||
| EuiForm, | ||
| EuiFormRow, | ||
| EuiModal, | ||
| EuiModalBody, | ||
| EuiModalFooter, | ||
| EuiModalHeader, | ||
| EuiModalHeaderTitle, | ||
| EuiOverlayMask, | ||
| EuiTitle, | ||
| } from '@elastic/eui'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
|
|
||
| interface Props { | ||
| isInvalid: boolean; | ||
| isLoading: boolean; | ||
| onChange: (e: ChangeEvent<HTMLInputElement>) => void; | ||
| onClose: () => void; | ||
| onSubmit: () => void; | ||
| value: string; | ||
| } | ||
|
|
||
| export const ImportModal = ({ | ||
| isInvalid, | ||
| isLoading, | ||
| onChange, | ||
| onClose, | ||
| onSubmit, | ||
| value, | ||
| }: Props) => ( | ||
| <EuiOverlayMask> | ||
| <EuiModal onClose={onClose}> | ||
| <EuiModalHeader> | ||
| <EuiModalHeaderTitle> | ||
| <FormattedMessage | ||
| id="xpack.code.adminPage.repoTab.importRepoTitle" | ||
| defaultMessage="Import a new repo" | ||
| /> | ||
| </EuiModalHeaderTitle> | ||
| </EuiModalHeader> | ||
| <EuiModalBody> | ||
| <EuiTitle size="xs"> | ||
| <h3> | ||
| <FormattedMessage | ||
| id="xpack.code.adminPage.repoTab.repositoryUrlFormLabel" | ||
| defaultMessage="Repository URL" | ||
| /> | ||
| </h3> | ||
| </EuiTitle> | ||
| <EuiForm> | ||
| <EuiFormRow | ||
| isInvalid={isInvalid} | ||
| error={i18n.translate('xpack.code.adminPage.repoTab.repositoryUrlEmptyText', { | ||
| defaultMessage: "The URL shouldn't be empty.", | ||
| })} | ||
| > | ||
| <EuiFieldText | ||
| value={value} | ||
| onChange={onChange} | ||
| onBlur={onChange} | ||
| placeholder="https://github.com/Microsoft/TypeScript-Node-Starter" | ||
| aria-label="input project url" | ||
| data-test-subj="importRepositoryUrlInputBox" | ||
| isLoading={isLoading} | ||
| fullWidth={true} | ||
| isInvalid={isInvalid} | ||
| autoFocus={true} | ||
| /> | ||
| </EuiFormRow> | ||
| </EuiForm> | ||
| </EuiModalBody> | ||
| <EuiModalFooter> | ||
| <EuiButtonEmpty onClick={onClose}> | ||
| <FormattedMessage | ||
| id="xpack.code.adminPage.repoTab.cancelButtonLabel" | ||
| defaultMessage="Cancel" | ||
| /> | ||
| </EuiButtonEmpty> | ||
| <EuiButton fill onClick={onSubmit} disabled={isLoading}> | ||
| <FormattedMessage | ||
| id="xpack.code.adminPage.repoTab.importButtonLabel" | ||
| defaultMessage="Import" | ||
| /> | ||
| </EuiButton> | ||
| </EuiModalFooter> | ||
| </EuiModal> | ||
| </EuiOverlayMask> | ||
| ); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we going to implement the success notification in this PR. do you think it's currently blocked by the case that we haven't decided on if we should issue the REST API inside the component or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the import calls are stubbed out, but the components are written under the assumption that they'll be making the calls themselves.
We could certainly allow the consumer to make the call themselves with a simpler callback, but then CodeIntegrator's not doing much besides generating HTML.
We should discuss both approaches with APM and go with whatever they think is best, but I think both will need the simpler component that is callback-agnostic.