import React from 'react';
import { Mutation } from 'react-apollo';
import gql from 'graphql-tag';
import ReactSelect from 'react-select';
import Button from 'components/Button';
import { bp, color, fontSize } from 'lib/variables';

const taskDrushCron = gql`
  mutation taskDrushCron(
    $environment: Int!
  ) {
    taskDrushCron(
      environment: $environment
    ) {
      id
      name
      status
      created
      started
      completed
      remoteId
      command
      service
    }
  }
`;

const DrushCron = ({
  pageEnvironment,
  onCompleted,
  onError,
}) => (
  <Mutation
    mutation={taskDrushCron}
    onCompleted={onCompleted}
    onError={onError}
  >
    {(taskDrushCron, { loading, called, error, data }) => {
      return (
        <React.Fragment>
          <div className="envSelect">
            <label id="dest-env">Environment:</label>
            <ReactSelect
              aria-labelledby="dest-env"
              name="dest-environment"
              value={{
                label: pageEnvironment.name,
                value: pageEnvironment.id
              }}
              options={[
                {
                  label: pageEnvironment.name,
                  value: pageEnvironment.id
                }
              ]}
              isDisabled
              required
            />
          </div>
          <Button action={taskDrushCron}>Add task</Button>
          <style jsx>{`
            .envSelect {
              margin: 10px 0;
            }
          `}</style>
        </React.Fragment>
      );
    }}
  </Mutation>
);

export default DrushCron;

@@ -278,21 +278,16 @@
 ushCron(
-%0A    
 $environ
@@ -296,19 +296,16 @@
 nt: Int!
-%0A  
 ) %7B%0A    
@@ -318,23 +318,16 @@
 ushCron(
-%0A      
 environm
@@ -343,21 +343,16 @@
 ironment
-%0A    
 ) %7B%0A    
@@ -501,18 +501,16 @@
 ron = (%7B
-%0A 
  pageEnv
@@ -518,18 +518,16 @@
 ronment,
-%0A 
  onCompl
@@ -535,18 +535,16 @@
 ted,
-%0A 
  onError
 ,%0A%7D)
@@ -539,18 +539,17 @@
  onError
-,%0A
+ 
 %7D) =%3E (%0A
@@ -641,16 +641,78 @@
 nError%7D%0A
+    variables=%7B%7B%0A      environment: pageEnvironment.id%0A    %7D%7D%0A
   %3E%0A    

Update convention and add variables to core-cron task.