Port.js 897 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Mutation } from 'react-apollo'
  2. import gql from 'graphql-tag'
  3. import { INTERFACE_LIST } from './InterfaceList'
  4. const CONNECT_PORT = gql`
  5. mutation CONNECT_PORT($interfaceName: String!, $device: String!) {
  6. connect(interfaceName: $interfaceName, device: $device) {
  7. id
  8. device
  9. interfaceName
  10. }
  11. }
  12. `
  13. class Port extends React.Component {
  14. render () {
  15. const { interfaceName, device, name, description } = this.props.data
  16. return (
  17. <Mutation
  18. mutation={CONNECT_PORT}
  19. variables={{ interfaceName, device }}
  20. refetchQueries={[{ query: INTERFACE_LIST }]}
  21. >
  22. {connect => (
  23. <div>
  24. <h1>{device}</h1>
  25. <p>Name:</p><p>{name}</p>
  26. <p>{description}</p>
  27. <button onClick={connect}>Connect</button>
  28. </div>
  29. )}
  30. </Mutation>
  31. )
  32. }
  33. }
  34. export default Port