Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/actions/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ type UpdateTenantSettings struct {
Title string `json:"title"`
Invitation string `json:"invitation"`
WelcomeMessage string `json:"welcomeMessage"`
WelcomeHeader string `json:"welcomeHeader"`
Locale string `json:"locale"`
CNAME string `json:"cname" format:"lower"`
}
Expand Down Expand Up @@ -242,6 +243,10 @@ func (action *UpdateTenantSettings) Validate(ctx context.Context, user *entity.U
result.AddFieldFailure("invitation", "Invitation must have less than 60 characters.")
}

if len(action.WelcomeHeader) > 100 {
result.AddFieldFailure("welcomeHeader", "Welcome Header must have less than 100 characters.")
}

if !i18n.IsValidLocale(action.Locale) {
result.AddFieldFailure("locale", "Locale is invalid.")
}
Expand Down
1 change: 1 addition & 0 deletions app/handlers/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func UpdateSettings() web.HandlerFunc {
Title: action.Title,
Invitation: action.Invitation,
WelcomeMessage: action.WelcomeMessage,
WelcomeHeader: action.WelcomeHeader,
CNAME: action.CNAME,
Locale: action.Locale,
},
Expand Down
3 changes: 2 additions & 1 deletion app/handlers/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ func Index() web.HandlerFunc {
return c.Page(http.StatusOK, web.Props{
Page: "Home/Home.page",
Description: description,
Data: data,
// Header: c.Tenant().WelcomeHeader,
Data: data,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions app/models/cmd/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type UpdateTenantSettings struct {
Title string
Invitation string
WelcomeMessage string
WelcomeHeader string
CNAME string
Locale string
}
Expand Down
1 change: 1 addition & 0 deletions app/models/entity/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Tenant struct {
Subdomain string `json:"subdomain"`
Invitation string `json:"invitation"`
WelcomeMessage string `json:"welcomeMessage"`
WelcomeHeader string `json:"welcomeHeader"`
CNAME string `json:"cname"`
Status enum.TenantStatus `json:"status"`
Locale string `json:"locale"`
Expand Down
6 changes: 4 additions & 2 deletions app/pkg/web/react_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func TestReactRenderer_RenderEmptyHomeHTML(t *testing.T) {
},
})
Expect(html).ContainsSubstring(`<div class="c-dev-banner">DEV</div>`)
Expect(html).ContainsSubstring(`<button type="submit" class="c-button c-button--default c-button--secondary c-input">Enter your suggestion here...</button>`)
Expect(html).ContainsSubstring(`<button class="p-home__add-idea-btn">`)
Expect(html).ContainsSubstring(`Enter your suggestion here...`)
Expect(html).ContainsSubstring(`What can we do better? This is the place for you to vote, discuss and share ideas.`)
Expect(html).ContainsSubstring(`No posts have been created yet.`)
Expect(html).ContainsSubstring(`Powered by Fider`)
Expand Down Expand Up @@ -81,7 +82,8 @@ func TestReactRenderer_RenderEmptyHomeHTML_Portuguese(t *testing.T) {
},
})
Expect(html).ContainsSubstring(`<div class="c-dev-banner">DEV</div>`)
Expect(html).ContainsSubstring(`<button type="submit" class="c-button c-button--default c-button--secondary c-input">Insira sua sugestão aqui...</button`)
Expect(html).ContainsSubstring(`<button class="p-home__add-idea-btn">`)
Expect(html).ContainsSubstring(`Insira sua sugestão aqui...`)
Expect(html).ContainsSubstring(`O que podemos fazer melhor? Este é o lugar para você votar, discutir e compartilhar ideias.`)
Expect(html).ContainsSubstring(`Nenhuma postagem foi criada ainda.`)
Expect(html).ContainsSubstring(`Powered by Fider`)
Expand Down
2 changes: 1 addition & 1 deletion app/pkg/web/testdata/home_ssr.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h2 class="text-display2">Please enable JavaScript</h2>

<script id="server-data" type="application/json">

{"contextID":"CONTEXT_ID","description":"My Page Description","page":"Test.page","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"locale":"en","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false},"title":"My Page Title · "}
{"contextID":"CONTEXT_ID","description":"My Page Description","page":"Test.page","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"","subdomain":"","invitation":"","welcomeMessage":"","welcomeHeader":"","cname":"","status":0,"locale":"en","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false},"title":"My Page Title · "}

</script>

Expand Down
2 changes: 1 addition & 1 deletion app/pkg/web/testdata/tenant.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h2 class="text-display2">Please enable JavaScript</h2>

<script id="server-data" type="application/json">

