fix 导入仓库页面提示信息错乱

This commit is contained in:
bwcx_jzy 2023-03-14 09:30:44 +08:00
parent f910fb0a45
commit d0db5ec0a3
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
4 changed files with 49 additions and 62 deletions

View File

@ -13,6 +13,7 @@
5. 【all】更新 fastjson2 版本
6. 【all】优化 SSH 命令脚本、服务端脚本、插件端脚本执行参数优化
(感谢 [@大灰灰大](https://gitee.com/linjianhui) [Gitee issues I6IPDY](https://gitee.com/dromara/Jpom/issues/I6IPDY)
7. 【server】优化 导入仓库页面提示信息错乱(感谢@零壹)
### ❌ 不兼容功能

View File

@ -185,18 +185,19 @@ public class RepositoryController extends BaseServerController {
@GetMapping(value = "/build/repository/authorize_repos")
@Feature(method = MethodFeature.LIST)
public JsonMessage<PageResultDto<JSONObject>> authorizeRepos(HttpServletRequest request) {
public JsonMessage<PageResultDto<JSONObject>> authorizeRepos(HttpServletRequest request,
@ValidatorItem String token,
String address,
@ValidatorItem String type,
String condition) {
// 获取分页信息
Map<String, String> paramMap = ServletUtil.getParamMap(request);
Page page = repositoryService.parsePage(paramMap);
String token = paramMap.get("token");
Assert.hasText(token, "请填写个人令牌");
String gitlabAddress = StrUtil.blankToDefault(paramMap.get("gitlabAddress"), "https://gitlab.com");
String giteaAddress = paramMap.get("giteaAddress");
//String gitlabAddress = StrUtil.blankToDefault(paramMap.get("gitlabAddress"), "https://gitlab.com");
//String giteaAddress = paramMap.get("giteaAddress");
// 搜索条件
String condition = paramMap.get("condition");
// 远程仓库
String type = paramMap.get("type");
PageResultDto<JSONObject> pageResultDto;
switch (type) {
case "gitee":
@ -207,21 +208,21 @@ public class RepositoryController extends BaseServerController {
pageResultDto = this.githubRepos(token, page, request);
break;
case "gitlab":
pageResultDto = this.gitlabRepos(token, page, condition, gitlabAddress, request);
pageResultDto = this.gitlabRepos(token, page, condition, address, request);
break;
case "gitea":
pageResultDto = this.giteaRepos(token, page, condition, giteaAddress, request);
pageResultDto = this.giteaRepos(token, page, condition, address, request);
break;
default:
throw new IllegalArgumentException("不支持的类型");
}
return new JsonMessage<>(HttpStatus.OK.value(), HttpStatus.OK.name(), pageResultDto);
return JsonMessage.success(HttpStatus.OK.name(), pageResultDto);
}
/**
* gitlab 仓库
* <p>
* https://docs.gitlab.com/ee/api/projects.html#list-all-projects
* <a href="https://docs.gitlab.com/ee/api/projects.html#list-all-projects">https://docs.gitlab.com/ee/api/projects.html#list-all-projects</a>
*
* @param token 个人令牌
* @param page 分页
@ -229,6 +230,7 @@ public class RepositoryController extends BaseServerController {
* @return page
*/
private PageResultDto<JSONObject> gitlabRepos(String token, Page page, String condition, String gitlabAddress, HttpServletRequest request) {
gitlabAddress = StrUtil.blankToDefault(gitlabAddress, "https://gitlab.com");
// 删除最后的 /
if (gitlabAddress.endsWith("/")) {
gitlabAddress = gitlabAddress.substring(0, gitlabAddress.length() - 1);
@ -361,6 +363,7 @@ public class RepositoryController extends BaseServerController {
* @return page
*/
private PageResultDto<JSONObject> giteaRepos(String token, Page page, String condition, String giteaAddress, HttpServletRequest request) {
Assert.hasText(giteaAddress, "请填写 gitea 地址");
String giteaUsername = GiteaUtil.getGiteaUsername(giteaAddress, token);
Map<String, Object> giteaReposMap = GiteaUtil.getGiteaRepos(giteaAddress, token, page, condition);

View File

@ -436,7 +436,8 @@ export default {
{ title: "序号", width: 80, ellipsis: true, align: "center", customRender: (text, record, index) => `${index + 1}` },
{ title: "服务Id", dataIndex: "id", ellipsis: true, scopedSlots: { customRender: "id" } },
{ title: "名称", dataIndex: "spec.name", ellipsis: true, scopedSlots: { customRender: "tooltip" } },
{ title: "模式", dataIndex: "spec.mode.mode", ellipsis: true, width: 120, scopedSlots: { customRender: "tooltip" } },
{ title: "运行模式", dataIndex: "spec.mode.mode", ellipsis: true, width: 120, scopedSlots: { customRender: "tooltip" } },
{ title: "网络模式", dataIndex: "spec.endpointSpec.mode", ellipsis: true, width: 120, scopedSlots: { customRender: "tooltip" } },
{ title: "副本数", dataIndex: "spec.mode.replicated.replicas", align: "center", width: 90, ellipsis: true, scopedSlots: { customRender: "replicas" } },
{ title: "解析模式", dataIndex: "spec.endpointSpec.mode", ellipsis: true, width: 100, scopedSlots: { customRender: "tooltip" } },

View File

@ -181,44 +181,25 @@
</a-modal>
<a-modal destroyOnClose v-model="giteeImportVisible" title="通过私人令牌导入仓库" width="80%" :footer="null" :maskClosable="false">
<a-form-model :label-col="{ span: 4 }" :rules="giteeImportFormRules" :model="giteeImportForm" ref="giteeImportForm" :wrapper-col="{ span: 20 }">
<a-form-model-item prop="token">
<template slot="label">
私人令牌
<a-tooltip>
<template slot="title">
<ul>
<li>使用私人令牌可以在你不输入账号密码的情况下对你账号内的仓库进行管理你可以在创建令牌时指定令牌所拥有的权限</li>
</ul>
</template>
<a-icon type="question-circle" theme="filled" />
</a-tooltip>
</template>
<a-input-group compact>
<a-select v-model="giteeImportForm.type" @change="importTypeChange">
<a-select-option value="gitee"> gitee </a-select-option>
<a-select-option value="github"> github </a-select-option>
<a-select-option value="gitlab"> gitlab </a-select-option>
<a-select-option value="gitea"> gitea </a-select-option>
</a-select>
<a-tooltip :title="`${giteeImportForm.type} 的令牌${importTypePlaceholder}`">
<a-input-search style="width: 55%; margin-top: 1px" enter-button v-model="giteeImportForm.token" @search="handleGiteeImportFormOk" :placeholder="importTypePlaceholder" />
</a-tooltip>
</a-input-group>
<a-input-group compact style="width: 105%">
<a-tooltip title="输入仓库名称或者仓库路径进行搜索">
<a-input style="width: 55%; margin-top: 1px" enter-button v-model="giteeImportForm.condition" placeholder="输入仓库名称或者仓库路径进行搜索" />
</a-tooltip>
</a-input-group>
<a-input-group compact style="width: 105%" v-if="giteeImportForm.type === 'gitlab'">
<a-tooltip title="请输入 GitLab 的地址,支持自建 GitLab不需要输入协议gitlab.com、gitlab.jpom.io、10.1.2.3、10.1.2.3:8888 等">
<a-input style="width: 55%; margin-top: 1px" enter-button v-model="giteeImportForm.gitlabAddress" placeholder="gitlab.com" />
</a-tooltip>
</a-input-group>
<a-input-group compact style="width: 105%" v-if="giteeImportForm.type === 'gitea'">
<a-tooltip title="请输入 gitea 的地址不需要输入协议10.1.2.3、10.1.2.3:3000 等">
<a-input style="width: 55%; margin-top: 1px" enter-button v-model="giteeImportForm.giteaAddress" placeholder="10.1.2.3:3000" />
</a-tooltip>
</a-input-group>
<a-form-model-item prop="token" label="私人令牌" help="使用私人令牌,可以在你不输入账号密码的情况下对你账号内的仓库进行管理,你可以在创建令牌时指定令牌所拥有的权限。">
<a-tooltip :title="`${giteeImportForm.type} 的令牌${importTypePlaceholder[giteeImportForm.type]}`">
<a-input v-model="giteeImportForm.token" :placeholder="importTypePlaceholder[giteeImportForm.type]">
<a-select slot="addonBefore" v-model="giteeImportForm.type" @change="importTypeChange">
<a-select-option value="gitee"> gitee </a-select-option>
<a-select-option value="github"> github </a-select-option>
<a-select-option value="gitlab"> gitlab </a-select-option>
<a-select-option value="gitea"> gitea </a-select-option>
</a-select>
<a-button slot="addonAfter" size="small" type="primary" icon="search" @click="handleGiteeImportFormOk"> </a-button>
</a-input>
</a-tooltip>
</a-form-model-item>
<a-form-model-item prop="address" label="地址" :help="importTypeAddressHelp[giteeImportForm.type]" v-if="giteeImportForm.type === 'gitlab' || giteeImportForm.type === 'gitea'">
<a-input v-model="giteeImportForm.address" placeholder="请填写平台地址" />
</a-form-model-item>
<a-form-model-item prop="condition" label="搜索" help="输入仓库名称或者仓库路径进行搜索">
<a-input v-model="giteeImportForm.condition" placeholder="输入仓库名称或者仓库路径进行搜索" />
</a-form-model-item>
</a-form-model>
<a-table :loading="loading" :columns="reposColumns" :data-source="repos" bordered rowKey="full_name" @change="reposChange" :pagination="reposPagination">
@ -264,7 +245,7 @@ export default {
giteeImportVisible: false,
repos: [],
username: null,
importTypePlaceholder: "",
columns: [
{ title: "仓库名称", dataIndex: "name", sorter: true, ellipsis: true, scopedSlots: { customRender: "name" } },
{
@ -335,11 +316,23 @@ export default {
giteeImportForm: Object.assign({}, PAGE_DEFAULT_LIST_QUERY, { limit: 15, type: "gitee" }),
giteeImportFormRules: {
token: [{ required: true, message: "请输入私人令牌", trigger: "blur" }],
// address: [{ required: true, message: "", trigger: "blur" }],
},
rules: {
name: [{ required: true, message: "请填写仓库名称", trigger: "blur" }],
gitUrl: [{ required: true, message: "请填写仓库地址", trigger: "blur" }],
},
importTypePlaceholder: {
gitee: "在 设置-->安全设置-->私人令牌 中获取",
github: "在 Settings-->Developer settings-->Personal access tokens 中获取",
gitlab: "在 preferences-->Access Tokens 中获取",
gitea: "在 设置 --> 应用 --> 生成令牌",
other: "请输入私人令牌",
},
importTypeAddressHelp: {
gitlab: "请输入 GitLab 的地址,支持自建 GitLab不需要输入协议gitlab.com、gitlab.jpom.io、10.1.2.3、10.1.2.3:8888 等",
gitea: "请输入 gitea 的地址不需要输入协议10.1.2.3、10.1.2.3:3000 等",
},
};
},
computed: {
@ -503,18 +496,7 @@ export default {
this.listQuery = CHANGE_PAGE(this.listQuery, { pagination, sorter });
this.loadData();
},
// git
importTypeChange(val) {
if (val === "gitee") {
this.importTypePlaceholder = "在 设置-->安全设置-->私人令牌 中获取";
} else if (val === "github") {
this.importTypePlaceholder = "在 Settings-->Developer settings-->Personal access tokens 中获取";
} else if (val === "gitlab") {
this.importTypePlaceholder = "在 preferences-->Access Tokens 中获取";
} else {
this.importTypePlaceholder = "请输入私人令牌";
}
},
//
sortItemHander(record, index, method) {
const msgData = {