From 3fe37370a447fa81979d77a62eec69b7b37bd8ca Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Tue, 10 Sep 2019 16:36:32 +0200 Subject: [PATCH 1/7] remove unnecessary buttongroup --- .../packages/ui-components/src/Breadcrumb.js | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/Breadcrumb.js b/scm-ui-components/packages/ui-components/src/Breadcrumb.js index d2f3409af6..5b0f151c61 100644 --- a/scm-ui-components/packages/ui-components/src/Breadcrumb.js +++ b/scm-ui-components/packages/ui-components/src/Breadcrumb.js @@ -1,10 +1,9 @@ //@flow import React from "react"; -import { Link } from "react-router-dom"; -import type { Branch, Repository } from "@scm-manager/ui-types"; +import {Link} from "react-router-dom"; +import type {Branch, Repository} from "@scm-manager/ui-types"; import injectSheet from "react-jss"; -import { ExtensionPoint, binder } from "@scm-manager/ui-extensions"; -import {ButtonGroup} from "./buttons"; +import {binder, ExtensionPoint} from "@scm-manager/ui-extensions"; import classNames from "classnames"; type Props = { @@ -64,33 +63,48 @@ class Breadcrumb extends React.Component { } render() { - const { classes, baseUrl, branch, defaultBranch, branches, revision, path, repository } = this.props; + const { + classes, + baseUrl, + branch, + defaultBranch, + branches, + revision, + path, + repository + } = this.props; return ( <>
-

