Skip to content

Commit

Permalink
Merge branch 'master' into beats-cm/migrate-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored May 13, 2020
2 parents c25f6ae + ff1d129 commit 3fbc812
Show file tree
Hide file tree
Showing 635 changed files with 5,900 additions and 4,674 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
# Pulse
/packages/kbn-analytics/ @elastic/pulse
/src/legacy/core_plugins/ui_metric/ @elastic/pulse
/src/plugins/kibana_usage_collection/ @elastic/pulse
/src/plugins/telemetry/ @elastic/pulse
/src/plugins/telemetry_collection_manager/ @elastic/pulse
/src/plugins/telemetry_management_section/ @elastic/pulse
Expand Down
1 change: 1 addition & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ files:
- 'x-pack/plugins/cross_cluster_replication/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/maps/**/*.s+(a|c)ss'
- 'x-pack/plugins/maps/**/*.s+(a|c)ss'
- 'x-pack/plugins/spaces/**/*.s+(a|c)ss'
ignore:
- 'x-pack/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss'
rules:
Expand Down
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,34 @@ extract them to a `JSON` file or integrate translations back to Kibana. To know
We cannot support accepting contributions to the translations from any source other than the translators we have engaged to do the work.
We are still to develop a proper process to accept any contributed translations. We certainly appreciate that people care enough about the localization effort to want to help improve the quality. We aim to build out a more comprehensive localization process for the future and will notify you once contributions can be supported, but for the time being, we are not able to incorporate suggestions.

### Syling with SASS

When writing a new component, create a sibling SASS file of the same name and import directly into the JS/TS component file. Doing so ensures the styles are never separated or lost on import and allows for better modularization (smaller individual plugin asset footprint).

Any JavaScript (or TypeScript) file that imports SASS (.scss) files will automatically build with the [EUI](https://elastic.github.io/eui/#/guidelines/sass) & Kibana invisibles (SASS variables, mixins, functions) from the [`styling_constants.scss` file](https://github.com/elastic/kibana/blob/master/src/legacy/ui/public/styles/_styling_constants.scss). However, any Legacy (file path includes `/legacy`) files will not.

**Example:**

```tsx
// component.tsx

import './component.scss';

export const Component = () => {
return (
<div className="plgComponent" />
);
}
```

```scss
// component.scss

.plgComponent { ... }
```

Do not use the underscore `_` SASS file naming pattern when importing directly into a javascript file.

### Testing and Building

To ensure that your changes will not break other functionality, please run the test suite and build process before submitting your Pull Request.
Expand Down
8 changes: 4 additions & 4 deletions docs/api/features.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The API returns the following:
"id": "discover",
"name": "Discover",
"icon": "discoverApp",
"navLinkId": "kibana:discover",
"navLinkId": "discover",
"app": [
"kibana"
],
Expand Down Expand Up @@ -74,7 +74,7 @@ The API returns the following:
"id": "visualize",
"name": "Visualize",
"icon": "visualizeApp",
"navLinkId": "kibana:visualize",
"navLinkId": "visualize",
"app": [
"kibana"
],
Expand Down Expand Up @@ -121,7 +121,7 @@ The API returns the following:
"id": "dashboard",
"name": "Dashboard",
"icon": "dashboardApp",
"navLinkId": "kibana:dashboard",
"navLinkId": "dashboards",
"app": [
"kibana"
],
Expand Down Expand Up @@ -173,7 +173,7 @@ The API returns the following:
"id": "dev_tools",
"name": "Dev Tools",
"icon": "devToolsApp",
"navLinkId": "kibana:dev_tools",
"navLinkId": "dev_tools",
"app": [
"kibana"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ init(server) {
defaultMessage: 'Dev Tools',
}),
icon: 'devToolsApp',
navLinkId: 'kibana:dev_tools',
navLinkId: 'dev_tools',
app: ['kibana'],
catalogue: ['console', 'searchprofiler', 'grokdebugger'],
privileges: {
Expand Down Expand Up @@ -216,7 +216,7 @@ init(server) {
}),
order: 100,
icon: 'discoverApp',
navLinkId: 'kibana:discover',
navLinkId: 'discover',
app: ['kibana'],
catalogue: ['discover'],
privileges: {
Expand Down
2 changes: 1 addition & 1 deletion docs/user/dashboard.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ to view an embedded dashboard.
* Generate a PNG report

TIP: To create a link to a dashboard by title, use: +
`${domain}/${basepath?}/app/kibana#/dashboards?title=${yourdashboardtitle}`
`${domain}/${basepath?}/app/dashboards#/list?title=${yourdashboardtitle}`

TIP: When sharing a link to a dashboard snapshot, use the *Short URL*. Snapshot
URLs are long and can be problematic for Internet Explorer and other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function getAlertType(): AlertTypeModel {
}
return validationResult;
},
requiresAppContext: false,
};
}

