From d04b179350eeb614673ee851e6b7c5fe469147fe Mon Sep 17 00:00:00 2001 From: Damian Stasik Date: Tue, 7 Dec 2021 23:44:00 +0100 Subject: [PATCH] refactor: replace deprecated componentWillMount --- .../ChromeDropdown/ChromeDropdown.react.js | 8 ------- src/components/FourOhFour/FourOhFour.react.js | 2 +- src/components/LiveReload/LiveReload.react.js | 2 +- .../PushAudienceDialog.react.js | 2 +- .../PushAudiencesBaseRow.react.js | 2 +- .../PushExperimentDropdown.react.js | 8 ------- src/components/Sidebar/SidebarHeader.react.js | 2 +- .../Analytics/Explorer/Explorer.react.js | 2 -- .../Analytics/Overview/Overview.react.js | 2 +- .../Performance/Performance.react.js | 2 -- .../Analytics/Retention/Retention.react.js | 2 +- .../SlowQueries/SlowQueries.react.js | 2 +- src/dashboard/Apps/AppsIndex.react.js | 12 +++++----- .../Browser/AttachSelectedRowsDialog.react.js | 2 +- src/dashboard/Data/Browser/Browser.react.js | 2 +- .../Data/Browser/ExportDialog.react.js | 2 +- .../Data/Browser/ObjectPickerDialog.react.js | 23 ++++++++++--------- .../Data/Browser/SchemaOverview.react.js | 2 +- .../Data/CloudCode/CloudCode.react.js | 2 +- src/dashboard/Data/Config/Config.react.js | 2 +- src/dashboard/Data/Jobs/JobEdit.react.js | 2 +- src/dashboard/Data/Jobs/Jobs.react.js | 2 +- src/dashboard/Data/Webhooks/Webhooks.react.js | 2 +- src/dashboard/Push/PushAudiencesData.react.js | 2 +- .../Push/PushAudiencesIndex.react.js | 2 +- src/dashboard/Push/PushDetails.react.js | 2 +- src/dashboard/Push/PushIndex.react.js | 2 +- src/dashboard/Push/PushNew.react.js | 2 +- 28 files changed, 40 insertions(+), 59 deletions(-) diff --git a/src/components/ChromeDropdown/ChromeDropdown.react.js b/src/components/ChromeDropdown/ChromeDropdown.react.js index 07000eadd3..db50d2d777 100644 --- a/src/components/ChromeDropdown/ChromeDropdown.react.js +++ b/src/components/ChromeDropdown/ChromeDropdown.react.js @@ -34,10 +34,6 @@ export default class ChromeDropdown extends React.Component { } } - componentWillMount() { - this.styles = this.props.styles || styles; - } - componentDidMount() { this.node = ReactDOM.findDOMNode(this); } @@ -54,7 +50,6 @@ export default class ChromeDropdown extends React.Component { render() { let widthStyle = { width: parseFloat(this.props.width || 140) }; - let styles = this.styles; let color = this.props.color || 'purple'; let label = this.props.value; @@ -119,7 +114,4 @@ ChromeDropdown.propTypes = { placeholder: PropTypes.string.describe( 'Placeholder text used in place of default selection.' ), - styles: PropTypes.object.describe( - 'Styles override used to provide dropdown with differnt skin.' - ), }; diff --git a/src/components/FourOhFour/FourOhFour.react.js b/src/components/FourOhFour/FourOhFour.react.js index 53aba06e1a..c9f4ace335 100644 --- a/src/components/FourOhFour/FourOhFour.react.js +++ b/src/components/FourOhFour/FourOhFour.react.js @@ -22,7 +22,7 @@ export default class FourOhFour extends React.Component { this.updateEmoji = this.updateEmoji.bind(this); } - componentWillMount() { + componentDidMount() { this.timeout = setTimeout(this.updateEmoji, 3000); } diff --git a/src/components/LiveReload/LiveReload.react.js b/src/components/LiveReload/LiveReload.react.js index 2497760ac3..21a39d50a4 100644 --- a/src/components/LiveReload/LiveReload.react.js +++ b/src/components/LiveReload/LiveReload.react.js @@ -53,7 +53,7 @@ export default class LiveReload extends React.Component { return promise; } - componentWillMount() { + componentDidMount() { this.shouldContinueReloading = true; if (!this.state.currentData) { this.fetchNewData(); diff --git a/src/components/PushAudienceDialog/PushAudienceDialog.react.js b/src/components/PushAudienceDialog/PushAudienceDialog.react.js index 8fb0355dbd..c27a3ce817 100644 --- a/src/components/PushAudienceDialog/PushAudienceDialog.react.js +++ b/src/components/PushAudienceDialog/PushAudienceDialog.react.js @@ -59,7 +59,7 @@ export default class PushAudienceDialog extends React.Component { }; } - componentWillMount() { + componentDidMount() { let stateSettings = {}; let audienceInfo = this.props.audienceInfo; //this case is only for 'New Segment' to prepopulate existing audience diff --git a/src/components/PushAudiencesSelector/PushAudiencesBaseRow.react.js b/src/components/PushAudiencesSelector/PushAudiencesBaseRow.react.js index f643b9c5b0..4fd7b1e29e 100644 --- a/src/components/PushAudiencesSelector/PushAudiencesBaseRow.react.js +++ b/src/components/PushAudiencesSelector/PushAudiencesBaseRow.react.js @@ -43,7 +43,7 @@ export default class PushAudiencesBaseRow extends React.Component { }, () => {}); } - componentWillMount() { + componentDidMount() { this.fetchPushSubscriberCount.call(this,this.context); if (this.props.id == NEW_SEGMENT_ID) { this.setState({ isNewSegment: true }); diff --git a/src/components/PushExperimentDropdown/PushExperimentDropdown.react.js b/src/components/PushExperimentDropdown/PushExperimentDropdown.react.js index e1efbb1c68..4374c4db65 100644 --- a/src/components/PushExperimentDropdown/PushExperimentDropdown.react.js +++ b/src/components/PushExperimentDropdown/PushExperimentDropdown.react.js @@ -22,10 +22,6 @@ export default class PushExperimentDropdown extends React.Component { }; } - componentWillMount() { - this.styles = this.props.styles || styles; - } - componentDidMount() { this.node = ReactDOM.findDOMNode(this); } @@ -42,7 +38,6 @@ export default class PushExperimentDropdown extends React.Component { render() { let widthStyle = { width: this.props.width || 140 }; - let styles = this.styles; let color = this.props.color; let content = (
this.setState({ open: true })}> @@ -86,7 +81,4 @@ PushExperimentDropdown.propTypes = { placeHolder: PropTypes.string.describe( 'Placeholder text used in place of default selection.' ), - styles: PropTypes.object.describe( - 'Styles override used to provide dropdown with differnt skin.' - ), }; diff --git a/src/components/Sidebar/SidebarHeader.react.js b/src/components/Sidebar/SidebarHeader.react.js index bab045fe4f..b45e92a548 100644 --- a/src/components/Sidebar/SidebarHeader.react.js +++ b/src/components/Sidebar/SidebarHeader.react.js @@ -17,7 +17,7 @@ export default class SidebarHeader extends React.Component { super(); this.state = { }; } - componentWillMount() { + componentDidMount() { let mountPath = window.PARSE_DASHBOARD_PATH; fetch(mountPath).then(response => { this.setState({ dashboardUser: response.headers.get('username') }); diff --git a/src/dashboard/Analytics/Explorer/Explorer.react.js b/src/dashboard/Analytics/Explorer/Explorer.react.js index 203fcfff4a..ce68732308 100644 --- a/src/dashboard/Analytics/Explorer/Explorer.react.js +++ b/src/dashboard/Analytics/Explorer/Explorer.react.js @@ -74,9 +74,7 @@ class Explorer extends DashboardView { width: display.offsetWidth, height: display.offsetHeight }; - } - componentWillMount() { this.props.customQueries.dispatch(ActionTypes.LIST); this.props.customQueries.dispatch(ActionTypes.LIST_RECENT); } diff --git a/src/dashboard/Analytics/Overview/Overview.react.js b/src/dashboard/Analytics/Overview/Overview.react.js index 7b4af28c22..3db330ca8c 100644 --- a/src/dashboard/Analytics/Overview/Overview.react.js +++ b/src/dashboard/Analytics/Overview/Overview.react.js @@ -99,7 +99,7 @@ export default class Overview extends DashboardView { } } - componentWillMount() { + componentDidMount() { this.fetchOverview(this.context.currentApp); } diff --git a/src/dashboard/Analytics/Performance/Performance.react.js b/src/dashboard/Analytics/Performance/Performance.react.js index cbfa034065..44f527fb17 100644 --- a/src/dashboard/Analytics/Performance/Performance.react.js +++ b/src/dashboard/Analytics/Performance/Performance.react.js @@ -99,9 +99,7 @@ export default class Performance extends DashboardView { width: display.offsetWidth, height: display.offsetHeight }; - } - componentWillMount() { this.handleRunQuery(this.context.currentApp); } diff --git a/src/dashboard/Analytics/Retention/Retention.react.js b/src/dashboard/Analytics/Retention/Retention.react.js index 6634eeb5bd..b1e5e67be7 100644 --- a/src/dashboard/Analytics/Retention/Retention.react.js +++ b/src/dashboard/Analytics/Retention/Retention.react.js @@ -52,7 +52,7 @@ export default class Retention extends DashboardView { }; } - componentWillMount() { + componentDidMount() { this.fetchRetention(this.context.currentApp); } diff --git a/src/dashboard/Analytics/SlowQueries/SlowQueries.react.js b/src/dashboard/Analytics/SlowQueries/SlowQueries.react.js index 62066dca50..0f551337c2 100644 --- a/src/dashboard/Analytics/SlowQueries/SlowQueries.react.js +++ b/src/dashboard/Analytics/SlowQueries/SlowQueries.react.js @@ -65,7 +65,7 @@ class SlowQueries extends TableView { this.xhrHandles = []; } - componentWillMount() { + componentDidMount() { this.fetchDropdownData(this.props); this.fetchSlowQueries(this.context.currentApp); } diff --git a/src/dashboard/Apps/AppsIndex.react.js b/src/dashboard/Apps/AppsIndex.react.js index eca859d94b..2b0835f894 100644 --- a/src/dashboard/Apps/AppsIndex.react.js +++ b/src/dashboard/Apps/AppsIndex.react.js @@ -96,16 +96,16 @@ export default class AppsIndex extends React.Component { this.searchRef = React.createRef(); } - componentWillMount() { + componentDidMount() { if (AppsManager.apps().length === 1) { const [app] = AppsManager.apps(); history.push(`/apps/${app.slug}/browser`); - return; + } else { + document.body.addEventListener('keydown', this.focusField); + AppsManager.getAllAppsIndexStats().then(() => { + this.forceUpdate(); + }); } - document.body.addEventListener('keydown', this.focusField); - AppsManager.getAllAppsIndexStats().then(() => { - this.forceUpdate(); - }); } componentWillUnmount() { diff --git a/src/dashboard/Data/Browser/AttachSelectedRowsDialog.react.js b/src/dashboard/Data/Browser/AttachSelectedRowsDialog.react.js index 6bdd247aca..2d8c1b2ad9 100644 --- a/src/dashboard/Data/Browser/AttachSelectedRowsDialog.react.js +++ b/src/dashboard/Data/Browser/AttachSelectedRowsDialog.react.js @@ -24,7 +24,7 @@ export default class AttachSelectedRowsDialog extends React.Component { this.handleTargetObjectIdChange = this.handleTargetObjectIdChange.bind(this); } - componentWillMount() { + componentDidMount() { const { selection, classes, onSelectClass } = this.props; if (selection) { const currentClass = classes[0]; diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index c13286ffe6..5b31caedf7 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -152,7 +152,7 @@ class Browser extends DashboardView { this.dataBrowserRef = React.createRef(); } - componentWillMount() { + componentDidMount() { const { currentApp } = this.context; if (!currentApp.preventSchemaEdits) { this.action = new SidebarAction('Create a class', this.showCreateClass.bind(this)); diff --git a/src/dashboard/Data/Browser/ExportDialog.react.js b/src/dashboard/Data/Browser/ExportDialog.react.js index 6a368333da..a9a56303bf 100644 --- a/src/dashboard/Data/Browser/ExportDialog.react.js +++ b/src/dashboard/Data/Browser/ExportDialog.react.js @@ -18,7 +18,7 @@ export default class ExportDialog extends React.Component { }; } - componentWillMount() { + componentDidMount() { this.context.currentApp.getExportProgress().then((progress) => { this.setState({ progress }); }); diff --git a/src/dashboard/Data/Browser/ObjectPickerDialog.react.js b/src/dashboard/Data/Browser/ObjectPickerDialog.react.js index 9c13bcb2f6..3e62293bcc 100644 --- a/src/dashboard/Data/Browser/ObjectPickerDialog.react.js +++ b/src/dashboard/Data/Browser/ObjectPickerDialog.react.js @@ -50,19 +50,20 @@ export default class ObjectPickerDialog extends React.Component { this.onConfirm = this.onConfirm.bind(this); } - async componentWillMount() { + componentDidMount() { const { filters } = this.state; const { className, pointerId, relation } = this.props; - await this.fetchData(className, filters); - if (pointerId) { - this.selectRow(pointerId, true); - } - if (relation) { - this.selectRelationRows(relation, filters); - } - document - .getElementById(SELECTION_INPUT_ID) - .addEventListener('focus', this.disableDataBrowserKeyControls); + this.fetchData(className, filters).then(() => { + if (pointerId) { + this.selectRow(pointerId, true); + } + if (relation) { + this.selectRelationRows(relation, filters); + } + document + .getElementById(SELECTION_INPUT_ID) + .addEventListener('focus', this.disableDataBrowserKeyControls); + }) } componentWillUnmount() { diff --git a/src/dashboard/Data/Browser/SchemaOverview.react.js b/src/dashboard/Data/Browser/SchemaOverview.react.js index d8fb5f896b..0698467271 100644 --- a/src/dashboard/Data/Browser/SchemaOverview.react.js +++ b/src/dashboard/Data/Browser/SchemaOverview.react.js @@ -30,7 +30,7 @@ class Browser extends DashboardView { }; } - componentWillMount() { + componentDidMount() { this.props.schema.dispatch(ActionTypes.FETCH); } diff --git a/src/dashboard/Data/CloudCode/CloudCode.react.js b/src/dashboard/Data/CloudCode/CloudCode.react.js index 9387271680..48878e912c 100644 --- a/src/dashboard/Data/CloudCode/CloudCode.react.js +++ b/src/dashboard/Data/CloudCode/CloudCode.react.js @@ -30,7 +30,7 @@ export default class CloudCode extends DashboardView { }; } - componentWillMount() { + componentDidMount() { this.fetchSource(this.context.currentApp, getPath(this.props.params)); } diff --git a/src/dashboard/Data/Config/Config.react.js b/src/dashboard/Data/Config/Config.react.js index 4f5a9e2dda..0f1e3b575c 100644 --- a/src/dashboard/Data/Config/Config.react.js +++ b/src/dashboard/Data/Config/Config.react.js @@ -37,7 +37,7 @@ class Config extends TableView { }; } - componentWillMount() { + componentDidMount() { this.props.config.dispatch(ActionTypes.FETCH); } diff --git a/src/dashboard/Data/Jobs/JobEdit.react.js b/src/dashboard/Data/Jobs/JobEdit.react.js index fecf08c8d1..523867b0e9 100644 --- a/src/dashboard/Data/Jobs/JobEdit.react.js +++ b/src/dashboard/Data/Jobs/JobEdit.react.js @@ -57,7 +57,7 @@ class JobEdit extends React.Component { return promise; } - componentWillMount() { + componentDidMount() { this.props.jobs.dispatch(ActionTypes.FETCH); } diff --git a/src/dashboard/Data/Jobs/Jobs.react.js b/src/dashboard/Data/Jobs/Jobs.react.js index c7d761c2ff..0067d97538 100644 --- a/src/dashboard/Data/Jobs/Jobs.react.js +++ b/src/dashboard/Data/Jobs/Jobs.react.js @@ -75,7 +75,7 @@ class Jobs extends TableView { }; } - componentWillMount() { + componentDidMount() { this.loadData(); } diff --git a/src/dashboard/Data/Webhooks/Webhooks.react.js b/src/dashboard/Data/Webhooks/Webhooks.react.js index 99e797db67..6c6da0d468 100644 --- a/src/dashboard/Data/Webhooks/Webhooks.react.js +++ b/src/dashboard/Data/Webhooks/Webhooks.react.js @@ -50,7 +50,7 @@ class Webhooks extends TableView { }; } - componentWillMount() { + componentDidMount() { this.props.webhooks.dispatch(WebhookActionTypes.FETCH); this.props.schema.dispatch(SchemaActionTypes.FETCH); } diff --git a/src/dashboard/Push/PushAudiencesData.react.js b/src/dashboard/Push/PushAudiencesData.react.js index b16a13fbae..4cb7f64f19 100644 --- a/src/dashboard/Push/PushAudiencesData.react.js +++ b/src/dashboard/Push/PushAudiencesData.react.js @@ -39,7 +39,7 @@ export default class PushAudiencesData extends React.Component { }; } - componentWillMount(){ + componentDidMount(){ if (this.props.loaded){ //case when data already fetched this.setState({ loading: false}); } diff --git a/src/dashboard/Push/PushAudiencesIndex.react.js b/src/dashboard/Push/PushAudiencesIndex.react.js index b0162bfbd3..80bcec616d 100644 --- a/src/dashboard/Push/PushAudiencesIndex.react.js +++ b/src/dashboard/Push/PushAudiencesIndex.react.js @@ -49,7 +49,7 @@ class PushAudiencesIndex extends DashboardView { } } - componentWillMount() { + componentDidMount() { this.props.schema.dispatch(SchemaStore.ActionTypes.FETCH); this.props.pushaudiences.dispatch(PushAudiencesStore.ActionTypes.FETCH, { diff --git a/src/dashboard/Push/PushDetails.react.js b/src/dashboard/Push/PushDetails.react.js index 384d8b85da..990ceca4a4 100644 --- a/src/dashboard/Push/PushDetails.react.js +++ b/src/dashboard/Push/PushDetails.react.js @@ -222,7 +222,7 @@ class PushDetails extends DashboardView { this.xhrHandles = []; } - componentWillMount() { + componentDidMount() { this.props.schema.dispatch(SchemaStore.ActionTypes.FETCH); let promise = this.context.currentApp.fetchPushDetails(this.props.params.pushId); promise.then((pushDetails) => { diff --git a/src/dashboard/Push/PushIndex.react.js b/src/dashboard/Push/PushIndex.react.js index 370421a458..5b0aec6da2 100644 --- a/src/dashboard/Push/PushIndex.react.js +++ b/src/dashboard/Push/PushIndex.react.js @@ -262,7 +262,7 @@ export default class PushIndex extends DashboardView { }); } - componentWillMount() { + componentDidMount() { this.handleFetch(this.props.params.category); //TODO: make xhr map and generic abort for existing xhrs. this.context.currentApp.fetchAvailableDevices().then(({ available_devices }) => { diff --git a/src/dashboard/Push/PushNew.react.js b/src/dashboard/Push/PushNew.react.js index 40307f2297..23e6b5ce54 100644 --- a/src/dashboard/Push/PushNew.react.js +++ b/src/dashboard/Push/PushNew.react.js @@ -144,7 +144,7 @@ class PushNew extends DashboardView { } } - componentWillMount() { + componentDidMount() { this.props.schema.dispatch(SchemaStore.ActionTypes.FETCH); let options = { xhrKey: XHR_KEY }; const query = new URLSearchParams(this.props.location.search);