From e27d52b2766ba83e583940401a8f20c3b2a7ff5e Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 19 Oct 2022 07:39:55 +0200 Subject: [PATCH 01/13] Fix branch dropdown shifting on page load (#21428) Removed the "tag/branch" prefix and did some misc tweaks like changing to `
From 37ca4cb7d61c0460d5d8e3dce35964ffc72a9f9d Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 19 Oct 2022 08:50:19 +0200 Subject: [PATCH 02/13] Remove vitest globals (#21505) Explicitly import them instead which is cleaner and enables better editor integration. Co-authored-by: Lunny Xiao Co-authored-by: wxiaoguang --- .eslintrc.yaml | 3 --- vitest.config.js | 1 - web_src/js/features/repo-findfile.test.js | 1 + web_src/js/svg.test.js | 1 + web_src/js/utils.test.js | 1 + 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 66d4452ec5072..4dafc8f492186 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -35,9 +35,6 @@ overrides: rules: import/no-unresolved: [0] import/no-extraneous-dependencies: [0] - - files: ["*.test.js"] - env: - jest: true - files: ["*.config.js"] rules: import/no-unused-modules: [0] diff --git a/vitest.config.js b/vitest.config.js index d17abd26c37ed..838360970f7c6 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -24,7 +24,6 @@ export default defineConfig({ open: false, allowOnly: true, passWithNoTests: true, - globals: true, watch: false, }, plugins: [ diff --git a/web_src/js/features/repo-findfile.test.js b/web_src/js/features/repo-findfile.test.js index 2d96ed4463ee1..a90b0bf0a2cab 100644 --- a/web_src/js/features/repo-findfile.test.js +++ b/web_src/js/features/repo-findfile.test.js @@ -1,3 +1,4 @@ +import {describe, expect, test} from 'vitest'; import {strSubMatch, calcMatchedWeight, filterRepoFilesWeighted} from './repo-findfile.js'; describe('Repo Find Files', () => { diff --git a/web_src/js/svg.test.js b/web_src/js/svg.test.js index 9f2836b667890..c5d6d07535c7b 100644 --- a/web_src/js/svg.test.js +++ b/web_src/js/svg.test.js @@ -1,3 +1,4 @@ +import {expect, test} from 'vitest'; import {svg} from './svg.js'; test('svg', () => { diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js index b56d80ac7ade9..7bf5bb7eb61d8 100644 --- a/web_src/js/utils.test.js +++ b/web_src/js/utils.test.js @@ -1,3 +1,4 @@ +import {expect, test} from 'vitest'; import { basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref, prettyNumber, parseUrl, From 7d1aed83f4d0cdf096ec8758ff8a85ddccf1328d Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 19 Oct 2022 10:08:33 +0200 Subject: [PATCH 03/13] Disable the 'Add File' button when not able to edit repo (#21503) Previously, the button would render a dropdown with zero items when `.CanEnableEditor` was false (for example on a mirror repo). Now it disables the button instead which is better UX. image image Co-authored-by: Lauris BH Co-authored-by: Lunny Xiao --- templates/repo/home.tmpl | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index c523ce3556632..39e58d8e0fb6d 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -77,25 +77,23 @@ {{svg "octicon-file-moved" 15}} {{end}} {{if or .CanAddFile .CanUploadFile}} - + +
+ + + +{{template "base/footer" .}} diff --git a/templates/org/team/members.tmpl b/templates/org/team/members.tmpl index ecb7830f18b33..1a58dc5339ec8 100644 --- a/templates/org/team/members.tmpl +++ b/templates/org/team/members.tmpl @@ -13,7 +13,7 @@ {{.CsrfTokenHtml}}
- + {{if and .Invites $.IsOrganizationOwner}} +

{{$.locale.Tr "org.teams.invite_team_member.list"}}

+
+ {{range .Invites}} +
+
+ {{$.CsrfTokenHtml}} + + +
+ {{.Email}} +
+ {{end}} +
+ {{end}}
diff --git a/tests/integration/org_team_invite_test.go b/tests/integration/org_team_invite_test.go new file mode 100644 index 0000000000000..470478589aa6b --- /dev/null +++ b/tests/integration/org_team_invite_test.go @@ -0,0 +1,72 @@ +// Copyright 2022 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package integration + +import ( + "fmt" + "net/http" + "testing" + + "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/organization" + "code.gitea.io/gitea/models/unittest" + user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/test" + "code.gitea.io/gitea/tests" + + "github.com/stretchr/testify/assert" +) + +func TestOrgTeamEmailInvite(t *testing.T) { + if setting.MailService == nil { + t.Skip() + return + } + + defer tests.PrepareTestEnv(t)() + + org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3}) + team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 2}) + user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}) + + isMember, err := organization.IsTeamMember(db.DefaultContext, team.OrgID, team.ID, user.ID) + assert.NoError(t, err) + assert.False(t, isMember) + + session := loginUser(t, "user1") + + url := fmt.Sprintf("/org/%s/teams/%s", org.Name, team.Name) + csrf := GetCSRF(t, session, url) + req := NewRequestWithValues(t, "POST", url+"/action/add", map[string]string{ + "_csrf": csrf, + "uid": "1", + "uname": user.Email, + }) + resp := session.MakeRequest(t, req, http.StatusSeeOther) + req = NewRequest(t, "GET", test.RedirectURL(resp)) + session.MakeRequest(t, req, http.StatusOK) + + // get the invite token + invites, err := organization.GetInvitesByTeamID(db.DefaultContext, team.ID) + assert.NoError(t, err) + assert.Len(t, invites, 1) + + session = loginUser(t, user.Name) + + // join the team + url = fmt.Sprintf("/org/invite/%s", invites[0].Token) + csrf = GetCSRF(t, session, url) + req = NewRequestWithValues(t, "POST", url, map[string]string{ + "_csrf": csrf, + }) + resp = session.MakeRequest(t, req, http.StatusSeeOther) + req = NewRequest(t, "GET", test.RedirectURL(resp)) + session.MakeRequest(t, req, http.StatusOK) + + isMember, err = organization.IsTeamMember(db.DefaultContext, team.OrgID, team.ID, user.ID) + assert.NoError(t, err) + assert.True(t, isMember) +} diff --git a/web_src/js/features/comp/SearchUserBox.js b/web_src/js/features/comp/SearchUserBox.js index 08f97595af0c6..46ecb8ebf4a92 100644 --- a/web_src/js/features/comp/SearchUserBox.js +++ b/web_src/js/features/comp/SearchUserBox.js @@ -3,15 +3,20 @@ import {htmlEscape} from 'escape-goat'; const {appSubUrl} = window.config; +const looksLikeEmailAddressCheck = /^\S+@\S+$/; + export function initCompSearchUserBox() { const $searchUserBox = $('#search-user-box'); + const allowEmailInput = $searchUserBox.attr('data-allow-email') === 'true'; + const allowEmailDescription = $searchUserBox.attr('data-allow-email-description'); $searchUserBox.search({ minCharacters: 2, apiSettings: { url: `${appSubUrl}/user/search?q={query}`, onResponse(response) { const items = []; - const searchQueryUppercase = $searchUserBox.find('input').val().toUpperCase(); + const searchQuery = $searchUserBox.find('input').val(); + const searchQueryUppercase = searchQuery.toUpperCase(); $.each(response.data, (_i, item) => { let title = item.login; if (item.full_name && item.full_name.length > 0) { @@ -28,6 +33,14 @@ export function initCompSearchUserBox() { } }); + if (allowEmailInput && items.length === 0 && looksLikeEmailAddressCheck.test(searchQuery)) { + const resultItem = { + title: searchQuery, + description: allowEmailDescription + }; + items.push(resultItem); + } + return {results: items}; } }, diff --git a/web_src/less/_organization.less b/web_src/less/_organization.less index b80739671f28e..c52753e29b0f3 100644 --- a/web_src/less/_organization.less +++ b/web_src/less/_organization.less @@ -119,6 +119,11 @@ margin-top: -3px; } } + + .ui.avatar { + width: 100%; + height: 100%; + } } &.members { From 6b712465a815d0da51ca7d33289610eaef0887ad Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 19 Oct 2022 14:48:29 +0000 Subject: [PATCH 05/13] Revert increased width on pull pages (#21470) - Revert a behavior from #21012, which liberally added `fluid padded` to non-split style pull pages, this caused it to take up the whole screen(such in split-style pull pages) on pull pages where the diff was shown. - Resolves #21460 ### Before ![image](https://user-images.githubusercontent.com/25481501/196005545-bb8370c1-330d-4d47-be52-6d0c93e61583.png) ![image](https://user-images.githubusercontent.com/25481501/196005546-0022198e-6ef7-45d1-958c-77a042e5f80b.png) ### After ![image](https://user-images.githubusercontent.com/25481501/196005572-76a38309-9a41-412a-854f-24eae2b9ae4f.png) ![image](https://user-images.githubusercontent.com/25481501/196005551-2495b93d-ad08-4f59-abba-c327dadcc915.png) --- templates/repo/commit_page.tmpl | 2 +- templates/repo/diff/compare.tmpl | 2 +- templates/repo/pulls/files.tmpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index da37aaa9b323f..8ece768832fb7 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -1,7 +1,7 @@ {{template "base/head" .}}
{{template "repo/header" .}} -
+
{{$class := ""}} {{if .Commit.Signature}} {{$class = (printf "%s%s" $class " isSigned")}} diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index e0e6837203d1e..029e7717a44e8 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -1,7 +1,7 @@ {{template "base/head" .}}
{{template "repo/header" .}} -
+

{{if and $.PageIsComparePull $.IsSigned (not .Repository.IsArchived)}} diff --git a/templates/repo/pulls/files.tmpl b/templates/repo/pulls/files.tmpl index 7b72f7f8152af..9b24000002863 100644 --- a/templates/repo/pulls/files.tmpl +++ b/templates/repo/pulls/files.tmpl @@ -5,7 +5,7 @@
{{template "repo/header" .}} -
+