Merge branch 'feature_router' of https://git.trustie.net/Gitlink/forgeplus-react into feature_router
# Conflicts: # src/forge/Team/List.jsx
This commit is contained in:
commit
322260c3fc
54
src/App.js
54
src/App.js
|
@ -91,6 +91,10 @@ const ProjectIndex = Loadable({
|
|||
loader: () => import("./forge/Index"),
|
||||
loading: Loading,
|
||||
});
|
||||
|
||||
// 此处仅维护前端可能的一级路由,不用进行项目或者组织判断的字段。
|
||||
const keyWord = ["explore", "settings", "setting", "CCF", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search"];
|
||||
|
||||
class App extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -101,7 +105,7 @@ class App extends Component {
|
|||
occupation: 0,
|
||||
mygetHelmetapi: null,
|
||||
pathType: null,
|
||||
pathName:'',
|
||||
pathName: '',
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,14 +117,15 @@ class App extends Component {
|
|||
// 添加路由监听,决定组织还是个人
|
||||
this.unlisten = this.props.history.listen((location) => {
|
||||
let newPathname = location.pathname.split('/')[1];
|
||||
if(this.state.pathName!==newPathname){
|
||||
this.setState({pathType:''});
|
||||
if (this.state.pathName !== newPathname) {
|
||||
this.setState({ pathType: '' });
|
||||
newPathname && this.getPathnameType(newPathname);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
// (!keyWord.includes(this.props.location.pathname.split('/')[1])) &&
|
||||
if (nextProps.location.pathname.split('/')[1] !== this.props.location.pathname.split('/')[1] && nextState.pathType === this.state.pathType) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -129,17 +134,21 @@ class App extends Component {
|
|||
}
|
||||
|
||||
getPathnameType = (pathname) => {
|
||||
let keyWord = ["Gitlink", "Trustie", "explore", "settings", "setting", "CCF", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search"];
|
||||
if (!keyWord.includes(pathname)) {
|
||||
let url = `/owners/${pathname}.json`;
|
||||
axios.get(url).then((response) => {
|
||||
if (response && response.status === 200) {
|
||||
this.setState({
|
||||
pathType: response.data.type || '404',
|
||||
pathName:pathname,
|
||||
pathName: pathname,
|
||||
})
|
||||
}
|
||||
});
|
||||
}else{
|
||||
this.setState({
|
||||
pathType: pathname,
|
||||
pathName: pathname,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +286,7 @@ class App extends Component {
|
|||
}
|
||||
}>
|
||||
</Route>
|
||||
|
||||
|
||||
<Route
|
||||
path="/register"
|
||||
render={
|
||||
|
@ -308,15 +317,6 @@ class App extends Component {
|
|||
}
|
||||
/>
|
||||
|
||||
{/* <Route
|
||||
path={"/:owner/:projectsId"}
|
||||
render={
|
||||
(props) => {
|
||||
return (<Projects {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
}>
|
||||
</Route> */}
|
||||
|
||||
{/*项目*/}
|
||||
<Route
|
||||
path={"/projects"}
|
||||
|
@ -342,19 +342,21 @@ class App extends Component {
|
|||
return (<OrganizeIndex {...props} {...this.props} {...this.state} />)
|
||||
}
|
||||
}>
|
||||
</Route> : pathType === '404' ? <Route path="/nopage" component={Shixunnopage} /> : <Route exact path="/"
|
||||
render={
|
||||
(props) => (
|
||||
personal && personal.length > 0 ?
|
||||
<InfosIndex {...this.props} {...props} />
|
||||
:
|
||||
<ProjectIndex {...this.props} {...props} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Route> : pathType === '404' ? <Route path="/nopage" component={Shixunnopage} /> :
|
||||
<Route exact path="/"
|
||||
render={
|
||||
(props) => (
|
||||
personal && personal.length > 0 ?
|
||||
<InfosIndex {...this.props} {...props} />
|
||||
:
|
||||
<ProjectIndex {...this.props} {...props} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
// <Route path="/" component={Loading} />
|
||||
}
|
||||
|
||||
|
||||
|
||||
{/* 组织 */}
|
||||
<Route path={"/organize"}
|
||||
render={
|
||||
|
|
|
@ -70,12 +70,6 @@ class Index extends Component {
|
|||
<ProjectIndex {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/"
|
||||
render={(props) => (
|
||||
<ProjectIndex {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -179,11 +179,9 @@ class Setting extends Component {
|
|||
content: <span style={{display:"block",textAlign:"left"}}>该操作无法撤销!且将会一并删除相关的易修、合并请求、工作流、里程碑、动态等数据。<br/>是否确认删除 <span style={{fontWeight:"bold"}}>{owner}/{projectName}({projectsId})</span>?</span>,
|
||||
onOk: () => {
|
||||
const url = `/${owner}/${projectsId}.json`;
|
||||
axios
|
||||
.delete(url)
|
||||
.then((result) => {
|
||||
axios.delete(url).then((result) => {
|
||||
this.props.showNotification("仓库删除成功!");
|
||||
this.props.history.push("/projects");
|
||||
this.props.history.push(`/${owner}`);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
|
|
|
@ -87,9 +87,9 @@ export default ((props) => {
|
|||
if (username) {
|
||||
const url = `/organizations/${OIdentifier}/teams/${groupId}/team_users/quit.json`;
|
||||
axios.delete(url).then((result) => {
|
||||
if (result && result.data) {
|
||||
if (result && result.message==='success') {
|
||||
props.showNotification(`已成功退出团队!`);
|
||||
props.history.push(`/${OIdentifier}`);
|
||||
props.history.push(`/${username}`);
|
||||
}
|
||||
}).catch((error) => { });
|
||||
}
|
||||
|
|
|
@ -72,6 +72,14 @@ export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(
|
|||
}}
|
||||
></Route>
|
||||
|
||||
{/* 组织详情(包含组织设置) */}
|
||||
<Route
|
||||
path="/:OIdentifier/setting"
|
||||
render={(p) => (
|
||||
<DetailIndex {...props} {...p}/>
|
||||
)}
|
||||
></Route>
|
||||
|
||||
{/* 组织下的项目详情 */}
|
||||
<Route
|
||||
path="/:owner/:projectsId"
|
||||
|
|
|
@ -63,10 +63,10 @@ function List(props){
|
|||
const menu_new=(
|
||||
<Menu>
|
||||
<Menu.Item key="updated_on">
|
||||
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/deposit/new/${OIdentifier}`)}}>新建托管项目</CheckProfile>
|
||||
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/deposit/new/${OIdentifier}`)}}>新建托管项目</CheckProfile>
|
||||
</Menu.Item>
|
||||
<Menu.Item key="created_on">
|
||||
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/mirror/new/${OIdentifier}`)}}>新建镜像项目</CheckProfile>
|
||||
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/mirror/new/${OIdentifier}`)}}>新建镜像项目</CheckProfile>
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
)
|
||||
|
|
|
@ -22,21 +22,26 @@ const ProjectDetail = Loadable({
|
|||
});
|
||||
export default withRouter(
|
||||
(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC((props) => {
|
||||
|
||||
// 个人中心新增的二级目录都需在此添加一次。将项目放组织和个人名下后,此处根据二级目录作判断,
|
||||
let secondRouter = '';
|
||||
let firstRouter = '';
|
||||
if (props.location.pathname) {
|
||||
firstRouter =props.location.pathname.split('/')[1];
|
||||
secondRouter = props.location.pathname.split('/')[2];
|
||||
}
|
||||
// 如果是explore,把所有路由相关的都改成当前登录人;
|
||||
let changePathProps={...props};
|
||||
if(firstRouter==='explore'){
|
||||
let login=props.current_user.login;
|
||||
changePathProps.match.path=`/${login}`;
|
||||
changePathProps.match.url=`/${login}`;
|
||||
changePathProps.location.pathname=`/${login}`;
|
||||
changePathProps.history.location.pathname=`/${login}`;
|
||||
}
|
||||
let userRouterArr = ['statistics', 'projects', 'notice', 'devops', 'organizes', 'info', 'watchers', 'fan_users', 'password'];
|
||||
return (
|
||||
<Switch>
|
||||
{/* <Route
|
||||
path="/:username"
|
||||
render={(p) => (
|
||||
secondRouter && (!userRouterArr.includes(secondRouter)) ?
|
||||
<ProjectDetail {...props} {...p} /> : <Infos {...props} {...p} />
|
||||
)}
|
||||
></Route> */}
|
||||
|
||||
{secondRouter && (!userRouterArr.includes(secondRouter)) ? <Route
|
||||
path="/:owner/:projectsId"
|
||||
|
@ -46,7 +51,7 @@ export default withRouter(
|
|||
></Route> : <Route
|
||||
path="/:username"
|
||||
render={(p) => (
|
||||
<Infos {...props} {...p} />
|
||||
<Infos {...changePathProps} {...p} />
|
||||
)}
|
||||
></Route>}
|
||||
|
||||
|
|
Loading…
Reference in New Issue