Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] calendar eui conversion #26741

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9ccf174
Create calendar list in react
alvarezmelissa87 Nov 20, 2018
928d19a
wip: create new_calendar page
alvarezmelissa87 Nov 20, 2018
506436e
Update new calendar settings directory name
alvarezmelissa87 Nov 21, 2018
10047e0
Edit button action + update utils
alvarezmelissa87 Nov 26, 2018
33b8349
Adds ability to create new calendar
alvarezmelissa87 Nov 26, 2018
b964ab4
Display calendar data on edit
alvarezmelissa87 Nov 26, 2018
5b26098
rename directory to settings/calendar
alvarezmelissa87 Nov 27, 2018
ad9cce2
Add scss files to calendar dir
alvarezmelissa87 Nov 27, 2018
b50886e
Create new group from form
alvarezmelissa87 Nov 27, 2018
ca01ff7
Adds event table and partial event modal.
alvarezmelissa87 Nov 27, 2018
a7f5cd3
adds datepicker to modal
alvarezmelissa87 Nov 28, 2018
d3eebd6
Time range event functionality
alvarezmelissa87 Nov 30, 2018
df8dee8
add import event functionality
alvarezmelissa87 Dec 4, 2018
fd4b3c9
upate new event modal design
alvarezmelissa87 Dec 4, 2018
e82862d
Add error handling to list/edit
alvarezmelissa87 Dec 4, 2018
fb7bac7
calendarId validity check
alvarezmelissa87 Dec 4, 2018
2b23fff
Create/delete permission. List/form style tweak
alvarezmelissa87 Dec 5, 2018
4ebdf0b
Update calendarList to match filterList
alvarezmelissa87 Dec 5, 2018
85d0678
Add missing newlines in scss files
alvarezmelissa87 Dec 6, 2018
d9e0530
Initial tests for calendar list
alvarezmelissa87 Dec 6, 2018
38ce90c
Update classnames to meet guidelines
alvarezmelissa87 Dec 7, 2018
c8d6248
ImportedEvents component + create utils
alvarezmelissa87 Dec 7, 2018
b5d6c24
remove unnecessary import
alvarezmelissa87 Dec 10, 2018
2fc753b
rename calendars dir
alvarezmelissa87 Dec 10, 2018
f8d7a3b
include past evens in import if checkbox checked
alvarezmelissa87 Dec 10, 2018
9ed166c
code review updates
alvarezmelissa87 Dec 10, 2018
1ba8bc6
move components into own directories
alvarezmelissa87 Dec 10, 2018
3059db9
update index.scss with dir name change
alvarezmelissa87 Dec 11, 2018
0677295
skip irrelevant tests
alvarezmelissa87 Dec 11, 2018
7f8ca52
fix unsaved event deletion. rename scss file.
alvarezmelissa87 Dec 11, 2018
36ad67d
Add modal tests
alvarezmelissa87 Dec 11, 2018
52ef6e5
Show calendarId and description as header on edit
alvarezmelissa87 Dec 12, 2018
7152675
update snapshot for refactor
alvarezmelissa87 Dec 12, 2018
369f356
update classnames to BEM guidelines
alvarezmelissa87 Dec 12, 2018
3bbc4f7
Update snapshot for classname change
alvarezmelissa87 Dec 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/settings/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import 'settings';
@import 'filter_lists/index';
@import 'scheduled_events/index';
@import 'calendars/index';
4 changes: 4 additions & 0 deletions x-pack/plugins/ml/public/settings/calendars/_calendars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.mlCalendarManagement {
background: $euiColorLightestShade;
min-height: 100vh;
}
3 changes: 3 additions & 0 deletions x-pack/plugins/ml/public/settings/calendars/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import 'calendars';
@import 'edit/index';
@import 'list/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`NewCalendar Renders new calendar form 1`] = `
<EuiPage
className="mlCalendarEditForm"
restrictWidth={false}
>
<EuiPageContent
className="mlCalendarEditForm__content"
horizontalPosition="center"
panelPaddingSize="l"
verticalPosition="center"
>
<CalendarForm
calendarId=""
description=""
eventsList={Array []}
groupIds={Array []}
isEdit={false}
isNewCalendarIdValid={true}
jobIds={Array []}
onCalendarIdChange={[Function]}
onCreate={[Function]}
onCreateGroupOption={[Function]}
onDescriptionChange={[Function]}
onEdit={[Function]}
onEventDelete={[Function]}
onGroupSelection={[Function]}
onJobSelection={[Function]}
saving={false}
selectedGroupOptions={Array []}
selectedJobOptions={Array []}
showImportModal={[Function]}
showNewEventModal={[Function]}
/>
</EuiPageContent>
</EuiPage>
`;
8 changes: 8 additions & 0 deletions x-pack/plugins/ml/public/settings/calendars/edit/_edit.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.mlCalendarEditForm {
.mlCalendarEditForm__content {
max-width: map-get($euiBreakpoints, 'xl');
width: 100%;
margin-top: $euiSize;
margin-bottom: $euiSize;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'edit';
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CalendarForm Renders calendar form 1`] = `
<EuiForm>
<React.Fragment>
<EuiFormRow
describedByIds={Array []}
error={
Array [
"Use lowercase alphanumerics (a-z and 0-9), hyphens or underscores;
must start and end with an alphanumeric character",
]
}
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={true}
label="Calendar ID"
>
<EuiFieldText
compressed={false}
disabled={false}
fullWidth={false}
isLoading={false}
name="calendarId"
onChange={[MockFunction]}
value=""
/>
</EuiFormRow>
<EuiFormRow
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Description"
>
<EuiFieldText
compressed={false}
disabled={false}
fullWidth={false}
isLoading={false}
name="description"
onChange={[MockFunction]}
value=""
/>
</EuiFormRow>
</React.Fragment>
<EuiFormRow
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Jobs"
>
<EuiComboBox
compressed={false}
disabled={false}
fullWidth={false}
isClearable={true}
onChange={[MockFunction]}
options={Array []}
selectedOptions={Array []}
singleSelection={false}
/>
</EuiFormRow>
<EuiFormRow
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Groups"
>
<EuiComboBox
compressed={false}
disabled={false}
fullWidth={false}
isClearable={true}
onChange={[MockFunction]}
onCreateOption={[MockFunction]}
options={Array []}
selectedOptions={Array []}
singleSelection={false}
/>
</EuiFormRow>
<EuiSpacer
size="xl"
/>
<EuiFormRow
describedByIds={Array []}
fullWidth={true}
hasEmptyLabelSpace={false}
label="Events"
>
<EventsTable
eventsList={Array []}
onDeleteClick={[MockFunction]}
showImportModal={[MockFunction]}
showNewEventModal={[MockFunction]}
showSearchBar={true}
/>
</EuiFormRow>
<EuiSpacer
size="l"
/>
<EuiFlexGroup
alignItems="stretch"
component="div"
direction="row"
gutterSize="l"
justifyContent="flexEnd"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={false}
>
<EuiButton
color="primary"
disabled={true}
fill={true}
iconSide="left"
onClick={[MockFunction]}
type="button"
>
Save
</EuiButton>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<EuiButton
color="primary"
disabled={false}
fill={false}
href="undefined/app/ml#/settings/calendars_list"
iconSide="left"
type="button"
>
Cancel
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiForm>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/



import React, { Fragment } from 'react';
import { PropTypes } from 'prop-types';

import {
EuiButton,
EuiComboBox,
EuiFieldText,
EuiFlexGroup,
EuiFlexItem,
EuiForm,
EuiFormRow,
EuiSpacer,
EuiText,
EuiTitle,
} from '@elastic/eui';

import chrome from 'ui/chrome';
import { EventsTable } from '../events_table/';


function EditHeader({
calendarId,
description
}) {
return (
<Fragment>
<EuiTitle>
<h1>Calendar {calendarId}</h1>
</EuiTitle>
<EuiText>
<p>
{description}
</p>
</EuiText>
<EuiSpacer size="l"/>
</Fragment>
);
}

export function CalendarForm({
calendarId,
description,
eventsList,
groupIds,
isEdit,
isNewCalendarIdValid,
jobIds,
onCalendarIdChange,
onCreate,
onCreateGroupOption,
onDescriptionChange,
onEdit,
onEventDelete,
onGroupSelection,
showImportModal,
onJobSelection,
saving,
selectedGroupOptions,
selectedJobOptions,
showNewEventModal
}) {
const msg = `Use lowercase alphanumerics (a-z and 0-9), hyphens or underscores;
must start and end with an alphanumeric character`;
const helpText = (isNewCalendarIdValid === true && !isEdit) ? msg : undefined;
const error = (isNewCalendarIdValid === false && !isEdit) ? [msg] : undefined;

return (
<EuiForm>
{!isEdit &&
<Fragment>
<EuiFormRow
label="Calendar ID"
helpText={helpText}
error={error}
isInvalid={!isNewCalendarIdValid}
>
<EuiFieldText
name="calendarId"
value={calendarId}
onChange={onCalendarIdChange}
disabled={isEdit === true || saving === true}
/>
</EuiFormRow>

<EuiFormRow
label="Description"
>
<EuiFieldText
name="description"
value={description}
onChange={onDescriptionChange}
disabled={isEdit === true || saving === true}
/>
</EuiFormRow>
</Fragment>
}
{isEdit &&
<EditHeader
calendarId={calendarId}
description={description}
/>}
<EuiFormRow
label="Jobs"
>
<EuiComboBox
options={jobIds}
selectedOptions={selectedJobOptions}
onChange={onJobSelection}
disabled={saving === true}
/>
</EuiFormRow>

<EuiFormRow
label="Groups"
>
<EuiComboBox
onCreateOption={onCreateGroupOption}
options={groupIds}
selectedOptions={selectedGroupOptions}
onChange={onGroupSelection}
disabled={saving === true}
/>
</EuiFormRow>

<EuiSpacer size="xl" />

<EuiFormRow
label="Events"
fullWidth
>
<EventsTable
eventsList={eventsList}
onDeleteClick={onEventDelete}
showImportModal={showImportModal}
showNewEventModal={showNewEventModal}
showSearchBar
/>
</EuiFormRow>
<EuiSpacer size="l" />
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButton
fill
onClick={isEdit ? onEdit : onCreate}
disabled={saving || !isNewCalendarIdValid || calendarId === ''}
>
{saving ? 'Saving...' : 'Save'}
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
disabled={saving}
href={`${chrome.getBasePath()}/app/ml#/settings/calendars_list`}
>
Cancel
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiForm>
);
}

CalendarForm.propTypes = {
calendarId: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
groupIds: PropTypes.array.isRequired,
isEdit: PropTypes.bool.isRequired,
isNewCalendarIdValid: PropTypes.bool.isRequired,
jobIds: PropTypes.array.isRequired,
onCalendarIdChange: PropTypes.func.isRequired,
onCreate: PropTypes.func.isRequired,
onCreateGroupOption: PropTypes.func.isRequired,
onDescriptionChange: PropTypes.func.isRequired,
onEdit: PropTypes.func.isRequired,
onEventDelete: PropTypes.func.isRequired,
onGroupSelection: PropTypes.func.isRequired,
showImportModal: PropTypes.func.isRequired,
onJobSelection: PropTypes.func.isRequired,
saving: PropTypes.bool.isRequired,
selectedGroupOptions: PropTypes.array.isRequired,
selectedJobOptions: PropTypes.array.isRequired,
showNewEventModal: PropTypes.func.isRequired,
};
Loading