From 84f3edcfc7213d5a02f10ba002e091e1563f2e27 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 15:59:17 +0100 Subject: Refs #5529 @0.5h; Refactor buttons --- app/javascript/helpers/save_button.js | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 app/javascript/helpers/save_button.js (limited to 'app/javascript/helpers/save_button.js') diff --git a/app/javascript/helpers/save_button.js b/app/javascript/helpers/save_button.js new file mode 100644 index 000000000..7e0bd5bbe --- /dev/null +++ b/app/javascript/helpers/save_button.js @@ -0,0 +1,47 @@ +import React, { PropTypes, Component } from 'react' + +export default class SaveButton extends Component{ + constructor(props){ + super(props) + } + + btnDisabled(){ + return !this.props.status.fetchSuccess || this.props.status.isFetching + } + + btnClass(){ + let className = ['btn btn-default'] + if(this.btnDisabled()){ + className.push('disabled') + } + return className.join(' ') + } + + render() { + if (!this.hasPolicy()) { + return false + }else{ + return ( +