Skip to content

Commit

Permalink
feat: Pagination not updating after last item deletion (casdoor#3120)
Browse files Browse the repository at this point in the history
  • Loading branch information
EZ4Jam1n authored Aug 13, 2024
1 parent ab5fcf8 commit 38e389e
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 69 deletions.
8 changes: 5 additions & 3 deletions web/src/AdapterListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ class AdapterListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/ApplicationListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ class ApplicationListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/CertListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ class CertListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/EnforcerListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class EnforcerListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/GroupListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ class GroupListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/InvitationListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ class InvitationListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/ModelListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ class ModelListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
6 changes: 3 additions & 3 deletions web/src/OrganizationListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ class OrganizationListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
this.fetch({
pagination: {
...this.state.pagination,
total: this.state.pagination.total - 1},
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
window.dispatchEvent(new Event("storageOrganizationsChanged"));
} else {
Expand Down
8 changes: 5 additions & 3 deletions web/src/PaymentListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ class PaymentListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/PermissionListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ class PermissionListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/PlanListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ class PlanListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/PricingListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ class PricingListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/ProductListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ class ProductListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/ProviderListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ class ProviderListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/ResourceListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ class ResourceListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/RoleListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ class RoleListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/SessionListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class SessionListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/SubscriptionListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ class SubscriptionListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/SyncerListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ class SyncerListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/TokenListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ class TokenListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/TransactionListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ class TransactionListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/UserListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ class UserListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down
8 changes: 5 additions & 3 deletions web/src/WebhookListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ class WebhookListPage extends BaseListPage {
.then((res) => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
Expand Down

0 comments on commit 38e389e

Please sign in to comment.