Skip to content

Commit

Permalink
Merge branch '7.x' of github.com:elastic/kibana into pr/73328
Browse files Browse the repository at this point in the history
# Conflicts:
#	yarn.lock
  • Loading branch information
spalger committed Jul 27, 2020
2 parents db2184e + 0f2d863 commit e652619
Show file tree
Hide file tree
Showing 146 changed files with 988 additions and 770 deletions.
21 changes: 12 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,19 +775,22 @@ module.exports = {
},

/**
* APM overrides
* APM and Observability overrides
*/
{
files: ['x-pack/plugins/apm/**/*.js'],
files: [
'x-pack/plugins/apm/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability/**/*.{js,mjs,ts,tsx}',
],
rules: {
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
'no-console': ['warn', { allow: ['error'] }],
},
},
{
plugins: ['react-hooks'],
files: ['x-pack/plugins/apm/**/*.{ts,tsx}'],
rules: {
'react/function-component-definition': [
'warn',
{
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
},
],
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': ['error', { additionalHooks: '^useFetcher$' }],
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-react-perf": "^3.2.3",
"exit-hook": "^2.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ describe('Inspector Data View', () => {
});

it('should render loading state', () => {
const component = mountWithIntl(<DataView.component title="Test Data" adapters={adapters} />);
const component = mountWithIntl(<DataView.component title="Test Data" adapters={adapters} />); // eslint-disable-line react/jsx-pascal-case

expect(component).toMatchSnapshot();
});

