Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 63762
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Apr 30, 2020
2 parents 3e64a00 + 497c5da commit 59dbde7
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,21 @@ test('tests processing object field with property, reverse order', () => {
const mappings = generateMappings(processedFields);
expect(JSON.stringify(mappings)).toEqual(JSON.stringify(objectFieldWithPropertyReversedMapping));
});

test('tests constant_keyword field type handling', () => {
const constantKeywordLiteralYaml = `
- name: constantKeyword
type: constant_keyword
`;
const constantKeywordMapping = {
properties: {
constantKeyword: {
type: 'constant_keyword',
},
},
};
const fields: Field[] = safeLoad(constantKeywordLiteralYaml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(JSON.stringify(mappings)).toEqual(JSON.stringify(constantKeywordMapping));
});
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ describe('creating index patterns from yaml fields', () => {
{ fields: [{ name: 'testField', type: 'text' }], expect: 'string' },
{ fields: [{ name: 'testField', type: 'date' }], expect: 'date' },
{ fields: [{ name: 'testField', type: 'geo_point' }], expect: 'geo_point' },
{ fields: [{ name: 'testField', type: 'constant_keyword' }], expect: 'string' },
];

tests.forEach(test => {
Expand Down Expand Up @@ -191,6 +192,7 @@ describe('creating index patterns from yaml fields', () => {
attr: 'aggregatable',
},
{ fields: [{ name, type: 'keyword' }], expect: true, attr: 'aggregatable' },
{ fields: [{ name, type: 'constant_keyword' }], expect: true, attr: 'aggregatable' },
{ fields: [{ name, type: 'text', aggregatable: true }], expect: false, attr: 'aggregatable' },
{ fields: [{ name, type: 'text' }], expect: false, attr: 'aggregatable' },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const typeMap: TypeMap = {
date: 'date',
ip: 'ip',
boolean: 'boolean',
constant_keyword: 'string',
};

export interface IndexPatternField {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/common/types/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export const userMlCapabilities = {
canGetCalendars: false,
// File Data Visualizer
canFindFileStructure: false,
// Filters
canGetFilters: false,
// Data Frame Analytics
canGetDataFrameAnalytics: false,
// Annotations
Expand All @@ -38,6 +36,8 @@ export const adminMlCapabilities = {
canStartStopDatafeed: false,
canUpdateDatafeed: false,
canPreviewDatafeed: false,
// Filters
canGetFilters: false,
// Calendars
canCreateCalendar: false,
canDeleteCalendar: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '../../hooks/use_create_analytics_form';
import { State } from '../../hooks/use_create_analytics_form/state';
import { DataFrameAnalyticsListRow } from './common';
import { checkPermission } from '../../../../../capabilities/check_capabilities';

interface PropDefinition {
/**
Expand Down Expand Up @@ -322,6 +323,8 @@ interface CloneActionProps {
* to support EuiContext with a valid DOM structure without nested buttons.
*/
export const CloneAction: FC<CloneActionProps> = ({ createAnalyticsForm, item }) => {
const canCreateDataFrameAnalytics: boolean = checkPermission('canCreateDataFrameAnalytics');

const buttonText = i18n.translate('xpack.ml.dataframe.analyticsList.cloneJobButtonLabel', {
defaultMessage: 'Clone job',
});
Expand All @@ -338,6 +341,7 @@ export const CloneAction: FC<CloneActionProps> = ({ createAnalyticsForm, item })
iconType="copy"
onClick={onClick}
aria-label={buttonText}
disabled={canCreateDataFrameAnalytics === false}
>
{buttonText}
</EuiButtonEmpty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('check_capabilities', () => {
expect(capabilities.canGetDatafeeds).toBe(true);
expect(capabilities.canGetCalendars).toBe(true);
expect(capabilities.canFindFileStructure).toBe(true);
expect(capabilities.canGetFilters).toBe(true);
expect(capabilities.canGetDataFrameAnalytics).toBe(true);
expect(capabilities.canGetAnnotations).toBe(true);
expect(capabilities.canCreateAnnotation).toBe(true);
Expand All @@ -81,6 +80,7 @@ describe('check_capabilities', () => {
expect(capabilities.canDeleteDatafeed).toBe(false);
expect(capabilities.canUpdateDatafeed).toBe(false);
expect(capabilities.canPreviewDatafeed).toBe(false);
expect(capabilities.canGetFilters).toBe(false);
expect(capabilities.canCreateCalendar).toBe(false);
expect(capabilities.canDeleteCalendar).toBe(false);
expect(capabilities.canCreateFilter).toBe(false);
Expand Down Expand Up @@ -113,7 +113,6 @@ describe('check_capabilities', () => {
expect(capabilities.canGetDatafeeds).toBe(true);
expect(capabilities.canGetCalendars).toBe(true);
expect(capabilities.canFindFileStructure).toBe(true);
expect(capabilities.canGetFilters).toBe(true);
expect(capabilities.canGetDataFrameAnalytics).toBe(true);
expect(capabilities.canGetAnnotations).toBe(true);
expect(capabilities.canCreateAnnotation).toBe(true);
Expand All @@ -130,6 +129,7 @@ describe('check_capabilities', () => {
expect(capabilities.canDeleteDatafeed).toBe(true);
expect(capabilities.canUpdateDatafeed).toBe(true);
expect(capabilities.canPreviewDatafeed).toBe(true);
expect(capabilities.canGetFilters).toBe(true);
expect(capabilities.canCreateCalendar).toBe(true);
expect(capabilities.canDeleteCalendar).toBe(true);
expect(capabilities.canCreateFilter).toBe(true);
Expand Down Expand Up @@ -162,7 +162,6 @@ describe('check_capabilities', () => {
expect(capabilities.canGetDatafeeds).toBe(true);
expect(capabilities.canGetCalendars).toBe(true);
expect(capabilities.canFindFileStructure).toBe(true);
expect(capabilities.canGetFilters).toBe(true);
expect(capabilities.canGetDataFrameAnalytics).toBe(true);
expect(capabilities.canGetAnnotations).toBe(true);
expect(capabilities.canCreateAnnotation).toBe(false);
Expand All @@ -177,6 +176,7 @@ describe('check_capabilities', () => {
expect(capabilities.canUpdateJob).toBe(false);
expect(capabilities.canCreateDatafeed).toBe(false);
expect(capabilities.canDeleteDatafeed).toBe(false);
expect(capabilities.canGetFilters).toBe(false);
expect(capabilities.canUpdateDatafeed).toBe(false);
expect(capabilities.canPreviewDatafeed).toBe(false);
expect(capabilities.canCreateCalendar).toBe(false);
Expand Down Expand Up @@ -211,7 +211,6 @@ describe('check_capabilities', () => {
expect(capabilities.canGetDatafeeds).toBe(true);
expect(capabilities.canGetCalendars).toBe(true);
expect(capabilities.canFindFileStructure).toBe(true);
expect(capabilities.canGetFilters).toBe(true);
expect(capabilities.canGetDataFrameAnalytics).toBe(true);
expect(capabilities.canGetAnnotations).toBe(true);
expect(capabilities.canCreateAnnotation).toBe(false);
Expand All @@ -228,6 +227,7 @@ describe('check_capabilities', () => {
expect(capabilities.canDeleteDatafeed).toBe(false);
expect(capabilities.canUpdateDatafeed).toBe(false);
expect(capabilities.canPreviewDatafeed).toBe(false);
expect(capabilities.canGetFilters).toBe(false);
expect(capabilities.canCreateCalendar).toBe(false);
expect(capabilities.canDeleteCalendar).toBe(false);
expect(capabilities.canCreateFilter).toBe(false);
Expand Down Expand Up @@ -260,7 +260,6 @@ describe('check_capabilities', () => {
expect(capabilities.canGetDatafeeds).toBe(false);
expect(capabilities.canGetCalendars).toBe(false);
expect(capabilities.canFindFileStructure).toBe(false);
expect(capabilities.canGetFilters).toBe(false);
expect(capabilities.canGetDataFrameAnalytics).toBe(false);
expect(capabilities.canGetAnnotations).toBe(false);
expect(capabilities.canCreateAnnotation).toBe(false);
Expand All @@ -277,6 +276,7 @@ describe('check_capabilities', () => {
expect(capabilities.canDeleteDatafeed).toBe(false);
expect(capabilities.canUpdateDatafeed).toBe(false);
expect(capabilities.canPreviewDatafeed).toBe(false);
expect(capabilities.canGetFilters).toBe(false);
expect(capabilities.canCreateCalendar).toBe(false);
expect(capabilities.canDeleteCalendar).toBe(false);
expect(capabilities.canCreateFilter).toBe(false);
Expand Down Expand Up @@ -311,7 +311,6 @@ describe('check_capabilities', () => {
expect(capabilities.canGetDatafeeds).toBe(false);
expect(capabilities.canGetCalendars).toBe(false);
expect(capabilities.canFindFileStructure).toBe(false);
expect(capabilities.canGetFilters).toBe(false);
expect(capabilities.canGetDataFrameAnalytics).toBe(false);
expect(capabilities.canGetAnnotations).toBe(false);
expect(capabilities.canCreateAnnotation).toBe(false);
Expand All @@ -328,6 +327,7 @@ describe('check_capabilities', () => {
expect(capabilities.canDeleteDatafeed).toBe(false);
expect(capabilities.canUpdateDatafeed).toBe(false);
expect(capabilities.canPreviewDatafeed).toBe(false);
expect(capabilities.canGetFilters).toBe(false);
expect(capabilities.canCreateCalendar).toBe(false);
expect(capabilities.canDeleteCalendar).toBe(false);
expect(capabilities.canCreateFilter).toBe(false);
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -15899,7 +15899,6 @@
"xpack.triggersActionsUI.sections.alertsList.actionTypeFilterLabel": "アクションタイプ",
"xpack.triggersActionsUI.sections.alertsList.addActionButtonLabel": "アラートの作成",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.alertTypeTitle": "タイプ",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle": "編集",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.intervalTitle": "次の間隔で実行",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.nameTitle": "名前",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.tagsText": "タグ",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -15904,7 +15904,6 @@
"xpack.triggersActionsUI.sections.alertsList.actionTypeFilterLabel": "操作类型",
"xpack.triggersActionsUI.sections.alertsList.addActionButtonLabel": "创建告警",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.alertTypeTitle": "类型",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle": "编辑",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.intervalTitle": "运行间隔",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.nameTitle": "名称",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.tagsText": "标记",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,25 @@ describe('alert_form', () => {
const alertTypeSelectOptions = wrapper.find('[data-test-subj="selectedAlertTypeTitle"]');
expect(alertTypeSelectOptions.exists()).toBeTruthy();
});

it('should update throttle value', async () => {
const newThrottle = 17;
await setup();
const throttleField = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleField.exists()).toBeTruthy();
throttleField.at(1).simulate('change', { target: { value: newThrottle.toString() } });
const throttleFieldAfterUpdate = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleFieldAfterUpdate.at(1).prop('value')).toEqual(newThrottle);
});

it('should unset throttle value', async () => {
const newThrottle = '';
await setup();
const throttleField = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleField.exists()).toBeTruthy();
throttleField.at(1).simulate('change', { target: { value: newThrottle } });
const throttleFieldAfterUpdate = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleFieldAfterUpdate.at(1).prop('value')).toEqual(newThrottle);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ describe('alerts_list component with items', () => {
expect(wrapper.find('EuiBasicTable')).toHaveLength(1);
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
});
it('renders edit button for registered alert types', async () => {
await setup();
expect(wrapper.find('[data-test-subj="alertsTableCell-editLink"]').length).toBeGreaterThan(0);
});
});

describe('alerts_list component empty with show only capability', () => {
Expand Down Expand Up @@ -442,8 +438,4 @@ describe('alerts_list with show only capability', () => {
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
// TODO: check delete button
});
it('not renders edit button for non registered alert types', async () => {
await setup();
expect(wrapper.find('[data-test-subj="alertsTableCell-editLink"]').length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { isEmpty } from 'lodash';
import { AlertsContextProvider } from '../../../context/alerts_context';
import { useAppDependencies } from '../../../app_context';
import { ActionType, Alert, AlertTableItem, AlertTypeIndex, Pagination } from '../../../../types';
import { AlertAdd, AlertEdit } from '../../alert_form';
import { AlertAdd } from '../../alert_form';
import { BulkOperationPopover } from '../../common/components/bulk_operation_popover';
import { AlertQuickEditButtonsWithApi as AlertQuickEditButtons } from '../../common/components/alert_quick_edit_buttons';
import { CollapsedItemActionsWithApi as CollapsedItemActions } from './collapsed_item_actions';
Expand Down Expand Up @@ -85,8 +85,6 @@ export const AlertsList: React.FunctionComponent = () => {
data: [],
totalItemCount: 0,
});
const [editedAlertItem, setEditedAlertItem] = useState<AlertTableItem | undefined>(undefined);
const [editFlyoutVisible, setEditFlyoutVisibility] = useState<boolean>(false);
const [alertsToDelete, setAlertsToDelete] = useState<string[]>([]);

useEffect(() => {
Expand Down Expand Up @@ -162,11 +160,6 @@ export const AlertsList: React.FunctionComponent = () => {
}
}

async function editItem(alertTableItem: AlertTableItem) {
setEditedAlertItem(alertTableItem);
setEditFlyoutVisibility(true);
}

const alertsTableColumns = [
{
field: 'name',
Expand Down Expand Up @@ -219,27 +212,6 @@ export const AlertsList: React.FunctionComponent = () => {
truncateText: false,
'data-test-subj': 'alertsTableCell-interval',
},
{
name: '',
width: '50px',
render(item: AlertTableItem) {
if (!canSave || !alertTypeRegistry.has(item.alertTypeId)) {
return;
}
return (
<EuiLink
data-test-subj="alertsTableCell-editLink"
color="primary"
onClick={() => editItem(item)}
>
<FormattedMessage
defaultMessage="Edit"
id="xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle"
/>
</EuiLink>
);
},
},
{
name: '',
width: '40px',
Expand Down Expand Up @@ -453,14 +425,6 @@ export const AlertsList: React.FunctionComponent = () => {
addFlyoutVisible={alertFlyoutVisible}
setAddFlyoutVisibility={setAlertFlyoutVisibility}
/>
{editFlyoutVisible && editedAlertItem ? (
<AlertEdit
key={editedAlertItem.id}
initialAlert={editedAlertItem}
editFlyoutVisible={editFlyoutVisible}
setEditFlyoutVisibility={setEditFlyoutVisibility}
/>
) : null}
</AlertsContextProvider>
</section>
);
Expand Down
Loading

0 comments on commit 59dbde7

Please sign in to comment.