From f66a6b12cda96807c29f3c6b2fc851c49f24d739 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Sun, 2 Feb 2025 12:00:52 +0000 Subject: [PATCH] templates: release: Add JS to set default release title to tag name (#6645) Closes #6485 Adds a bit of javascript in the template responsible for the "create release" page When typing a name in the "tag name" field, the content will be automatically set in the "Title" field as a placeholder. This way, you can type a version number (ex: `v5.0.2`), and the title will default to it (`v5.0.2` in this case) ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [x] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [x] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6645 Reviewed-by: Gusted Co-authored-by: Litchi Pi Co-committed-by: Litchi Pi --- templates/repo/release/new.tmpl | 2 +- tests/e2e/release.test.e2e.ts | 4 +++- web_src/js/features/repo-release.js | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl index 9bbd11f027..788d7f015c 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -46,7 +46,7 @@
- +
{{template "shared/combomarkdowneditor" (dict diff --git a/tests/e2e/release.test.e2e.ts b/tests/e2e/release.test.e2e.ts index 49c67793e6..6d1fff2102 100644 --- a/tests/e2e/release.test.e2e.ts +++ b/tests/e2e/release.test.e2e.ts @@ -28,7 +28,9 @@ test('External Release Attachments', async ({page, isMobile}) => { // Fill out form and create new release await expect(page).toHaveURL('/user2/repo2/releases/new'); await validate_form({page}, 'fieldset'); - await page.fill('input[name=tag_name]', '2.0'); + const textarea = page.locator('input[name=tag_name]'); + await textarea.pressSequentially('2.0'); + await expect(page.locator('input[name=title]')).toHaveAttribute('placeholder', '2.0'); await page.fill('input[name=title]', '2.0'); await page.click('#add-external-link'); await page.click('#add-external-link'); diff --git a/web_src/js/features/repo-release.js b/web_src/js/features/repo-release.js index 0db9b8ac73..1ac44f22ef 100644 --- a/web_src/js/features/repo-release.js +++ b/web_src/js/features/repo-release.js @@ -43,6 +43,9 @@ function initTagNameEditor() { showElem('#tag-target-selector'); tagHelper.textContent = value ? newTagHelperText : defaultTagHelperText; } + + const title_input = document.getElementById('release-title'); + title_input.placeholder = value; }); }