Merge remote-tracking branch 'upstream/gitlink_ssr_head' into gitlink_ssr_head
This commit is contained in:
commit
abf7d338d7
|
@ -291,7 +291,7 @@ class Detail extends Component {
|
|||
this.setState({
|
||||
firstSync: false,
|
||||
secondSync: false,
|
||||
mirror_status:data.mirror_status ? data.mirror_status : 0
|
||||
mirror_status:data.mirror_status || 0
|
||||
})
|
||||
this.getBanner(this.props.projectMenu)
|
||||
let projectdata
|
||||
|
|
|
@ -275,8 +275,8 @@ class CreateMerge extends Component {
|
|||
let _url = `/${mergeOwner}/${projectId}/compare/`;
|
||||
// type为pull时,pullBranch取value,否则取原有值
|
||||
// type为pull时,mergeBranch取原有值,否则取value
|
||||
let _pullBranch = type === 'pull' ? value : pullBranch;
|
||||
let _mergeBranch = type === 'pull' ? mergeBranch : value;
|
||||
let _pullBranch = type === 'pull' ? value : returnbar(pullBranch);
|
||||
let _mergeBranch = type === 'pull' ? returnbar(mergeBranch) : value;
|
||||
if (pullOwner === mergeOwner) {
|
||||
// 如果仓库相同, compare/目标分支...源分支
|
||||
_url += `${turnbar(_mergeBranch)}...${turnbar(_pullBranch)}`;
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Input , Form , Select , Checkbox , Button , Spin , AutoComplete, Modal } from 'antd';
|
||||
import { Input , Form , Select , Checkbox , Button , Spin , AutoComplete, Modal , Radio, Tooltip } from 'antd';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { AlignCenter } from '../Component/layout';
|
||||
import { withTranslation } from 'react-i18next';
|
||||
|
||||
import '../css/index.scss';
|
||||
import './new.scss'
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
const addr={
|
||||
"gitea": "https://docs.gitea.com/development/api-usage",
|
||||
"gitee": "https://forum.gitlink.org.cn/forums/10603/detail",
|
||||
"github": "https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token",
|
||||
"gitlab": "https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html",
|
||||
"gitcode": "https://docs.gitcode.com/docs/users/pat/"
|
||||
}
|
||||
|
||||
const plat=["gitea","gitee","github","gitlab","gitcode"];
|
||||
const Option = Select.Option;
|
||||
class Index extends Component {
|
||||
constructor(props) {
|
||||
|
@ -19,7 +27,6 @@ class Index extends Component {
|
|||
gitignoreType: "0",
|
||||
LicensesType: "0",
|
||||
|
||||
mirrorCheck:false,
|
||||
|
||||
CategoryList: undefined,
|
||||
LanguageList: undefined,
|
||||
|
@ -57,7 +64,10 @@ class Index extends Component {
|
|||
tokenConTri: false,
|
||||
|
||||
gitHubUrl:false,
|
||||
checkToken:undefined
|
||||
checkToken:"",
|
||||
isToken:true,
|
||||
isPrivate:false,
|
||||
platName:undefined
|
||||
}
|
||||
}
|
||||
componentDidMount = () => {
|
||||
|
@ -207,28 +217,29 @@ class Index extends Component {
|
|||
isSpin: true
|
||||
})
|
||||
const { projectsType } = this.props.match.params;
|
||||
const { project_language_id, project_category_id, license_id
|
||||
, ignore_id, owners_id, ignoreFlag, licenseFlag,
|
||||
categoreFlag, languageFlag, tokenConTri,gitHubUrl} = this.state;
|
||||
const { project_language_id, project_category_id, license_id, ignore_id, ignoreFlag,
|
||||
licenseFlag , categoreFlag, languageFlag, tokenConTri, isPrivate,isToken} = this.state;
|
||||
const decoderPass = Base64.encode(values.password);
|
||||
const url = (projectsType && projectsType === "mirror") ? "/projects/migrate.json" : "/projects.json";
|
||||
// 新建项目的时候,暂存数据,如果失败,返回的时候可以重新赋值
|
||||
sessionStorage.newProjectValue=JSON.stringify({...values,project_language_id,project_category_id,license_id,ignore_id});
|
||||
// 贡献值激励确权机制
|
||||
const {blockchain_init} = values;
|
||||
const { clone_addr } = values;
|
||||
axios.post(url, {
|
||||
...values,
|
||||
clone_addr:(projectsType && projectsType === "mirror") ? values.clone_addr.trim() :undefined,
|
||||
clone_addr:(projectsType && projectsType === "mirror") ? clone_addr.trim() :undefined,
|
||||
auth_password:decoderPass,
|
||||
project_language_id:languageFlag ? project_language_id : undefined,
|
||||
project_category_id:categoreFlag ? project_category_id : undefined,
|
||||
license_id:licenseFlag ? license_id : undefined,
|
||||
ignore_id:ignoreFlag ? ignore_id : undefined,
|
||||
// user_id:owners_id,
|
||||
blockchain: tokenConTri,
|
||||
blockchain_token_all: 10000,
|
||||
blockchain_init_token: parseInt(blockchain_init),
|
||||
auth_token:((projectsType && projectsType === "mirror") && gitHubUrl)? values.auth_token : undefined
|
||||
blockchain: tokenConTri ,
|
||||
blockchain_token_all:tokenConTri ? 10000 : undefined,
|
||||
blockchain_init_token: tokenConTri ? parseInt(blockchain_init):undefined,
|
||||
auth_token: isPrivate && isToken ? values.auth_token : undefined,
|
||||
importType:undefined
|
||||
}).then((result) => {
|
||||
if (result && result.data.id) {
|
||||
projectsType && projectsType !== "mirror" && this.props.showNotification(`项目创建成功!`);
|
||||
|
@ -288,16 +299,10 @@ class Index extends Component {
|
|||
callback();
|
||||
}
|
||||
|
||||
changeMirrorCheck=()=>{
|
||||
const { mirrorCheck } = this.state;
|
||||
this.setState({
|
||||
mirrorCheck:!mirrorCheck
|
||||
})
|
||||
}
|
||||
|
||||
ChangeAddr=(e)=>{
|
||||
let value = e.target.value;
|
||||
if(value.indexOf("/") > -1){
|
||||
ChangeAddr=(value,unUpdateName)=>{
|
||||
// 将路径最后一个/后的字符作为项目标识
|
||||
if(value.indexOf("/") > -1 && !unUpdateName){
|
||||
let arr = value.split("/");
|
||||
let first = arr[arr.length-1];
|
||||
if(first.indexOf(".") > -1){
|
||||
|
@ -312,9 +317,13 @@ class Index extends Component {
|
|||
repository_name:first
|
||||
})
|
||||
}
|
||||
this.setState({gitHubUrl:value.indexOf("https://github.com")>-1 ? true : false})
|
||||
}else{
|
||||
this.setState({gitHubUrl:false,checkToken:undefined})
|
||||
}
|
||||
// 根据htts://gitlab.com等判断是哪个平台
|
||||
if(value){
|
||||
let name = "";
|
||||
plat.map(i=>{return value.indexOf(`://${i}`)>0 ? name = i :""});
|
||||
name && this.props.form.setFieldsValue({service:name})
|
||||
name && this.setState({platName:name})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,8 +368,7 @@ class Index extends Component {
|
|||
}
|
||||
|
||||
|
||||
blurFunc=(e)=>{
|
||||
let value = e.target.value;
|
||||
blurFunc=(rule, value, callback)=>{
|
||||
if(value){
|
||||
const { clone_addr } = this.props.form.getFieldsValue();
|
||||
if(clone_addr){
|
||||
|
@ -369,22 +377,23 @@ class Index extends Component {
|
|||
auth_token:value,
|
||||
clone_addr
|
||||
}).then(response=>{
|
||||
if(response && response.data){
|
||||
this.setState({
|
||||
checkToken:response.data.data
|
||||
})
|
||||
let res = response.data;
|
||||
if(res && res.data === false){
|
||||
callback("请输入正确的令牌");
|
||||
}else{
|
||||
callback();
|
||||
}
|
||||
callback();
|
||||
}).catch(error=>{})
|
||||
}
|
||||
}else{
|
||||
this.setState({checkToken:undefined})
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
changeName=(e)=>{
|
||||
let value = e.target.value;
|
||||
const { t } = this.props;
|
||||
console.log(this.props,t(value,'en'));
|
||||
if(value){
|
||||
let reg = /[a-zA-Z0-9]/g;
|
||||
let strArr = value.match(reg);
|
||||
|
@ -398,6 +407,29 @@ class Index extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
changeVisibility=(e)=>{
|
||||
let value = e.target.value;
|
||||
let flag = value === "token";
|
||||
this.setState({isToken:flag})
|
||||
let { clone_addr } = this.props.form.getFieldsValue();
|
||||
if(!flag && clone_addr){
|
||||
setTimeout(() => {
|
||||
this.ChangeAddr(clone_addr,true);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
changeIsPrivate=(e)=>{
|
||||
this.setState({
|
||||
isPrivate:e.target.checked
|
||||
})
|
||||
if(e.target.checked){
|
||||
this.props.form.setFieldsValue({
|
||||
importType:"token"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
// 项目类型:deposit-托管项目,mirror-镜像项目
|
||||
|
@ -418,7 +450,6 @@ class Index extends Component {
|
|||
license_list,
|
||||
ignore_list,
|
||||
|
||||
mirrorCheck,
|
||||
|
||||
descNum,
|
||||
|
||||
|
@ -427,8 +458,10 @@ class Index extends Component {
|
|||
languageFlag,
|
||||
categoreFlag,
|
||||
tokenConTri,
|
||||
gitHubUrl,
|
||||
checkToken
|
||||
checkToken,
|
||||
isToken,
|
||||
platName,
|
||||
isPrivate
|
||||
} = this.state;
|
||||
return (
|
||||
<div className="main back-white" style={{padding:"0px",border:"none"}}>
|
||||
|
@ -450,7 +483,7 @@ class Index extends Component {
|
|||
required: true, message: '请填写镜像版本库地址'
|
||||
}],
|
||||
})(
|
||||
<Input placeholder="请输入需要导入到本项目的仓库地址" onBlur={this.ChangeAddr} />
|
||||
<Input placeholder="请输入需要导入到本项目的仓库地址" onBlur={(e)=>this.ChangeAddr(e.target.value)} />
|
||||
)}
|
||||
</Form.Item>
|
||||
<p className="formTip" style={{color:"#D1d1c9"}}>示例:https://github.com/Stability-AI/StableStudio.git</p>
|
||||
|
@ -458,40 +491,55 @@ class Index extends Component {
|
|||
}
|
||||
{
|
||||
projectsType && projectsType === "mirror" &&
|
||||
<div className="pb10">
|
||||
<p className="mt10 mb10 color-grey-3 pointer" onClick={this.changeMirrorCheck}>
|
||||
需要授权验证<i className={mirrorCheck ? "iconfont icon-xiajiantou font-13 ml10 color-grey-8":"iconfont icon-youjiantou font-13 ml10 color-grey-8"}></i>
|
||||
<span className="ml20 font-12" style={{color:"#D1d1c9"}}>
|
||||
如果导入项目为私有仓库,{gitHubUrl ? `则需输入目标平台用户token进行授权,`:"则必须填写相应平台正确的用户名和密码"}
|
||||
{gitHubUrl && <a href="https://forum.gitlink.org.cn/forums/8516/detail" className="color-blue" target="_blank">如何获取token?</a>}
|
||||
</span>
|
||||
</p>
|
||||
<div className="mb10">
|
||||
<Form.Item
|
||||
label=""
|
||||
style={{marginBottom:"0px"}}
|
||||
>
|
||||
{getFieldDecorator('isPrivate', {
|
||||
rules: [],
|
||||
})(
|
||||
<Checkbox value="importPrivate" onChange={this.changeIsPrivate}>导入私有项目</Checkbox>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label=""
|
||||
style={{marginBottom:"10px",display:isPrivate?"block":"none"}}
|
||||
>
|
||||
{getFieldDecorator('importType', {
|
||||
rules: [],
|
||||
})(
|
||||
<Radio.Group onChange={this.changeVisibility}>
|
||||
<Radio value="token">访问令牌方式导入</Radio>
|
||||
<Radio value="pwd">用户名+密码方式导入</Radio>
|
||||
</Radio.Group>
|
||||
)}
|
||||
</Form.Item>
|
||||
{/* token导入 */}
|
||||
{
|
||||
mirrorCheck && gitHubUrl &&
|
||||
<div className="df mb10 token_box">
|
||||
<span className="mr10">Token</span>
|
||||
<input type="password" style={{display:"none"}} />
|
||||
<Form.Item
|
||||
style={{ marginBottom: "0px" }}
|
||||
label=""
|
||||
>
|
||||
{getFieldDecorator('auth_token')(
|
||||
<Input placeholder="请输入对应平台的有效token" style={{width:"240px"}} onBlur={this.blurFunc} />
|
||||
)}
|
||||
</Form.Item>
|
||||
<span style={{marginLeft:"-20px"}}>
|
||||
{ checkToken === false && <i className="iconfont icon-cuo color-red"></i>}
|
||||
{ checkToken === true && <i className="iconfont icon-dui color-green"></i>}
|
||||
</span>
|
||||
</div>
|
||||
isToken && isPrivate &&
|
||||
<Form.Item
|
||||
label={<span>访问令牌(Access Token){addr[`${platName && platName.toLowerCase()}`] && <a className='color-blue' href={addr[`${platName.toLowerCase()}`]} target='_blank'>如何配置?</a>}</span>}
|
||||
>
|
||||
{getFieldDecorator('auth_token',{
|
||||
rules: [
|
||||
{required: true, message: '请输入需要导入仓库的访问令牌'},
|
||||
{validator:(rule, value, callback)=>this.blurFunc(rule, value, callback)}
|
||||
],
|
||||
validateTrigger:"onBlur",
|
||||
})(
|
||||
<Input placeholder="请输入需要导入仓库的访问令牌"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
{
|
||||
mirrorCheck && !gitHubUrl &&
|
||||
<div className="df mb10" style={{alignItems:'center'}}>
|
||||
isPrivate && !isToken &&
|
||||
<div className="df mb20" style={{alignItems:'center'}}>
|
||||
{/* 用户名密码导入 */}
|
||||
<span className="mr10">用户名</span>
|
||||
<input type="password" style={{display:"none"}} />
|
||||
<Form.Item
|
||||
style={{ marginBottom: "0px" }}
|
||||
style={{ marginBottom: "0px"}}
|
||||
label=""
|
||||
>
|
||||
{getFieldDecorator('auth_username', {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import './index.scss';
|
||||
import dianzan from './image/dianzan.png';
|
||||
import fork from './image/fork.png';
|
||||
import RenderHtml from '../../components/render-html';
|
||||
|
||||
export default (props) => {
|
||||
const { list } = props;
|
||||
|
@ -25,7 +26,7 @@ export default (props) => {
|
|||
</p>}
|
||||
|
||||
</div >
|
||||
<p className="search-item-content" dangerouslySetInnerHTML={{ __html: item.content }}></p>
|
||||
{item.content && <RenderHtml className="break_word_comments imageLayerParent search-item-content hide-2 task-hide mb15" value={item.content} />}
|
||||
<div>{item.updateTime}</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -64,6 +64,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
setTerm(val);
|
||||
setPage(1);
|
||||
setForcesearch(!forcesearch);
|
||||
history.push(`/search?value=${val}`);
|
||||
}
|
||||
|
||||
function searchDataList() {
|
||||
|
@ -178,9 +179,9 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
size="large"
|
||||
onSearch={searchFun}
|
||||
className={{ 'global-search': true, "required-search": !searchValue }}
|
||||
ref={(el) => setRef(el)}
|
||||
value={searchValue}
|
||||
onChange={(e) => { setSearchValue(e.target.value) }}
|
||||
ref={(el) => setRef(el)}
|
||||
/>
|
||||
{!searchValue && <span className="ant-form-explain">请输入搜索关键字</span>}
|
||||
</Col>
|
||||
|
@ -208,7 +209,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
创建时间{iconSwitch(orderBy === "createTimeDesc" ? "desc" : orderBy === "createTimeAsc" ? "asc" :"")}
|
||||
</li>
|
||||
</ul>
|
||||
<p>{`找到${totalType1}条结果`}</p>
|
||||
<p className='mb15'>{`找到${totalType1}条结果`}</p>
|
||||
<ItemList
|
||||
list={dataList}
|
||||
/>
|
||||
|
@ -228,7 +229,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
|
||||
<TabPane tab={`帖子(${totalType2})`} key="2">
|
||||
<div className="search-content">
|
||||
<p>{`找到${totalType2}条结果`}</p>
|
||||
<p className='mb15'>{`找到${totalType2}条结果`}</p>
|
||||
<ItemList
|
||||
list={dataList}
|
||||
/>
|
||||
|
@ -285,7 +286,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
|
||||
<TabPane tab={`疑修(${totalType5})`} key="5">
|
||||
<div className="search-content">
|
||||
<p>{`找到${totalType5}条结果`}</p>
|
||||
<p className='mb15'>{`找到${totalType5}条结果`}</p>
|
||||
<ItemList
|
||||
list={dataList}
|
||||
/>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
.search-content {
|
||||
width: 1200px;
|
||||
margin: 1.5vw auto;
|
||||
p{
|
||||
.search-item-title{
|
||||
margin-bottom: .75em !important;
|
||||
}
|
||||
}
|
||||
|
@ -85,12 +85,18 @@
|
|||
&:hover{
|
||||
color: #466aff;
|
||||
}
|
||||
span{
|
||||
.highlightByGitlinkSearch{
|
||||
color: #466aff;
|
||||
}
|
||||
}
|
||||
.search-item-content{
|
||||
span{
|
||||
-webkit-line-clamp: 5;
|
||||
color: rgba(0, 0, 0, 0.65);
|
||||
font-size: 14px;
|
||||
a{
|
||||
color: rgba(0, 0, 0, 0.65);
|
||||
}
|
||||
.highlightByGitlinkSearch{
|
||||
color: #466aff;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue