Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
MelsHyrule committed Oct 26, 2022
1 parent 5fbb798 commit 13d33b7
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
39 changes: 23 additions & 16 deletions app/javascript/components/timeline-options/timeline-options.jsx
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand All @@ -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;
Expand Down Expand Up @@ -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: [] },
}));
};

Expand All @@ -94,4 +93,12 @@ const TimelineOptions = ({ url }) => {
);
};

TimelineOptions.propTypes = {
url: PropTypes.string,
};

TimelineOptions.defaultProps = {
url: '',
};

export default TimelineOptions;
278 changes: 139 additions & 139 deletions app/javascript/spec/timeline-options-form/sample-data.js
Original file line number Diff line number Diff line change
@@ -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',
};
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand All @@ -25,7 +24,7 @@ describe('Show Timeline Options form component', () => {
it('should render form', async(done) => {
let wrapper;
await act(async() => {
wrapper = mount(<TimelineOptions url="sample/url"/>);
wrapper = mount(<TimelineOptions url="sample/url" />);
});
setImmediate(() => {
wrapper.update();
Expand Down
3 changes: 1 addition & 2 deletions app/views/layouts/_tl_show.html.haml
Original file line number Diff line number Diff line change
@@ -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]}

0 comments on commit 13d33b7

Please sign in to comment.