fix AdminInvitesCount pluralization
This commit is contained in:
parent
6126e46a2a
commit
e6b65e3d5d
1
go.mod
1
go.mod
|
@ -5,6 +5,7 @@ go 1.16
|
|||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/PuerkitoBio/goquery v1.5.0
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/friendsofgo/errors v0.9.2
|
||||
github.com/go-kit/kit v0.10.0
|
||||
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
||||
|
|
1
go.sum
1
go.sum
|
@ -84,6 +84,7 @@ github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUn
|
|||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
|
|
|
@ -7,7 +7,9 @@ import (
|
|||
"math/rand"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"go.mindeco.de/http/render"
|
||||
|
@ -75,12 +77,10 @@ func newSession(t *testing.T) *testSession {
|
|||
}
|
||||
return msgID + "Plural"
|
||||
}
|
||||
testFuncs["current_page_is"] = func(routeName string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
testFuncs["current_page_is"] = func(routeName string) bool { return true }
|
||||
testFuncs["is_logged_in"] = func() *roomdb.User { return ts.User }
|
||||
testFuncs["urlToNotice"] = func(name string) string { return "" }
|
||||
testFuncs["relative_time"] = func(when time.Time) string { return humanize.Time(when) }
|
||||
|
||||
r, err := render.New(web.Templates,
|
||||
render.SetLogger(log),
|
||||
|
|
|
@ -9,11 +9,60 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/web"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/web/router"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/web/webassert"
|
||||
)
|
||||
|
||||
func TestInvitesOverview(t *testing.T) {
|
||||
ts := newSession(t)
|
||||
a := assert.New(t)
|
||||
|
||||
testUser := roomdb.User{ID: 23}
|
||||
|
||||
lst := []roomdb.Invite{
|
||||
{ID: 1, CreatedBy: testUser, AliasSuggestion: "foo"},
|
||||
{ID: 2, CreatedBy: testUser, AliasSuggestion: "bar"},
|
||||
{ID: 3, CreatedBy: testUser, AliasSuggestion: "baz"},
|
||||
}
|
||||
ts.InvitesDB.ListReturns(lst, nil)
|
||||
|
||||
html, resp := ts.Client.GetHTML("/invites")
|
||||
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
|
||||
|
||||
webassert.Localized(t, html, []webassert.LocalizedElement{
|
||||
{"#welcome", "AdminInvitesWelcome"},
|
||||
{"title", "AdminInvitesTitle"},
|
||||
{"#invite-list-count", "AdminInvitesCountPlural"},
|
||||
})
|
||||
|
||||
trSelector := "#the-table-rows tr"
|
||||
a.EqualValues(3, html.Find(trSelector).Length(), "wrong number of entries on the table (plural)")
|
||||
|
||||
lst = []roomdb.Invite{
|
||||
{ID: 666, CreatedBy: testUser, AliasSuggestion: "single entry"},
|
||||
}
|
||||
ts.InvitesDB.ListReturns(lst, nil)
|
||||
|
||||
html, resp = ts.Client.GetHTML("/invites")
|
||||
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
|
||||
|
||||
webassert.Localized(t, html, []webassert.LocalizedElement{
|
||||
{"#welcome", "AdminInvitesWelcome"},
|
||||
{"title", "AdminInvitesTitle"},
|
||||
{"#invite-list-count", "AdminInvitesCountSingular"},
|
||||
})
|
||||
|
||||
elems := html.Find(trSelector)
|
||||
a.EqualValues(1, elems.Length(), "wrong number of entries on the table (signular)")
|
||||
|
||||
// check for link to remove confirm link
|
||||
link, yes := elems.ContentsFiltered("a").Attr("href")
|
||||
a.True(yes, "a-tag has href attribute")
|
||||
a.Equal("/admin/invites/revoke/confirm?id=666", link)
|
||||
}
|
||||
|
||||
func TestInvitesCreateForm(t *testing.T) {
|
||||
ts := newSession(t)
|
||||
a := assert.New(t)
|
||||
|
|
|
@ -32,8 +32,7 @@ AdminAllowListRemoveConfirmTitle = "Confirm member removal"
|
|||
AdminInvitesTitle = "Invites"
|
||||
AdminInvitesWelcome = "Create invite tokens for people who are not yet members of this room. At the same time as you create an invite, you can also (optionally) attach an alias to it so that the person who receives the invite can automatically use that claim that alias for themselves."
|
||||
AdminInvitesAliasSuggestion = "(Optional) Alias suggestion"
|
||||
AdminInvitesCount = "{{.Count}} invites still unclaimed"
|
||||
AdminInvitesIDColumn = "ID"
|
||||
AdminInvitesCreatedAtColumn = "Created at"
|
||||
AdminInvitesCreatorColumn = "Created by"
|
||||
AdminInvitesAliasColumn = "Alias suggestion"
|
||||
AdminInvitesSummaryFrom = "From"
|
||||
|
@ -42,6 +41,7 @@ AdminInviteRevoke = "Revoke"
|
|||
AdminInviteRevokeConfirmTitle = "Confirm invite revocation"
|
||||
AdminInviteRevokeConfirmWelcome = "Are you sure you want to remove this invite? If you already sent it out, they will not be able to use it."
|
||||
|
||||
|
||||
# TODO: add placeholder support to the template helpers (https://github.com/ssb-ngi-pointer/go-ssb-room/issues/60)
|
||||
AdminInviteCreatedBy = "Created by:"
|
||||
AdminInviteSuggestedAliasIs = "The suggested alias is:"
|
||||
|
@ -89,3 +89,8 @@ other = "There are {{.Count}} items on the List"
|
|||
description = "The number of people in a room"
|
||||
one = "There is one person in the Room"
|
||||
other = "There are {{.Count}} people in the Room"
|
||||
|
||||
[AdminInvitesCount]
|
||||
description = "the number of invites that are not yet claimed"
|
||||
one = "1 invite still unclaimed"
|
||||
other = "{{.Count}} invites still unclaimed"
|
|
@ -10,7 +10,10 @@
|
|||
<thead class="block sm:table-header-group">
|
||||
<tr class="sm:h-12 sm:table-row flex flex-col items-stretch">
|
||||
<td class="sm:w-3 sm:table-cell block" colspan="2">
|
||||
<div class="inline ml-0 rounded-full px-3 py-1 tracking-tight font-black text-white bg-gradient-to-r from-pink-400 to-red-400">{{i18npl "AdminInvitesCount" .Count}}</div>
|
||||
<div
|
||||
id="invite-list-count"
|
||||
class="inline ml-0 rounded-full px-3 py-1 tracking-tight font-black text-white bg-gradient-to-r from-pink-400 to-red-400"
|
||||
>{{i18npl "AdminInvitesCount" .Count}}</div>
|
||||
</td>
|
||||
<td class="sm:w-1/2 sm:pl-2 pr-0 sm:table-cell block sm:my-0 my-4" colspan="2">
|
||||
<form
|
||||
|
@ -36,16 +39,16 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="hidden sm:table-row h-8 uppercase text-sm text-gray-400">
|
||||
<th class="w-3 text-center pl-3 pr-6">{{i18n "AdminInvitesCreatedAtColumn"}}</th>
|
||||
<th class="w-1/2 text-left px-6">{{i18n "AdminInvitesCreatorColumn"}}</th>
|
||||
<th class="w-1/2 text-left px-6">{{i18n "AdminInvitesAliasColumn"}}</th>
|
||||
<th class="w-10 text-center pl-3 pr-6">{{i18n "AdminInvitesCreatedAtColumn"}}</th>
|
||||
<th class="w-1/3 text-left px-6">{{i18n "AdminInvitesCreatorColumn"}}</th>
|
||||
<th class="w-1/3 text-left px-6">{{i18n "AdminInvitesAliasColumn"}}</th>
|
||||
<th class="w-0"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y">
|
||||
<tbody id="the-table-rows" class="divide-y">
|
||||
{{range .Entries}}
|
||||
<tr class="h-12 hidden sm:table-row">
|
||||
<td class="pl-3 pr-6 text-gray-400 text-center">{{.CreatedAt.Format "2006-01-02 15:04"}}</td>
|
||||
<td class="pl-3 pr-6 text-gray-400 text-center">{{human_time .CreatedAt}}</td>
|
||||
<td class="px-6">{{.CreatedBy.Name}}</td>
|
||||
<td class="px-6">{{if ne .AliasSuggestion ""}}{{.AliasSuggestion}}{{end}}</td>
|
||||
<td class="pl-6 pr-3">
|
||||
|
|
14
web/utils.go
14
web/utils.go
|
@ -11,20 +11,24 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
|
||||
"github.com/gorilla/securecookie"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/go-kit/kit/log/level"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/internal/repo"
|
||||
"github.com/gorilla/securecookie"
|
||||
"go.mindeco.de/logging"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/internal/repo"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
)
|
||||
|
||||
// TemplateFuncs returns a map of template functions
|
||||
func TemplateFuncs(m *mux.Router) template.FuncMap {
|
||||
return template.FuncMap{
|
||||
"human_time": func(when time.Time) string {
|
||||
return humanize.Time(when)
|
||||
},
|
||||
"urlTo": NewURLTo(m),
|
||||
"inc": func(i int) int { return i + 1 },
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue