-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:elastic/kibana into service-inven…
…tory
- Loading branch information
Showing
79 changed files
with
11,222 additions
and
13,106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { buildContextMenuForActions } from './build_eui_context_menu_panels'; | ||
import { Action, createAction } from '../actions'; | ||
|
||
const createTestAction = ({ | ||
type, | ||
dispayName, | ||
order, | ||
}: { | ||
type: string; | ||
dispayName: string; | ||
order: number; | ||
}) => | ||
createAction({ | ||
type: type as any, // mapping doesn't matter for this test | ||
getDisplayName: () => dispayName, | ||
order, | ||
execute: async () => {}, | ||
}); | ||
|
||
test('contextMenu actions sorting: order, type, displayName', async () => { | ||
const actions: Action[] = [ | ||
createTestAction({ | ||
order: 100, | ||
type: '1', | ||
dispayName: 'a', | ||
}), | ||
createTestAction({ | ||
order: 100, | ||
type: '1', | ||
dispayName: 'b', | ||
}), | ||
createTestAction({ | ||
order: 0, | ||
type: '2', | ||
dispayName: 'c', | ||
}), | ||
createTestAction({ | ||
order: 0, | ||
type: '2', | ||
dispayName: 'd', | ||
}), | ||
createTestAction({ | ||
order: 0, | ||
type: '3', | ||
dispayName: 'aa', | ||
}), | ||
].sort(() => 0.5 - Math.random()); | ||
|
||
const result = await buildContextMenuForActions({ | ||
actions: actions.map((action) => ({ action, context: {}, trigger: '' as any })), | ||
}); | ||
|
||
expect(result.items?.map((item) => item.name as string)).toMatchInlineSnapshot(` | ||
Array [ | ||
"a", | ||
"b", | ||
"c", | ||
"d", | ||
"aa", | ||
] | ||
`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/plugins/visualizations/server/usage_collector/get_past_days.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import moment from 'moment'; | ||
import { getPastDays } from './get_past_days'; | ||
|
||
describe('getPastDays', () => { | ||
test('Returns 2 days that have passed from the current date', () => { | ||
const pastDate = moment().subtract(2, 'days').startOf('day').toString(); | ||
|
||
expect(getPastDays(pastDate)).toEqual(2); | ||
}); | ||
|
||
test('Returns 30 days that have passed from the current date', () => { | ||
const pastDate = moment().subtract(30, 'days').startOf('day').toString(); | ||
|
||
expect(getPastDays(pastDate)).toEqual(30); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
src/plugins/visualizations/server/usage_collector/get_past_days.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export const getPastDays = (dateString: string): number => { | ||
const date = new Date(dateString); | ||
const today = new Date(); | ||
const diff = Math.abs(date.getTime() - today.getTime()); | ||
return Math.trunc(diff / (1000 * 60 * 60 * 24)); | ||
}; |
Oops, something went wrong.