mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
fix: handle add message in frontend (#1340)
This commit is contained in:
@ -45,9 +45,12 @@ class AdapterListPage extends BaseListPage {
|
|||||||
const newAdapter = this.newAdapter();
|
const newAdapter = this.newAdapter();
|
||||||
AdapterBackend.addAdapter(newAdapter)
|
AdapterBackend.addAdapter(newAdapter)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/adapters/${newAdapter.organization}/${newAdapter.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/adapters/${newAdapter.organization}/${newAdapter.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Adapter failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Adapter failed to add: ${error}`);
|
Setting.showMessage("error", `Adapter failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -786,7 +786,7 @@ class ApplicationEditPage extends React.Component {
|
|||||||
const application = Setting.deepCopy(this.state.application);
|
const application = Setting.deepCopy(this.state.application);
|
||||||
ApplicationBackend.updateApplication("admin", this.state.applicationName, application)
|
ApplicationBackend.updateApplication("admin", this.state.applicationName, application)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.msg === "") {
|
if (res.status === "ok") {
|
||||||
Setting.showMessage("success", "Successfully saved");
|
Setting.showMessage("success", "Successfully saved");
|
||||||
this.setState({
|
this.setState({
|
||||||
applicationName: this.state.application.name,
|
applicationName: this.state.application.name,
|
||||||
|
@ -78,9 +78,12 @@ class ApplicationListPage extends BaseListPage {
|
|||||||
const newApplication = this.newApplication();
|
const newApplication = this.newApplication();
|
||||||
ApplicationBackend.addApplication(newApplication)
|
ApplicationBackend.addApplication(newApplication)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/applications/${newApplication.organization}/${newApplication.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/applications/${newApplication.organization}/${newApplication.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Application failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Application failed to add: ${error}`);
|
Setting.showMessage("error", `Application failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -43,9 +43,12 @@ class CertListPage extends BaseListPage {
|
|||||||
const newCert = this.newCert();
|
const newCert = this.newCert();
|
||||||
CertBackend.addCert(newCert)
|
CertBackend.addCert(newCert)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/certs/${newCert.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/certs/${newCert.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Cert failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Cert failed to add: ${error}`);
|
Setting.showMessage("error", `Cert failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -38,9 +38,12 @@ class ModelListPage extends BaseListPage {
|
|||||||
const newModel = this.newModel();
|
const newModel = this.newModel();
|
||||||
ModelBackend.addModel(newModel)
|
ModelBackend.addModel(newModel)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/models/${newModel.owner}/${newModel.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/models/${newModel.owner}/${newModel.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Model failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Model failed to add: ${error}`);
|
Setting.showMessage("error", `Model failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -335,7 +335,7 @@ class OrganizationEditPage extends React.Component {
|
|||||||
const organization = Setting.deepCopy(this.state.organization);
|
const organization = Setting.deepCopy(this.state.organization);
|
||||||
OrganizationBackend.updateOrganization(this.state.organization.owner, this.state.organizationName, organization)
|
OrganizationBackend.updateOrganization(this.state.organization.owner, this.state.organizationName, organization)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.msg === "") {
|
if (res.status === "ok") {
|
||||||
Setting.showMessage("success", "Successfully saved");
|
Setting.showMessage("success", "Successfully saved");
|
||||||
this.setState({
|
this.setState({
|
||||||
organizationName: this.state.organization.name,
|
organizationName: this.state.organization.name,
|
||||||
|
@ -75,9 +75,12 @@ class OrganizationListPage extends BaseListPage {
|
|||||||
const newOrganization = this.newOrganization();
|
const newOrganization = this.newOrganization();
|
||||||
OrganizationBackend.addOrganization(newOrganization)
|
OrganizationBackend.addOrganization(newOrganization)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/organizations/${newOrganization.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/organizations/${newOrganization.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Organization failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Organization failed to add: ${error}`);
|
Setting.showMessage("error", `Organization failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,11 @@ class PaymentListPage extends BaseListPage {
|
|||||||
const newPayment = this.newPayment();
|
const newPayment = this.newPayment();
|
||||||
PaymentBackend.addPayment(newPayment)
|
PaymentBackend.addPayment(newPayment)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/payments/${newPayment.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
|
this.props.history.push({pathname: `/payments/${newPayment.name}`, mode: "add"});
|
||||||
|
} else {
|
||||||
|
Setting.showMessage("error", `Payment failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
@ -48,13 +48,12 @@ class PermissionListPage extends BaseListPage {
|
|||||||
const newPermission = this.newPermission();
|
const newPermission = this.newPermission();
|
||||||
PermissionBackend.addPermission(newPermission)
|
PermissionBackend.addPermission(newPermission)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.msg !== "") {
|
if (res.status === "ok") {
|
||||||
Setting.showMessage("error", res.msg);
|
this.props.history.push({pathname: `/permissions/${newPermission.owner}/${newPermission.name}`, mode: "add"});
|
||||||
return;
|
} else {
|
||||||
|
Setting.showMessage("error", `Permission failed to add: ${res.msg}`);
|
||||||
}
|
}
|
||||||
this.props.history.push({pathname: `/permissions/${newPermission.owner}/${newPermission.name}`, mode: "add"});
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Permission failed to add: ${error}`);
|
Setting.showMessage("error", `Permission failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -45,9 +45,12 @@ class ProductListPage extends BaseListPage {
|
|||||||
const newProduct = this.newProduct();
|
const newProduct = this.newProduct();
|
||||||
ProductBackend.addProduct(newProduct)
|
ProductBackend.addProduct(newProduct)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/products/${newProduct.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/products/${newProduct.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Product failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Product failed to add: ${error}`);
|
Setting.showMessage("error", `Product failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -789,7 +789,7 @@ class ProviderEditPage extends React.Component {
|
|||||||
const provider = Setting.deepCopy(this.state.provider);
|
const provider = Setting.deepCopy(this.state.provider);
|
||||||
ProviderBackend.updateProvider(this.state.owner, this.state.providerName, provider)
|
ProviderBackend.updateProvider(this.state.owner, this.state.providerName, provider)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.msg === "") {
|
if (res.status === "ok") {
|
||||||
Setting.showMessage("success", "Successfully saved");
|
Setting.showMessage("success", "Successfully saved");
|
||||||
this.setState({
|
this.setState({
|
||||||
owner: this.state.provider.owner,
|
owner: this.state.provider.owner,
|
||||||
|
@ -61,9 +61,12 @@ class ProviderListPage extends BaseListPage {
|
|||||||
const newProvider = this.newProvider();
|
const newProvider = this.newProvider();
|
||||||
ProviderBackend.addProvider(newProvider)
|
ProviderBackend.addProvider(newProvider)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/providers/${newProvider.owner}/${newProvider.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/providers/${newProvider.owner}/${newProvider.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Provider failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Provider failed to add: ${error}`);
|
Setting.showMessage("error", `Provider failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -40,9 +40,12 @@ class RoleListPage extends BaseListPage {
|
|||||||
const newRole = this.newRole();
|
const newRole = this.newRole();
|
||||||
RoleBackend.addRole(newRole)
|
RoleBackend.addRole(newRole)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/roles/${newRole.owner}/${newRole.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/roles/${newRole.owner}/${newRole.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Role failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Role failed to add: ${error}`);
|
Setting.showMessage("error", `Role failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -49,9 +49,12 @@ class SyncerListPage extends BaseListPage {
|
|||||||
const newSyncer = this.newSyncer();
|
const newSyncer = this.newSyncer();
|
||||||
SyncerBackend.addSyncer(newSyncer)
|
SyncerBackend.addSyncer(newSyncer)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/syncers/${newSyncer.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/syncers/${newSyncer.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Syncer failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Syncer failed to add: ${error}`);
|
Setting.showMessage("error", `Syncer failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -42,9 +42,12 @@ class TokenListPage extends BaseListPage {
|
|||||||
const newToken = this.newToken();
|
const newToken = this.newToken();
|
||||||
TokenBackend.addToken(newToken)
|
TokenBackend.addToken(newToken)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/tokens/${newToken.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/tokens/${newToken.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Token failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Token failed to add: ${error}`);
|
Setting.showMessage("error", `Token failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -611,7 +611,7 @@ class UserEditPage extends React.Component {
|
|||||||
const user = Setting.deepCopy(this.state.user);
|
const user = Setting.deepCopy(this.state.user);
|
||||||
UserBackend.updateUser(this.state.organizationName, this.state.userName, user)
|
UserBackend.updateUser(this.state.organizationName, this.state.userName, user)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.msg === "") {
|
if (res.status === "ok") {
|
||||||
Setting.showMessage("success", "Successfully saved");
|
Setting.showMessage("success", "Successfully saved");
|
||||||
this.setState({
|
this.setState({
|
||||||
organizationName: this.state.user.owner,
|
organizationName: this.state.user.owner,
|
||||||
|
@ -72,9 +72,12 @@ class UserListPage extends BaseListPage {
|
|||||||
const newUser = this.newUser();
|
const newUser = this.newUser();
|
||||||
UserBackend.addUser(newUser)
|
UserBackend.addUser(newUser)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/users/${newUser.owner}/${newUser.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/users/${newUser.owner}/${newUser.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `User failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `User failed to add: ${error}`);
|
Setting.showMessage("error", `User failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
@ -42,9 +42,12 @@ class WebhookListPage extends BaseListPage {
|
|||||||
const newWebhook = this.newWebhook();
|
const newWebhook = this.newWebhook();
|
||||||
WebhookBackend.addWebhook(newWebhook)
|
WebhookBackend.addWebhook(newWebhook)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.props.history.push({pathname: `/webhooks/${newWebhook.name}`, mode: "add"});
|
if (res.status === "ok") {
|
||||||
}
|
this.props.history.push({pathname: `/webhooks/${newWebhook.name}`, mode: "add"});
|
||||||
)
|
} else {
|
||||||
|
Setting.showMessage("error", `Webhook failed to add: ${res.msg}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Webhook failed to add: ${error}`);
|
Setting.showMessage("error", `Webhook failed to add: ${error}`);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user