Improve load default store in home
This commit is contained in:
parent
ac76b1fb9b
commit
5dd0581a0e
|
@ -393,7 +393,7 @@ class App extends Component {
|
|||
textAlign: "center",
|
||||
}
|
||||
}>
|
||||
Made with <span style={{color: "rgb(255, 255, 255)"}}>❤️</span> by <a style={{fontWeight: "bold", color: "black"}} target="_blank" rel="noreferrer" href="https://github.com/casbin/casibase">Casibase</a>, {Setting.isMobile() ? "Mobile" : "Desktop"} View
|
||||
Powered by <a style={{fontWeight: "bold", color: "black"}} target="_blank" rel="noreferrer" href="https://github.com/casbin/casibase">Casibase</a>
|
||||
</Footer>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -252,6 +252,10 @@ class FileTree extends React.Component {
|
|||
}
|
||||
|
||||
isFileOk(file, action) {
|
||||
if (this.props.account.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.state.permissionMap === null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class FileTreePage extends React.Component {
|
|||
this.state = {
|
||||
classes: props,
|
||||
owner: props.match?.params?.owner !== undefined ? props.match.params.owner : "admin",
|
||||
storeName: props.match?.params?.storeName !== undefined ? props.match.params.storeName : "default",
|
||||
storeName: props.match?.params?.storeName !== undefined ? props.match.params.storeName : this.props.storeName,
|
||||
store: null,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,20 +1,48 @@
|
|||
import React from "react";
|
||||
import FileTreePage from "./FileTreePage";
|
||||
import {Redirect} from "react-router-dom";
|
||||
import * as StoreBackend from "./backend/StoreBackend";
|
||||
import * as Setting from "./Setting";
|
||||
|
||||
class HomePage extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
classes: props,
|
||||
store: null,
|
||||
};
|
||||
}
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
this.getStores();
|
||||
}
|
||||
|
||||
getStores() {
|
||||
StoreBackend.getGlobalStores()
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
const stores = res.data;
|
||||
const store = stores.filter(store => store.domain !== "https://cdn.example.com")[0];
|
||||
if (store !== undefined) {
|
||||
this.setState({
|
||||
store: store,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Setting.showMessage("error", `Failed to get stores: ${res.msg}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.props.account.tag === "Video") {
|
||||
return <Redirect to="/videos" />;
|
||||
} else {
|
||||
return <FileTreePage account={this.props.account} />;
|
||||
if (this.state.store === null) {
|
||||
return null;
|
||||
} else {
|
||||
return <FileTreePage account={this.props.account} storeName={this.state.store.name} />;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue