@@ -173,7 +168,8 @@ class SchedulesPage extends React.Component
- {data ? Not found : Loading schedules...}
-
- }
+ emptyText={this.renderNotFound()}
/>
@@ -212,6 +204,14 @@ class SchedulesPage extends React.Component
+ Not found
+
+ );
+ }
+
handleTimezoneChange = (value: Timezone) => {
const { store } = this.props;
@@ -329,13 +329,6 @@ class SchedulesPage extends React.Component
)}
-
- {/* */}
);
};
@@ -380,23 +373,24 @@ class SchedulesPage extends React.Component {
return (
-
-
-
-
-
-
-
-
-
-
+ /* Wrapper div for onClick event to prevent expanding schedule view on delete/edit click */
+ event.stopPropagation()}>
+
+
+
+
+
+
+
+
+
+
+
);
};
getEditScheduleClickHandler = (id: Schedule['id']) => {
- return (event) => {
- event.stopPropagation();
-
+ return () => {
this.setState({ scheduleIdToEdit: id });
};
};
@@ -406,33 +400,42 @@ class SchedulesPage extends React.Component {
- scheduleStore.delete(id).then(this.update);
+ scheduleStore.delete(id).then(() => this.update(true));
};
};
handleSchedulesFiltersChange = (filters: SchedulesFiltersType) => {
- this.setState({ filters }, this.debouncedUpdateSchedules);
+ this.setState({ filters }, () => this.debouncedUpdateSchedules(filters));
};
- applyFilters = () => {
- const { filters } = this.state;
- const { store } = this.props;
- const { scheduleStore } = store;
- scheduleStore.updateItems(filters);
+ applyFilters = (filters: SchedulesFiltersType) => {
+ const { scheduleStore } = this.props.store;
+ const shouldUpdateFn = () => this.state.filters === filters;
+ scheduleStore.updateItems(filters, 1, shouldUpdateFn).then(() => {
+ if (shouldUpdateFn) {
+ this.setState({ page: 1 });
+ }
+ });
};
- debouncedUpdateSchedules = debounce(this.applyFilters, 1000);
+ debouncedUpdateSchedules = debounce(this.applyFilters, FILTERS_DEBOUNCE_MS);
handlePageChange = (page: number) => {
this.setState({ page }, this.updateSchedules);
this.setState({ expandedRowKeys: [] });
};
- update = () => {
+ update = (isRemoval = false) => {
const { store } = this.props;
+ const { filters, page } = this.state;
const { scheduleStore } = store;
- return scheduleStore.updateItems();
+ // For removal we need to check if count is 1
+ // which means we should change the page to the previous one
+ const { results } = store.scheduleStore.getSearchResult();
+ const newPage = results.length === 1 ? Math.max(page - 1, 1) : page;
+
+ return scheduleStore.updateItems(filters, isRemoval ? newPage : page);
};
getUpdateRelatedEscalationChainsHandler = (scheduleId: Schedule['id']) => {