Skip to content

Commit

Permalink
Added react-ui-components to dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed May 14, 2018
1 parent 5c14bdb commit 4b4b514
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
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 {
nameRequired,
nameOptional,
createUrl,
cancelUrl,
...rest
Expand All @@ -24,9 +24,9 @@ const VmSnapshotFormComponent = (props) => {
<VmSnapshotForm
errorMessages={errorMessages}
labels={labels}
hideName={!nameRequired}
hideName={nameOptional}
nameRequired
descriptionRequired={!nameRequired}
descriptionRequired={nameOptional}
onSubmit={values => window.miqAjaxButton(createUrl, values)}
onCancel={() => window.miqAjaxButton(cancelUrl)}
{...rest}
Expand All @@ -35,13 +35,13 @@ const VmSnapshotFormComponent = (props) => {
};

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

VmSnapshotFormComponent.defaultProps = {
nameRequired: true,
nameOptional: false,
};

export default VmSnapshotFormComponent;
2 changes: 1 addition & 1 deletion app/javascript/miq-component/helpers.js
Expand Up @@ -10,7 +10,7 @@ export function componentFactory(blueprintName, selector) {
if (!isDefined(blueprintName)) {
throw new Error(`Attempt to create instance of ${blueprintName}. Blueprint ${blueprintName} is not defined!`);
}
const element = document.getElementById(selector);
const element = document.querySelector(selector);
const props = element.dataset;
ManageIQ.component.newInstance(blueprintName, props, element);
}
4 changes: 1 addition & 3 deletions app/javascript/packs/component-definitions-common.js
@@ -1,6 +1,4 @@
import React from 'react';
import VmSnapshotFormComponent from '../components/vm-snapshot-form-component';

ManageIQ.component.define('VmSnapshotForm', ManageIQ.component.reactBlueprint(props => (
<VmSnapshotFormComponent {...props} />
)));
ManageIQ.component.addReact('VmSnapshotForm', props => <VmSnapshotFormComponent {...props} />);
4 changes: 2 additions & 2 deletions app/views/vm_common/_snap.html.haml
@@ -1,7 +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-name-required" => !!@record.try(:snapshot_name_optional?)}
"data-name-optional" => @record.try(:snapshot_name_optional?)}
:javascript
ManageIQ.component.componentFactory('VmSnapshotForm', 'snap-form');
ManageIQ.component.componentFactory('VmSnapshotForm', '#snap-form');
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -21,6 +21,7 @@
},
"homepage": "https://github.com/ManageIQ/manageiq#readme",
"dependencies": {
"@manageiq/react-ui-components": "^0.3.0",
"angular": "~1.6.6",
"angular-animate": "~1.6.6",
"angular-bootstrap-switch": "~0.5.2",
Expand Down

0 comments on commit 4b4b514

Please sign in to comment.