Skip to content

Commit

Permalink
Merge branch 'master' into discover-saved-object-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 11, 2021
2 parents 150a2ca + c73dc23 commit 54a9508
Show file tree
Hide file tree
Showing 55 changed files with 514 additions and 176 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/developer/advanced/images/sharing-saved-objects-step-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions docs/developer/advanced/sharing-saved-objects.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ export class MyPlugin implements Plugin<{}, {}, {}, PluginStartDeps> {
if (spacesApi && resolveResult.outcome === 'aliasMatch') {
// We found this object by a legacy URL alias from its old ID; redirect the user to the page with its new ID, preserving any URL hash
const newObjectId = resolveResult.alias_target_id!; // This is always defined if outcome === 'aliasMatch'
const newPath = http.basePath.prepend(
`path/to/this/page/${newObjectId}${window.location.hash}`
);
const newPath = `/this/page/${newObjectId}${window.location.hash}`; // Use the *local* path within this app (do not include the "/app/appId" prefix)
await spacesApi.ui.redirectLegacyUrl(newPath, OBJECT_NOUN);
return;
}
Expand All @@ -255,9 +253,7 @@ const getLegacyUrlConflictCallout = () => {
// callout with a warning for the user, and provide a way for them to navigate to the other object.
const currentObjectId = savedObject.id;
const otherObjectId = resolveResult.alias_target_id!; // This is always defined if outcome === 'conflict'
const otherObjectPath = http.basePath.prepend(
`path/to/this/page/${otherObjectId}${window.location.hash}`
);
const otherObjectPath = `/this/page/${otherObjectId}${window.location.hash}`; // Use the *local* path within this app (do not include the "/app/appId" prefix)
return (
<>
{spacesApi.ui.components.getLegacyUrlConflict({
Expand Down Expand Up @@ -391,6 +387,13 @@ These should be handled on a case-by-case basis at the plugin owner's discretion
* Any "secondary" objects on the page may handle the outcomes differently. If the secondary object ID is not important (for example, it just
functions as a page anchor), it may make more sense to ignore the different outcomes. If the secondary object _is_ important but it is not
directly represented in the UI, it may make more sense to throw a descriptive error when a `'conflict'` outcome is encountered.
- Embeddables should use `spacesApi.ui.components.getEmbeddableLegacyUrlConflict` to render conflict errors:
+
image::images/sharing-saved-objects-faq-multiple-deep-link-objects-1.png["Sharing Saved Objects embeddable legacy URL conflict"]
Viewing details shows the user how to disable the alias and fix the problem using the
<<spaces-api-disable-legacy-url-aliases,_disable_legacy_url_aliases API>>:
+
image::images/sharing-saved-objects-faq-multiple-deep-link-objects-2.png["Sharing Saved Objects embeddable legacy URL conflict (showing details)"]
- If the secondary object is resolved by an external service (such as the index pattern service), the service should simply make the full
outcome available to consumers.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ readonly links: {
datastreamsNamingScheme: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
}>;
readonly ecs: {
readonly guide: string;
Expand Down
4 changes: 3 additions & 1 deletion packages/kbn-cli-dev-mode/src/optimizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import { Optimizer, Options } from './optimizer';

jest.mock('@kbn/optimizer');
const realOptimizer = jest.requireActual('@kbn/optimizer');
const { runOptimizer, OptimizerConfig, logOptimizerState } = jest.requireMock('@kbn/optimizer');
const { runOptimizer, OptimizerConfig, logOptimizerState, logOptimizerProgress } =
jest.requireMock('@kbn/optimizer');

logOptimizerState.mockImplementation(realOptimizer.logOptimizerState);
logOptimizerProgress.mockImplementation(realOptimizer.logOptimizerProgress);

class MockOptimizerConfig {}

Expand Down
9 changes: 8 additions & 1 deletion packages/kbn-cli-dev-mode/src/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ import {
} from '@kbn/dev-utils';
import * as Rx from 'rxjs';
import { ignoreElements } from 'rxjs/operators';
import { runOptimizer, OptimizerConfig, logOptimizerState, OptimizerUpdate } from '@kbn/optimizer';
import {
runOptimizer,
OptimizerConfig,
logOptimizerState,
logOptimizerProgress,
OptimizerUpdate,
} from '@kbn/optimizer';

export interface Options {
enabled: boolean;
Expand Down Expand Up @@ -111,6 +117,7 @@ export class Optimizer {
subscriber.add(
runOptimizer(config)
.pipe(
logOptimizerProgress(log),
logOptimizerState(log, config),
tap(({ state }) => {
this.phase$.next(state.phase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Path from 'path';
import crypto from 'crypto';
import execa from 'execa';
import Axios from 'axios';
// @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things
import httpAdapter from 'axios/lib/adapters/http';

import { ToolingLog } from '../tooling_log';
import { parseConfig, Config } from './ci_stats_config';
Expand Down Expand Up @@ -225,6 +227,7 @@ export class CiStatsReporter {
baseURL: BASE_URL,
headers,
data: body,
adapter: httpAdapter,
});

return true;
Expand Down
15 changes: 14 additions & 1 deletion packages/kbn-optimizer/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { lastValueFrom } from '@kbn/std';
import { run, createFlagError, Flags } from '@kbn/dev-utils';

import { logOptimizerState } from './log_optimizer_state';
import { logOptimizerProgress } from './log_optimizer_progress';
import { OptimizerConfig } from './optimizer';
import { runOptimizer } from './run_optimizer';
import { validateLimitsForAllBundles, updateBundleLimits } from './limits';
Expand Down Expand Up @@ -97,6 +98,11 @@ export function runKbnOptimizerCli(options: { defaultLimitsPath: string }) {
throw createFlagError('expected --report-stats to have no value');
}

const logProgress = flags.progress ?? false;
if (typeof logProgress !== 'boolean') {
throw createFlagError('expected --progress to have no value');
}

const filter = typeof flags.filter === 'string' ? [flags.filter] : flags.filter;
if (!Array.isArray(filter) || !filter.every((f) => typeof f === 'string')) {
throw createFlagError('expected --filter to be one or more strings');
Expand Down Expand Up @@ -144,7 +150,11 @@ export function runKbnOptimizerCli(options: { defaultLimitsPath: string }) {
const update$ = runOptimizer(config);

await lastValueFrom(
update$.pipe(logOptimizerState(log, config), reportOptimizerTimings(log, config))
update$.pipe(
logProgress ? logOptimizerProgress(log) : (x) => x,
logOptimizerState(log, config),
reportOptimizerTimings(log, config)
)
);

if (updateLimits) {
Expand All @@ -169,19 +179,22 @@ export function runKbnOptimizerCli(options: { defaultLimitsPath: string }) {
'inspect-workers',
'validate-limits',
'update-limits',
'progress',
],
string: ['workers', 'scan-dir', 'filter', 'limits'],
default: {
core: true,
examples: true,
cache: true,
'inspect-workers': true,
progress: true,
filter: [],
focus: [],
},
help: `
--watch run the optimizer in watch mode
--workers max number of workers to use
--no-progress disable logging of progress information
--oss only build oss plugins
--profile profile the webpack builds and write stats.json files to build outputs
--no-core disable generating the core bundle
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export { OptimizerConfig } from './optimizer';
export * from './run_optimizer';
export * from './log_optimizer_state';
export * from './log_optimizer_progress';
export * from './node';
export * from './limits';
export * from './cli';
Expand Down
62 changes: 62 additions & 0 deletions packages/kbn-optimizer/src/log_optimizer_progress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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 { ToolingLog } from '@kbn/dev-utils';
import * as Rx from 'rxjs';
import { tap } from 'rxjs/operators';

import { OptimizerUpdate } from './run_optimizer';

const PROGRESS_REPORT_INTERVAL = 10_000;

export function logOptimizerProgress(
log: ToolingLog
): Rx.MonoTypeOperatorFunction<OptimizerUpdate> {
return (update$) =>
new Rx.Observable((subscriber) => {
const allBundleIds = new Set();
const completeBundles = new Set();
let loggedCompletion = new Set();

// catalog bundle ids and which have completed at least once, forward
// updates to next subscriber
subscriber.add(
update$
.pipe(
tap(({ state }) => {
for (const { bundleId, type } of state.compilerStates) {
allBundleIds.add(bundleId);
if (type !== 'running') {
completeBundles.add(bundleId);
}
}
}),
tap(subscriber)
)
.subscribe()
);

// on interval check to see if at least 3 new bundles have completed at
// least one build and log about our progress if so
subscriber.add(
Rx.interval(PROGRESS_REPORT_INTERVAL).subscribe(
() => {
if (completeBundles.size - loggedCompletion.size < 3) {
return;
}

log.info(
`[${completeBundles.size}/${allBundleIds.size}] initial bundle builds complete`
);
loggedCompletion = new Set(completeBundles);
},
(error) => subscriber.error(error)
)
);
});
}
7 changes: 2 additions & 5 deletions packages/kbn-optimizer/src/log_optimizer_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ export function logOptimizerState(log: ToolingLog, config: OptimizerConfig) {
continue;
}

bundleStates.set(id, type);

if (type === 'running') {
bundlesThatWereBuilt.add(id);
}

bundleStates.set(id, type);
log.debug(
`[${id}] state = "${type}"${type !== 'running' ? ` after ${state.durSec} sec` : ''}`
);
}

if (state.phase === 'running' || state.phase === 'initializing') {
Expand Down
6 changes: 5 additions & 1 deletion packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8965,6 +8965,8 @@ var _execa = _interopRequireDefault(__webpack_require__(134));

var _axios = _interopRequireDefault(__webpack_require__(177));

var _http = _interopRequireDefault(__webpack_require__(199));

var _ci_stats_config = __webpack_require__(218);

/*
Expand All @@ -8974,6 +8976,7 @@ var _ci_stats_config = __webpack_require__(218);
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
// @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things
const BASE_URL = 'https://ci-stats.kibana.dev';

class CiStatsReporter {
Expand Down Expand Up @@ -9173,7 +9176,8 @@ class CiStatsReporter {
url: path,
baseURL: BASE_URL,
headers,
data: body
data: body,
adapter: _http.default
});
return true;
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ export class DocLinksService {
datastreamsNamingScheme: `${FLEET_DOCS}data-streams.html#data-streams-naming-scheme`,
upgradeElasticAgent: `${FLEET_DOCS}upgrade-elastic-agent.html`,
upgradeElasticAgent712lower: `${FLEET_DOCS}upgrade-elastic-agent.html#upgrade-7.12-lower`,
learnMoreBlog: `${ELASTIC_WEBSITE_URL}blog/elastic-agent-and-fleet-make-it-easier-to-integrate-your-systems-with-elastic`,
},
ecs: {
guide: `${ELASTIC_WEBSITE_URL}guide/en/ecs/current/index.html`,
Expand Down Expand Up @@ -730,6 +731,7 @@ export interface DocLinksStart {
datastreamsNamingScheme: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
}>;
readonly ecs: {
readonly guide: string;
Expand Down
1 change: 1 addition & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ export interface DocLinksStart {
datastreamsNamingScheme: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
}>;
readonly ecs: {
readonly guide: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ export const useField = <T, FormType = FormData, I = T>(
if (resetValue) {
hasBeenReset.current = true;
const newValue = deserializeValue(updatedDefaultValue ?? defaultValue);
// updateStateIfMounted('value', newValue);
setValue(newValue);
return newValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,17 @@ export const EditPackagePolicyForm = memo<{
fill
data-test-subj="saveIntegration"
>
<FormattedMessage
id="xpack.fleet.editPackagePolicy.saveButton"
defaultMessage="Save integration"
/>
{isUpgrade ? (
<FormattedMessage
id="xpack.fleet.editPackagePolicy.upgradeButton"
defaultMessage="Upgrade integration"
/>
) : (
<FormattedMessage
id="xpack.fleet.editPackagePolicy.saveButton"
defaultMessage="Save integration"
/>
)}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface ListProps {
setSelectedCategory: (category: string) => void;
onSearchChange: (search: string) => void;
showMissingIntegrationMessage?: boolean;
callout?: JSX.Element | null;
}

export function PackageListGrid({
Expand All @@ -49,6 +50,7 @@ export function PackageListGrid({
onSearchChange,
setSelectedCategory,
showMissingIntegrationMessage = false,
callout,
}: ListProps) {
const [searchTerm, setSearchTerm] = useState(initialSearch || '');
const localSearchRef = useLocalSearch(list);
Expand Down Expand Up @@ -105,6 +107,7 @@ export function PackageListGrid({
}}
onChange={onQueryChange}
/>
{callout ? callout : null}
<EuiSpacer />
{gridContent}
{showMissingIntegrationMessage && (
Expand Down
Loading

0 comments on commit 54a9508

Please sign in to comment.