From 8fe80ab8117067a6bb719a6e5b90fbb7360b4960 Mon Sep 17 00:00:00 2001 From: Johannes Batzill Date: Mon, 7 Nov 2022 14:37:50 -0800 Subject: [PATCH] Remove `Identifier` from UI - Replace with original `Name` (#59) * remove identifier from UI and replace it with original 'Name' * extend uid to length 100 * allow repo name of length 1 --- types/check/common.go | 8 ++++---- .../NewRepoModalButton/NewRepoModalButton.tsx | 20 +++++++++---------- web/src/framework/strings/stringTypes.ts | 7 +++---- web/src/i18n/strings.en.yaml | 7 +++---- .../RepositoriesListing.tsx | 2 +- web/src/utils/Utils.ts | 2 +- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/types/check/common.go b/types/check/common.go index 197b5508d..57c72bdf9 100644 --- a/types/check/common.go +++ b/types/check/common.go @@ -14,9 +14,9 @@ const ( minDisplayNameLength = 1 maxDisplayNameLength = 256 - minUIDLength = 2 - maxUIDLength = 64 - uidRegex = "^[a-zA-Z_][a-zA-Z0-9-_]*$" + minUIDLength = 1 + maxUIDLength = 100 + uidRegex = "^[a-zA-Z_][a-zA-Z0-9-_.]*$" minEmailLength = 1 maxEmailLength = 250 @@ -33,7 +33,7 @@ var ( minUIDLength, maxUIDLength), } ErrUIDRegex = &ValidationError{ - "UID has to start with a letter (or _) and only contain the following characters [a-zA-Z0-9-_].", + "UID has to start with a letter (or _) and only contain the following characters [a-zA-Z0-9-_.].", } ErrEmailLen = &ValidationError{ diff --git a/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx b/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx index bc2d0de5b..d81bc30b9 100644 --- a/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx +++ b/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx @@ -33,7 +33,7 @@ import { useStrings } from 'framework/strings' import { DEFAULT_BRANCH_NAME, getErrorMessage, - REGEX_VALID_IDENTIFIER, + REGEX_VALID_REPO_NAME, SUGGESTED_BRANCH_NAMES, Unknown } from 'utils/Utils' @@ -48,7 +48,7 @@ enum RepoVisibility { } interface RepoFormData { - identifier: string + name: string description: string license: string defaultBranch: string @@ -58,7 +58,7 @@ interface RepoFormData { } const formInitialValues: RepoFormData = { - identifier: '', + name: '', description: '', license: '', defaultBranch: 'main', @@ -122,7 +122,7 @@ export const NewRepoModalButton: React.FC = ({ gitIgnore: get(formData, 'gitignore', 'none'), isPublic: get(formData, 'isPublic') === RepoVisibility.PUBLIC, license: get(formData, 'license', 'none'), - uid: get(formData, 'identifier', '').trim(), + uid: get(formData, 'name', '').trim(), readme: get(formData, 'addReadme', false), parentId: standalone ? space : 0 } as OpenapiCreateRepositoryRequest) @@ -159,22 +159,22 @@ export const NewRepoModalButton: React.FC = ({ formName="editVariations" enableReinitialize={true} validationSchema={yup.object().shape({ - identifier: yup + name: yup .string() .trim() .required() - .matches(REGEX_VALID_IDENTIFIER, getString('validation.identifierPatternIsNotValid')) + .matches(REGEX_VALID_REPO_NAME, getString('validation.repoNamePatternIsNotValid')) })} validateOnChange validateOnBlur onSubmit={handleSubmit}> diff --git a/web/src/framework/strings/stringTypes.ts b/web/src/framework/strings/stringTypes.ts index 93d9235dc..706d0d15d 100644 --- a/web/src/framework/strings/stringTypes.ts +++ b/web/src/framework/strings/stringTypes.ts @@ -31,12 +31,11 @@ export interface StringsMap { editFile: string email: string enterDescription: string - enterRepoIdentifier: string + enterRepoName: string existingAccount: string failedToCreateRepo: string files: string history: string - identifier: string inactiveBranches: string loading: string name: string @@ -54,8 +53,8 @@ export interface StringsMap { 'repos.activities': string 'repos.data': string 'repos.enterBranchName': string - 'repos.identifier': string 'repos.lastChange': string + 'repos.name': string 'repos.noDataMessage': string 'repos.updated': string repositories: string @@ -67,7 +66,7 @@ export interface StringsMap { status: string updated: string 'validation.gitBranchNameInvalid': string - 'validation.identifierPatternIsNotValid': string + 'validation.repoNamePatternIsNotValid': string viewCommitDetails: string yourBranches: string } diff --git a/web/src/i18n/strings.en.yaml b/web/src/i18n/strings.en.yaml index 410b27300..6c62cc3e0 100644 --- a/web/src/i18n/strings.en.yaml +++ b/web/src/i18n/strings.en.yaml @@ -9,7 +9,6 @@ public: Public private: Private cancel: Cancel name: Name -identifier: Identifier search: Search description: Description repositories: Repositories @@ -25,7 +24,7 @@ content: Content history: History newRepo: New Repository createRepo: Create Repository -enterRepoIdentifier: Enter Repository Identifier +enterRepoName: Enter Repository Name enterDescription: Enter a description (optional) addLicense: Add License none: None @@ -53,7 +52,7 @@ searchBranches: Search branches updated: Updated cloneHTTPS: Clone with HTTPS repos: - identifier: Repo Identifier + name: Repo Name data: Repo Data activities: Monthly Activities updated: Updated Date @@ -66,5 +65,5 @@ createRepoModal: publicLabel: Anyone on the internet can see this repository. privateLabel: You choose who can see and commit to this repository. validation: - identifierPatternIsNotValid: 'Identifier can only contain alphanumerics, _ and $' + repoNamePatternIsNotValid: "Name can only contain alphanumerics, '-', '_', '.', and '$'" gitBranchNameInvalid: Branch name is invalid. diff --git a/web/src/pages/RepositoriesListing/RepositoriesListing.tsx b/web/src/pages/RepositoriesListing/RepositoriesListing.tsx index 3f0e1862b..273188ff5 100644 --- a/web/src/pages/RepositoriesListing/RepositoriesListing.tsx +++ b/web/src/pages/RepositoriesListing/RepositoriesListing.tsx @@ -56,7 +56,7 @@ export default function RepositoriesListing() { const columns: Column[] = useMemo( () => [ { - Header: getString('repos.identifier'), + Header: getString('repos.name'), width: 'calc(100% - 180px)', Cell: ({ row }: CellProps) => { const record = row.original diff --git a/web/src/utils/Utils.ts b/web/src/utils/Utils.ts index 01f6905e5..db70b8710 100644 --- a/web/src/utils/Utils.ts +++ b/web/src/utils/Utils.ts @@ -12,7 +12,7 @@ export const X_TOTAL_PAGES = 'x-total-pages' export const X_PER_PAGE = 'x-per-page' export type Unknown = any // eslint-disable-line @typescript-eslint/no-explicit-any export const DEFAULT_BRANCH_NAME = 'main' -export const REGEX_VALID_IDENTIFIER = /^[a-zA-Z_][0-9a-zA-Z_$]{0,63}$/ +export const REGEX_VALID_REPO_NAME = /^[a-zA-Z_][0-9a-zA-Z-_.$]*$/ export const SUGGESTED_BRANCH_NAMES = [DEFAULT_BRANCH_NAME, 'master'] /** This utility shows a toaster without being bound to any component.