-
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 implement/v2-test-group-api
- Loading branch information
Showing
91 changed files
with
2,636 additions
and
1,195 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...-optimizer/src/babel_runtime_helpers/find_node_libs_browser_polyfills_in_entry_bundles.ts
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,53 @@ | ||
/* | ||
* 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 Path from 'path'; | ||
|
||
import { run } from '@kbn/dev-utils'; | ||
import { REPO_ROOT } from '@kbn/utils'; | ||
|
||
import { OptimizerConfig } from '../optimizer'; | ||
import { parseStats, inAnyEntryChunk } from './parse_stats'; | ||
|
||
export async function runFindNodeLibsBrowserPolyfillsInEntryBundlesCli() { | ||
run(async ({ log }) => { | ||
const config = OptimizerConfig.create({ | ||
includeCoreBundle: true, | ||
repoRoot: REPO_ROOT, | ||
}); | ||
|
||
const paths = config.bundles.map((b) => Path.resolve(b.outputDir, 'stats.json')); | ||
|
||
log.info('analyzing', paths.length, 'stats files'); | ||
log.verbose(paths); | ||
|
||
const imports = new Set(); | ||
for (const path of paths) { | ||
const stats = parseStats(path); | ||
|
||
for (const module of stats.modules) { | ||
if (!inAnyEntryChunk(stats, module)) { | ||
continue; | ||
} | ||
|
||
// Relying on module name instead of actual imports because these are usual polyfills that assume the global | ||
// Node.js environment when development (i.e.: Buffer doesn't require an import to be used). | ||
if (module.name.includes('node-libs-browser/node_modules/')) { | ||
imports.add(module.name); | ||
} | ||
} | ||
} | ||
|
||
log.success('found', imports.size, 'node-libs-browser/* imports in entry bundles'); | ||
log.write( | ||
Array.from(imports, (i) => `'${i}',`) | ||
.sort() | ||
.join('\n') | ||
); | ||
}); | ||
} |
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,10 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
require('../src/setup_node_env/no_transpilation'); | ||
require('@kbn/optimizer').runFindNodeLibsBrowserPolyfillsInEntryBundlesCli(); |
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
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
66 changes: 66 additions & 0 deletions
66
...ins/fleet/public/applications/fleet/components/fleet_server_instructions/advanced_tab.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,66 @@ | ||
/* | ||
* 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 { EuiSteps } from '@elastic/eui'; | ||
import React from 'react'; | ||
|
||
import { useAdvancedForm } from './hooks'; | ||
|
||
import { | ||
getAddFleetServerHostStep, | ||
getSelectAgentPolicyStep, | ||
getGenerateServiceTokenStep, | ||
getSetDeploymentModeStep, | ||
getInstallFleetServerStep, | ||
getConfirmFleetServerConnectionStep, | ||
} from './steps'; | ||
|
||
export const AdvancedTab: React.FunctionComponent = () => { | ||
const { | ||
eligibleFleetServerPolicies, | ||
refreshEligibleFleetServerPolicies, | ||
fleetServerPolicyId, | ||
setFleetServerPolicyId, | ||
isFleetServerReady, | ||
serviceToken, | ||
isLoadingServiceToken, | ||
generateServiceToken, | ||
fleetServerHostForm, | ||
deploymentMode, | ||
setDeploymentMode, | ||
} = useAdvancedForm(); | ||
|
||
const steps = [ | ||
getSelectAgentPolicyStep({ | ||
policyId: fleetServerPolicyId, | ||
setPolicyId: setFleetServerPolicyId, | ||
eligibleFleetServerPolicies, | ||
refreshEligibleFleetServerPolicies, | ||
}), | ||
getSetDeploymentModeStep({ | ||
deploymentMode, | ||
setDeploymentMode, | ||
disabled: !Boolean(fleetServerPolicyId), | ||
}), | ||
getAddFleetServerHostStep({ fleetServerHostForm, disabled: !Boolean(fleetServerPolicyId) }), | ||
getGenerateServiceTokenStep({ | ||
serviceToken, | ||
generateServiceToken, | ||
isLoadingServiceToken, | ||
disabled: !Boolean(fleetServerHostForm.isFleetServerHostSubmitted), | ||
}), | ||
getInstallFleetServerStep({ | ||
isFleetServerReady, | ||
serviceToken, | ||
fleetServerHost: fleetServerHostForm.fleetServerHost, | ||
fleetServerPolicyId, | ||
disabled: !Boolean(serviceToken), | ||
}), | ||
getConfirmFleetServerConnectionStep({ isFleetServerReady, disabled: !Boolean(serviceToken) }), | ||
]; | ||
|
||
return <EuiSteps steps={steps} className="eui-textLeft" />; | ||
}; |
77 changes: 77 additions & 0 deletions
77
...ions/fleet/components/fleet_server_instructions/components/fleet_server_host_combobox.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,77 @@ | ||
/* | ||
* 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, { useState } from 'react'; | ||
import type { EuiComboBoxOptionOption } from '@elastic/eui'; | ||
import { EuiComboBox, EuiText } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
interface Props { | ||
fleetServerHost: string | undefined; | ||
fleetServerHostSettings: string[]; | ||
isDisabled: boolean; | ||
isInvalid: boolean; | ||
onFleetServerHostChange: (host: string) => void; | ||
} | ||
|
||
export const FleetServerHostComboBox: React.FunctionComponent<Props> = ({ | ||
fleetServerHost, | ||
fleetServerHostSettings, | ||
isDisabled = false, | ||
isInvalid = false, | ||
onFleetServerHostChange, | ||
}) => { | ||
// Track options that are created inline | ||
const [createdOptions, setCreatedOptions] = useState<string[]>([]); | ||
|
||
const options = [...createdOptions, ...fleetServerHostSettings].map((option) => ({ | ||
label: option, | ||
value: option, | ||
})); | ||
|
||
const handleChange = (selectedOptions: Array<EuiComboBoxOptionOption<string>>) => { | ||
const host = selectedOptions[0].value ?? ''; | ||
onFleetServerHostChange(host); | ||
}; | ||
|
||
const handleCreateOption = (option: string) => { | ||
setCreatedOptions([...createdOptions, option]); | ||
onFleetServerHostChange(option); | ||
}; | ||
|
||
return ( | ||
<EuiComboBox<string> | ||
fullWidth | ||
isClearable={false} | ||
singleSelection={{ asPlainText: true }} | ||
placeholder="https://fleet-server-host.com:8220" | ||
options={options} | ||
customOptionText={i18n.translate( | ||
'xpack.fleet.fleetServerSetup.addFleetServerHostCustomOptionText', | ||
{ | ||
defaultMessage: 'Add {searchValuePlaceholder} as a new Fleet Server host', | ||
values: { searchValuePlaceholder: '{searchValue}' }, | ||
} | ||
)} | ||
selectedOptions={fleetServerHost ? [{ label: fleetServerHost, value: fleetServerHost }] : []} | ||
prepend={ | ||
<EuiText> | ||
<FormattedMessage | ||
id="xpack.fleet.fleetServerSetup.addFleetServerHostInputLabel" | ||
defaultMessage="Fleet Server host" | ||
/> | ||
</EuiText> | ||
} | ||
noSuggestions={fleetServerHostSettings.length === 0} | ||
data-test-subj="fleetServerHostInput" | ||
isDisabled={isDisabled} | ||
isInvalid={isInvalid} | ||
onChange={handleChange} | ||
onCreateOption={handleCreateOption} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.