Skip to content

Commit

Permalink
feat(Stealth): Adds a checkbox in the stealth core to control whether…
Browse files Browse the repository at this point in the history
… stealth changes the alert condition.
  • Loading branch information
alexanderson1993 committed Jan 28, 2021
1 parent 1483469 commit 539712e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions server/typeDefs/stealthField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ const resolver = {
"stealthFieldUpdate",
App.systems.filter(s => s.type === "StealthField"),
);
console.log("changed alert", id, change);
pubsub.publish("simulatorsUpdate", App.simulators);
},
stealthSensorsSonar(rootValue, {id, sonar}) {
App.systems.find(s => s.id === id)?.setSensorsSonar(sonar);
Expand Down
28 changes: 27 additions & 1 deletion src/components/views/StealthField/core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from "react";
import gql from "graphql-tag.macro";
import {Container, Row, Col, Button} from "helpers/reactstrap";
import {Query, withApollo} from "react-apollo";
import {Mutation, Query, withApollo} from "react-apollo";
import {OutputField} from "../../generic/core";
import SubscriptionHelper from "helpers/subscriptionHelper";

Expand All @@ -15,6 +15,7 @@ export const STEALTH_CORE_SUB = gql`
state
charge
activated
changeAlert
quadrants {
fore
aft
Expand Down Expand Up @@ -114,6 +115,31 @@ class StealthFieldCore extends Component {
<Button color="warning" size="sm" onClick={this.fluxCharge}>
Flux
</Button>
<label>
<Mutation
mutation={gql`
mutation ToggleChangeAlert($id: ID!, $change: Boolean!) {
stealthChangeAlert(id: $id, change: $change)
}
`}
>
{action => (
<input
type="checkbox"
checked={stealthField.changeAlert}
onChange={e =>
action({
variables: {
id: stealthField.id,
change: e.target.checked,
},
})
}
/>
)}
</Mutation>
Change simulator alert color when stealthed
</label>
<Row>
<Col sm="12">
<OutputField
Expand Down

0 comments on commit 539712e

Please sign in to comment.