Skip to content

Commit

Permalink
Merge branch 'master' into field_list_not_indexed-array_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Oct 14, 2019
2 parents f1fbb7e + 209fef0 commit b0fb48b
Show file tree
Hide file tree
Showing 159 changed files with 3,642 additions and 11,350 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
# Platform
/src/core/ @elastic/kibana-platform
/src/legacy/server/saved_objects/ @elastic/kibana-platform
/src/legacy/ui/public/saved_objects @elastic/kibana-platform
/config/kibana.yml @elastic/kibana-platform
/x-pack/plugins/features/ @elastic/kibana-platform

Expand All @@ -56,6 +55,7 @@
/x-pack/legacy/plugins/encrypted_saved_objects/ @elastic/kibana-security
/src/legacy/server/csp/ @elastic/kibana-security
/x-pack/plugins/security/ @elastic/kibana-security
/x-pack/test/api_integration/apis/security/ @elastic/kibana-security

# Kibana Stack Services
/packages/kbn-analytics/ @elastic/kibana-stack-services
Expand Down
2 changes: 1 addition & 1 deletion docs/management/dashboard_only_mode/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[[xpack-dashboard-only-mode]]
== Dashboard-only mode

deprecated[7.4.0, Using the `kibana_dashboard_only_user` role is deprecated. Use <<kibana-feature-privileges,feature privileges>> instead.]
deprecated[7.4.0, "Using the `kibana_dashboard_only_user` role is deprecated. Use <<kibana-feature-privileges,feature privileges>> instead."]