Expand Down
1 change: 1 addition & 0 deletions examples/alerting_example/public/alert_types/astros.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function getAlertType(): AlertTypeModel {

return validationResult;
},
requiresAppContext: false,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import uuid from 'uuid';
import { range } from 'lodash';
import { AlertType } from '../../../../x-pack/plugins/alerting/server';
import { DEFAULT_INSTANCES_TO_GENERATE } from '../../common/constants';
import { DEFAULT_INSTANCES_TO_GENERATE, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';

export const alertType: AlertType = {
id: 'example.always-firing',
Expand All @@ -43,4 +43,5 @@ export const alertType: AlertType = {
count,
};
},
producer: ALERTING_EXAMPLE_APP_ID,
};
3 changes: 2 additions & 1 deletion examples/alerting_example/server/alert_types/astros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import axios from 'axios';
import { AlertType } from '../../../../x-pack/plugins/alerting/server';
import { Operator, Craft } from '../../common/constants';
import { Operator, Craft, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';

interface PeopleInSpace {
people: Array<{
Expand Down Expand Up @@ -79,4 +79,5 @@ export const alertType: AlertType = {
peopleInSpace,
};
},
producer: ALERTING_EXAMPLE_APP_ID,
};
2 changes: 0 additions & 2 deletions packages/kbn-plugin-helpers/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,4 @@ program
}))
);

program.command('postinstall').action(createCommanderAction('postinstall'));

program.parse(process.argv);
2 changes: 0 additions & 2 deletions packages/kbn-plugin-helpers/lib/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ const startTask = require('../tasks/start');
const testAllTask = require('../tasks/test/all');
const testKarmaTask = require('../tasks/test/karma');
const testMochaTask = require('../tasks/test/mocha');
const postinstallTask = require('../tasks/postinstall');

module.exports = {
build: buildTask,
start: startTask,
testAll: testAllTask,
testKarma: testKarmaTask,
testMocha: testMochaTask,
postinstall: postinstallTask,
};
30 changes: 30 additions & 0 deletions src/core/CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,36 @@ export class MyPlugin implements Plugin {
}
```

Prefer the pattern shown above, using `core.getStartServices()`, rather than store local references retrieved from `start`.

**Bad:**
```ts
export class MyPlugin implements Plugin {
// Anti pattern
private coreStart?: CoreStart;
private depsStart?: DepsStart;

public setup(core) {
core.application.register({
id: 'my-app',
async mount(params) {
const { renderApp } = await import('./application/my_app');
// Anti pattern - use `core.getStartServices()` instead!
return renderApp(this.coreStart, this.depsStart, params);
}
});
}

public start(core, deps) {
// Anti pattern
this.coreStart = core;
this.depsStart = deps;
}
}
```

The main reason to prefer the provided async accessor, is that it doesn't requires the developer to understand and reason about when that function can be called. Having an API that fails sometimes isn't a good API design, and it makes accurately testing this difficult.

#### Services

Service structure should mirror the plugin lifecycle to make reasoning about how the service is executed more clear.
Expand Down
4 changes: 2 additions & 2 deletions src/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Core is a set of systems (frontend, backend etc.) that Kibana and its plugins ar

## Plugin development
Core Plugin API Documentation:
- [Core Public API](/docs/development/core/public/kibana-plugin-public.md)
- [Core Server API](/docs/development/core/server/kibana-plugin-server.md)
- [Core Public API](/docs/development/core/public/kibana-plugin-core-public.md)
- [Core Server API](/docs/development/core/server/kibana-plugin-core-server.md)
- [Conventions for Plugins](./CONVENTIONS.md)
- [Testing Kibana Plugins](./TESTING.md)
- [Migration guide for porting existing plugins](./MIGRATION.md)
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class ChromeService {
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))}
homeHref={http.basePath.prepend('/app/kibana#/home')}
homeHref={http.basePath.prepend('/app/home')}
isVisible$={this.isVisible$}
kibanaVersion={injectedMetadata.getKibanaVersion()}
legacyMode={injectedMetadata.getLegacyMode()}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/public/chrome/ui/header/collapsible_nav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function mockProps() {
storage: new StubBrowserStorage(),
onIsOpenUpdate: () => {},
onIsLockedUpdate: () => {},
navigateToApp: () => {},
};
}

Expand Down
16 changes: 15 additions & 1 deletion src/core/public/chrome/ui/header/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface Props {
storage?: Storage;
onIsLockedUpdate: OnIsLockedUpdate;
onIsOpenUpdate: (isOpen?: boolean) => void;
navigateToApp: (appId: string) => void;
}

export function CollapsibleNav({
Expand All @@ -89,6 +90,7 @@ export function CollapsibleNav({
onIsOpenUpdate,
homeHref,
id,
navigateToApp,
storage = window.localStorage,
}: Props) {
const lockRef = useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -124,7 +126,19 @@ export function CollapsibleNav({
label: 'Home',
iconType: 'home',
href: homeHref,
onClick: () => onIsOpenUpdate(false),
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
onIsOpenUpdate(false);
if (
event.isDefaultPrevented() ||
event.altKey ||
event.metaKey ||
event.ctrlKey
) {
return;
}
event.preventDefault();
navigateToApp('home');
},
},
]}
maxWidth="none"
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export class Header extends Component<HeaderProps, State> {
href={this.props.homeHref}
forceNavigation={this.state.forceNavigation}
navLinks={navLinks}
navigateToApp={this.props.application.navigateToApp}
/>
</EuiHeaderSectionItem>

Expand Down Expand Up @@ -287,6 +288,7 @@ export class Header extends Component<HeaderProps, State> {
this.toggleCollapsibleNavRef.current.focus();
}
}}
navigateToApp={this.props.application.navigateToApp}
/>
) : (
// TODO #64541
Expand Down
Loading

0 comments on commit 3fbc812

Please sign in to comment.