Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-samuel committed Nov 19, 2024
1 parent 6519236 commit d367450
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 0 additions & 2 deletions app/controllers/ops_controller/settings/help_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ def help_menu_form_get_vars
id = item.id.to_sym
%i[title href type].map do |field|
param = params["#{id}_#{field}"]
next if param.nil?

@edit[:new][id][field] = param
@edit[:new][id].delete(field) if param.empty?
end
end
changed = @edit[:new] != @edit[:current]
Expand Down
14 changes: 7 additions & 7 deletions app/javascript/components/settings-help-menu-form/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
import MiqFormRenderer, { useFormApi } from '@@ddf';
import MiqFormRenderer from '@@ddf';
import PropTypes from 'prop-types';
import createSchema from './help-menu-form.schema';

Expand Down Expand Up @@ -39,13 +39,13 @@ const HelpMenuTab = ({ initialValues, initialDropdownValues }) => {

const onSubmit = (values) => {
const submitValues = {};
submitValues.documentation_title = values.item_label_1;
submitValues.product_title = values.item_label_2;
submitValues.about_title = values.item_label_3;
submitValues.documentation_title = values.item_label_1 || '';
submitValues.product_title = values.item_label_2 || '';
submitValues.about_title = values.item_label_3 || '';

submitValues.documentation_href = values.url_1;
submitValues.product_href = values.url_2;
submitValues.about_href = values.url_3;
submitValues.documentation_href = values.url_1 || '';
submitValues.product_href = values.url_2 || '';
submitValues.about_href = values.url_3 || '';

submitValues.documentation_type = values.select_dropdown_1;
submitValues.product_type = values.select_dropdown_2;
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/ui/Settings/SettingsHelpMenu.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Settings > Application Settings > Settings', () => {
cy.get('[name="item_label_1"]').type('changed', {force: true});
cy.contains('Save').click({ force: true });
cy.get('[name="item_label_1"]').should('have.value', 'changed');
cy.get('[name="item_label_1"]').clear().type('initial', {force: true});
cy.get('[name="item_label_1"]').clear();
cy.contains('Save').click({ force: true });
});

Expand All @@ -27,15 +27,15 @@ describe('Settings > Application Settings > Settings', () => {
cy.get('[name="url_1"]').type('changed', {force: true});
cy.contains('Save').click({ force: true });
cy.get('[name="url_1"]').should('have.value', 'changed');
cy.get('[name="url_1"]').clear().type('initial', {force: true});
cy.get('[name="url_1"]').clear();
cy.contains('Save').click({ force: true });
});

it('Changes dropdown', () => {
cy.get('[name="select_dropdown_1"]').contains('About Modal').click({force: true});
cy.get('#select_dropdown_1').invoke('val', 'default').trigger('change', { force: true });
cy.contains('Save').click({ force: true });
cy.get('[name="select_dropdown_1"]').should('have.value', 'About Modal');
cy.get('[name="select_dropdown_1"]').contains('Current Window').click({force: true});
cy.get('[name="select_dropdown_1"]').should('have.value', 'default');
cy.get('[name="select_dropdown_1"]').select('new_window', { force: true });
cy.contains('Save').click({ force: true });
});
});
Expand Down

0 comments on commit d367450

Please sign in to comment.