it('should render empty state', async () => {
const component = mountWithIntl(<DataView.component title="Test Data" adapters={adapters} />);
const component = mountWithIntl(<DataView.component title="Test Data" adapters={adapters} />); // eslint-disable-line react/jsx-pascal-case
const tabularLoader = Promise.resolve(null);
adapters.data.setTabularLoader(() => tabularLoader);
await tabularLoader;
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/apm/e2e/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module.exports = (on) => {

// readFileMaybe
on('task', {
// ESLint thinks this is a react component for some reason.
// eslint-disable-next-line react/function-component-definition
readFileMaybe(filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8');
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/apm/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const MainContainer = styled.div`
height: 100%;
`;

const App = () => {
function App() {
const [darkMode] = useUiSetting$<boolean>('theme:darkMode');

return (
Expand All @@ -59,9 +59,9 @@ const App = () => {
</MainContainer>
</ThemeProvider>
);
};
}

const ApmAppRoot = ({
function ApmAppRoot({
core,
deps,
routerHistory,
Expand All @@ -71,7 +71,7 @@ const ApmAppRoot = ({
deps: ApmPluginSetupDeps;
routerHistory: typeof history;
config: ConfigSchema;
}) => {
}) {
const i18nCore = core.i18n;
const plugins = deps;
const apmPluginContextValue = {
Expand Down Expand Up @@ -111,7 +111,7 @@ const ApmAppRoot = ({
</AlertsContextProvider>
</ApmPluginContext.Provider>
);
};
}

/**
* This module is rendered asynchronously in the Kibana platform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface Props {
items: ErrorGroupListAPIResponse;
}

const ErrorGroupList: React.FC<Props> = (props) => {
function ErrorGroupList(props: Props) {
const { items } = props;
const { urlParams } = useUrlParams();
const { serviceName } = urlParams;
Expand Down Expand Up @@ -213,6 +213,6 @@ const ErrorGroupList: React.FC<Props> = (props) => {
sortItems={false}
/>
);
};
}

export { ErrorGroupList };
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { ErrorDistribution } from '../ErrorGroupDetails/Distribution';
import { ErrorGroupList } from './List';

const ErrorGroupOverview: React.FC = () => {
function ErrorGroupOverview() {
const { urlParams, uiFilters } = useUrlParams();

const { serviceName, start, end, sortField, sortDirection } = urlParams;
Expand Down Expand Up @@ -123,6 +123,6 @@ const ErrorGroupOverview: React.FC = () => {
</EuiFlexGroup>
</>
);
};
}

export { ErrorGroupOverview };
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '../../../context/ApmPluginContext/MockApmPluginContext';

const setBreadcrumbs = jest.fn();
const changeTitle = jest.fn();

function mountBreadcrumb(route: string, params = '') {
mount(
Expand All @@ -27,6 +28,7 @@ function mountBreadcrumb(route: string, params = '') {
...mockApmPluginContextValue.core,
chrome: {
...mockApmPluginContextValue.core.chrome,
docTitle: { change: changeTitle },
setBreadcrumbs,
},
},
Expand All @@ -42,23 +44,14 @@ function mountBreadcrumb(route: string, params = '') {
}

describe('UpdateBreadcrumbs', () => {
let realDoc: Document;

beforeEach(() => {
realDoc = window.document;
(window.document as any) = {
title: 'Kibana',
};
setBreadcrumbs.mockReset();
changeTitle.mockReset();
});

afterEach(() => {
(window.document as any) = realDoc;
});

it('Homepage', () => {
it('Changes the homepage title', () => {
mountBreadcrumb('/');
expect(window.document.title).toMatchInlineSnapshot(`"APM"`);
expect(changeTitle).toHaveBeenCalledWith(['APM']);
});

it('/services/:serviceName/errors/:groupId', () => {
Expand Down Expand Up @@ -90,9 +83,13 @@ describe('UpdateBreadcrumbs', () => {
},
{ text: 'myGroupId', href: undefined },
]);
expect(window.document.title).toMatchInlineSnapshot(
`"myGroupId | Errors | opbeans-node | Services | APM"`
);
expect(changeTitle).toHaveBeenCalledWith([
'myGroupId',
'Errors',
'opbeans-node',
'Services',
'APM',
]);
});

it('/services/:serviceName/errors', () => {
Expand All @@ -104,9 +101,12 @@ describe('UpdateBreadcrumbs', () => {
{ text: 'opbeans-node', href: '#/services/opbeans-node?kuery=myKuery' },
{ text: 'Errors', href: undefined },
]);
expect(window.document.title).toMatchInlineSnapshot(
`"Errors | opbeans-node | Services | APM"`
);
expect(changeTitle).toHaveBeenCalledWith([
'Errors',
'opbeans-node',
'Services',
'APM',
]);
});

it('/services/:serviceName/transactions', () => {
Expand All @@ -118,9 +118,12 @@ describe('UpdateBreadcrumbs', () => {
{ text: 'opbeans-node', href: '#/services/opbeans-node?kuery=myKuery' },
{ text: 'Transactions', href: undefined },
]);
expect(window.document.title).toMatchInlineSnapshot(
`"Transactions | opbeans-node | Services | APM"`
);
expect(changeTitle).toHaveBeenCalledWith([
'Transactions',
'opbeans-node',
'Services',
'APM',
]);
});

it('/services/:serviceName/transactions/view?transactionName=my-transaction-name', () => {
Expand All @@ -139,8 +142,12 @@ describe('UpdateBreadcrumbs', () => {
},
{ text: 'my-transaction-name', href: undefined },
]);
expect(window.document.title).toMatchInlineSnapshot(
`"my-transaction-name | Transactions | opbeans-node | Services | APM"`
);
expect(changeTitle).toHaveBeenCalledWith([
'my-transaction-name',
'Transactions',
'opbeans-node',
'Services',
'APM',
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ interface Props {
}

function getTitleFromBreadCrumbs(breadcrumbs: Breadcrumb[]) {
return breadcrumbs
.map(({ value }) => value)
.reverse()
.join(' | ');
return breadcrumbs.map(({ value }) => value).reverse();
}

class UpdateBreadcrumbsComponent extends React.Component<Props> {
Expand All @@ -43,7 +40,9 @@ class UpdateBreadcrumbsComponent extends React.Component<Props> {
}
);

document.title = getTitleFromBreadCrumbs(this.props.breadcrumbs);
this.props.core.chrome.docTitle.change(
getTitleFromBreadCrumbs(this.props.breadcrumbs)
);
this.props.core.chrome.setBreadcrumbs(breadcrumbs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ interface Props {
onBreakdownChange: (values: BreakdownItem[]) => void;
}

export const BreakdownFilter = ({
export function BreakdownFilter({
id,
selectedBreakdowns,
onBreakdownChange,
}: Props) => {
}: Props) {
const categories: BreakdownItem[] = [
{
name: 'Browser',
Expand Down Expand Up @@ -65,4 +65,4 @@ export const BreakdownFilter = ({
}}
/>
);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export interface BreakdownGroupProps {
onChange: (values: BreakdownItem[]) => void;
}

export const BreakdownGroup = ({
export function BreakdownGroup({
id,
disabled,
onChange,
items,
}: BreakdownGroupProps) => {
}: BreakdownGroupProps) {
const [isOpen, setIsOpen] = useState<boolean>(false);

const [activeItems, setActiveItems] = useState<BreakdownItem[]>(items);
Expand Down Expand Up @@ -97,4 +97,4 @@ export const BreakdownGroup = ({
</EuiPopover>
</EuiFilterGroup>
);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { FC, HTMLAttributes } from 'react';
import React, { HTMLAttributes, ReactNode } from 'react';
import {
EuiErrorBoundary,
EuiFlexGroup,
Expand All @@ -13,6 +13,7 @@ import {
} from '@elastic/eui';

interface Props {
children?: ReactNode;
/**
* Height for the chart
*/
Expand All @@ -27,12 +28,12 @@ interface Props {
'aria-label'?: string;
}

export const ChartWrapper: FC<Props> = ({
export function ChartWrapper({
loading = false,
height = '100%',
children,
...rest
}) => {
}: Props) {
const opacity = loading === true ? 0.3 : 1;

return (
Expand Down Expand Up @@ -60,4 +61,4 @@ export const ChartWrapper: FC<Props> = ({
)}
</EuiErrorBoundary>
);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function PageLoadDistChart({
onPercentileChange(minX, maxX);
};

// eslint-disable-next-line react/function-component-definition
const headerFormatter: TooltipValueFormatter = (tooltip: TooltipValue) => {
return (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Props {
}>;
}

export const VisitorBreakdownChart = ({ options }: Props) => {
export function VisitorBreakdownChart({ options }: Props) {
const [darkMode] = useUiSetting$<boolean>('theme:darkMode');

return (
Expand Down Expand Up @@ -93,4 +93,4 @@ export const VisitorBreakdownChart = ({ options }: Props) => {
</Chart>
</ChartWrapper>
);
};
}
Loading

0 comments on commit e652619

Please sign in to comment.