From ba68cec4fa07148b9a71b290a15905d793a0b6d2 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Wed, 11 Sep 2019 14:54:07 +0200 Subject: [PATCH 2/7] add validator for filepath --- .../packages/ui-components/src/validation.js | 8 +++++++- scm-ui/src/users/components/userValidation.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/validation.js b/scm-ui-components/packages/ui-components/src/validation.js index fcfffcee45..221f9f12ea 100644 --- a/scm-ui-components/packages/ui-components/src/validation.js +++ b/scm-ui-components/packages/ui-components/src/validation.js @@ -5,7 +5,7 @@ export const isNameValid = (name: string) => { return nameRegex.test(name); }; -const mailRegex = /^[ -~]+@[A-Za-z0-9][\w\-.]*\.[A-Za-z0-9][A-Za-z0-9-]+$/; +const mailRegex = /^[ -~]+@[A-Za-z0-9][\w\-.]*\.[A-Za-z0-9][A-Za-z0-9-]+$/; export const isMailValid = (mail: string) => { return mailRegex.test(mail); @@ -14,3 +14,9 @@ export const isMailValid = (mail: string) => { export const isNumberValid = (number: string) => { return !isNaN(number); }; + +const pathRegex = /^((?!\/{2,}).)*$/; + +export const isValidPath = (path: string) => { + return pathRegex.test(path); +}; diff --git a/scm-ui/src/users/components/userValidation.js b/scm-ui/src/users/components/userValidation.js index c9460fdd50..8078df4bcd 100644 --- a/scm-ui/src/users/components/userValidation.js +++ b/scm-ui/src/users/components/userValidation.js @@ -2,9 +2,9 @@ import { validation } from "@scm-manager/ui-components"; -const { isNameValid, isMailValid } = validation; +const { isNameValid, isMailValid, isValidPath } = validation; -export { isNameValid, isMailValid }; +export { isNameValid, isMailValid, isValidPath }; export const isDisplayNameValid = (displayName: string) => { if (displayName) { From 6cad53ec875d283b7ca3d236a778da310b03f1b3 Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Thu, 12 Sep 2019 11:29:42 +0200 Subject: [PATCH 3/7] Add unit test --- .../ui-components/src/validation.test.js | 183 ++++++++++-------- 1 file changed, 99 insertions(+), 84 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/validation.test.js b/scm-ui-components/packages/ui-components/src/validation.test.js index d50996ff2b..6348bd67ba 100644 --- a/scm-ui-components/packages/ui-components/src/validation.test.js +++ b/scm-ui-components/packages/ui-components/src/validation.test.js @@ -2,102 +2,117 @@ import * as validator from "./validation"; describe("test name validation", () => { - it("should return false", () => { - // invalid names taken from ValidationUtilTest.java - const invalidNames = [ - "@test", - " test 123", - " test 123 ", - "test 123 ", - "test/123", - "test%123", - "test:123", - "t ", - " t", - " t ", - "", + // invalid names taken from ValidationUtilTest.java + const invalidNames = [ + "@test", + " test 123", + " test 123 ", + "test 123 ", + "test/123", + "test%123", + "test:123", + "t ", + " t", + " t ", + "", - " invalid_name", - "another%one", - "!!!", - "!_!" - ]; - for (let name of invalidNames) { + " invalid_name", + "another%one", + "!!!", + "!_!" + ]; + for (let name of invalidNames) { + it(`should return false for '${name}'`, () => { expect(validator.isNameValid(name)).toBe(false); - } - }); + }); + } - it("should return true", () => { - // valid names taken from ValidationUtilTest.java - const validNames = [ - "test", - "test.git", - "Test123.git", - "Test123-git", - "Test_user-123.git", - "test@scm-manager.de", - "test123", - "tt", - "t", - "valid_name", - "another1", - "stillValid", - "this.one_as-well", - "and@this" - ]; - for (let name of validNames) { + // valid names taken from ValidationUtilTest.java + const validNames = [ + "test", + "test.git", + "Test123.git", + "Test123-git", + "Test_user-123.git", + "test@scm-manager.de", + "test123", + "tt", + "t", + "valid_name", + "another1", + "stillValid", + "this.one_as-well", + "and@this" + ]; + for (let name of validNames) { + it(`should return true for '${name}'`, () => { expect(validator.isNameValid(name)).toBe(true); - } - }); + }); + } }); describe("test mail validation", () => { - it("should return false", () => { - // invalid taken from ValidationUtilTest.java - const invalid = [ - "ostfalia.de", - "@ostfalia.de", - "s.sdorra@", - "s.sdorra@ostfalia", - "s.sdorra@ ostfalia.de", - "s.sdorra@[ostfalia.de" - ]; - for (let mail of invalid) { + // invalid taken from ValidationUtilTest.java + const invalid = [ + "ostfalia.de", + "@ostfalia.de", + "s.sdorra@", + "s.sdorra@ostfalia", + "s.sdorra@ ostfalia.de", + "s.sdorra@[ostfalia.de" + ]; + for (let mail of invalid) { + it(`should return false for '${mail}'`, () => { expect(validator.isMailValid(mail)).toBe(false); - } - }); + }); + } - it("should return true", () => { - // valid taken from ValidationUtilTest.java - const valid = [ - "s.sdorra@ostfalia.de", - "sdorra@ostfalia.de", - "s.sdorra@hbk-bs.de", - "s.sdorra@gmail.com", - "s.sdorra@t.co", - "s.sdorra@ucla.college", - "s.sdorra@example.xn--p1ai", - "s.sdorra@scm.solutions", - "s'sdorra@scm.solutions", - "\"S Sdorra\"@scm.solutions" - ]; - for (let mail of valid) { + // valid taken from ValidationUtilTest.java + const valid = [ + "s.sdorra@ostfalia.de", + "sdorra@ostfalia.de", + "s.sdorra@hbk-bs.de", + "s.sdorra@gmail.com", + "s.sdorra@t.co", + "s.sdorra@ucla.college", + "s.sdorra@example.xn--p1ai", + "s.sdorra@scm.solutions", + "s'sdorra@scm.solutions", + "\"S Sdorra\"@scm.solutions" + ]; + for (let mail of valid) { + it(`should return true for '${mail}'`, () => { expect(validator.isMailValid(mail)).toBe(true); - } - }); + }); + } }); describe("test number validation", () => { - it("should return false", () => { - const invalid = ["1a", "35gu", "dj6", "45,5", "test"]; - for (let number of invalid) { - expect(validator.isNumberValid(number)).toBe(false); - } - }); - it("should return true", () => { - const valid = ["1", "35", "2", "235", "34.4"]; - for (let number of valid) { + const invalid = ["1a", "35gu", "dj6", "45,5", "test"]; + for (let number of invalid) { + it(`should return false for '${number}'`, () => { + expect(validator.isNumberValid(number)).toBe(false); + }); + } + const valid = ["1", "35", "2", "235", "34.4"]; + for (let number of valid) { + it(`should return true for '${number}'`, () => { expect(validator.isNumberValid(number)).toBe(true); - } - }); + }); + } +}); + +describe("test path validation", () => { + const invalid = ["//", "some//path", "end//"]; + for (let path of invalid) { + it(`should return false for '${path}'`, () => { + expect(validator.isValidPath(path)).toBe(false); + }); + } + const valid = ["", "/", "dir", "some/path", "end/"]; + for (let path of valid) { + it(`should return true for '${path}'`, () => { + expect(validator.isValidPath(path)).toBe(true); + }); + } }); From 7807f5d49db5f96279b6c72414e96c32700109c7 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Thu, 12 Sep 2019 11:36:49 +0200 Subject: [PATCH 4/7] rename path validation method --- scm-ui-components/packages/ui-components/src/validation.js | 2 +- scm-ui/src/users/components/userValidation.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/validation.js b/scm-ui-components/packages/ui-components/src/validation.js index 221f9f12ea..98a36c6f0e 100644 --- a/scm-ui-components/packages/ui-components/src/validation.js +++ b/scm-ui-components/packages/ui-components/src/validation.js @@ -17,6 +17,6 @@ export const isNumberValid = (number: string) => { const pathRegex = /^((?!\/{2,}).)*$/; -export const isValidPath = (path: string) => { +export const isPathValid = (path: string) => { return pathRegex.test(path); }; diff --git a/scm-ui/src/users/components/userValidation.js b/scm-ui/src/users/components/userValidation.js index 8078df4bcd..e53dce229c 100644 --- a/scm-ui/src/users/components/userValidation.js +++ b/scm-ui/src/users/components/userValidation.js @@ -2,9 +2,9 @@ import { validation } from "@scm-manager/ui-components"; -const { isNameValid, isMailValid, isValidPath } = validation; +const { isNameValid, isMailValid, isPathValid } = validation; -export { isNameValid, isMailValid, isValidPath }; +export { isNameValid, isMailValid, isPathValid }; export const isDisplayNameValid = (displayName: string) => { if (displayName) { From 17125d9c338396352958640ded3f8186d8d784f0 Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Thu, 12 Sep 2019 11:39:04 +0200 Subject: [PATCH 5/7] Fix unit test --- .../packages/ui-components/src/validation.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/validation.test.js b/scm-ui-components/packages/ui-components/src/validation.test.js index 6348bd67ba..4af5d755d0 100644 --- a/scm-ui-components/packages/ui-components/src/validation.test.js +++ b/scm-ui-components/packages/ui-components/src/validation.test.js @@ -106,13 +106,13 @@ describe("test path validation", () => { const invalid = ["//", "some//path", "end//"]; for (let path of invalid) { it(`should return false for '${path}'`, () => { - expect(validator.isValidPath(path)).toBe(false); + expect(validator.isPathValid(path)).toBe(false); }); } const valid = ["", "/", "dir", "some/path", "end/"]; for (let path of valid) { it(`should return true for '${path}'`, () => { - expect(validator.isValidPath(path)).toBe(true); + expect(validator.isPathValid(path)).toBe(true); }); } }); From a9fbd5f21ac1d786780323a2fc18b712a8848cc2 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Thu, 12 Sep 2019 14:44:42 +0200 Subject: [PATCH 6/7] remove buttongroup from extensionpoint --- .../src/repos/sources/containers/Content.js | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scm-ui/src/repos/sources/containers/Content.js b/scm-ui/src/repos/sources/containers/Content.js index b9032ae681..4d297c05bc 100644 --- a/scm-ui/src/repos/sources/containers/Content.js +++ b/scm-ui/src/repos/sources/containers/Content.js @@ -106,17 +106,15 @@ class Content extends React.Component {
{selector}
- - - +
From fcba0999a7046f42742aa10b1544b4a657e23a1c Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Fri, 13 Sep 2019 15:48:48 +0000 Subject: [PATCH 7/7] Close branch feature/editor_file_create