In dashboard-only mode, users have access to only the *Dashboard* app.
Users can view and filter the dashboards, but cannot create, edit, or delete
Expand Down
6 changes: 6 additions & 0 deletions docs/settings/code-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Whitelist of protocols for git clone address. Defaults to `[ 'https', 'git', 'ss
`xpack.code.security.enableGitCertCheck`::
Whether enable HTTPS certificate check when clone from HTTPS URL.

`xpack.code.security.enableJavaSecurityManager`::
Whether enable Java security manager for Java langserver. Defaults to `true`.

`xpack.code.security.extraJavaRepositoryWhitelist`::
Whitelist of extra repository to download dependencies for Java language. Defaults to `[]`.

`xpack.code.maxWorkspace`::
Maximal number of workspaces each language server allows to span. Defaults to `5`.

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"@babel/register": "^7.5.5",
"@elastic/charts": "^13.5.1",
"@elastic/datemath": "5.0.2",
"@elastic/ems-client": "^1.0.2",
"@elastic/eui": "14.4.0",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2",
Expand Down Expand Up @@ -171,7 +172,7 @@
"hapi": "^17.5.3",
"hapi-auth-cookie": "^9.0.0",
"history": "^4.9.0",
"hjson": "3.1.2",
"hjson": "3.2.0",
"hoek": "^5.0.4",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.2",
Expand Down Expand Up @@ -358,7 +359,7 @@
"babel-jest": "^24.9.0",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-istanbul": "^5.2.0",
"backport": "4.7.1",
"backport": "4.7.3",
"chai": "3.5.0",
"chance": "1.0.18",
"cheerio": "0.22.0",
Expand Down Expand Up @@ -446,7 +447,7 @@
"strip-ansi": "^3.0.1",
"supertest": "^3.1.0",
"supertest-as-promised": "^4.0.2",
"tree-kill": "^1.1.0",
"tree-kill": "^1.2.1",
"typescript": "3.5.3",
"typings-tester": "^0.3.2",
"vinyl-fs": "^3.0.3",
Expand Down
32 changes: 20 additions & 12 deletions packages/kbn-babel-preset/common_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,28 @@
* under the License.
*/

const plugins = [
require.resolve('babel-plugin-add-module-exports'),

// The class properties proposal was merged with the private fields proposal
// into the "class fields" proposal. Babel doesn't support this combined
// proposal yet, which includes private field, so this transform is
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
//
// See https://github.com/babel/proposals/issues/12 for progress
require.resolve('@babel/plugin-proposal-class-properties'),
];

module.exports = {
presets: [require.resolve('@babel/preset-typescript'), require.resolve('@babel/preset-react')],
plugins: [
require.resolve('@kbn/elastic-idx/babel'),
require.resolve('babel-plugin-add-module-exports'),

// The class properties proposal was merged with the private fields proposal
// into the "class fields" proposal. Babel doesn't support this combined
// proposal yet, which includes private field, so this transform is
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
//
// See https://github.com/babel/proposals/issues/12 for progress
require.resolve('@babel/plugin-proposal-class-properties'),
],
plugins: plugins.concat(require.resolve('@kbn/elastic-idx/babel')),
// Do not use the idx plugin in the test environment because it causes
// causes conflicts with Jest's coverage mapping.
env: {
test: {
plugins,
},
},
overrides: [
{
// Babel 7 don't support the namespace feature on typescript code.
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"getopts": "^2.2.5",
"moment": "^2.20.1",
"rxjs": "^6.2.1",
"tree-kill": "^1.2.0",
"tree-kill": "^1.2.1",
"tslib": "^1.9.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/src/proc_runner/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import chalk from 'chalk';

import treeKill from 'tree-kill';
import { promisify } from 'util';
const treeKillAsync = promisify(treeKill);
const treeKillAsync = promisify((...args: [number, string, any]) => treeKill(...args));

import { ToolingLog } from '../tooling_log';
import { observeLines } from './observe_lines';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"node-fetch": "^2.6.0",
"simple-git": "^1.91.0",
"tar-fs": "^1.16.3",
"tree-kill": "^1.1.0",
"tree-kill": "^1.2.1",
"yauzl": "^2.10.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { i18n } from '@kbn/i18n';
import { fieldFormats } from 'ui/registry/field_formats';
// @ts-ignore
import { expandShorthand } from 'ui/utils/mapping_setup';
import { toastNotifications } from 'ui/notify';
import { findObjectByTitle } from 'ui/saved_objects';
import { NotificationsSetup, SavedObjectsClientContract } from 'src/core/public';
import { SavedObjectNotFound, DuplicateField } from '../../../../../../plugins/kibana_utils/public';
Expand Down Expand Up @@ -462,7 +461,7 @@ export class IndexPattern implements StaticIndexPattern {
'Unable to write index pattern! Refresh the page to get the most up to date changes for this index pattern.',
} // eslint-disable-line max-len
);
toastNotifications.addDanger(message);
this.notifications.toasts.addDanger(message);
throw err;
}

Expand Down Expand Up @@ -501,11 +500,11 @@ export class IndexPattern implements StaticIndexPattern {
// but we do not want to potentially make any pages unusable
// so do not rethrow the error here
if (err instanceof IndexPatternMissingIndices) {
toastNotifications.addDanger((err as any).message);
this.notifications.toasts.addDanger((err as any).message);
return [];
}

toastNotifications.addError(err, {
this.notifications.toasts.addError(err, {
title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import { SavedQuery } from '../../index';
import { SavedQueryService } from '../../lib/saved_query_service';
import { SavedQueryListItem } from './saved_query_list_item';

const pageCount = 50;

const perPage = 50;
interface Props {
showSaveQuery?: boolean;
loadedSavedQuery?: SavedQuery;
Expand All @@ -61,18 +60,22 @@ export const SavedQueryManagementComponent: FunctionComponent<Props> = ({
}) => {
const [isOpen, setIsOpen] = useState(false);
const [savedQueries, setSavedQueries] = useState([] as SavedQuery[]);
const [count, setTotalCount] = useState(0);
const [activePage, setActivePage] = useState(0);

useEffect(() => {
const fetchQueries = async () => {
const allSavedQueries = await savedQueryService.getAllSavedQueries();
const sortedAllSavedQueries = sortBy(allSavedQueries, 'attributes.title');
setSavedQueries(sortedAllSavedQueries);
const fetchCountAndSavedQueries = async () => {
const savedQueryCount = await savedQueryService.getSavedQueryCount();
setTotalCount(savedQueryCount);

const savedQueryItems = await savedQueryService.findSavedQueries('', perPage, activePage + 1);
const sortedSavedQueryItems = sortBy(savedQueryItems, 'attributes.title');
setSavedQueries(sortedSavedQueryItems);
};
if (isOpen) {
fetchQueries();
fetchCountAndSavedQueries();
}
}, [isOpen]);
}, [isOpen, activePage]);

const goToPage = (pageNumber: number) => {
setActivePage(pageNumber);
Expand Down Expand Up @@ -131,7 +134,6 @@ export const SavedQueryManagementComponent: FunctionComponent<Props> = ({
);

const savedQueryRows = () => {
// we should be recalculating the savedQueryRows after a delete action
const savedQueriesWithoutCurrent = savedQueries.filter(savedQuery => {
if (!loadedSavedQuery) return true;
return savedQuery.id !== loadedSavedQuery.id;
Expand All @@ -140,11 +142,7 @@ export const SavedQueryManagementComponent: FunctionComponent<Props> = ({
loadedSavedQuery && savedQueriesWithoutCurrent.length !== savedQueries.length
? [loadedSavedQuery, ...savedQueriesWithoutCurrent]
: [...savedQueriesWithoutCurrent];
const savedQueriesDisplayRows = savedQueriesReordered.slice(
activePage * pageCount,
activePage * pageCount + pageCount
);
return savedQueriesDisplayRows.map(savedQuery => (
return savedQueriesReordered.map(savedQuery => (
<SavedQueryListItem
key={savedQuery.id}
savedQuery={savedQuery}
Expand Down Expand Up @@ -195,7 +193,7 @@ export const SavedQueryManagementComponent: FunctionComponent<Props> = ({
</div>
<EuiPagination
className="kbnSavedQueryManagement__pagination"
pageCount={Math.ceil(savedQueries.length / pageCount)}
pageCount={Math.ceil(count / perPage)}
activePage={activePage}
onPageClick={goToPage}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ const savedQueryAttributes: SavedQueryAttributes = {
query: 'response:200',
},
};
const savedQueryAttributesBar: SavedQueryAttributes = {
title: 'bar',
description: 'baz',
query: {
language: 'kuery',
query: 'response:200',
},
};

const savedQueryAttributesWithFilters: SavedQueryAttributes = {
...savedQueryAttributes,
Expand Down Expand Up @@ -61,7 +69,14 @@ const mockSavedObjectsClient = {
delete: jest.fn(),
};

const { deleteSavedQuery, getSavedQuery, findSavedQueries, saveQuery } = createSavedQueryService(
const {
deleteSavedQuery,
getSavedQuery,
findSavedQueries,
saveQuery,
getAllSavedQueries,
getSavedQueryCount,
} = createSavedQueryService(
// @ts-ignore
mockSavedObjectsClient
);
Expand Down Expand Up @@ -151,7 +166,7 @@ describe('saved query service', () => {
});
});
describe('findSavedQueries', function() {
it('should find and return saved queries without search text', async () => {
it('should find and return saved queries without search text or pagination parameters', async () => {
mockSavedObjectsClient.find.mockReturnValue({
savedObjects: [{ id: 'foo', attributes: savedQueryAttributes }],
});
Expand All @@ -166,6 +181,8 @@ describe('saved query service', () => {
});
const response = await findSavedQueries('foo');
expect(mockSavedObjectsClient.find).toHaveBeenCalledWith({
page: 1,
perPage: 50,
search: 'foo',
searchFields: ['title^5', 'description'],
sortField: '_score',
Expand Down Expand Up @@ -203,6 +220,43 @@ describe('saved query service', () => {
])
);
});
it('should accept perPage and page properties', async () => {
mockSavedObjectsClient.find.mockReturnValue({
savedObjects: [
{ id: 'foo', attributes: savedQueryAttributes },
{ id: 'bar', attributes: savedQueryAttributesBar },
],
});
const response = await findSavedQueries(undefined, 2, 1);
expect(mockSavedObjectsClient.find).toHaveBeenCalledWith({
page: 1,
perPage: 2,
search: '',
searchFields: ['title^5', 'description'],
sortField: '_score',
type: 'query',
});
expect(response).toEqual(
expect.objectContaining([
{
attributes: {
description: 'bar',
query: { language: 'kuery', query: 'response:200' },
title: 'foo',
},
id: 'foo',
},
{
attributes: {
description: 'baz',
query: { language: 'kuery', query: 'response:200' },
title: 'bar',
},
id: 'bar',
},
])
);
});
});

describe('getSavedQuery', function() {
Expand All @@ -226,4 +280,40 @@ describe('saved query service', () => {
expect(mockSavedObjectsClient.delete).toHaveBeenCalledWith('query', 'foo');
});
});

describe('getAllSavedQueries', function() {
it('should return all the saved queries', async () => {
mockSavedObjectsClient.find.mockReturnValue({
savedObjects: [{ id: 'foo', attributes: savedQueryAttributes }],
});
const response = await getAllSavedQueries();
expect(response).toEqual(
expect.objectContaining([
{
attributes: {
description: 'bar',
query: { language: 'kuery', query: 'response:200' },
title: 'foo',
},
id: 'foo',
},
])
);
expect(mockSavedObjectsClient.find).toHaveBeenCalledWith({
page: 1,
perPage: 0,
type: 'query',
});
});
});

describe('getSavedQueryCount', function() {
it('should return the total number of saved queries', async () => {
mockSavedObjectsClient.find.mockReturnValue({
total: 1,
});
const response = await getSavedQueryCount();
expect(response).toEqual(1);
});
});
});
Loading

0 comments on commit b0fb48b

Please sign in to comment.