Open platform to collect and prioritize feedback
Edit the welcome header
Matt Robertsd3f4b344a3bf
diff --git a/app/actions/tenant.go b/app/actions/tenant.goindex 9ecb47c03..c702f1a72 100644--- a/app/actions/tenant.go+++ b/app/actions/tenant.go@@ -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"`}@@ -242,6 +243,10 @@ func (action *UpdateTenantSettings) Validate(ctx context.Context, user *entity.Uresult.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.")}diff --git a/app/handlers/admin.go b/app/handlers/admin.goindex 17a4561b7..ec48fe800 100644--- a/app/handlers/admin.go+++ b/app/handlers/admin.go@@ -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,},diff --git a/app/handlers/post.go b/app/handlers/post.goindex ced787e70..0cb663431 100644--- a/app/handlers/post.go+++ b/app/handlers/post.go@@ -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,})}}diff --git a/app/models/cmd/tenant.go b/app/models/cmd/tenant.goindex 62b0006fc..a4dcbc9a9 100644--- a/app/models/cmd/tenant.go+++ b/app/models/cmd/tenant.go@@ -30,6 +30,7 @@ type UpdateTenantSettings struct {Title stringInvitation stringWelcomeMessage string+ WelcomeHeader stringCNAME stringLocale string}diff --git a/app/models/entity/tenant.go b/app/models/entity/tenant.goindex 98c92e2a6..69165efc3 100644--- a/app/models/entity/tenant.go+++ b/app/models/entity/tenant.go@@ -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"`diff --git a/app/services/sqlstore/postgres/tenant.go b/app/services/sqlstore/postgres/tenant.goindex 5473ad2c4..2c91c0817 100644--- a/app/services/sqlstore/postgres/tenant.go+++ b/app/services/sqlstore/postgres/tenant.go@@ -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"`@@ -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,@@ -153,8 +155,8 @@ func updateTenantSettings(ctx context.Context, c *cmd.UpdateTenantSettings) erroc.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")}@@ -163,6 +165,7 @@ func updateTenantSettings(ctx context.Context, c *cmd.UpdateTenantSettings) errotenant.Invitation = c.Invitationtenant.CNAME = c.CNAMEtenant.WelcomeMessage = c.WelcomeMessage+ tenant.WelcomeHeader = c.WelcomeHeaderreturn nil})@@ -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_indexingFROM tenantsORDER BY id LIMIT 1`)@@ -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_indexingFROM tenants tWHERE subdomain = $1 OR subdomain = $2 OR cname = $3ORDER BY cname DESCdiff --git a/migrations/202512071400_add_welcome_header.sql b/migrations/202512071400_add_welcome_header.sqlnew file mode 100644index 000000000..23bce1266--- /dev/null+++ b/migrations/202512071400_add_welcome_header.sql@@ -0,0 +1,2 @@+-- Add welcome_header column to tenants table+ALTER TABLE tenants ADD COLUMN welcome_header TEXT NULL DEFAULT '';diff --git a/public/models/identity.ts b/public/models/identity.tsindex 4e724f9e2..33728d220 100644--- a/public/models/identity.ts+++ b/public/models/identity.ts@@ -6,6 +6,7 @@ export interface Tenant {locale: stringinvitation: stringwelcomeMessage: string+ welcomeHeader: stringstatus: TenantStatusisPrivate: booleanlogoBlobKey: stringdiff --git a/public/pages/Administration/pages/GeneralSettings.page.tsx b/public/pages/Administration/pages/GeneralSettings.page.tsxindex a08a2ed8c..1a44518fa 100644--- a/public/pages/Administration/pages/GeneralSettings.page.tsx+++ b/public/pages/Administration/pages/GeneralSettings.page.tsx@@ -11,6 +11,7 @@ const GeneralSettingsPage = () => {const fider = useFider()const [title, setTitle] = useState<string>(fider.session.tenant.name)const [welcomeMessage, setWelcomeMessage] = useState<string>(fider.session.tenant.welcomeMessage)+ const [welcomeHeader, setWelcomeHeader] = useState<string>(fider.session.tenant.welcomeHeader)const [invitation, setInvitation] = useState<string>(fider.session.tenant.invitation)const [logo, setLogo] = useState<ImageUpload | undefined>(undefined)const [cname, setCNAME] = useState<string>(fider.session.tenant.cname)@@ -18,7 +19,7 @@ const GeneralSettingsPage = () => {const [error, setError] = useState<Failure | undefined>(undefined)const handleSave = async (e: ButtonClickEvent) => {- const result = await actions.updateTenantSettings({ title, cname, welcomeMessage, invitation, logo, locale })+ const result = await actions.updateTenantSettings({ title, cname, welcomeMessage, welcomeHeader, invitation, logo, locale })if (result.ok) {e.preventEnable()location.href = `/`@@ -48,6 +49,20 @@ const GeneralSettingsPage = () => {<p className="text-muted">Keep it short and snappy. Your product / service name is usually best.</p></Input>+ <Input+ field="welcomeHeader"+ label="Welcome Header"+ maxLength={100}+ value={welcomeHeader}+ disabled={!fider.session.user.isAdministrator}+ placeholder="Help us build the _best feedback platform_"+ onChange={setWelcomeHeader}+ >+ <p className="text-muted">+ Large header text shown on the home page. Leave empty to hide. Wrap text with underscores (e.g., _highlighted_) to show it in blue.+ </p>+ </Input>+<TextAreafield="welcomeMessage"label="Welcome Message"diff --git a/public/pages/Home/Home.page.tsx b/public/pages/Home/Home.page.tsxindex a64c82cd4..c126f5234 100644--- a/public/pages/Home/Home.page.tsx+++ b/public/pages/Home/Home.page.tsx@@ -85,6 +85,34 @@ What can we do better? This is the place for you to vote, discuss and share ideasetIsShareFeedbackOpen(true)}+ const parseWelcomeHeader = (text: string): JSX.Element[] => {+ const parts: JSX.Element[] = []+ let currentIndex = 0+ const regex = /_([^_]+)_/g+ let match: RegExpExecArray | null++ while ((match = regex.exec(text)) !== null) {+ // Add text before the match+ if (match.index > currentIndex) {+ parts.push(<span key={currentIndex}>{text.slice(currentIndex, match.index)}</span>)+ }+ // Add the highlighted text+ parts.push(+ <span key={match.index} className="text-primary-base">+ {match[1]}+ </span>+ )+ currentIndex = regex.lastIndex+ }++ // Add remaining text+ if (currentIndex < text.length) {+ parts.push(<span key={currentIndex}>{text.slice(currentIndex)}</span>)+ }++ return parts+ }+return (<><ShareFeedback@@ -98,9 +126,7 @@ What can we do better? This is the place for you to vote, discuss and share idea<div className="p-home__welcome-col"><VStack spacing={6}><div>- <h1 className="p-home__welcome-title mb-5">- Help us build the <span className="text-primary-base">best feedback platform.</span>- </h1>+ {fider.session.tenant.welcomeHeader && <h1 className="p-home__welcome-title mb-5">{parseWelcomeHeader(fider.session.tenant.welcomeHeader)}</h1>}<Markdown className="p-home__welcome-body" text={fider.session.tenant.welcomeMessage || defaultWelcomeMessage} style="full" /></div></VStack>diff --git a/public/pages/ShowPost/ShowPost.page.scss b/public/pages/ShowPost/ShowPost.page.scssindex 9bdb219e6..378342111 100644--- a/public/pages/ShowPost/ShowPost.page.scss+++ b/public/pages/ShowPost/ShowPost.page.scss@@ -1,7 +1,7 @@@use "~@fider/assets/styles/variables.scss" as *;#p-show-post {- background-color: var(--colors-gray-50);+ background-color: var(--colors-gray-100);padding-top: spacing(12);padding-bottom: spacing(12);diff --git a/public/services/actions/tenant.ts b/public/services/actions/tenant.tsindex 58e5d62d9..9b66d23d3 100644--- a/public/services/actions/tenant.ts+++ b/public/services/actions/tenant.ts@@ -28,6 +28,7 @@ export interface UpdateTenantSettingsRequest {title: stringinvitation: stringwelcomeMessage: string+ welcomeHeader: stringcname: stringlocale: string}