From ce921c00cdb69c4c546ad533f33bd538409d44bf Mon Sep 17 00:00:00 2001 From: XDTD <34300181+XDTD@users.noreply.github.com> Date: Wed, 17 May 2023 17:17:58 +0800 Subject: [PATCH] fix: resolve the problem of cert being unable to be accessed properly (#1850) * fix: resolve the problem of cert being unable to be accessed properly * Update CertEditPage.js --------- Co-authored-by: hsluoyz --- web/src/App.js | 2 +- web/src/CertEditPage.js | 18 +++++++++++++++--- web/src/CertListPage.js | 6 +++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/web/src/App.js b/web/src/App.js index 4c746e53..e1c9a929 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -550,7 +550,7 @@ class App extends Component { this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> - this.renderLoginIfNotLoggedIn()} /> + this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> this.renderLoginIfNotLoggedIn()} /> diff --git a/web/src/CertEditPage.js b/web/src/CertEditPage.js index 4e422c36..403deb01 100644 --- a/web/src/CertEditPage.js +++ b/web/src/CertEditPage.js @@ -15,6 +15,7 @@ import React from "react"; import {Button, Card, Col, Input, InputNumber, Row, Select} from "antd"; import * as CertBackend from "./backend/CertBackend"; +import * as OrganizationBackend from "./backend/OrganizationBackend"; import * as Setting from "./Setting"; import i18next from "i18next"; import copy from "copy-to-clipboard"; @@ -29,6 +30,7 @@ class CertEditPage extends React.Component { this.state = { classes: props, certName: props.match.params.certName, + owner: props.match.params.organizationName, cert: null, organizations: [], mode: props.location.mode !== undefined ? props.location.mode : "edit", @@ -37,10 +39,11 @@ class CertEditPage extends React.Component { UNSAFE_componentWillMount() { this.getCert(); + this.getOrganizations(); } getCert() { - CertBackend.getCert(this.props.account.owner, this.state.certName) + CertBackend.getCert(this.state.owner, this.state.certName) .then((cert) => { this.setState({ cert: cert, @@ -48,6 +51,15 @@ class CertEditPage extends React.Component { }); } + getOrganizations() { + OrganizationBackend.getOrganizations("admin") + .then((res) => { + this.setState({ + organizations: (res.msg === undefined) ? res : [], + }); + }); + } + parseCertField(key, value) { if (["port"].includes(key)) { value = Setting.myParseInt(value); @@ -230,7 +242,7 @@ class CertEditPage extends React.Component { submitCertEdit(willExist) { const cert = Setting.deepCopy(this.state.cert); - CertBackend.updateCert(this.state.cert.owner, this.state.certName, cert) + CertBackend.updateCert(this.state.owner, this.state.certName, cert) .then((res) => { if (res.status === "ok") { Setting.showMessage("success", i18next.t("general:Successfully saved")); @@ -241,7 +253,7 @@ class CertEditPage extends React.Component { if (willExist) { this.props.history.push("/certs"); } else { - this.props.history.push(`/certs/${this.state.cert.name}`); + this.props.history.push(`/certs/${this.state.cert.owner}/${this.state.cert.name}`); } } else { Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`); diff --git a/web/src/CertListPage.js b/web/src/CertListPage.js index 4868f7c6..b2701d7b 100644 --- a/web/src/CertListPage.js +++ b/web/src/CertListPage.js @@ -45,7 +45,7 @@ class CertListPage extends BaseListPage { CertBackend.addCert(newCert) .then((res) => { if (res.status === "ok") { - this.props.history.push({pathname: `/certs/${newCert.name}`, mode: "add"}); + this.props.history.push({pathname: `/certs/${newCert.owner}/${newCert.name}`, mode: "add"}); Setting.showMessage("success", i18next.t("general:Successfully added")); } else { Setting.showMessage("error", `${i18next.t("general:Failed to add")}: ${res.msg}`); @@ -86,7 +86,7 @@ class CertListPage extends BaseListPage { ...this.getColumnSearchProps("name"), render: (text, record, index) => { return ( - + {text} ); @@ -176,7 +176,7 @@ class CertListPage extends BaseListPage { render: (text, record, index) => { return (
- +