Skip to content

Commit

Permalink
Small changes to fit the ui code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed May 3, 2018
1 parent 515a359 commit ba09138
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/vm_common.rb
Expand Up @@ -449,7 +449,7 @@ def snap_vm
:userid => session[:userid],
:name => params[:name],
:description => params[:description],
:memory => params[:snap_memory] == "1")
:memory => params[:snap_memory] == "true")
rescue => bang
puts bang.backtrace.join("\n")
flash = _("Error during 'Create Snapshot': %{message}") % {:message => bang.message}
Expand Down
10 changes: 5 additions & 5 deletions app/javascript/components/vm-snapshot-form-component.jsx
Expand Up @@ -4,7 +4,7 @@ import { VmSnapshotForm } from '@manageiq/react-ui-components/dist/vm-snapshot-f

const VmSnapshotFormComponent = (props) => {
const {
vendor,
nameRequired,
createUrl,
cancelUrl,
...rest
Expand All @@ -24,9 +24,9 @@ const VmSnapshotFormComponent = (props) => {
<VmSnapshotForm
errorMessages={errorMessages}
labels={labels}
hideName={vendor === 'redhat'}
hideName={!nameRequired}
nameRequired
descriptionRequired={vendor === 'host'}
descriptionRequired={!nameRequired}
onSubmit={values => window.miqAjaxButton(createUrl, values)}
onCancel={() => window.miqAjaxButton(cancelUrl)}
{...rest}
Expand All @@ -35,13 +35,13 @@ const VmSnapshotFormComponent = (props) => {
};

VmSnapshotFormComponent.propTypes = {
vendor: PropTypes.string,
nameRequired: PropTypes.bool,
createUrl: PropTypes.string.isRequired,
cancelUrl: PropTypes.string.isRequired,
};

VmSnapshotFormComponent.defaultProps = {
vendor: '',
nameRequired: true,
};

export default VmSnapshotFormComponent;
4 changes: 4 additions & 0 deletions app/javascript/miq-component/helpers.js
Expand Up @@ -6,6 +6,10 @@ export function addReact(name, component) {
}

export function componentFactory(blueprintName, selector) {
const { isDefined } = ManageIQ.component;
if (!isDefined(blueprintName)) {
throw new Error(`Attempt to create instance of ${blueprintName}. Blueprint ${blueprintName} is not defined!`);
}
const element = document.getElementById(selector);
const props = element.dataset;
ManageIQ.component.newInstance(blueprintName, props, element);
Expand Down
3 changes: 2 additions & 1 deletion app/views/vm_common/_snap.html.haml
@@ -1,6 +1,7 @@
= render :partial => "layouts/flash_msg"
#snap-form{"data-create-url" => url_for_only_path(:action => "snap_vm", :id => @record.id, :button => @edit ? "create" : nil),
"data-cancel-url" => url_for_only_path(:action => "snap_vm", :id => @record.id, :button => @edit ? "cancel" : nil),
"data-vendor" => @record.vendor}
"data-name-required" => !!@record.try(:snapshot_name_optional?)}
:javascript
ManageIQ.component.componentFactory('VmSnapshotForm', 'snap-form');

0 comments on commit ba09138

Please sign in to comment.