feat: show 404 error for non-existent objects in edit pages

This commit is contained in:
Jiawei Chen
2023-06-09 21:52:30 +08:00
committed by Yang Luo
parent 05703720c5
commit 0bda29f143
19 changed files with 95 additions and 0 deletions

View File

@ -50,6 +50,11 @@ class AdapterEditPage extends React.Component {
AdapterBackend.getAdapter("admin", this.state.adapterName)
.then((res) => {
if (res.status === "ok") {
if (res.data === null) {
this.props.history.push("/404");
return;
}
this.setState({
adapter: res.data,
});

View File

@ -119,6 +119,11 @@ class ApplicationEditPage extends React.Component {
getApplication() {
ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => {
if (application === null) {
this.props.history.push("/404");
return;
}
if (application.grantTypes === null || application.grantTypes === undefined || application.grantTypes.length === 0) {
application.grantTypes = ["authorization_code"];
}

View File

@ -45,6 +45,11 @@ class CertEditPage extends React.Component {
getCert() {
CertBackend.getCert(this.state.owner, this.state.certName)
.then((cert) => {
if (cert === null) {
this.props.history.push("/404");
return;
}
this.setState({
cert: cert,
});

View File

@ -41,6 +41,11 @@ class ChatEditPage extends React.Component {
getChat() {
ChatBackend.getChat("admin", this.state.chatName)
.then((chat) => {
if (chat === null) {
this.props.history.push("/404");
return;
}
this.setState({
chat: chat,
});

View File

@ -46,6 +46,11 @@ class MessageEditPage extends React.Component {
getMessage() {
MessageBackend.getMessage("admin", this.state.messageName)
.then((message) => {
if (message === null) {
this.props.history.push("/404");
return;
}
this.setState({
message: message,
});

View File

@ -48,6 +48,11 @@ class ModelEditPage extends React.Component {
getModel() {
ModelBackend.getModel(this.state.organizationName, this.state.modelName)
.then((model) => {
if (model === null) {
this.props.history.push("/404");
return;
}
this.setState({
model: model,
});

View File

@ -50,6 +50,11 @@ class OrganizationEditPage extends React.Component {
getOrganization() {
OrganizationBackend.getOrganization("admin", this.state.organizationName)
.then((organization) => {
if (organization === null) {
this.props.history.push("/404");
return;
}
this.setState({
organization: organization,
});

View File

@ -42,6 +42,11 @@ class PaymentEditPage extends React.Component {
getPayment() {
PaymentBackend.getPayment("admin", this.state.paymentName)
.then((payment) => {
if (payment === null) {
this.props.history.push("/404");
return;
}
this.setState({
payment: payment,
});

View File

@ -50,6 +50,11 @@ class PermissionEditPage extends React.Component {
getPermission() {
PermissionBackend.getPermission(this.state.organizationName, this.state.permissionName)
.then((permission) => {
if (permission === null) {
this.props.history.push("/404");
return;
}
this.setState({
permission: permission,
});

View File

@ -47,6 +47,11 @@ class PlanEditPage extends React.Component {
getPlan() {
PlanBackend.getPlan(this.state.organizationName, this.state.planName)
.then((plan) => {
if (plan === null) {
this.props.history.push("/404");
return;
}
this.setState({
plan: plan,
});

View File

@ -50,6 +50,11 @@ class PricingEditPage extends React.Component {
getPricing() {
PricingBackend.getPricing(this.state.organizationName, this.state.pricingName)
.then((pricing) => {
if (pricing === null) {
this.props.history.push("/404");
return;
}
this.setState({
pricing: pricing,
});

View File

@ -45,6 +45,11 @@ class ProductEditPage extends React.Component {
getProduct() {
ProductBackend.getProduct(this.props.account.owner, this.state.productName)
.then((product) => {
if (product === null) {
this.props.history.push("/404");
return;
}
this.setState({
product: product,
});

View File

@ -50,6 +50,11 @@ class ProviderEditPage extends React.Component {
getProvider() {
ProviderBackend.getProvider(this.state.owner, this.state.providerName)
.then((res) => {
if (res === null) {
this.props.history.push("/404");
return;
}
if (res.status === "ok") {
this.setState({
provider: res.data,

View File

@ -43,6 +43,11 @@ class RoleEditPage extends React.Component {
getRole() {
RoleBackend.getRole(this.state.organizationName, this.state.roleName)
.then((role) => {
if (role === null) {
this.props.history.push("/404");
return;
}
this.setState({
role: role,
});

View File

@ -47,6 +47,11 @@ class SubscriptionEditPage extends React.Component {
getSubscription() {
SubscriptionBackend.getSubscription(this.state.organizationName, this.state.subscriptionName)
.then((subscription) => {
if (subscription === null) {
this.props.history.push("/404");
return;
}
this.setState({
subscription: subscription,
});

View File

@ -48,6 +48,11 @@ class SyncerEditPage extends React.Component {
getSyncer() {
SyncerBackend.getSyncer("admin", this.state.syncerName)
.then((syncer) => {
if (syncer === null) {
this.props.history.push("/404");
return;
}
this.setState({
syncer: syncer,
});

View File

@ -36,6 +36,11 @@ class TokenEditPage extends React.Component {
getToken() {
TokenBackend.getToken("admin", this.state.tokenName)
.then((token) => {
if (token === null) {
this.props.history.push("/404");
return;
}
this.setState({
token: token,
});

View File

@ -66,6 +66,11 @@ class UserEditPage extends React.Component {
getUser() {
UserBackend.getUser(this.state.organizationName, this.state.userName)
.then((data) => {
if (data === null) {
this.props.history.push("/404");
return;
}
if (data.status === null || data.status !== "error") {
this.setState({
user: data,

View File

@ -123,6 +123,11 @@ class WebhookEditPage extends React.Component {
getWebhook() {
WebhookBackend.getWebhook("admin", this.state.webhookName)
.then((webhook) => {
if (webhook === null) {
this.props.history.push("/404");
return;
}
this.setState({
webhook: webhook,
});