U update the default sort rule of app

pull/223/head
vapao 2020-11-08 10:01:59 +08:00
parent 658bc3be7b
commit 2888f70b5b
5 changed files with 13 additions and 9 deletions

View File

@ -13,7 +13,7 @@ import store from './store';
import styles from './index.module.css'; import styles from './index.module.css';
export default observer(function Ext1From() { export default observer(function Ext1From() {
const appName = store.records[store.app_id].name; const appName = store.currentRecord.name;
let title = `常规发布 - ${appName}`; let title = `常规发布 - ${appName}`;
if (store.deploy.id) { if (store.deploy.id) {
store.isReadOnly ? title = '查看' + title : title = '编辑' + title; store.isReadOnly ? title = '查看' + title : title = '编辑' + title;

View File

@ -14,12 +14,12 @@ export default observer(function Ext1Setup1() {
const [envs, setEnvs] = useState([]); const [envs, setEnvs] = useState([]);
function updateEnvs() { function updateEnvs() {
const ids = store.records[store.app_id]['deploys'].map(x => x.env_id); const ids = store.currentRecord['deploys'].map(x => x.env_id);
setEnvs(ids.filter(x => x !== store.deploy.env_id)) setEnvs(ids.filter(x => x !== store.deploy.env_id))
} }
useEffect(() => { useEffect(() => {
if (store.records[store.app_id]['deploys'] === undefined) { if (store.currentRecord['deploys'] === undefined) {
store.loadDeploys(store.app_id).then(updateEnvs) store.loadDeploys(store.app_id).then(updateEnvs)
} else { } else {
updateEnvs() updateEnvs()

View File

@ -13,7 +13,7 @@ import Setup3 from './Ext2Setup3';
import store from './store'; import store from './store';
export default observer(function Ext2From() { export default observer(function Ext2From() {
const appName = store.records[store.app_id].name; const appName = store.currentRecord.name;
let title = `自定义发布 - ${appName}`; let title = `自定义发布 - ${appName}`;
if (store.deploy.id) { if (store.deploy.id) {
store.isReadOnly ? title = '查看' + title : title = '编辑' + title; store.isReadOnly ? title = '查看' + title : title = '编辑' + title;

View File

@ -14,12 +14,12 @@ export default observer(function Ext2Setup1() {
const [envs, setEnvs] = useState([]); const [envs, setEnvs] = useState([]);
function updateEnvs() { function updateEnvs() {
const ids = store.records[store.app_id]['deploys'].map(x => x.env_id); const ids = store.currentRecord['deploys'].map(x => x.env_id);
setEnvs(ids.filter(x => x !== store.deploy.env_id)) setEnvs(ids.filter(x => x !== store.deploy.env_id))
} }
useEffect(() => { useEffect(() => {
if (store.records[store.app_id]['deploys'] === undefined) { if (store.currentRecord['deploys'] === undefined) {
store.loadDeploys(store.app_id).then(updateEnvs) store.loadDeploys(store.app_id).then(updateEnvs)
} else { } else {
updateEnvs() updateEnvs()

View File

@ -3,7 +3,7 @@
* Copyright (c) <spug.dev@gmail.com> * Copyright (c) <spug.dev@gmail.com>
* Released under the AGPL-3.0 License. * Released under the AGPL-3.0 License.
*/ */
import { observable } from "mobx"; import { observable, computed } from "mobx";
import http from 'libs/http'; import http from 'libs/http';
class Store { class Store {
@ -22,13 +22,17 @@ class Store {
@observable f_name; @observable f_name;
@observable f_desc; @observable f_desc;
@computed get currentRecord() {
return this.records[`a${this.app_id}`]
}
fetchRecords = () => { fetchRecords = () => {
this.isFetching = true; this.isFetching = true;
http.get('/api/app/') http.get('/api/app/')
.then(res => { .then(res => {
const tmp = {}; const tmp = {};
for (let item of res) { for (let item of res) {
tmp[item.id] = item tmp[`a${item.id}`] = item
} }
this.records = tmp this.records = tmp
}) })
@ -37,7 +41,7 @@ class Store {
loadDeploys = (app_id) => { loadDeploys = (app_id) => {
return http.get('/api/app/deploy/', {params: {app_id}}) return http.get('/api/app/deploy/', {params: {app_id}})
.then(res => this.records[app_id]['deploys'] = res) .then(res => this.records[`a${app_id}`]['deploys'] = res)
}; };
showForm = (e, info) => { showForm = (e, info) => {