From b0deb39e3ab01112d58378542b2f3d60451bb62c Mon Sep 17 00:00:00 2001 From: benjobs Date: Sat, 6 Jan 2024 09:51:10 +0800 Subject: [PATCH] [Improve] git clone connect type improvement (#3450) * [Improve] git clone connect type improvement * [Improve] minor improve * [Improve] StringUtils minor improvement * [Improve] maven build args minor improve --------- Co-authored-by: benjobs --- .../main/assembly/script/data/mysql-data.sql | 2 +- .../main/assembly/script/data/pgsql-data.sql | 2 +- .../assembly/script/schema/mysql-schema.sql | 1 - .../assembly/script/schema/pgsql-schema.sql | 1 - .../console/base/util/GitUtils.java | 85 +++++++++---------- .../console/core/entity/Project.java | 78 +++++++++-------- .../core/service/impl/ProjectServiceImpl.java | 4 +- .../console/core/task/ProjectBuildTask.java | 5 +- .../src/main/resources/db/data-h2.sql | 2 +- .../src/main/resources/db/schema-h2.sql | 1 - .../resources/mapper/core/ProjectMapper.xml | 1 - .../console/core/entity/ProjectTest.java | 2 - .../Application/src/AppDarkModeToggle.vue | 4 +- .../ContextMenu/src/ContextMenu.vue | 4 +- .../src/components/Form/src/BasicForm.vue | 2 +- .../Form/src/components/FormItem.vue | 8 +- .../Modal/src/components/ModalWrapper.vue | 4 +- .../src/components/Page/src/PageFooter.vue | 4 +- .../Table/src/components/HeaderCell.vue | 2 +- .../src/enums/projectEnum.ts | 5 -- .../src/hooks/setting/useMenuSetting.ts | 10 +-- .../src/hooks/web/useLockPage.ts | 9 +- .../src/locales/lang/en/flink/project.ts | 6 +- .../src/locales/lang/zh-CN/flink/project.ts | 3 - .../src/utils/props.ts | 48 +++++------ .../src/views/base/error-log/data.tsx | 12 +-- .../flink/app/hooks/useCreateAndEditSchema.ts | 2 +- .../src/views/resource/project/Add.vue | 1 - .../src/views/resource/project/Edit.vue | 1 - .../project/components/RepositoryGroup.tsx | 78 ++++++----------- .../src/views/resource/project/useProject.tsx | 37 ++------ 31 files changed, 181 insertions(+), 243 deletions(-) diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql b/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql index b514325fc3..3650b01c3c 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql @@ -40,7 +40,7 @@ insert into `t_flink_effective` values (100000, 100000, 2, 100000, now()); -- ---------------------------- -- Records of t_flink_project -- ---------------------------- -insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', '1', 'https://github.com/apache/incubator-streampark-quickstart', 'release-2.0.0', null, null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now()); +insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', 'https://github.com/apache/incubator-streampark-quickstart', 'release-2.0.0', null, null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now()); -- ---------------------------- -- Records of t_flink_sql diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql b/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql index 8e0fa63b8b..1b2b72657d 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql @@ -35,7 +35,7 @@ insert into "public"."t_flink_effective" values (100000, 100000, 2, 100000, now( -- ---------------------------- -- Records of t_flink_project -- ---------------------------- -insert into "public"."t_flink_project" values (100000, 100000, 'streampark-quickstart', '1', 'https://github.com/apache/incubator-streampark-quickstart', 'release-2.0.0', null, null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now()); +insert into "public"."t_flink_project" values (100000, 100000, 'streampark-quickstart', 'https://github.com/apache/incubator-streampark-quickstart', 'release-2.0.0', null, null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now()); -- ---------------------------- diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql b/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql index 3c69e14578..3a00c9b8cb 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql @@ -185,7 +185,6 @@ create table `t_flink_project` ( `id` bigint not null auto_increment, `team_id` bigint not null, `name` varchar(255) collate utf8mb4_general_ci default null, - `git_credential` tinyint not null, `url` varchar(255) collate utf8mb4_general_ci default null, `branches` varchar(64) collate utf8mb4_general_ci default null, `user_name` varchar(64) collate utf8mb4_general_ci default null, diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql b/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql index 8af5c6a32c..02cd0cfcd0 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql @@ -430,7 +430,6 @@ create table "public"."t_flink_project" ( "id" int8 not null default nextval('streampark_t_flink_project_id_seq'::regclass), "team_id" int8, "name" varchar(255) collate "pg_catalog"."default", - "git_credential" int2, "url" varchar(255) collate "pg_catalog"."default", "branches" varchar(64) collate "pg_catalog"."default", "user_name" varchar(64) collate "pg_catalog"."default", diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java index a54117b71e..109fe60f34 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java @@ -20,7 +20,6 @@ import org.apache.streampark.common.util.FileUtils; import org.apache.streampark.common.util.SystemPropertyUtils; import org.apache.streampark.console.core.entity.Project; -import org.apache.streampark.console.core.enums.GitCredentialEnum; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -83,55 +82,51 @@ public static List getBranchList(Project project) throws GitAPIException } private static void setCredentials(TransportCommand transportCommand, Project project) { - GitCredentialEnum gitCredentialEnum = GitCredentialEnum.of(project.getGitCredential()); - switch (gitCredentialEnum) { - case HTTPS: - if (!StringUtils.isAllBlank(project.getUserName(), project.getPassword())) { - UsernamePasswordCredentialsProvider credentialsProvider = - new UsernamePasswordCredentialsProvider(project.getUserName(), project.getPassword()); - transportCommand.setCredentialsProvider(credentialsProvider); - } - break; - case SSH: - transportCommand.setTransportConfigCallback( - transport -> { - SshTransport sshTransport = (SshTransport) transport; - sshTransport.setSshSessionFactory( - new JschConfigSessionFactory() { - @Override - protected void configure(OpenSshConfig.Host hc, Session session) { - session.setConfig("StrictHostKeyChecking", "no"); - } + if (project.isHttpRepositoryUrl()) { + if (!StringUtils.isAllEmpty(project.getUserName(), project.getPassword())) { + UsernamePasswordCredentialsProvider credentialsProvider = + new UsernamePasswordCredentialsProvider(project.getUserName(), project.getPassword()); + transportCommand.setCredentialsProvider(credentialsProvider); + } + } else if (project.isSshRepositoryUrl()) { + transportCommand.setTransportConfigCallback( + transport -> { + SshTransport sshTransport = (SshTransport) transport; + sshTransport.setSshSessionFactory( + new JschConfigSessionFactory() { + @Override + protected void configure(OpenSshConfig.Host hc, Session session) { + session.setConfig("StrictHostKeyChecking", "no"); + } - @Override - protected JSch createDefaultJSch(FS fs) throws JSchException { - JSch jSch = super.createDefaultJSch(fs); - String prvkeyPath = project.getPrvkeyPath(); - if (StringUtils.isBlank(prvkeyPath)) { - String userHome = SystemPropertyUtils.getUserHome(); - if (userHome != null) { - String rsaPath = userHome.concat("/.ssh/id_rsa"); - if (FileUtils.exists(rsaPath)) { - prvkeyPath = rsaPath; - } + @Override + protected JSch createDefaultJSch(FS fs) throws JSchException { + JSch jSch = super.createDefaultJSch(fs); + String prvkeyPath = project.getPrvkeyPath(); + if (StringUtils.isBlank(prvkeyPath)) { + String userHome = SystemPropertyUtils.getUserHome(); + if (userHome != null) { + String rsaPath = userHome.concat("/.ssh/id_rsa"); + if (FileUtils.exists(rsaPath)) { + prvkeyPath = rsaPath; } } - if (prvkeyPath == null) { - return jSch; - } - if (StringUtils.isBlank(project.getPassword())) { - jSch.addIdentity(prvkeyPath); - } else { - jSch.addIdentity(prvkeyPath, project.getPassword()); - } + } + if (prvkeyPath == null) { return jSch; } - }); - }); - break; - default: - throw new IllegalStateException( - "[StreamPark] git setCredentials: unsupported protocol type"); + if (StringUtils.isBlank(project.getPassword())) { + jSch.addIdentity(prvkeyPath); + } else { + jSch.addIdentity(prvkeyPath, project.getPassword()); + } + return jSch; + } + }); + }); + } else { + throw new IllegalStateException( + "[StreamPark] repository URL is invalid, must be ssh or http(s)"); } } } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java index fd68e3fc59..813598f7a9 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java @@ -20,7 +20,6 @@ import org.apache.streampark.common.conf.CommonConfig; import org.apache.streampark.common.conf.InternalConfigHolder; import org.apache.streampark.common.conf.Workspace; -import org.apache.streampark.common.util.CommandUtils; import org.apache.streampark.common.util.Utils; import org.apache.streampark.console.base.exception.ApiDetailException; import org.apache.streampark.console.base.util.GitUtils; @@ -68,8 +67,6 @@ public class Project implements Serializable { private Date lastBuild; - private Integer gitCredential; - @TableField(updateStrategy = FieldStrategy.IGNORED) private String userName; @@ -195,13 +192,21 @@ public String getMavenArgs() { if (mavenHome == null) { mavenHome = System.getenv("MAVEN_HOME"); } + + boolean useWrapper = true; if (mavenHome != null) { mvn = mavenHome + "/bin/" + mvn; + try { + Process process = Runtime.getRuntime().exec(mvn + " --version"); + process.waitFor(); + Utils.required(process.exitValue() == 0); + useWrapper = false; + } catch (Exception ignored) { + log.warn("try using user-installed maven failed, now use maven-wrapper."); + } } - try { - CommandUtils.execute(mvn + " --version"); - } catch (Exception e) { + if (useWrapper) { if (windows) { mvn = WebUtils.getAppHome().concat("/bin/mvnw.cmd"); } else { @@ -212,62 +217,53 @@ public String getMavenArgs() { StringBuilder cmdBuffer = new StringBuilder(mvn).append(" clean package -DskipTests "); if (StringUtils.isNotBlank(this.buildArgs)) { - String dangerArgs = getDangerArgs(this.buildArgs); - if (dangerArgs == null) { - cmdBuffer.append(this.buildArgs.trim()); - } else { + String args = getIllegalArgs(this.buildArgs); + if (args != null) { throw new IllegalArgumentException( String.format( - "Invalid maven argument, dangerous args: %s, in your buildArgs: %s", - dangerArgs, this.buildArgs)); + "Illegal argument: \"%s\" in maven build parameters: %s", args, this.buildArgs)); } + cmdBuffer.append(this.buildArgs.trim()); } String setting = InternalConfigHolder.get(CommonConfig.MAVEN_SETTINGS_PATH()); if (StringUtils.isNotBlank(setting)) { - String dangerArgs = getDangerArgs(setting); - if (dangerArgs == null) { - File file = new File(setting); - if (file.exists() && file.isFile()) { - cmdBuffer.append(" --settings ").append(setting); - } else { - throw new IllegalArgumentException( - String.format("Invalid maven-setting file path, %s no exists or not file", setting)); - } + String args = getIllegalArgs(setting); + if (args != null) { + throw new IllegalArgumentException( + String.format("Illegal argument \"%s\" in maven-setting file path: %s", args, setting)); + } + File file = new File(setting); + if (file.exists() && file.isFile()) { + cmdBuffer.append(" --settings ").append(setting); } else { throw new IllegalArgumentException( String.format( - "Invalid maven-setting file path, dangerous args: %s, in your maven setting path: %s", - dangerArgs, setting)); + "Invalid maven-setting file path \"%s\", the path not exist or is not file", + setting)); } } return cmdBuffer.toString(); } - private String getDangerArgs(String param) { + private String getIllegalArgs(String param) { Pattern pattern = Pattern.compile("(`.*?`)|(\\$\\((.*?)\\))"); Matcher matcher = pattern.matcher(param); if (matcher.find()) { - String dangerArgs = matcher.group(1); - if (dangerArgs == null) { - dangerArgs = matcher.group(2); - } - return dangerArgs; + return matcher.group(1) == null ? matcher.group(2) : matcher.group(1); } - String result = null; - Iterator dangerIter = Arrays.asList(";", "|", "&", ">").iterator(); + Iterator iterator = Arrays.asList(";", "|", "&", ">").iterator(); String[] argsList = param.split("\\s+"); - while (result == null && dangerIter.hasNext()) { - String danger = dangerIter.next(); + while (iterator.hasNext()) { + String chr = iterator.next(); for (String arg : argsList) { - if (arg.contains(danger)) { - result = arg; - break; + if (arg.contains(chr)) { + return arg; } } } - return result; + return null; } @JsonIgnore @@ -298,4 +294,12 @@ public String getLog4CloneStart() { private String getLogHeader(String header) { return "---------------------------------[ " + header + " ]---------------------------------\n"; } + + public boolean isHttpRepositoryUrl() { + return url != null && (url.trim().startsWith("https://") || url.trim().startsWith("http://")); + } + + public boolean isSshRepositoryUrl() { + return url != null && url.trim().startsWith("git@"); + } } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java index 6470876804..fe8ec49024 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java @@ -33,7 +33,6 @@ import org.apache.streampark.console.core.entity.Application; import org.apache.streampark.console.core.entity.Project; import org.apache.streampark.console.core.enums.BuildStateEnum; -import org.apache.streampark.console.core.enums.GitCredentialEnum; import org.apache.streampark.console.core.enums.ReleaseStateEnum; import org.apache.streampark.console.core.mapper.ProjectMapper; import org.apache.streampark.console.core.service.ProjectService; @@ -118,14 +117,13 @@ public boolean update(Project projectParam) { project.setName(projectParam.getName()); project.setUrl(projectParam.getUrl()); project.setBranches(projectParam.getBranches()); - project.setGitCredential(projectParam.getGitCredential()); project.setPrvkeyPath(projectParam.getPrvkeyPath()); project.setUserName(projectParam.getUserName()); project.setPassword(projectParam.getPassword()); project.setPom(projectParam.getPom()); project.setDescription(projectParam.getDescription()); project.setBuildArgs(projectParam.getBuildArgs()); - if (GitCredentialEnum.isSSH(project.getGitCredential())) { + if (project.isSshRepositoryUrl()) { project.setUserName(null); } else { project.setPrvkeyPath(null); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/task/ProjectBuildTask.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/task/ProjectBuildTask.java index 45c950efd5..aca7626395 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/task/ProjectBuildTask.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/task/ProjectBuildTask.java @@ -23,7 +23,6 @@ import org.apache.streampark.console.base.util.GitUtils; import org.apache.streampark.console.core.entity.Project; import org.apache.streampark.console.core.enums.BuildStateEnum; -import org.apache.streampark.console.core.enums.GitCredentialEnum; import ch.qos.logback.classic.Logger; import lombok.extern.slf4j.Slf4j; @@ -107,9 +106,7 @@ private boolean cloneSourceCode(Project project) { return true; } catch (Exception e) { if (e instanceof InvalidRemoteException) { - GitCredentialEnum gitCredential = GitCredentialEnum.of(project.getGitCredential()); - if (gitCredential == GitCredentialEnum.HTTPS) { - project.setGitCredential(GitCredentialEnum.SSH.getValue()); + if (project.isHttpRepositoryUrl()) { String url = project .getUrl() diff --git a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql index 61be9f74d7..5eadb987ae 100644 --- a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql +++ b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql @@ -34,7 +34,7 @@ insert into `t_flink_effective` values (100000, 100000, 2, 100000, now()); -- ---------------------------- -- Records of t_flink_project -- ---------------------------- -insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', '1', 'https://github.com/apache/incubator-streampark-quickstart', 'dev', null, null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now()); +insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', 'https://github.com/apache/incubator-streampark-quickstart', 'dev', null, null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now()); -- ---------------------------- -- Records of t_flink_sql diff --git a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql index 596801a9ad..8ddbda8076 100644 --- a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql +++ b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql @@ -168,7 +168,6 @@ create table if not exists `t_flink_project` ( `id` bigint generated by default as identity not null, `team_id` bigint not null, `name` varchar(255) default null, - `git_credential` tinyint not null, `url` varchar(255) default null, `branches` varchar(64) default null, `user_name` varchar(64) default null, diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml index 78a85b8239..a53aa78868 100644 --- a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml +++ b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml @@ -22,7 +22,6 @@ - diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/ProjectTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/ProjectTest.java index 6c1f6807a1..af249b0057 100644 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/ProjectTest.java +++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/ProjectTest.java @@ -18,7 +18,6 @@ package org.apache.streampark.console.core.entity; import org.apache.streampark.console.core.enums.GitAuthorizedErrorEnum; -import org.apache.streampark.console.core.enums.GitCredentialEnum; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.BeforeEach; @@ -35,7 +34,6 @@ class ProjectTest { @BeforeEach void before() { project.setUrl("https://github.com/apache/incubator-streampark.git"); - project.setGitCredential(GitCredentialEnum.HTTPS.getValue()); } @Disabled("This test case can't be runnable due to external service is not available.") diff --git a/streampark-console/streampark-console-webapp/src/components/Application/src/AppDarkModeToggle.vue b/streampark-console/streampark-console-webapp/src/components/Application/src/AppDarkModeToggle.vue index 19ba3b1514..d4e0ce1646 100644 --- a/streampark-console/streampark-console-webapp/src/components/Application/src/AppDarkModeToggle.vue +++ b/streampark-console/streampark-console-webapp/src/components/Application/src/AppDarkModeToggle.vue @@ -63,7 +63,9 @@ height: 18px; background-color: #fff; border-radius: 50%; - transition: transform 0.5s, background-color 0.5s; + transition: + transform 0.5s, + background-color 0.5s; will-change: transform; } diff --git a/streampark-console/streampark-console-webapp/src/components/ContextMenu/src/ContextMenu.vue b/streampark-console/streampark-console-webapp/src/components/ContextMenu/src/ContextMenu.vue index e08c25f36b..78cac5c5b6 100644 --- a/streampark-console/streampark-console-webapp/src/components/ContextMenu/src/ContextMenu.vue +++ b/streampark-console/streampark-console-webapp/src/components/ContextMenu/src/ContextMenu.vue @@ -179,7 +179,9 @@ background-color: @component-background; border: 1px solid rgb(0 0 0 / 8%); border-radius: 0.25rem; - box-shadow: 0 2px 2px 0 rgb(0 0 0 / 14%), 0 3px 1px -2px rgb(0 0 0 / 10%), + box-shadow: + 0 2px 2px 0 rgb(0 0 0 / 14%), + 0 3px 1px -2px rgb(0 0 0 / 10%), 0 1px 5px 0 rgb(0 0 0 / 6%); background-clip: padding-box; user-select: none; diff --git a/streampark-console/streampark-console-webapp/src/components/Form/src/BasicForm.vue b/streampark-console/streampark-console-webapp/src/components/Form/src/BasicForm.vue index 1cd7e3809b..e5a9dacf62 100644 --- a/streampark-console/streampark-console-webapp/src/components/Form/src/BasicForm.vue +++ b/streampark-console/streampark-console-webapp/src/components/Form/src/BasicForm.vue @@ -113,7 +113,7 @@ }); const getBindValue = computed( - () => ({ ...attrs, ...props, ...unref(getProps) } as Recordable), + () => ({ ...attrs, ...props, ...unref(getProps) }) as Recordable, ); const getSchema = computed((): FormSchema[] => { diff --git a/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue b/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue index 137ae94d6c..9bbb5023fa 100644 --- a/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue +++ b/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue @@ -333,8 +333,8 @@ return slot ? getSlot(slots, slot, unref(getValues)) : render - ? render(unref(getValues)) - : renderComponent(); + ? render(unref(getValues)) + : renderComponent(); }; const showSuffix = !!suffix; @@ -382,8 +382,8 @@ return colSlot ? getSlot(slots, colSlot, values) : renderColContent - ? renderColContent(values) - : renderItem(); + ? renderColContent(values) + : renderItem(); }; return ( diff --git a/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue b/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue index 1b1b9a6137..52c8b5eb8b 100644 --- a/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue +++ b/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue @@ -153,8 +153,8 @@ realHeightRef.value = props.height ? props.height : realHeight > maxHeight - ? maxHeight - : realHeight; + ? maxHeight + : realHeight; } emit('height-change', unref(realHeightRef)); } catch (error) { diff --git a/streampark-console/streampark-console-webapp/src/components/Page/src/PageFooter.vue b/streampark-console/streampark-console-webapp/src/components/Page/src/PageFooter.vue index e89a6ce979..8fdbc8f41a 100644 --- a/streampark-console/streampark-console-webapp/src/components/Page/src/PageFooter.vue +++ b/streampark-console/streampark-console-webapp/src/components/Page/src/PageFooter.vue @@ -39,7 +39,9 @@ line-height: 44px; background-color: @component-background; border-top: 1px solid @border-color-base; - box-shadow: 0 -6px 16px -8px rgb(0 0 0 / 8%), 0 -9px 28px 0 rgb(0 0 0 / 5%), + box-shadow: + 0 -6px 16px -8px rgb(0 0 0 / 8%), + 0 -9px 28px 0 rgb(0 0 0 / 5%), 0 -12px 48px 16px rgb(0 0 0 / 3%); transition: width 0.2s; diff --git a/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue b/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue index 35c0802696..36ab854c59 100644 --- a/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue +++ b/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue @@ -22,7 +22,7 @@ props: { column: { type: Object as PropType, - default: () => ({} as BasicColumn), + default: () => ({}) as BasicColumn, }, }, setup(props) { diff --git a/streampark-console/streampark-console-webapp/src/enums/projectEnum.ts b/streampark-console/streampark-console-webapp/src/enums/projectEnum.ts index 3be6455ad3..e5b5454cf3 100644 --- a/streampark-console/streampark-console-webapp/src/enums/projectEnum.ts +++ b/streampark-console/streampark-console-webapp/src/enums/projectEnum.ts @@ -3,11 +3,6 @@ export enum ProjectTypeEnum { SPARK = 2, } -export enum GitCredentialEnum { - HTTPS = 1, - SSH = 2, -} - export enum CVSTypeEnum { GIT = 1, SVN = 2, diff --git a/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts b/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts index 3566bfd27c..f501c6e80d 100644 --- a/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts +++ b/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts @@ -105,8 +105,8 @@ export function useMenuSetting() { return siderHidden ? 0 : collapsedShowTitle - ? SIDE_BAR_SHOW_TIT_MINI_WIDTH - : SIDE_BAR_MINI_WIDTH; + ? SIDE_BAR_SHOW_TIT_MINI_WIDTH + : SIDE_BAR_MINI_WIDTH; }); const getCalcContentWidth = computed(() => { @@ -114,9 +114,9 @@ export function useMenuSetting() { unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden)) ? 0 : unref(getIsMixSidebar) - ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) + - (unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0) - : unref(getRealWidth); + ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) + + (unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0) + : unref(getRealWidth); return `calc(100% - ${unref(width)}px)`; }); diff --git a/streampark-console/streampark-console-webapp/src/hooks/web/useLockPage.ts b/streampark-console/streampark-console-webapp/src/hooks/web/useLockPage.ts index c543be9542..9a66074210 100644 --- a/streampark-console/streampark-console-webapp/src/hooks/web/useLockPage.ts +++ b/streampark-console/streampark-console-webapp/src/hooks/web/useLockPage.ts @@ -32,9 +32,12 @@ export function useLockPage() { } clear(); - timeId = setTimeout(() => { - lockPage(); - }, lockTime * 60 * 1000); + timeId = setTimeout( + () => { + lockPage(); + }, + lockTime * 60 * 1000, + ); } function lockPage(): void { diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts index 4f569def3f..245f717a16 100644 --- a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts +++ b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts @@ -34,14 +34,11 @@ export default { cvs: 'CVS', prvkeyPath: 'Private Key Path', prvkeyPathPlaceholder: 'private key path, e.g: ~/.ssh/id_rsa', - gitCredential: 'Connect Type', - gitCredentialPlaceholder: 'Git connection type, http/ssh', cvsPlaceholder: 'CVS', repositoryURL: 'Repository URL', repositoryURLPlaceholder: 'The Repository URL for this project', repositoryURLRequired: 'The repository URL is required', - httpChecked: 'The repository address must be a valid http(s) address', - gitChecked: 'The repository address must be a valid ssh address', + credentialError: 'The repository address must be a valid ssh or http(s) address', userName: 'UserName', userNamePlaceholder: 'UserName for this project', password: 'Password', @@ -62,7 +59,6 @@ export default { projectNameIsRequiredMessage: 'Project Name is required', projectNameIsUniqueMessage: 'The Project Name is already exists. Please check', projectTypeIsRequiredMessage: 'Project Type is required', - gitCredentialIsRequiredMessage: 'Connect Type is required', cvsIsRequiredMessage: 'CVS is required', repositoryURLIsRequiredMessage: 'Repository URL is required', pomSpecifiesModuleMessage: diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts index 572e153d36..7d077a5d65 100644 --- a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts +++ b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts @@ -34,8 +34,6 @@ export default { cvs: 'CVS', prvkeyPath: '私钥路径', prvkeyPathPlaceholder: '私钥文件路径, 如: ~/.ssh/id_rsa', - gitCredential: '连接方式', - gitCredentialPlaceholder: 'Git连接方式, http/ssh', cvsPlaceholder: 'CVS类型: git/svn', repositoryURL: '仓库地址', repositoryURLPlaceholder: '请输入该项目的仓库地址', @@ -61,7 +59,6 @@ export default { projectNameIsRequiredMessage: '项目名称必填', projectNameIsUniqueMessage: '项目名称已存在,请再次输入', projectTypeIsRequiredMessage: '项目类型必选', - gitCredentialIsRequiredMessage: 'Git连接方式为必填项', cvsIsRequiredMessage: '资源来源必选', repositoryURLIsRequiredMessage: '(项目)仓库地址必填', pomSpecifiesModuleMessage: '指定编译pom.xml的模块 如未指定,则在根路径pom.xml下找到', diff --git a/streampark-console/streampark-console-webapp/src/utils/props.ts b/streampark-console/streampark-console-webapp/src/utils/props.ts index 4a15ec465b..4a5491b270 100644 --- a/streampark-console/streampark-console-webapp/src/utils/props.ts +++ b/streampark-console/streampark-console-webapp/src/utils/props.ts @@ -28,8 +28,8 @@ export type BuildPropOption, R, V, C> = { default?: R extends true ? never : D extends Record | Array - ? () => D - : (() => D) | D; + ? () => D + : (() => D) | D; validator?: ((val: any) => val is C) | ((val: any) => boolean); }; @@ -37,8 +37,8 @@ type _BuildPropType = | (T extends PropWrapper ? T[typeof wrapperKey] : [V] extends [never] - ? ResolvePropTypeWithReadonly - : never) + ? ResolvePropTypeWithReadonly + : never) | V | C; export type BuildPropType = _BuildPropType< @@ -53,8 +53,8 @@ type _BuildPropDefault = [T] extends [ ] ? D : D extends () => T - ? ReturnType - : D; + ? ReturnType + : D; export type BuildPropDefault = R extends true ? { readonly default?: undefined } @@ -146,12 +146,12 @@ export const buildProps = < [K in keyof O]: O[K] extends BuildPropReturn ? O[K] : [O[K]] extends NativePropType - ? O[K] - : O[K] extends BuildPropOption - ? D extends BuildPropType - ? BuildPropOption - : never - : never; + ? O[K] + : O[K] extends BuildPropOption + ? D extends BuildPropType + ? BuildPropOption + : never + : never; }, >( props: O, @@ -162,20 +162,20 @@ export const buildProps = < [K in keyof O]: O[K] extends { [propKey]: boolean } ? O[K] : [O[K]] extends NativePropType - ? O[K] - : O[K] extends BuildPropOption< - infer T, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - infer _D, - infer R, - infer V, - infer C - > - ? BuildPropReturn - : never; + ? O[K] + : O[K] extends BuildPropOption< + infer T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + infer _D, + infer R, + infer V, + infer C + > + ? BuildPropReturn + : never; }; -export const definePropType = (val: any) => ({ [wrapperKey]: val } as PropWrapper); +export const definePropType = (val: any) => ({ [wrapperKey]: val }) as PropWrapper; export const keyOf = (arr: T) => Object.keys(arr) as Array; export const mutable = >(val: T) => diff --git a/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx b/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx index 3ffc2f4537..73120a425e 100644 --- a/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx +++ b/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx @@ -16,12 +16,12 @@ export function getColumns(): BasicColumn[] { text === ErrorTypeEnum.VUE ? 'green' : text === ErrorTypeEnum.RESOURCE - ? 'cyan' - : text === ErrorTypeEnum.PROMISE - ? 'blue' - : ErrorTypeEnum.AJAX - ? 'red' - : 'purple'; + ? 'cyan' + : text === ErrorTypeEnum.PROMISE + ? 'blue' + : ErrorTypeEnum.AJAX + ? 'red' + : 'purple'; return {() => text}; }, }, diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts index 7e693ea1ba..3aab70a4db 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts @@ -491,7 +491,7 @@ export const useCreateAndEditSchema = ( { field: 'hadoopUser', label: t('flink.app.hadoopUser'), - component: 'Input' + component: 'Input', }, { field: 'description', diff --git a/streampark-console/streampark-console-webapp/src/views/resource/project/Add.vue b/streampark-console/streampark-console-webapp/src/views/resource/project/Add.vue index c90578a336..e3a6a6f07c 100644 --- a/streampark-console/streampark-console-webapp/src/views/resource/project/Add.vue +++ b/streampark-console/streampark-console-webapp/src/views/resource/project/Add.vue @@ -40,7 +40,6 @@ try { const res = await createProject({ name: values.name, - gitCredential: values.gitCredential, url: values.url, repository: values.repository, type: values.type, diff --git a/streampark-console/streampark-console-webapp/src/views/resource/project/Edit.vue b/streampark-console/streampark-console-webapp/src/views/resource/project/Edit.vue index 29374009be..a31dcc3b16 100644 --- a/streampark-console/streampark-console-webapp/src/views/resource/project/Edit.vue +++ b/streampark-console/streampark-console-webapp/src/views/resource/project/Edit.vue @@ -60,7 +60,6 @@ const { data } = await updateProject({ id: route.query.id, name: values.name, - gitCredential: values.gitCredential, url: values.url, repository: values.repository, type: values.type, diff --git a/streampark-console/streampark-console-webapp/src/views/resource/project/components/RepositoryGroup.tsx b/streampark-console/streampark-console-webapp/src/views/resource/project/components/RepositoryGroup.tsx index 5f317752fe..449d6eb330 100644 --- a/streampark-console/streampark-console-webapp/src/views/resource/project/components/RepositoryGroup.tsx +++ b/streampark-console/streampark-console-webapp/src/views/resource/project/components/RepositoryGroup.tsx @@ -1,4 +1,4 @@ -/* +/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. @@ -12,18 +12,14 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. + limitations under the License. */ -import { defineComponent, h } from 'vue'; -import type { PropType } from 'vue'; -import { Form, Input, Select, Tag } from 'ant-design-vue'; +import { defineComponent } from 'vue'; +import { Form, Input, Tag } from 'ant-design-vue'; export interface RepositoryProps { - gitCredential: string | number; url: string; } import { useI18n } from '/@/hooks/web/useI18n'; -import { GitCredentialEnum } from '/@/enums/projectEnum'; -import { SvgIcon } from '/@/components/Icon'; export default defineComponent({ name: 'RepositoryUrl', props: { @@ -32,63 +28,43 @@ export default defineComponent({ required: true, }, }, - emits: ['updateProtocol', 'updateUrl'], + emits: ['updateUrl'], setup(props, { emit }) { const { t } = useI18n(); const formItemContext = Form.useInjectFormItemContext(); - const handleProtocolChange = (value: any) => { - emit('updateProtocol', value); - formItemContext.onFieldChange(); - }; const handleUrlChange = (value: any) => { emit('updateUrl', value); formItemContext.onFieldChange(); }; - const options = [ - { - label: h('div', {}, [h(SvgIcon, { name: 'http', color: '#108ee9', size: '30' }, '')]), - value: GitCredentialEnum.HTTPS, - }, - { - label: h('div', {}, [h(SvgIcon, { name: 'ssh', color: '#108ee9', size: '30' }, '')]), - value: GitCredentialEnum.SSH, - }, - ]; - return () => { return (
- - handleUrlChange(e.target.value)} - /> - + handleUrlChange(e.target.value)} + />

