diff --git a/app/controllers/application_controller/timelines/options.rb b/app/controllers/application_controller/timelines/options.rb
index 55dcbcd002a3..7c5ad88d9883 100644
--- a/app/controllers/application_controller/timelines/options.rb
+++ b/app/controllers/application_controller/timelines/options.rb
@@ -35,6 +35,7 @@ def update_from_params(params)
self.categories = {}
params.fetch(:tl_categories, []).each do |category_display_name|
next if category_display_name == "Other"
+
group_data = event_groups[events[category_display_name]]
category = {
:display_name => category_display_name,
diff --git a/app/javascript/components/timeline-options/timeline-options.jsx b/app/javascript/components/timeline-options/timeline-options.jsx
index ae61038c914a..dc6a6201ca92 100644
--- a/app/javascript/components/timeline-options/timeline-options.jsx
+++ b/app/javascript/components/timeline-options/timeline-options.jsx
@@ -1,14 +1,14 @@
import React, { useState, useEffect } from 'react';
import MiqFormRenderer from '@@ddf';
+import PropTypes from 'prop-types';
import createSchemaSimple from './timeline-options-simple.schema';
import mapper from '../../forms/mappers/componentMapper';
const TimelineOptions = ({ url }) => {
const [{
- isLoading, timelineEvents, managementGroupNames, managementGroupLevels, policyGroupNames, policyGroupLevels, tableContent,
+ isLoading, timelineEvents, managementGroupNames, managementGroupLevels, policyGroupNames, policyGroupLevels,
}, setState] = useState({
isLoading: true,
- tableContent: { headers: [], rows: [] },
});
useEffect(() => {
@@ -25,7 +25,7 @@ const TimelineOptions = ({ url }) => {
// Management Events
Object.entries(data.EmsEvent.group_names).forEach((entry) => {
const [key, value] = entry;
- managementGroupNames.push({ label: value, value: value });
+ managementGroupNames.push({ label: value, value });
});
Object.entries(data.EmsEvent.group_levels).forEach((entry) => {
const [key, value] = entry;
@@ -58,24 +58,23 @@ const TimelineOptions = ({ url }) => {
const onSubmit = (values) => {
miqSparkleOn();
- let show = values.timelineEvents === 'EmsEvent' ? "timeline" : "policy_timeline"
- let categories = values.timelineEvents === 'EmsEvent' ? values.managementGroupNames : values.policyGroupNames
- let result = values.timelineEvents === 'EmsEvent' ? values.managementGroupLevels : values.policyGroupLevels
- let vmData = {
- "tl_show": show,
- "tl_categories": categories,
- "tl_levels": result,
- "tl_result": "success",
- }
- window.ManageIQ.calendar.calDateFrom = values.startDate
- window.ManageIQ.calendar.calDateTo = values.endDate
- window.miqJqueryRequest(url, {beforeSend: true, data: vmData});
+ const show = values.timelineEvents === 'EmsEvent' ? 'timeline' : 'policy_timeline';
+ const categories = values.timelineEvents === 'EmsEvent' ? values.managementGroupNames : values.policyGroupNames;
+ const result = values.timelineEvents === 'EmsEvent' ? values.managementGroupLevels : values.policyGroupLevels;
+ const vmData = {
+ tl_show: show,
+ tl_categories: categories,
+ tl_levels: result,
+ tl_result: 'success',
+ };
+ window.ManageIQ.calendar.calDateFrom = values.startDate;
+ window.ManageIQ.calendar.calDateTo = values.endDate;
+ window.miqJqueryRequest(url, { beforeSend: true, data: vmData });
};
const onReset = () => {
setState((state) => ({
...state,
- tableContent: { headers: [], rows: [] },
}));
};
@@ -94,4 +93,12 @@ const TimelineOptions = ({ url }) => {
);
};
+TimelineOptions.propTypes = {
+ url: PropTypes.string,
+};
+
+TimelineOptions.defaultProps = {
+ url: '',
+};
+
export default TimelineOptions;
diff --git a/app/javascript/spec/timeline-options-form/sample-data.js b/app/javascript/spec/timeline-options-form/sample-data.js
index e63027d1ce7d..168ac9343d93 100644
--- a/app/javascript/spec/timeline-options-form/sample-data.js
+++ b/app/javascript/spec/timeline-options-form/sample-data.js
@@ -1,144 +1,144 @@
export const sampleReponse = {
- attributes: [
- "availability_zone_id",
- "chain_id",
- "container_group_id",
- "container_group_name",
- "container_id",
- "container_name",
- "container_namespace",
- "container_node_id",
- "container_node_name",
- "container_replicator_id",
- "container_replicator_name",
- "created_on",
- "dest_ems_cluster_id",
- "dest_ems_cluster_name",
- "dest_ems_cluster_uid",
- "dest_host_id",
- "dest_host_name",
- "dest_vm_ems_ref",
- "dest_vm_location",
- "dest_vm_name",
- "dest_vm_or_template_id",
- "ems_cluster_id",
- "ems_cluster_name",
- "ems_cluster_uid",
- "ems_id",
- "ems_ref",
- "event_type",
- "full_data",
- "generating_ems_id",
- "group_id",
- "host_id",
- "host_name",
- "id",
- "is_task",
- "message",
- "physical_chassis_id",
- "physical_server_id",
- "physical_storage_id",
- "physical_storage_name",
- "physical_switch_id",
- "source",
- "target_id",
- "target_type",
- "tenant_id",
- "timestamp",
- "type",
- "user_id",
- "username",
- "vm_ems_ref",
- "vm_location",
- "vm_name",
- "vm_or_template_id"
- ],
- virtual_attributes: [
- "group",
- "group_level",
- "group_name",
- "href_slug",
- "region_description",
- "region_number"
- ],
- relationships: [
- "availability_zone",
- "container_group",
- "container_node",
- "container_replicator",
- "dest_host",
- "dest_miq_template",
- "dest_vm",
- "dest_vm_or_template",
- "ext_management_system",
- "generating_ems",
- "host",
- "miq_template",
- "physical_chassis",
- "physical_server",
- "physical_storage",
- "physical_switch",
- "service",
- "target",
- "vm",
- "vm_or_template"
- ],
- subcollections: [],
- data: {
- timeline_events: {
- EmsEvent: {
- description: "Management Events",
- group_names: {
- other: "Other",
- addition: "Creation/Addition",
- configuration: "Configuration/Reconfiguration",
- },
- group_levels: {
- critical: "Critical",
- detail: "Detail",
- warning: "Warning"
- }
- },
- MiqEvent: {
- description: "Policy Events",
- group_names: {
- other: "Other",
- ems_operations: "Provider Operation",
- host_operations: "Host Operation",
- },
- group_levels: {
- success: "Success",
- failure: "Failure",
- detail: "Detail"
- }
- }
- }
- }
-}
+ attributes: [
+ 'availability_zone_id',
+ 'chain_id',
+ 'container_group_id',
+ 'container_group_name',
+ 'container_id',
+ 'container_name',
+ 'container_namespace',
+ 'container_node_id',
+ 'container_node_name',
+ 'container_replicator_id',
+ 'container_replicator_name',
+ 'created_on',
+ 'dest_ems_cluster_id',
+ 'dest_ems_cluster_name',
+ 'dest_ems_cluster_uid',
+ 'dest_host_id',
+ 'dest_host_name',
+ 'dest_vm_ems_ref',
+ 'dest_vm_location',
+ 'dest_vm_name',
+ 'dest_vm_or_template_id',
+ 'ems_cluster_id',
+ 'ems_cluster_name',
+ 'ems_cluster_uid',
+ 'ems_id',
+ 'ems_ref',
+ 'event_type',
+ 'full_data',
+ 'generating_ems_id',
+ 'group_id',
+ 'host_id',
+ 'host_name',
+ 'id',
+ 'is_task',
+ 'message',
+ 'physical_chassis_id',
+ 'physical_server_id',
+ 'physical_storage_id',
+ 'physical_storage_name',
+ 'physical_switch_id',
+ 'source',
+ 'target_id',
+ 'target_type',
+ 'tenant_id',
+ 'timestamp',
+ 'type',
+ 'user_id',
+ 'username',
+ 'vm_ems_ref',
+ 'vm_location',
+ 'vm_name',
+ 'vm_or_template_id',
+ ],
+ virtual_attributes: [
+ 'group',
+ 'group_level',
+ 'group_name',
+ 'href_slug',
+ 'region_description',
+ 'region_number',
+ ],
+ relationships: [
+ 'availability_zone',
+ 'container_group',
+ 'container_node',
+ 'container_replicator',
+ 'dest_host',
+ 'dest_miq_template',
+ 'dest_vm',
+ 'dest_vm_or_template',
+ 'ext_management_system',
+ 'generating_ems',
+ 'host',
+ 'miq_template',
+ 'physical_chassis',
+ 'physical_server',
+ 'physical_storage',
+ 'physical_switch',
+ 'service',
+ 'target',
+ 'vm',
+ 'vm_or_template',
+ ],
+ subcollections: [],
+ data: {
+ timeline_events: {
+ EmsEvent: {
+ description: 'Management Events',
+ group_names: {
+ other: 'Other',
+ addition: 'Creation/Addition',
+ configuration: 'Configuration/Reconfiguration',
+ },
+ group_levels: {
+ critical: 'Critical',
+ detail: 'Detail',
+ warning: 'Warning',
+ },
+ },
+ MiqEvent: {
+ description: 'Policy Events',
+ group_names: {
+ other: 'Other',
+ ems_operations: 'Provider Operation',
+ host_operations: 'Host Operation',
+ },
+ group_levels: {
+ success: 'Success',
+ failure: 'Failure',
+ detail: 'Detail',
+ },
+ },
+ },
+ },
+};
export const sampleSubmitPressedValues = {
- timeline_events: "EmsEvent",
- managementGroupNames: [
- "Configuration/Reconfiguration"
- ],
- managementGroupLevels: [
- "critical"
- ],
- startDate: [
- "2022-09-07T04:00:00.000Z"
- ],
- endDate: [
- "2022-09-28T04:00:00.000Z"
- ]
-}
+ timeline_events: 'EmsEvent',
+ managementGroupNames: [
+ 'Configuration/Reconfiguration',
+ ],
+ managementGroupLevels: [
+ 'critical',
+ ],
+ startDate: [
+ '2022-09-07T04:00:00.000Z',
+ ],
+ endDate: [
+ '2022-09-28T04:00:00.000Z',
+ ],
+};
export const sampleVmData = {
- tl_show: "timeline",
- tl_categories: [
- "Configuration/Reconfiguration"
- ],
- tl_levels: [
- "critical"
- ],
- tl_result: "success"
-}
+ tl_show: 'timeline',
+ tl_categories: [
+ 'Configuration/Reconfiguration',
+ ],
+ tl_levels: [
+ 'critical',
+ ],
+ tl_result: 'success',
+};
diff --git a/app/javascript/spec/timeline-options-form/timeline-options-form.spec.js b/app/javascript/spec/timeline-options-form/timeline-options-form.spec.js
index aa96415d73c2..b5e14e6313e3 100644
--- a/app/javascript/spec/timeline-options-form/timeline-options-form.spec.js
+++ b/app/javascript/spec/timeline-options-form/timeline-options-form.spec.js
@@ -1,10 +1,9 @@
import React from 'react';
import toJson from 'enzyme-to-json';
import fetchMock from 'fetch-mock';
-import { shallow } from 'enzyme';
import { act } from 'react-dom/test-utils';
import TimelineOptions from '../../components/timeline-options/timeline-options';
-import { sampleReponse, sampleSubmitPressedValues, sampleVmData } from './sample-data';
+import { sampleReponse } from './sample-data';
import { mount } from '../helpers/mountForm';
describe('Show Timeline Options form component', () => {
@@ -25,7 +24,7 @@ describe('Show Timeline Options form component', () => {
it('should render form', async(done) => {
let wrapper;
await act(async() => {
- wrapper = mount();
+ wrapper = mount();
});
setImmediate(() => {
wrapper.update();
diff --git a/app/views/layouts/_tl_show.html.haml b/app/views/layouts/_tl_show.html.haml
index 18e82fd97b56..bdad01f5ad74 100644
--- a/app/views/layouts/_tl_show.html.haml
+++ b/app/views/layouts/_tl_show.html.haml
@@ -1,8 +1,7 @@
%h1
= @title
= render :partial => "layouts/flash_msg"
-- url = url_for_only_path(:action => 'tl_chooser', :id => @record.id)
-= react 'TimelineOptions', {:url => url}
+= react 'TimelineOptions', {:url => url_for_only_path(:action => 'tl_chooser', :id => @record.id)}
= render :partial => 'layouts/tl_detail'
= _("* Dates/Times on this page are based on time zone: %{time_zone}.") % {:time_zone => session[:user_tz]}