From d67de7696d21d0bd6c2ef93d9b06ebcfc8190ff7 Mon Sep 17 00:00:00 2001 From: Louis Garman Date: Mon, 24 Jul 2023 14:11:37 +0100 Subject: [PATCH 1/3] fix(ui): improve dropdown box UX --- internal/auth/user.go | 8 ++-- internal/http/html/static/css/output.css | 8 ++++ .../templates/partials/search_dropdown.tmpl | 21 +++++----- internal/integration/team_ui_test.go | 39 ++++++++++++++----- 4 files changed, 52 insertions(+), 24 deletions(-) diff --git a/internal/auth/user.go b/internal/auth/user.go index bd1596a15..988478107 100644 --- a/internal/auth/user.go +++ b/internal/auth/user.go @@ -111,10 +111,10 @@ func (u *User) IsSiteAdmin() bool { func (u *User) CanAccessSite(action rbac.Action) bool { switch action { - case rbac.CreateUserAction: - // A user can create a user account only if they are an owner of at least - // one organization. This permits an owner to create a user before adding - // them to a team. + case rbac.CreateUserAction, rbac.ListUsersAction: + // A user can perform these actions only if they are an owner of at + // least one organization. This permits an owner to search users or create + // a user before adding them to a team. for _, team := range u.Teams { if team.IsOwners() { return true diff --git a/internal/http/html/static/css/output.css b/internal/http/html/static/css/output.css index 054941526..7691896aa 100644 --- a/internal/http/html/static/css/output.css +++ b/internal/http/html/static/css/output.css @@ -1127,6 +1127,10 @@ select { padding-left: 2.5rem; } +.pb-4 { + padding-bottom: 1rem; +} + .text-left { text-align: left; } @@ -1171,6 +1175,10 @@ select { font-weight: 600; } +.italic { + font-style: italic; +} + .leading-snug { line-height: 1.375; } diff --git a/internal/http/html/static/templates/partials/search_dropdown.tmpl b/internal/http/html/static/templates/partials/search_dropdown.tmpl index 924749919..6b1560a8f 100644 --- a/internal/http/html/static/templates/partials/search_dropdown.tmpl +++ b/internal/http/html/static/templates/partials/search_dropdown.tmpl @@ -26,21 +26,22 @@ >
-
- + + already added + + - -
+
{{ end }} diff --git a/internal/integration/team_ui_test.go b/internal/integration/team_ui_test.go index 0d1cea329..18d129898 100644 --- a/internal/integration/team_ui_test.go +++ b/internal/integration/team_ui_test.go @@ -1,11 +1,11 @@ package integration import ( - "fmt" "testing" "github.com/chromedp/cdproto/input" "github.com/chromedp/chromedp" + "github.com/stretchr/testify/require" ) // TestIntegration_TeamUI demonstrates managing teams and team members via the @@ -14,7 +14,10 @@ func TestIntegration_TeamUI(t *testing.T) { integrationTest(t) daemon, org, ctx := setup(t, nil) - newbie := daemon.createUser(t) + _, err := daemon.CreateUser(ctx, "bob") + require.NoError(t, err) + _, err = daemon.CreateUser(ctx, "alice") + require.NoError(t, err) browser.Run(t, ctx, chromedp.Tasks{ chromedp.Tasks{ @@ -27,20 +30,36 @@ func TestIntegration_TeamUI(t *testing.T) { // go to owners team page chromedp.Click(`//div[@class='content-list']//a[text()='owners']`), screenshot(t, "owners_team_page"), - // select newbie as new team member + // set focus to search box chromedp.Focus(`//input[@x-ref='input-search']`), - input.InsertText(newbie.Username), + input.InsertText(""), + // should trigger dropdown box showing both alice and bob + chromedp.WaitVisible(`//div[@x-ref='searchdrop']//button[text()='bob']`), + chromedp.WaitVisible(`//div[@x-ref='searchdrop']//button[text()='alice']`), + // select bob as new team member + input.InsertText("bob"), screenshot(t), // submit chromedp.Submit(`//input[@x-ref='input-search']`), screenshot(t), - // confirm newbie added - matchText(t, "//div[@role='alert']", "added team member: "+newbie.Username), - // remove newbie from team - chromedp.Click(fmt.Sprintf(`//div[@id='item-user-%s']//button[@id='remove-member-button']`, newbie.Username)), + // confirm bob added + matchText(t, "//div[@role='alert']", "added team member: bob"), + // remove bob from team + chromedp.Click(`//div[@id='item-user-bob']//button[@id='remove-member-button']`), screenshot(t), - // confirm newbie removed - matchText(t, "//div[@role='alert']", "removed team member: "+newbie.Username), + // confirm bob removed + matchText(t, "//div[@role='alert']", "removed team member: bob"), + // now demonstrate specifying a username that doesn't belong to an + // existing user. The dropdown box should prompt to create the user + // and add them to the team. + chromedp.Focus(`//input[@x-ref='input-search']`), + input.InsertText("sarah"), + matchRegex(t, `//div[@x-ref='searchdrop']//button`, `Create:.*sarah`), + // submit + chromedp.Submit(`//input[@x-ref='input-search']`), + screenshot(t), + // confirm sarah added + matchText(t, "//div[@role='alert']", "added team member: sarah"), }, }) } From 0506694f862475200f23b137ba39b6af2b755fa0 Mon Sep 17 00:00:00 2001 From: Louis Garman Date: Mon, 24 Jul 2023 14:18:33 +0100 Subject: [PATCH 2/3] fix(ui): new team form missing borders --- internal/http/html/static/css/output.css | 12 ------------ .../http/html/static/templates/content/team_new.tmpl | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/internal/http/html/static/css/output.css b/internal/http/html/static/css/output.css index 7691896aa..170930e25 100644 --- a/internal/http/html/static/css/output.css +++ b/internal/http/html/static/css/output.css @@ -729,14 +729,6 @@ select { position: relative; } -.sticky { - position: sticky; -} - -.bottom-0 { - bottom: 0px; -} - .m-0 { margin: 0px; } @@ -1127,10 +1119,6 @@ select { padding-left: 2.5rem; } -.pb-4 { - padding-bottom: 1rem; -} - .text-left { text-align: left; } diff --git a/internal/http/html/static/templates/content/team_new.tmpl b/internal/http/html/static/templates/content/team_new.tmpl index 9410d3066..5b748c1f0 100644 --- a/internal/http/html/static/templates/content/team_new.tmpl +++ b/internal/http/html/static/templates/content/team_new.tmpl @@ -5,10 +5,10 @@ {{ end }} {{ define "content" }} -
+
- +
From 3e9321be6cb85e29dd0bf0b121d2669ba1f5e3c1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:12:11 +0100 Subject: [PATCH 3/3] chore(master): release 0.1.1 (#530) :robot: I have created a release *beep* *boop* --- ## [0.1.1](https://github.com/leg100/otf/compare/v0.1.0...v0.1.1) (2023-07-24) ### Bug Fixes * **ui:** improve dropdown box UX ([d67de76](https://github.com/leg100/otf/commit/d67de7696d21d0bd6c2ef93d9b06ebcfc8190ff7)) * **ui:** new team form missing borders ([0506694](https://github.com/leg100/otf/commit/0506694f862475200f23b137ba39b6af2b755fa0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 466df71c8..a915e8c55 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.1.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index af7c09c23..97974ce7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [0.1.1](https://github.com/leg100/otf/compare/v0.1.0...v0.1.1) (2023-07-24) + + +### Bug Fixes + +* **ui:** improve dropdown box UX ([d67de76](https://github.com/leg100/otf/commit/d67de7696d21d0bd6c2ef93d9b06ebcfc8190ff7)) +* **ui:** new team form missing borders ([0506694](https://github.com/leg100/otf/commit/0506694f862475200f23b137ba39b6af2b755fa0)) + ## [0.1.0](https://github.com/leg100/otf/compare/v0.0.53...v0.1.0) (2023-07-24)