- - - {t('flink.app.noteInfo.note')} - - {props.value?.gitCredential === 1 && ( + {/^http(s)?:\/\//.test(props.value?.url) && ( + + + {t('flink.app.noteInfo.note')} + {t('flink.project.operationTips.httpsCredential')} - )} - {props.value?.gitCredential === 2 && ( + + )} + {/^git@(.*)/.test(props.value?.url) && ( + + + {t('flink.app.noteInfo.note')} + {t('flink.project.operationTips.sshCredential')} - )} - + + )}

); diff --git a/streampark-console/streampark-console-webapp/src/views/resource/project/useProject.tsx b/streampark-console/streampark-console-webapp/src/views/resource/project/useProject.tsx index 00d274fbaa..5c04c7126f 100644 --- a/streampark-console/streampark-console-webapp/src/views/resource/project/useProject.tsx +++ b/streampark-console/streampark-console-webapp/src/views/resource/project/useProject.tsx @@ -23,7 +23,7 @@ import { useMessage } from '/@/hooks/web/useMessage'; import { useRoute } from 'vue-router'; import { ProjectRecord } from '/@/api/resource/project/model/projectModel'; import { useI18n } from '/@/hooks/web/useI18n'; -import { GitCredentialEnum, ProjectTypeEnum, CVSTypeEnum } from '/@/enums/projectEnum'; +import { ProjectTypeEnum, CVSTypeEnum } from '/@/enums/projectEnum'; import RepositoryGroup from './components/RepositoryGroup'; import { Form } from 'ant-design-vue'; @@ -47,19 +47,10 @@ export const useProject = () => { if (!values.url) { return Promise.reject(t('flink.project.form.repositoryURLRequired')); } - switch (values.gitCredential) { - case GitCredentialEnum.SSH: - if (/^git@(.*)/.test(values.url)) { - return Promise.resolve(); - } else { - return Promise.reject(t('flink.project.form.gitChecked')); - } - default: - if (/^http(s)?:\/\//.test(values.url)) { - return Promise.resolve(); - } else { - return Promise.reject(t('flink.project.form.httpChecked')); - } + if (/^git@(.*)/.test(values.url) || /^http(s)?:\/\//.test(values.url)) { + return Promise.resolve(); + } else { + return Promise.reject(t('flink.project.form.credentialError')); } }; const projectFormSchema = computed((): FormSchema[] => { @@ -114,13 +105,6 @@ export const useProject = () => { }, ], }, - { - field: 'gitCredential', - label: '', - component: 'Input', - show: false, - defaultValue: GitCredentialEnum.HTTPS, - }, { field: 'url', label: '', component: 'Input', show: false }, { field: 'repositoryUrl', @@ -135,10 +119,8 @@ export const useProject = () => { > (model.gitCredential = value)} onUpdateUrl={(value) => (model.url = value)} /> @@ -149,7 +131,7 @@ export const useProject = () => { field: 'prvkeyPath', label: t('flink.project.form.prvkeyPath'), component: 'Input', - ifShow: ({ values }) => values.gitCredential == GitCredentialEnum.SSH, + ifShow: ({ values }) => /^git@(.*)/.test(values.url || ''), componentProps: { placeholder: t('flink.project.form.prvkeyPathPlaceholder'), }, @@ -158,7 +140,7 @@ export const useProject = () => { field: 'userName', label: t('flink.project.form.userName'), component: 'Input', - ifShow: ({ values }) => values.gitCredential == GitCredentialEnum.HTTPS, + ifShow: ({ values }) => /^http(s)?:\/\//.test(values.url || ''), componentProps: { placeholder: t('flink.project.form.userNamePlaceholder'), autocomplete: 'new-password', @@ -259,7 +241,6 @@ export const useProject = () => { const res = await gitCheck({ url: values.url, branches: values.branches, - gitCredential: values.gitCredential, userName: values.userName || null, password: values.password || null, prvkeyPath: values.prvkeyPath || null, @@ -296,14 +277,13 @@ export const useProject = () => { try { const url = values.url; if (url) { - const gitCredential = values.gitCredential; const userName = values.userName || null; const password = values.password || null; const prvkeyPath = values.prvkeyPath || null; const userNull = userName === null || userName === undefined || userName === ''; const passNull = password === null || password === undefined || password === ''; if ((userNull && passNull) || (!userNull && !passNull)) { - const res = await fetchBranches({ gitCredential, url, userName, password, prvkeyPath }); + const res = await fetchBranches({ url, userName, password, prvkeyPath }); if (res) branchList.value = res.map((i) => ({ label: i, value: i })); } } @@ -322,7 +302,6 @@ export const useProject = () => { name: res.name, type: res.type, repository: res.repository, - gitCredential: res.gitCredential || GitCredentialEnum.HTTPS, url: res.url, userName: res.userName, password: res.password,