{"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"locale":"","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false},"title":"Game of Thrones"}
{"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","welcomeHeader":"","cname":"","status":0,"locale":"","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false},"title":"Game of Thrones"}

</script>

Expand Down
2 changes: 1 addition & 1 deletion app/services/sqlstore/postgres/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func getCommentsByPost(ctx context.Context, q *query.GetCommentsByPost) error {
WHERE p.id = $1
AND p.tenant_id = $2
AND c.deleted_at IS NULL
ORDER BY c.created_at ASC`, q.Post.ID, tenant.ID, userId)
ORDER BY c.created_at DESC`, q.Post.ID, tenant.ID, userId)
if err != nil {
return errors.Wrap(err, "failed get comments of post with id '%d'", q.Post.ID)
}
Expand Down
8 changes: 4 additions & 4 deletions app/services/sqlstore/postgres/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ func TestPostStorage_AddAndReturnComments(t *testing.T) {
Expect(err).IsNil()
Expect(commentsByPost.Result).HasLen(2)

Expect(commentsByPost.Result[0].Content).Equals("Comment #1")
Expect(commentsByPost.Result[0].User.Name).Equals("Jon Snow")
Expect(commentsByPost.Result[1].Content).Equals("Comment #2")
Expect(commentsByPost.Result[1].User.Name).Equals("Arya Stark")
Expect(commentsByPost.Result[0].Content).Equals("Comment #2")
Expect(commentsByPost.Result[0].User.Name).Equals("Arya Stark")
Expect(commentsByPost.Result[1].Content).Equals("Comment #1")
Expect(commentsByPost.Result[1].User.Name).Equals("Jon Snow")
}

func TestPostStorage_AddGetUpdateComment(t *testing.T) {
Expand Down
11 changes: 7 additions & 4 deletions app/services/sqlstore/postgres/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type dbTenant struct {
CNAME string `db:"cname"`
Invitation string `db:"invitation"`
WelcomeMessage string `db:"welcome_message"`
WelcomeHeader string `db:"welcome_header"`
Status int `db:"status"`
Locale string `db:"locale"`
IsPrivate bool `db:"is_private"`
Expand All @@ -46,6 +47,7 @@ func (t *dbTenant) toModel() *entity.Tenant {
CNAME: t.CNAME,
Invitation: t.Invitation,
WelcomeMessage: t.WelcomeMessage,
WelcomeHeader: t.WelcomeHeader,
Status: enum.TenantStatus(t.Status),
Locale: t.Locale,
IsPrivate: t.IsPrivate,
Expand Down Expand Up @@ -153,8 +155,8 @@ func updateTenantSettings(ctx context.Context, c *cmd.UpdateTenantSettings) erro
c.Logo.BlobKey = ""
}

query := "UPDATE tenants SET name = $1, invitation = $2, welcome_message = $3, cname = $4, logo_bkey = $5, locale = $6 WHERE id = $7"
_, err := trx.Execute(query, c.Title, c.Invitation, c.WelcomeMessage, c.CNAME, c.Logo.BlobKey, c.Locale, tenant.ID)
query := "UPDATE tenants SET name = $1, invitation = $2, welcome_message = $3, welcome_header = $4, cname = $5, logo_bkey = $6, locale = $7 WHERE id = $8"
_, err := trx.Execute(query, c.Title, c.Invitation, c.WelcomeMessage, c.WelcomeHeader, c.CNAME, c.Logo.BlobKey, c.Locale, tenant.ID)
if err != nil {
return errors.Wrap(err, "failed update tenant settings")
}
Expand All @@ -163,6 +165,7 @@ func updateTenantSettings(ctx context.Context, c *cmd.UpdateTenantSettings) erro
tenant.Invitation = c.Invitation
tenant.CNAME = c.CNAME
tenant.WelcomeMessage = c.WelcomeMessage
tenant.WelcomeHeader = c.WelcomeHeader

return nil
})
Expand Down Expand Up @@ -290,7 +293,7 @@ func getFirstTenant(ctx context.Context, q *query.GetFirstTenant) error {
tenant := dbTenant{}

err := trx.Get(&tenant, `
SELECT id, name, subdomain, cname, invitation, locale, welcome_message, status, is_private, logo_bkey, custom_css, allowed_schemes, is_email_auth_allowed, is_feed_enabled, prevent_indexing
SELECT id, name, subdomain, cname, invitation, locale, welcome_message, welcome_header, status, is_private, logo_bkey, custom_css, allowed_schemes, is_email_auth_allowed, is_feed_enabled, prevent_indexing
FROM tenants
ORDER BY id LIMIT 1
`)
Expand All @@ -309,7 +312,7 @@ func getTenantByDomain(ctx context.Context, q *query.GetTenantByDomain) error {
tenant := dbTenant{}

err := trx.Get(&tenant, `
SELECT id, name, subdomain, cname, invitation, locale, welcome_message, status, is_private, logo_bkey, custom_css, allowed_schemes, is_email_auth_allowed, is_feed_enabled, prevent_indexing
SELECT id, name, subdomain, cname, invitation, locale, welcome_message, welcome_header, status, is_private, logo_bkey, custom_css, allowed_schemes, is_email_auth_allowed, is_feed_enabled, prevent_indexing
FROM tenants t
WHERE subdomain = $1 OR subdomain = $2 OR cname = $3
ORDER BY cname DESC
Expand Down
4 changes: 2 additions & 2 deletions e2e/step_definitions/home.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Then("I should be on the home page", async function (this: FiderWorld) {
})

Then("I click on the first post", async function (this: FiderWorld) {
await this.page.click(".c-posts-container__post:first-child a")
await this.page.click(".c-posts-container__post-link:first-of-type")
})

Then("I search for {string}", async function (this: FiderWorld, searchTerm: string) {
Expand All @@ -32,7 +32,7 @@ Given("I type {string} as the description", async function (this: FiderWorld, de
})

Given("I click enter your suggestion", async function () {
await this.page.click(".p-home__welcome-col .c-button--default")
await this.page.click(".p-home__add-idea-btn")
})

Given("I type my email address", async function (this: FiderWorld) {
Expand Down
3 changes: 2 additions & 1 deletion e2e/step_definitions/show_post.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ Then("I should see {string} as the post title", async function (this: FiderWorld
})

Then("I should see {int} vote\\(s)", async function (this: FiderWorld, voteCount: number) {
await expect(this.page.getByText(`${voteCount}${voteCount === 1 ? "Vote" : "Votes"}`, { exact: true })).toBeVisible()
// Look for the vote count number with the specific styling
await expect(this.page.locator(".text-2xl").filter({ hasText: voteCount.toString() })).toBeVisible()
})
2 changes: 1 addition & 1 deletion e2e/step_definitions/user.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Given("I sign in as {string}", async function (this: FiderWorld, userName: strin
}

const userEmail = `${userName}-${this.tenantName}@fider.io`
await this.page.click(".c-menu .uppercase.text-sm")
await this.page.getByRole("button", { name: "Sign in" }).click()
await this.page.fill(".c-signin-control #input-email", userEmail)
await this.page.click(".c-signin-control .c-button--primary")

Expand Down
12 changes: 9 additions & 3 deletions locale/ar/client.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"action.edit": "تعديل",
"action.markallasread": "تمييز الكل كمقروءة",
"action.ok": "حسناً",
"action.postcomment": "",
"action.postsfeed": "تغذية المنشورات",
"action.respond": "رد",
"action.save": "احفظ",
Expand Down Expand Up @@ -91,7 +92,9 @@
"label.unfollow": "إلغاء المتابعة",
"label.unread": "غير مقروء",
"label.unsubscribe": "إلغاء الاشتراك",
"label.vote": "",
"label.voters": "المصوتون",
"label.votes": "",
"labels.notagsavailable": "لا توجد وسوم متاحة",
"labels.notagsselected": "لم يتم تحديد أي علامات",
"legal.agreement": "لقد قرأت <0/> و<1/> وأوافق على ذلك.",
Expand Down Expand Up @@ -196,16 +199,21 @@
"showpost.mostwanted.votes": "{count, plural, one {# صوت} other {# أصوات}}",
"showpost.notificationspanel.message.subscribed": "أنت تتلقى إشعارات عن النشاط على هذا المنشور.",
"showpost.notificationspanel.message.unsubscribed": "لن تتلقى أي إشعار بشأن هذا المنشور.",
"showpost.postedby": "",
"showpost.postsearch.numofvotes": "{0} أصوات",
"showpost.postsearch.query.placeholder": "البحث في المنشور الأصلي...",
"showpost.response.date": "تغيرت الحالة إلى {status} على {statusDate}",
"showpost.responseform.message.mergedvotes": "سيتم دمج التصويتات من هذا المنشور في المنشور الأصلية.",
"showpost.responseform.text.placeholder": "ما الذي يجري مع هذا المنشور؟ أخبر المستخدمين ما هي خططك...",
"showpost.stayupdated.description": "",
"showpost.stayupdated.title": "",
"showpost.votespanel.more": "+{extraVotesCount} أكثر",
"showpost.votespanel.seedetails": "عرض التفاصيل",
"signin.code.edit": "يحرر",
"signin.code.expired": "انتهت صلاحية هذا الرمز أو تم استخدامه مسبقًا. يُرجى طلب رمز جديد.",
"signin.code.getnew": "احصل على رمز جديد",
"signin.code.instruction": "الرجاء كتابة الرمز الذي أرسلناه للتو إلى <0>{email}</0>",
"signin.code.invalid": "الرمز الذي أدخلته غير صحيح. يُرجى المحاولة مرة أخرى.",
"signin.code.placeholder": "اكتب الكود هنا",
"signin.code.sent": "لقد تم إرسال رمز جديد إلى بريدك الإلكتروني.",
"signin.code.submit": "يُقدِّم",
Expand All @@ -222,7 +230,5 @@
"signin.name.placeholder": "اسمك",
"validation.custom.maxattachments": "يُسمح بحد أقصى {number} من المرفقات.",
"validation.custom.maximagesize": "يجب أن يكون حجم الصورة أصغر من {kilobytes}KB.",
"{count, plural, one {# tag} other {# tags}}": "{count, plural, zero {}one {# وسم} two {# وسوم} few {# وسوم} many {# وسوم} other {# وسوم}}",
"signin.code.expired": "انتهت صلاحية هذا الرمز أو تم استخدامه مسبقًا. يُرجى طلب رمز جديد.",
"signin.code.invalid": "الرمز الذي أدخلته غير صحيح. يُرجى المحاولة مرة أخرى."
"{count, plural, one {# tag} other {# tags}}": "{count, plural, zero {}one {# وسم} two {# وسوم} few {# وسوم} many {# وسوم} other {# وسوم}}"
}
12 changes: 9 additions & 3 deletions locale/de/client.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"action.edit": "Bearbeiten",
"action.markallasread": "Alle als gelesen markieren",
"action.ok": "OK",
"action.postcomment": "",
"action.postsfeed": "Beiträge-Feed",
"action.respond": "Antworten",
"action.save": "Sichern",
Expand Down Expand Up @@ -91,7 +92,9 @@
"label.unfollow": "Entfolgen",
"label.unread": "Ungelesen",
"label.unsubscribe": "Abbestellen",
"label.vote": "",
"label.voters": "Wähler",
"label.votes": "",
"labels.notagsavailable": "Keine Tags verfügbar",
"labels.notagsselected": "Keine Tags ausgewählt",
"legal.agreement": "Ich habe die <0/> und <1/> gelesen und akzeptiere sie.",
Expand Down Expand Up @@ -196,16 +199,21 @@
"showpost.mostwanted.votes": "{count, plural, one {# Stimme} other {# Stimmen}}",
"showpost.notificationspanel.message.subscribed": "Du erhältst Benachrichtigungen über Aktivitäten auf diesem Beitrag.",
"showpost.notificationspanel.message.unsubscribed": "Du erhältst keine Benachrichtigungen über diesen Beitrag.",
"showpost.postedby": "",
"showpost.postsearch.numofvotes": "{0} Stimmen",
"showpost.postsearch.query.placeholder": "Originalbeitrag suchen...",
"showpost.response.date": "Status geändert zu {status} am {statusDate}",
"showpost.responseform.message.mergedvotes": "Stimmen aus diesem Beitrag werden mit den Stimmen vom ursprünglichen Beitrag zusammengeführt.",
"showpost.responseform.text.placeholder": "Was passiert in diesem Beitrag? Lass deine Benutzer wissen, was deine Pläne sind...",
"showpost.stayupdated.description": "",
"showpost.stayupdated.title": "",
"showpost.votespanel.more": "+{extraVotesCount} mehr",
"showpost.votespanel.seedetails": "Details anschauen",
"signin.code.edit": "Bearbeiten",
"signin.code.expired": "Dieser Code ist abgelaufen oder wurde bereits verwendet. Bitte fordern Sie einen neuen an.",
"signin.code.getnew": "Neuen Code anfordern",
"signin.code.instruction": "Bitte geben Sie den soeben gesendeten Code an <0>{email}</0> ein.",
"signin.code.invalid": "Der eingegebene Code ist ungültig. Bitte versuchen Sie es erneut.",
"signin.code.placeholder": "Geben Sie hier den Code ein.",
"signin.code.sent": "Ein neuer Code wurde an Ihre E-Mail-Adresse gesendet.",
"signin.code.submit": "Einreichen",
Expand All @@ -222,7 +230,5 @@
"signin.name.placeholder": "Ihr Name",
"validation.custom.maxattachments": "Es sind maximal {number} Anhänge zulässig.",
"validation.custom.maximagesize": "Die Bildgröße muss kleiner als {kilobytes}KB sein.",
"{count, plural, one {# tag} other {# tags}}": "{count, plural, one {# Tag} other {# Tags}}",
"signin.code.expired": "Dieser Code ist abgelaufen oder wurde bereits verwendet. Bitte fordern Sie einen neuen an.",
"signin.code.invalid": "Der eingegebene Code ist ungültig. Bitte versuchen Sie es erneut."
"{count, plural, one {# tag} other {# tags}}": "{count, plural, one {# Tag} other {# Tags}}"
}
Loading
Loading