import { Alert } from 'antd';
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';

import {
  REVISION_DRAFT,
  REVISION_OUTDATED,
} from 'control_new/state/constants';
import {
  getRevisionDraftStatus,
} from 'control_new/state/revisions/selectors';


@connect(
  (state, { revision }) => ({
    status: getRevisionDraftStatus(state, revision.get('id')),
  }),
)
export default class RevisionNotice extends React.Component {
  static propTypes = {
    status: PropTypes.string,
  };

  static defaultProps = {
    status: null,
  }

  render() {
    const { status } = this.props;

    let message;

    if (status === REVISION_DRAFT) {
      message = 'You are viewing a draft.';
    } else if (status === REVISION_OUTDATED) {
      message = 'You are viewing an outdated version.';
    } else {
      return (
        <Alert
          className="revision-notice"
          type="success"
          message="This is the published version."
          showIcon
        />
      );
    }

    return (
      <Alert
        className="revision-notice"
        type="warning"
        message={message}
        showIcon
      />
    );
  }
}

@@ -337,16 +337,75 @@
 ) =%3E (%7B%0A
+    enabled: revision.getIn(%5B'recipe', 'enabled'%5D, false),%0A
     stat
@@ -548,24 +548,64 @@
 opTypes = %7B%0A
+    enabled: PropTypes.bool.isRequired,%0A
     status: 
@@ -701,16 +701,25 @@
  const %7B
+ enabled,
  status 
@@ -751,16 +751,30 @@
 message;
+%0A    let type;
 %0A%0A    if
@@ -844,24 +844,48 @@
  a draft.';%0A
+      type = 'warning';%0A
     %7D else i
@@ -983,114 +983,54 @@
     
-%7D else %7B%0A      return (%0A        %3CAlert%0A          className=%22revision-notice%22%0A          type=%22success%22%0A    
+  type = 'warning';%0A    %7D else if (enabled) %7B%0A
     
@@ -1038,18 +1038,20 @@
  message
-=%22
+ = '
 This is 
@@ -1076,47 +1076,65 @@
 ion.
-%22
+';
 %0A      
-    showIcon%0A        /%3E%0A      )
+type = 'success';%0A    %7D else %7B%0A      return null
 ;%0A  
@@ -1217,17 +1217,14 @@
 ype=
-%22warning%22
+%7Btype%7D
 %0A   

Fix revision notice