Skip to content

Commit

Permalink
Merge branch 'master' into ingest/fix/72927
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 27, 2020
2 parents bc18957 + 6631a29 commit 42237b6
Show file tree
Hide file tree
Showing 231 changed files with 2,409 additions and 1,347 deletions.
21 changes: 12 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,19 +771,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 @@ -435,7 +435,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
29 changes: 20 additions & 9 deletions src/dev/build/tasks/os_packages/package_scripts/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ set -e

export KBN_PATH_CONF=${KBN_PATH_CONF:-<%= configDir %>}

set_chmod() {
chmod -f 660 ${KBN_PATH_CONF}/kibana.yml || true
chmod -f 2750 <%= dataDir %> || true
chmod -f 2750 ${KBN_PATH_CONF} || true
}

set_chown() {
chown -R <%= user %>:<%= group %> <%= dataDir %>
chown -R root:<%= group %> ${KBN_PATH_CONF}
}

set_access() {
set_chmod
set_chown
}

case $1 in
# Debian
configure)
Expand All @@ -14,6 +30,8 @@ case $1 in
adduser --quiet --system --no-create-home --disabled-password \
--ingroup "<%= group %>" --shell /bin/false "<%= user %>"
fi

set_access
;;
abort-deconfigure|abort-upgrade|abort-remove)
;;
Expand All @@ -28,19 +46,12 @@ case $1 in
useradd -r -g "<%= group %>" -M -s /sbin/nologin \
-c "kibana service user" "<%= user %>"
fi

set_access
;;

*)
echo "post install script called with unknown argument \`$1'" >&2
exit 1
;;
esac

chown -R <%= user %>:<%= group %> <%= dataDir %>
chmod 2750 <%= dataDir %>
chmod -R 2755 <%= dataDir %>/*

chown :<%= group %> ${KBN_PATH_CONF}
chown :<%= group %> ${KBN_PATH_CONF}/kibana.yml
chmod 2750 ${KBN_PATH_CONF}
chmod 660 ${KBN_PATH_CONF}/kibana.yml
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
1 change: 0 additions & 1 deletion test/functional/apps/visualize/_gauge_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function ({ getService, getPageObjects }) {
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'timePicker']);

// FLAKY: https://github.com/elastic/kibana/issues/45089
describe('gauge chart', function indexPatternCreation() {
async function initGaugeVis() {
log.debug('navigateToApp visualize');
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>
);
};
}
Loading

0 comments on commit 42237b6

Please sign in to comment.