Skip to content

Commit

Permalink
fix: deprecation fixes for 'errors'
Browse files Browse the repository at this point in the history
  • Loading branch information
josephgregoryii committed Feb 16, 2022
1 parent c97af83 commit 2653692
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 92 deletions.
4 changes: 2 additions & 2 deletions nerdlets/geo-ops-nerdlet/CreateMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class CreateMap extends React.PureComponent {

const {
data: mapLocations,
errors: mapLocationsLoadingErrors
error: mapLocationsLoadingErrors
} = await nerdStorageRequest({
service: getMapLocations,
params: { accountId, document: map }
Expand Down Expand Up @@ -152,7 +152,7 @@ export default class CreateMap extends React.PureComponent {
};

onMapLocationWrite = ({ mapLocation }) => {
// TODO: Handle errors from updating each
// TODO: Handle error from updating each
this.addOrUpdate({
collectionName: 'mapLocations',
item: mapLocation.data
Expand Down
8 changes: 4 additions & 4 deletions nerdlets/geo-ops-nerdlet/GeoMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class GeoMap extends Component {
constructor(props) {
super(props);
this.state = {
errors: [],
error: [],
mapReady: false,
queries: [],
selectedLocation: '',
Expand Down Expand Up @@ -311,8 +311,8 @@ export default class GeoMap extends Component {

render() {
const { map, mapLocations, zoom } = this.props;
const { mapReady, errors } = this.state;
const hasErrors = (errors && errors.length > 0) || false;
const { mapReady, error } = this.state;
const hasErrors = (error && error.length > 0) || false;

const startingCenter = this.calculateCenter();
const startingZoom = zoom || map.zoom || 3;
Expand All @@ -323,7 +323,7 @@ export default class GeoMap extends Component {
<>
{/* <h1>{map.title}</h1> */}
<div className="leaflet-wrapper">
{hasErrors && <pre>{JSON.stringify(errors, null, 2)}</pre>}
{hasErrors && <pre>{JSON.stringify(error, null, 2)}</pre>}
{!hasErrors && (
<Map
ref={this.mapRef}
Expand Down
12 changes: 6 additions & 6 deletions nerdlets/geo-ops-nerdlet/ViewMap/DetailPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ export default class DetailPanel extends React.PureComponent {
<DetailPanelQuery mapLocation={mapLocation}>
{({
loading,
errors,
error,
recentAlertViolations,
entities: distilledEntities
}) => {
if (loading) {
return <Spinner />;
}
const tooComplexWorkloadError =
errors && errors.find(findTooComplexQueryError);
if (errors && !tooComplexWorkloadError) {
error && error.find(findTooComplexQueryError);
if (error && !tooComplexWorkloadError) {
return (
<>
{errors.map((error, i) => {
{error.map((error, i) => {
if (error.graphQLErrors) {
return <NerdGraphError key={i} error={error} />;
} else {
Expand All @@ -140,7 +140,7 @@ export default class DetailPanel extends React.PureComponent {
</>
);
}
if (!errors) {
if (!error) {
mapLocation.recentAlertViolations = recentAlertViolations;
mapLocation.entities = distilledEntities;
}
Expand All @@ -155,7 +155,7 @@ export default class DetailPanel extends React.PureComponent {
<GenericError
error="Unable to retrieve Location alerts"
errorDescription={
errors.find(findTooComplexQueryError).message
error.find(findTooComplexQueryError).message
}
/>
) : (
Expand Down
22 changes: 11 additions & 11 deletions nerdlets/geo-ops-nerdlet/ViewMap/DetailPanelQuery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export default class DetailPanelQuery extends React.PureComponent {
});
const {
data: workloadEntitySearchQueryData,
errors: workEntitySearchQueryErrors
error: workEntitySearchQueryErrors
} = await NerdGraphQuery.query({ query: workloadEntitySearchQuery });
if (workEntitySearchQueryErrors) {
// eslint-disable-next-line no-console
console.debug('Return error for query', workloadEntitySearchQuery);
return { errors: workEntitySearchQueryErrors };
return { error: workEntitySearchQueryErrors };
}

// STEP 3: Retrieve the entity guids for all the entities in all the workloads
Expand All @@ -64,12 +64,12 @@ export default class DetailPanelQuery extends React.PureComponent {
});
const {
data: workloadEntityGuidsData,
errors: workloadEntityGuidsErrors
error: workloadEntityGuidsErrors
} = await NerdGraphQuery.query({ query: workloadEntityGuidsQuery });
if (workloadEntityGuidsErrors) {
// eslint-disable-next-line no-console
console.debug('Return error for query', workloadEntityGuidsQuery);
return { errors: workloadEntityGuidsErrors };
return { error: workloadEntityGuidsErrors };
}

// STEP 4: Build one list of entity guids
Expand Down Expand Up @@ -102,15 +102,15 @@ export default class DetailPanelQuery extends React.PureComponent {
const entityQuery = getEntitiesByGuidsQuery({ entityGuids });
const {
data: entityData,
errors: entityErrors
error: entityErrors
} = await NerdGraphQuery.query({
query: entityQuery,
variables
});
if (entityErrors) {
// eslint-disable-next-line no-console
console.debug('Return error for query', entityQuery);
return { errors: entityErrors };
return { error: entityErrors };
}

// STEP 6: Reduce both down to ordered lists
Expand Down Expand Up @@ -158,7 +158,7 @@ export default class DetailPanelQuery extends React.PureComponent {
loading: true,
recentAlertViolations: null,
entities: null,
errors: null
error: null
};
}

Expand Down Expand Up @@ -199,19 +199,19 @@ export default class DetailPanelQuery extends React.PureComponent {
const {
entities,
recentAlertViolations,
errors
error
} = await DetailPanelQuery.query({ mapLocation });
this.setState({
loading: false,
errors,
error,
recentAlertViolations,
entities
});
}

render() {
const { children } = this.props;
const { loading, recentAlertViolations, entities, errors } = this.state;
return children({ loading, recentAlertViolations, entities, errors });
const { loading, recentAlertViolations, entities, error } = this.state;
return children({ loading, recentAlertViolations, entities, error });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export default class MapLocationEntityQuery extends React.PureComponent {
const variables = { begin_time, end_time, entityGuids };
const query = getEntitiesByGuidsQuery(variables);
// console.debug('MapLocationEntityQuery', query);
const { errors, data } = await NerdGraphQuery.query({
const { error, data } = await NerdGraphQuery.query({
query,
variables,
fetchPolicyType
});
if (errors) {
return { errors, entities: null };
if (error) {
return { error, entities: null };
}
// console.debug('MapLocationEntityQuery.query', data);
const { actor } = data;
Expand All @@ -38,7 +38,7 @@ export default class MapLocationEntityQuery extends React.PureComponent {
});
entities = entities.map(mapWorkloadStatusValueToAlertSeverity);
}
return { entities, errors: null };
return { entities, error: null };
}

static propTypes = {
Expand All @@ -53,7 +53,7 @@ export default class MapLocationEntityQuery extends React.PureComponent {
super(props);
this.state = {
loading: true,
errors: null,
error: null,
entities: null
};
}
Expand Down Expand Up @@ -89,24 +89,24 @@ export default class MapLocationEntityQuery extends React.PureComponent {
async load() {
this.setState({ loading: true });

const { entities, errors } = await MapLocationEntityQuery.query({
const { entities, error } = await MapLocationEntityQuery.query({
entityGuids: this.props.entityGuids
});

this.setState({
loading: false,
entities,
errors
error
});
}

render() {
const { entities, loading, errors } = this.state;
const { entities, loading, error } = this.state;
const { children } = this.props;
return children({
loading,
entities,
errors
error
});
}
}
16 changes: 8 additions & 8 deletions nerdlets/geo-ops-nerdlet/ViewMap/MapQuery/MapLocationQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export default class MapLocationQuery extends React.PureComponent {
* Returns object with three attributes:
* - `mapLocations` the list of locations
* - `entityGuids` reduced list of all entityGuids from all locations
* - `errors` if the query generated errors, return those
* - `error` if the query generated error, return those
*/
static async query({ map }) {
const { accountId } = map;

const { data: mapLocations, errors } = await nerdStorageRequest({
const { data: mapLocations, error } = await nerdStorageRequest({
service: getMapLocations,
params: { accountId: parseInt(accountId, 10), document: map }
});
Expand All @@ -40,7 +40,7 @@ export default class MapLocationQuery extends React.PureComponent {
return {
mapLocations: mapLocations.map(m => m.document),
entityGuids,
errors
error
};
}

Expand All @@ -54,7 +54,7 @@ export default class MapLocationQuery extends React.PureComponent {
this.state = {
data: [],
loading: true,
errors: []
error: []
};
}

Expand All @@ -80,24 +80,24 @@ export default class MapLocationQuery extends React.PureComponent {
async load() {
this.setState({ loading: true });

const { mapLocations, entityGuids, errors } = await MapLocationQuery.query({
const { mapLocations, entityGuids, error } = await MapLocationQuery.query({
map: this.props.map
});

this.setState({
loading: false,
data: { mapLocations, entityGuids },
errors
error
});
}

render() {
const { data, loading, errors } = this.state;
const { data, loading, error } = this.state;
const { children } = this.props;
return children({
loading,
data,
errors
error
});
}
}
24 changes: 12 additions & 12 deletions nerdlets/geo-ops-nerdlet/ViewMap/MapQuery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ export default class MapQuery extends React.PureComponent {
const {
mapLocations,
entityGuids,
errors: mapLocationErrors
error: mapLocationErrors
} = await MapLocationQuery.query({
map
});
// console.debug("entityGuids", { mapLocations, entityGuids } );
if (mapLocationErrors) {
return { errors: mapLocationErrors };
return { error: mapLocationErrors };
}
if (!mapLocations || !entityGuids || entityGuids.length === 0) {
// if we have no entities or no locations
return {
errors: null,
error: null,
mapLocations,
hasEntities: entityGuids && entityGuids.length > 0
};
Expand All @@ -73,7 +73,7 @@ export default class MapQuery extends React.PureComponent {
// STEP 2: Entities, alerting status, and alert violations for each entity in the mapLocations
const {
entities,
errors: mapLocationEntityErrors
error: mapLocationEntityErrors
} = await MapLocationEntityQuery.query({
begin_time,
end_time,
Expand All @@ -82,13 +82,13 @@ export default class MapQuery extends React.PureComponent {

if (mapLocationEntityErrors) {
return {
errors: mapLocationEntityErrors
error: mapLocationEntityErrors
};
}

// STEP 3: distill the most critical entity into a new attribute
return {
errors: null,
error: null,
mapLocations: MapQuery._distillMostCriticalEntity(mapLocations, entities),
hasEntities: true
};
Expand All @@ -105,7 +105,7 @@ export default class MapQuery extends React.PureComponent {
super(props);
this.state = {
loading: true,
errors: null,
error: null,
mapLocations: null,
hasEntities: false
};
Expand Down Expand Up @@ -145,32 +145,32 @@ export default class MapQuery extends React.PureComponent {
if (resetFlag) {
this.setState({
loading: true,
errors: null,
error: null,
mapLocations: null,
hasEntities: false
});
}
const { map, begin_time, end_time } = this.props;

const { errors, mapLocations, hasEntities } = await MapQuery.query({
const { error, mapLocations, hasEntities } = await MapQuery.query({
map,
begin_time,
end_time
});
this.setState({
loading: false,
errors,
error,
mapLocations,
hasEntities
});
}

render() {
const { loading, errors, mapLocations, hasEntities } = this.state;
const { loading, error, mapLocations, hasEntities } = this.state;
const { children } = this.props;
return children({
loading,
errors,
error,
mapLocations,
hasEntities
});
Expand Down

0 comments on commit 2653692

Please sign in to comment.