工作流权限

This commit is contained in:
caishi 2020-10-16 17:29:10 +08:00
parent 51c2729916
commit a5657390fe
3 changed files with 21 additions and 8 deletions

View File

@ -12,11 +12,14 @@ const Div = styled.div`{
}`;
export default ((props)=>{
const [ menu , setMenu ] = useState(false);
const [ permission , setPermission ] = useState("");
const childRef = useRef();
const path = props.location.pathname;
const owner = props.match.params.owner;
const projectsId = props.match.params.projectsId;
const projectDetail = props.projectDetail;
useEffect(()=>{
if(path === `/projects/${owner}/${projectsId}/devops/list`){
setMenu(true);
@ -25,6 +28,12 @@ export default ((props)=>{
}
},[path])
useEffect(()=>{
if(projectDetail){
setPermission(props.projectDetail.permission);
}
},[projectDetail])
const updateChildState = () => {
// changeVal
if (childRef.current) {
@ -35,13 +44,13 @@ export default ((props)=>{
return(
<div className="disposePanel">
<Banner>
<Link to={`/projects/${owner}/${props.match.params.projectsId}/devops/dispose`} className={menu===false && "color-blue"}>工作流配置</Link>
<Link to={`/projects/${owner}/${props.match.params.projectsId}/devops/list`}className={menu===true && "color-blue"} style={{ marginLeft:"66px"}}>构建列表</Link>
{ permission !=="Reporter" && <Link to={`/projects/${owner}/${props.match.params.projectsId}/devops/dispose`} className={menu===false && "color-blue"} style={{ marginRight:"66px"}}>工作流配置</Link>}
<Link to={`/projects/${owner}/${props.match.params.projectsId}/devops/list`}className={menu===true && "color-blue"}>构建列表</Link>
{ menu===true && <a onClick={updateChildState} style={{float:"right",fontSize:"14px",color:"#FF6E21",marginTop:"5px"}}>刷新</a>}
</Banner>
<Div>
{ menu === true && <Structure {...props} wrappedComponentRef={(form) => childRef.current = form} ref={childRef}/> }
{ menu === false && <Dispost {...props}/> }
{ menu === false && permission !=="Reporter" && <Dispost {...props}/> }
</Div>
</div>
)

View File

@ -22,6 +22,7 @@ function Structure(props,ref){
let projectsId = props.match.params.projectsId;
let owner = props.match.params.owner;
const permission = props.projectDetail && props.projectDetail.permission;
useImperativeHandle(ref, () => ({
changeVal: () => {
@ -29,11 +30,13 @@ function Structure(props,ref){
Init();
}
}))
useEffect(() => {
if (projectsId) {
Init();
}
}, []);
let current_user = props.current_user;
function Init(status) {
const url = `/${owner}/${projectsId}/builds.json`;
@ -266,7 +269,11 @@ function Structure(props,ref){
dataIndex: "operation",
key: "operation",
render: (value, item, key) => {
return renderStatusBtn(item.status, item.number);
if(permission === "Admin" || permission === "Owner"){
return renderStatusBtn(item.status, item.number);
}else{
return "--";
}
},
},
];

View File

@ -369,7 +369,7 @@ class Detail extends Component {
const { projectDetail, watchers_count, praises_count,
forked_count, firstSync , secondSync ,
isManager, watched, praised,
project , open_devops , author } = this.state;
project , open_devops } = this.state;
const url = this.props.history.location.pathname;
const urlArr = url.split("/");
@ -379,8 +379,6 @@ class Detail extends Component {
const { projectsId , owner } = this.props.match.params;
const { state } = this.props.history.location;
const { current_user } = this.props;
const checkLogin = current_user && current_user.login;
const text = (
projectDetail && projectDetail.forked_from_project_id && projectDetail.fork_info ?
@ -392,7 +390,6 @@ class Detail extends Component {
</React.Fragment> : ""
);
const common = {
getDetail: this.getDetail,
changeOpenDevops:this.changeOpenDevops