mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [[Enterprise Search] Add copy button for pipelines (#147712)](https://github.com/elastic/kibana/pull/147712) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Sander Philipse","email":"94373878+sphilipse@users.noreply.github.com"},"sourceCommit":{"committedDate":"2022-12-19T14:24:26Z","message":"[Enterprise Search] Add copy button for pipelines (#147712)\n\nThis ensures the copy button shows up for curl requests on the\r\nconnectors pipeline page.","sha":"32de227cd1350dceffeae8b1093f4a81ad7103e9","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:EnterpriseSearch","v8.6.0","v8.7.0"],"number":147712,"url":"https://github.com/elastic/kibana/pull/147712","mergeCommit":{"message":"[Enterprise Search] Add copy button for pipelines (#147712)\n\nThis ensures the copy button shows up for curl requests on the\r\nconnectors pipeline page.","sha":"32de227cd1350dceffeae8b1093f4a81ad7103e9"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/147712","number":147712,"mergeCommit":{"message":"[Enterprise Search] Add copy button for pipelines (#147712)\n\nThis ensures the copy button shows up for curl requests on the\r\nconnectors pipeline page.","sha":"32de227cd1350dceffeae8b1093f4a81ad7103e9"}}]}] BACKPORT--> Co-authored-by: Sander Philipse <94373878+sphilipse@users.noreply.github.com>
This commit is contained in:
parent
6686c00b45
commit
3d1a52e139
1 changed files with 16 additions and 1 deletions
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import {
|
||||
EuiAccordion,
|
||||
|
@ -32,6 +32,19 @@ export const DefaultPipelineItem: React.FC<{
|
|||
pipelineName: string;
|
||||
pipelineState: IngestPipelineParams;
|
||||
}> = ({ index, indexName, ingestionMethod, openModal, pipelineName, pipelineState }) => {
|
||||
/**
|
||||
* If we don't open the accordion on load, the curl code never shows the copy button
|
||||
* Because if the accordion is closed, the code block is not present in the DOM
|
||||
* And EuiCodeBlock doesn't show the copy button if it's virtualized (ie not present in DOM)
|
||||
* It doesn't re-evaluate whether it's present in DOM if the inner text doesn't change
|
||||
* Opening and closing makes sure it's present in DOM on initial load, so the copy button shows
|
||||
* We use setImmediate to then close it on the next javascript loop
|
||||
*/
|
||||
const [accordionOpen, setAccordionOpen] = useState<boolean>(true);
|
||||
useEffect(() => {
|
||||
setImmediate(() => setAccordionOpen(false));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<EuiFlexGroup direction="column" gutterSize="xs">
|
||||
<EuiFlexItem>
|
||||
|
@ -65,6 +78,8 @@ export const DefaultPipelineItem: React.FC<{
|
|||
{ defaultMessage: 'Ingest a document using cURL' }
|
||||
)}
|
||||
id="ingestPipelinesCurlAccordion"
|
||||
forceState={accordionOpen ? 'open' : 'closed'}
|
||||
onClick={() => setAccordionOpen(!accordionOpen)}
|
||||
>
|
||||
<CurlRequest
|
||||
document={{ body: 'body', title: 'Title' }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue