Port.js 901 B

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