mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-01 00:49:02 +02:00
Do not show "tag exists" error in modal on creation
This commit is contained in:
2
gradle/changelog/tag_exists_error.yaml
Normal file
2
gradle/changelog/tag_exists_error.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: fixed
|
||||
description: Short display of "tag already exists" error message when creating a new tag
|
||||
@@ -29,10 +29,12 @@ type Props = {
|
||||
|
||||
const CreateTagModal: FC<Props> = ({ repository, changeset, onClose }) => {
|
||||
const { isLoading, error, data: tags } = useTags(repository);
|
||||
const { isLoading: isLoadingCreate, error: errorCreate, create, tag: createdTag } = useCreateTag(
|
||||
repository,
|
||||
changeset
|
||||
);
|
||||
const {
|
||||
isLoading: isLoadingCreate,
|
||||
error: errorCreate,
|
||||
create,
|
||||
tag: createdTag,
|
||||
} = useCreateTag(repository, changeset);
|
||||
const [t] = useTranslation("repos");
|
||||
const [newTagName, setNewTagName] = useState("");
|
||||
const initialFocusRef = useRef<HTMLInputElement>(null);
|
||||
@@ -43,12 +45,12 @@ const CreateTagModal: FC<Props> = ({ repository, changeset, onClose }) => {
|
||||
}
|
||||
}, [createdTag, onClose]);
|
||||
|
||||
const tagNames = tags?._embedded?.tags.map(tag => tag.name);
|
||||
const tagNames = tags?._embedded?.tags.map((tag) => tag.name);
|
||||
|
||||
let validationError = "";
|
||||
|
||||
if (tagNames !== undefined && newTagName !== "") {
|
||||
if (tagNames.includes(newTagName)) {
|
||||
if (!isLoadingCreate && tagNames.includes(newTagName)) {
|
||||
validationError = "tags.create.form.field.name.error.exists";
|
||||
} else if (!validation.isBranchValid(newTagName)) {
|
||||
validationError = "tags.create.form.field.name.error.format";
|
||||
@@ -68,7 +70,7 @@ const CreateTagModal: FC<Props> = ({ repository, changeset, onClose }) => {
|
||||
<InputField
|
||||
name="name"
|
||||
label={t("tags.create.form.field.name.label")}
|
||||
onChange={event => setNewTagName(event.target.value)}
|
||||
onChange={(event) => setNewTagName(event.target.value)}
|
||||
value={newTagName}
|
||||
validationError={!!validationError}
|
||||
errorMessage={t(validationError)}
|
||||
|
||||
Reference in New Issue
Block a user