Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Adding Deployment message details formatting and removing onRowClick #1117

Merged
merged 5 commits into from
Oct 5, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export class DeviceDetails extends Component {
device,
fetchModules
} = nextProps;

let tempState = this.state;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{}

let updateFlag = false;
/*
deviceModuleStatus is a prop fetched by making fetchModules() API call through deviceDetails.container on demand.
moduleStatus is a prop sent from deploymentDetailsGrid which it already has in rowData.
Expand All @@ -149,23 +150,31 @@ export class DeviceDetails extends Component {

// set deviceModuleStatus in state if moduleStatus doesn't exist and devicesReducer successfully received the API response
if (!moduleStatus && !isDeviceModuleStatusPending && !deviceModuleStatusError) {
this.setState({ currentModuleStatus: deviceModuleStatus });
tempState.currentModuleStatus = deviceModuleStatus;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tempState = {
  ...tempState,
  currentModuleStatus: deviceModuleStatus
}

updateFlag = true;
}

// Reset state if the device changes
if ((this.props.device || {}).id !== device.id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if

resetPendingAndError();
tempState = this.baseState;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tempState = {
  ...tempState,
  ...this.baseState
}

updateFlag = true;

// If moduleStatus exist in props, set it in state, otherwise make an API call to get deviceModuleStatus.
if (moduleStatus) {
this.setState({ ...this.baseState, currentModuleStatus: moduleStatus });
tempState.currentModuleStatus = moduleStatus;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tempState = {
  ...tempState,
  ...currentModuleStatus: moduleStatus
}

} else {
this.setState(this.baseState);
fetchModules(device.id);
}

const deviceId = (device || {}).id;
this.resetTelemetry$.next(deviceId);
this.fetchAlerts(deviceId);
}

if (updateFlag) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (Object.keys(tempState).length) this.setState(tempState);

this.setState(tempState);
}
}

componentWillUnmount() {
Expand Down