Skip to content

Commit 657cee8

Browse files
committed
chore(NA): merge and solve conflicts with master
2 parents b690900 + 9232a5a commit 657cee8

97 files changed

Lines changed: 5064 additions & 2673 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Inspired on from https://raw.githubusercontent.com/bazelbuild/rules_nodejs/master/.bazelrc
1+
# Inspired by https://raw.githubusercontent.com/bazelbuild/rules_nodejs/master/.bazelrc
22
# Import shared settings first so we can override below
33
import %workspace%/.bazelrc.common
44

packages/kbn-pm/dist/index.js

Lines changed: 1206 additions & 1030 deletions
Large diffs are not rendered by default.

packages/kbn-pm/src/commands/clean.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@
66
* Public License, v 1.
77
*/
88

9+
import dedent from 'dedent';
910
import del from 'del';
1011
import ora from 'ora';
1112
import { join, relative } from 'path';
1213

14+
import { runBazel } from '../utils/bazel';
1315
import { isDirectory } from '../utils/fs';
1416
import { log } from '../utils/log';
1517
import { ICommand } from './';
1618

1719
export const CleanCommand: ICommand = {
18-
description: 'Remove the node_modules and target directories from all projects.',
20+
description: 'Deletes output directories, node_modules and resets internal caches.',
1921
name: 'clean',
2022

2123
async run(projects) {
24+
log.warning(dedent`
25+
This command is only necessary for the rare circumstance where you need to recover a consistent
26+
state when problems arise. If you need to run this command often, please let us know by
27+
filling out this form: https://ela.st/yarn-kbn-clean
28+
`);
29+
2230
const toDelete = [];
2331
for (const project of projects.values()) {
2432
if (await isDirectory(project.nodeModulesLocation)) {
@@ -44,6 +52,10 @@ export const CleanCommand: ICommand = {
4452
}
4553
}
4654

55+
// Runs Bazel soft clean
56+
await runBazel(['clean']);
57+
log.success('Soft cleaned bazel');
58+
4759
if (toDelete.length === 0) {
4860
log.success('Nothing to delete');
4961
} else {

packages/kbn-pm/src/commands/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ export interface ICommand {
2424

2525
import { BootstrapCommand } from './bootstrap';
2626
import { CleanCommand } from './clean';
27+
import { ResetCommand } from './reset';
2728
import { RunCommand } from './run';
2829
import { WatchCommand } from './watch';
2930
import { Kibana } from '../utils/kibana';
3031

3132
export const commands: { [key: string]: ICommand } = {
3233
bootstrap: BootstrapCommand,
3334
clean: CleanCommand,
35+
reset: ResetCommand,
3436
run: RunCommand,
3537
watch: WatchCommand,
3638
};
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* and the Server Side Public License, v 1; you may not use this file except in
5+
* compliance with, at your election, the Elastic License or the Server Side
6+
* Public License, v 1.
7+
*/
8+
9+
import dedent from 'dedent';
10+
import del from 'del';
11+
import ora from 'ora';
12+
import { join, relative } from 'path';
13+
14+
import { getBazelDiskCacheFolder, getBazelRepositoryCacheFolder, runBazel } from '../utils/bazel';
15+
import { isDirectory } from '../utils/fs';
16+
import { log } from '../utils/log';
17+
import { ICommand } from './';
18+
19+
export const ResetCommand: ICommand = {
20+
description:
21+
'Deletes node_modules and output directories, resets internal and disk caches, and stops Bazel server',
22+
name: 'reset',
23+
24+
async run(projects) {
25+
log.warning(dedent`
26+
In most cases, 'yarn kbn clean' is all that should be needed to recover a consistent state when
27+
problems arise. If you need to use this command, please let us know, as it should not be necessary.
28+
`);
29+
30+
const toDelete = [];
31+
for (const project of projects.values()) {
32+
if (await isDirectory(project.nodeModulesLocation)) {
33+
toDelete.push({
34+
cwd: project.path,
35+
pattern: relative(project.path, project.nodeModulesLocation),
36+
});
37+
}
38+
39+
if (await isDirectory(project.targetLocation)) {
40+
toDelete.push({
41+
cwd: project.path,
42+
pattern: relative(project.path, project.targetLocation),
43+
});
44+
}
45+
46+
const { extraPatterns } = project.getCleanConfig();
47+
if (extraPatterns) {
48+
toDelete.push({
49+
cwd: project.path,
50+
pattern: extraPatterns,
51+
});
52+
}
53+
}
54+
55+
// Runs Bazel hard clean
56+
await runBazel(['clean', '--expunge']);
57+
log.success('Hard cleaned bazel');
58+
59+
// Deletes Bazel Cache Folders
60+
await del([await getBazelDiskCacheFolder(), await getBazelRepositoryCacheFolder()], {
61+
force: true,
62+
});
63+
log.success('Removed disk caches');
64+
65+
if (toDelete.length === 0) {
66+
return;
67+
}
68+
69+
/**
70+
* In order to avoid patterns like `/build` in packages from accidentally
71+
* impacting files outside the package we use `process.chdir()` to change
72+
* the cwd to the package and execute `del()` without the `force` option
73+
* so it will check that each file being deleted is within the package.
74+
*
75+
* `del()` does support a `cwd` option, but it's only for resolving the
76+
* patterns and does not impact the cwd check.
77+
*/
78+
const originalCwd = process.cwd();
79+
try {
80+
for (const { pattern, cwd } of toDelete) {
81+
process.chdir(cwd);
82+
const promise = del(pattern);
83+
84+
if (log.wouldLogLevel('info')) {
85+
ora.promise(promise, relative(originalCwd, join(cwd, String(pattern))));
86+
}
87+
88+
await promise;
89+
}
90+
} finally {
91+
process.chdir(originalCwd);
92+
}
93+
},
94+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* and the Server Side Public License, v 1; you may not use this file except in
5+
* compliance with, at your election, the Elastic License or the Server Side
6+
* Public License, v 1.
7+
*/
8+
9+
import { dirname, resolve } from 'path';
10+
import { spawn } from '../child_process';
11+
12+
async function rawRunBazelInfoRepoCache() {
13+
const { stdout: bazelRepositoryCachePath } = await spawn('bazel', ['info', 'repository_cache'], {
14+
stdio: 'pipe',
15+
});
16+
return bazelRepositoryCachePath;
17+
}
18+
19+
export async function getBazelDiskCacheFolder() {
20+
return resolve(dirname(await rawRunBazelInfoRepoCache()), 'disk-cache');
21+
}
22+
23+
export async function getBazelRepositoryCacheFolder() {
24+
return await rawRunBazelInfoRepoCache();
25+
}

packages/kbn-pm/src/utils/bazel/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
* Public License, v 1.
77
*/
88

9-
export * from './run';
9+
export * from './get_cache_folders';
1010
export * from './install_tools';
11+
export * from './run';

packages/kbn-ui-shared-deps/flot_charts/index.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
/*
2-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* and the Server Side Public License, v 1; you may not use this file except in
5-
* compliance with, at your election, the Elastic License or the Server Side
6-
* Public License, v 1.
7-
*/
8-
91
/* @notice
102
*
113
* This product includes code that is based on flot-charts, which was available

src/plugins/dashboard/public/application/_dashboard_app.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,37 @@
3333
margin-left: $euiSizeS;
3434
text-align: center;
3535
}
36+
37+
.dshUnsavedListingItem {
38+
margin-top: $euiSizeM;
39+
}
40+
41+
.dshUnsavedListingItem__icon {
42+
margin-right: $euiSizeM;
43+
}
44+
45+
.dshUnsavedListingItem__title {
46+
margin-bottom: 0 !important;
47+
}
48+
49+
.dshUnsavedListingItem__loading {
50+
color: $euiTextSubduedColor !important;
51+
}
52+
53+
.dshUnsavedListingItem__actions {
54+
margin-left: $euiSizeL + $euiSizeXS;
55+
}
56+
57+
@include euiBreakpoint('xs', 's') {
58+
.dshUnsavedListingItem {
59+
margin-top: $euiSize;
60+
}
61+
62+
.dshUnsavedListingItem__heading {
63+
margin-bottom: $euiSizeXS;
64+
}
65+
66+
.dshUnsavedListingItem__actions {
67+
flex-direction: column;
68+
}
69+
}

src/plugins/dashboard/public/application/dashboard_router.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ import { Switch, Route, RouteComponentProps, HashRouter, Redirect } from 'react-
1515

1616
import { DashboardListing } from './listing';
1717
import { DashboardApp } from './dashboard_app';
18-
import { addHelpMenuToAppChrome } from './lib';
18+
import { addHelpMenuToAppChrome, DashboardPanelStorage } from './lib';
1919
import { createDashboardListingFilterUrl } from '../dashboard_constants';
2020
import { getDashboardPageTitle, dashboardReadonlyBadge } from '../dashboard_strings';
2121
import { createDashboardEditUrl, DashboardConstants } from '../dashboard_constants';
2222
import { DashboardAppServices, DashboardEmbedSettings, RedirectToProps } from './types';
23-
import { DashboardSetupDependencies, DashboardStart, DashboardStartDependencies } from '../plugin';
23+
import {
24+
DashboardFeatureFlagConfig,
25+
DashboardSetupDependencies,
26+
DashboardStart,
27+
DashboardStartDependencies,
28+
} from '../plugin';
2429

2530
import { createKbnUrlStateStorage, withNotifyOnErrors } from '../services/kibana_utils';
2631
import { KibanaContextProvider } from '../services/kibana_react';
@@ -94,8 +99,11 @@ export async function mountApp({
9499
indexPatterns: dataStart.indexPatterns,
95100
savedQueryService: dataStart.query.savedQueries,
96101
savedObjectsClient: coreStart.savedObjects.client,
102+
dashboardPanelStorage: new DashboardPanelStorage(core.notifications.toasts),
97103
savedDashboards: dashboardStart.getSavedDashboardLoader(),
98104
savedObjectsTagging: savedObjectsTaggingOss?.getTaggingApi(),
105+
allowByValueEmbeddables: initializerContext.config.get<DashboardFeatureFlagConfig>()
106+
.allowByValueEmbeddables,
99107
dashboardCapabilities: {
100108
hideWriteControls: dashboardConfig.getHideWriteControls(),
101109
show: Boolean(coreStart.application.capabilities.dashboard.show),
@@ -122,7 +130,7 @@ export async function mountApp({
122130
let destination;
123131
if (redirectTo.destination === 'dashboard') {
124132
destination = redirectTo.id
125-
? createDashboardEditUrl(redirectTo.id)
133+
? createDashboardEditUrl(redirectTo.id, redirectTo.editMode)
126134
: DashboardConstants.CREATE_NEW_DASHBOARD_URL;
127135
} else {
128136
destination = createDashboardListingFilterUrl(redirectTo.filter);

0 commit comments

Comments
 (0)