Open platform to collect and prioritize feedback
Added support for tags to be set on post creation (#1211) (#1306)
JimKnoxxcb92c23b021d
diff --git a/app/pkg/web/renderer.go b/app/pkg/web/renderer.goindex 354b7facb..4edbe4ff9 100644--- a/app/pkg/web/renderer.go+++ b/app/pkg/web/renderer.go@@ -215,6 +215,7 @@ func (r *Renderer) Render(w io.Writer, statusCode int, props Props, ctx *Context"baseURL": ctx.BaseURL(),"assetsURL": AssetsURL(ctx, ""),"oauth": oauthProviders.Result,+ "postWithTags": env.Config.PostCreationWithTagsEnabled,}if ctx.IsAuthenticated() {diff --git a/app/pkg/web/testdata/basic.html b/app/pkg/web/testdata/basic.htmlindex 20c0f5574..c05ccf408 100755--- a/app/pkg/web/testdata/basic.html+++ b/app/pkg/web/testdata/basic.html@@ -44,7 +44,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":[]},"tenant":null,"title":"Fider"}+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":null,"title":"Fider"}</script>diff --git a/app/pkg/web/testdata/canonical.html b/app/pkg/web/testdata/canonical.htmlindex a69f4b7b9..4061b5129 100755--- a/app/pkg/web/testdata/canonical.html+++ b/app/pkg/web/testdata/canonical.html@@ -46,7 +46,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":[]},"tenant":null,"title":"Fider"}+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":null,"title":"Fider"}</script>diff --git a/app/pkg/web/testdata/chunk.html b/app/pkg/web/testdata/chunk.htmlindex 43603148e..5d496dac0 100644--- a/app/pkg/web/testdata/chunk.html+++ b/app/pkg/web/testdata/chunk.html@@ -44,7 +44,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","page":"Test.page","props":{},"sessionID":"","settings":{"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":[]},"tenant":null,"title":"Fider"}+ {"contextID":"CONTEXT_ID","page":"Test.page","props":{},"sessionID":"","settings":{"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":null,"title":"Fider"}</script>diff --git a/app/pkg/web/testdata/home.html b/app/pkg/web/testdata/home.htmlindex 7bebfe39d..9af79e4fb 100755--- a/app/pkg/web/testdata/home.html+++ b/app/pkg/web/testdata/home.html@@ -44,7 +44,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"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":[]},"tenant":null,"title":"My Page Title · Fider"}+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"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":null,"title":"My Page Title · Fider"}</script>diff --git a/app/pkg/web/testdata/home_ssr.html b/app/pkg/web/testdata/home_ssr.htmlindex 72749a104..3570269df 100755--- a/app/pkg/web/testdata/home_ssr.html+++ b/app/pkg/web/testdata/home_ssr.html@@ -44,7 +44,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","description":"My Page Description","page":"Test.page","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"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":[]},"tenant":{"id":0,"name":"","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"locale":"en","isPrivate":false,"logoBlobKey":"","isEmailAuthAllowed":false},"title":"My Page Title · "}+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"Test.page","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"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":"","isEmailAuthAllowed":false},"title":"My Page Title · "}</script>diff --git a/app/pkg/web/testdata/oauth.html b/app/pkg/web/testdata/oauth.htmlindex 4c4c186ef..81361adc5 100755--- a/app/pkg/web/testdata/oauth.html+++ b/app/pkg/web/testdata/oauth.html@@ -44,7 +44,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":[{"provider":"google","displayName":"Google","clientID":"1234","url":"https://demo.test.fider.io:3000/oauth/google","callbackURL":"https://demo.test.fider.io:3000/oauth/google/callback","logoBlobKey":"google.png","isCustomProvider":false,"isEnabled":true}]},"tenant":null,"title":"Fider"}+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":[{"provider":"google","displayName":"Google","clientID":"1234","url":"https://demo.test.fider.io:3000/oauth/google","callbackURL":"https://demo.test.fider.io:3000/oauth/google/callback","logoBlobKey":"google.png","isCustomProvider":false,"isEnabled":true}],"postWithTags":true},"tenant":null,"title":"Fider"}</script>diff --git a/app/pkg/web/testdata/tenant.html b/app/pkg/web/testdata/tenant.htmlindex c1dca07ee..71410bd00 100755--- a/app/pkg/web/testdata/tenant.html+++ b/app/pkg/web/testdata/tenant.html@@ -44,7 +44,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":[]},"tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"locale":"","isPrivate":false,"logoBlobKey":"","isEmailAuthAllowed":false},"title":"Game of Thrones"}+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"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":"","isEmailAuthAllowed":false},"title":"Game of Thrones"}</script>diff --git a/app/pkg/web/testdata/user.html b/app/pkg/web/testdata/user.htmlindex 12c4a16cc..efe50ceb5 100755--- a/app/pkg/web/testdata/user.html+++ b/app/pkg/web/testdata/user.html@@ -44,7 +44,7 @@<script id="server-data" type="application/json">- {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{},"sessionID":"","settings":{"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":[]},"tenant":null,"title":"My Page Title · Fider","user":{"avatarBlobKey":"","avatarType":"gravatar","avatarURL":"https://demo.test.fider.io:3000/static/avatars/gravatar/5/Jon%20Snow","email":"[email protected]","id":5,"isAdministrator":true,"isCollaborator":true,"name":"Jon Snow","role":"administrator","status":"active"}}+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{},"sessionID":"","settings":{"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":null,"title":"My Page Title · Fider","user":{"avatarBlobKey":"","avatarType":"gravatar","avatarURL":"https://demo.test.fider.io:3000/static/avatars/gravatar/5/Jon%20Snow","email":"[email protected]","id":5,"isAdministrator":true,"isCollaborator":true,"name":"Jon Snow","role":"administrator","status":"active"}}</script>diff --git a/locale/ar/client.json b/locale/ar/client.jsonindex 0f7a23e13..b3132392c 100644--- a/locale/ar/client.json+++ b/locale/ar/client.json@@ -71,6 +71,7 @@"label.name": "الاسم","label.none": "لا شيء","label.notagsavailable": "لا توجد وسوم متاحة",+ "label.notagsselected": "No tags selected","label.notifications": "الإشعارات","label.or": "أو","label.selecttags": "حدد وسوم...",diff --git a/locale/cs/client.json b/locale/cs/client.jsonindex 083d8c65b..bfff33bb9 100644--- a/locale/cs/client.json+++ b/locale/cs/client.json@@ -71,6 +71,7 @@"label.name": "Name","label.none": "None","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Notifications","label.or": "OR","label.selecttags": "Select tags...",diff --git a/locale/de/client.json b/locale/de/client.jsonindex 9098eb314..85dcbe897 100644--- a/locale/de/client.json+++ b/locale/de/client.json@@ -71,6 +71,7 @@"label.name": "Name","label.none": "Keine","label.notagsavailable": "Keine Tags verfügbar",+ "label.notagsselected": "Keine Tags ausgewählt","label.notifications": "Benachrichtigungen","label.or": "ODER","label.selecttags": "Tags auswählen...",diff --git a/locale/el/client.json b/locale/el/client.jsonindex e58d865bd..86a3e0794 100644--- a/locale/el/client.json+++ b/locale/el/client.json@@ -71,6 +71,7 @@"label.name": "Όνομα","label.none": "Κανένα","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Ειδοποιήσεις","label.or": "Ή","label.selecttags": "Select tags...",diff --git a/locale/en/client.json b/locale/en/client.jsonindex 5c4c291fc..f35966163 100644--- a/locale/en/client.json+++ b/locale/en/client.json@@ -71,6 +71,7 @@"label.name": "Name","label.none": "None","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Notifications","label.or": "OR","label.selecttags": "Select tags...",diff --git a/locale/es-ES/client.json b/locale/es-ES/client.jsonindex a577683c6..ed6967140 100644--- a/locale/es-ES/client.json+++ b/locale/es-ES/client.json@@ -71,6 +71,7 @@"label.name": "Nombre","label.none": "Ninguno","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Notificaciones","label.or": "O","label.selecttags": "Select tags...",diff --git a/locale/fr/client.json b/locale/fr/client.jsonindex 8515281ab..fa54bb2f0 100644--- a/locale/fr/client.json+++ b/locale/fr/client.json@@ -71,6 +71,7 @@"label.name": "Nom","label.none": "Aucun","label.notagsavailable": "Aucune étiquette disponible",+ "label.notagsselected": "No tags selected","label.notifications": "Notifications","label.or": "OU","label.selecttags": "Séléctionner des étiquettes...",diff --git a/locale/it/client.json b/locale/it/client.jsonindex 874d488b3..471747f29 100644--- a/locale/it/client.json+++ b/locale/it/client.json@@ -71,6 +71,7 @@"label.name": "Nome","label.none": "Vuoto","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Notifiche","label.or": "OPPURE","label.selecttags": "Select tags...",diff --git a/locale/ja/client.json b/locale/ja/client.jsonindex ba15578dc..1f97f6818 100644--- a/locale/ja/client.json+++ b/locale/ja/client.json@@ -71,6 +71,7 @@"label.name": "名前","label.none": "該当なし","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "通知","label.or": "または","label.selecttags": "Select tags...",diff --git a/locale/ko/client.json b/locale/ko/client.jsonindex 106484085..b6b4abf3a 100644--- a/locale/ko/client.json+++ b/locale/ko/client.json@@ -71,6 +71,7 @@"label.name": "Name","label.none": "None","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Notifications","label.or": "OR","label.selecttags": "Select tags...",diff --git a/locale/nl/client.json b/locale/nl/client.jsonindex 8fe50fd25..9d9ff3357 100644--- a/locale/nl/client.json+++ b/locale/nl/client.json@@ -71,6 +71,7 @@"label.name": "Naam","label.none": "Geen","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Meldingen","label.or": "OF","label.selecttags": "Select tags...",diff --git a/locale/pl/client.json b/locale/pl/client.jsonindex 4829977b1..93ba19186 100644--- a/locale/pl/client.json+++ b/locale/pl/client.json@@ -71,6 +71,7 @@"label.name": "Nazwa","label.none": "Brak","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Powiadomienia","label.or": "LUB","label.selecttags": "Select tags...",diff --git a/locale/pt-BR/client.json b/locale/pt-BR/client.jsonindex 8d1e50b3d..8834a79af 100644--- a/locale/pt-BR/client.json+++ b/locale/pt-BR/client.json@@ -71,6 +71,7 @@"label.name": "Nome","label.none": "Nenhum","label.notagsavailable": "Não há tags disponíveis",+ "label.notagsselected": "No tags selected","label.notifications": "Notificações","label.or": "OU","label.selecttags": "Escolha as tags...",diff --git a/locale/ru/client.json b/locale/ru/client.jsonindex 6739c7395..d43441d49 100644--- a/locale/ru/client.json+++ b/locale/ru/client.json@@ -71,6 +71,7 @@"label.name": "Имя пользователя","label.none": "Нет","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Уведомления","label.or": "ИЛИ","label.selecttags": "Select tags...",diff --git a/locale/si-LK/client.json b/locale/si-LK/client.jsonindex 5c4c291fc..f35966163 100644--- a/locale/si-LK/client.json+++ b/locale/si-LK/client.json@@ -71,6 +71,7 @@"label.name": "Name","label.none": "None","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Notifications","label.or": "OR","label.selecttags": "Select tags...",diff --git a/locale/sk/client.json b/locale/sk/client.jsonindex 7ee9c22e8..ea7e14238 100644--- a/locale/sk/client.json+++ b/locale/sk/client.json@@ -71,6 +71,7 @@"label.name": "Meno","label.none": "Žiadne","label.notagsavailable": "Značky nie sú dostupné",+ "label.notagsselected": "No tags selected","label.notifications": "Notifikácie","label.or": "ALEBO","label.selecttags": "Vybrať značky...",diff --git a/locale/sv-SE/client.json b/locale/sv-SE/client.jsonindex 7a0a37916..01df93df5 100644--- a/locale/sv-SE/client.json+++ b/locale/sv-SE/client.json@@ -71,6 +71,7 @@"label.name": "Namn","label.none": "Ingen","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Aviseringar","label.or": "ELLER","label.selecttags": "Select tags...",diff --git a/locale/tr/client.json b/locale/tr/client.jsonindex e598172fd..c6e20c0be 100644--- a/locale/tr/client.json+++ b/locale/tr/client.json@@ -71,6 +71,7 @@"label.name": "İsim","label.none": "Hiçbiri","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "Bildirimler","label.or": "VEYA","label.selecttags": "Select tags...",diff --git a/locale/zh-CN/client.json b/locale/zh-CN/client.jsonindex b0505879d..6791e5c5d 100644--- a/locale/zh-CN/client.json+++ b/locale/zh-CN/client.json@@ -71,6 +71,7 @@"label.name": "名称","label.none": "None","label.notagsavailable": "No tags available",+ "label.notagsselected": "No tags selected","label.notifications": "通知","label.or": "或者","label.selecttags": "Select tags...",diff --git a/public/components/ShowTag.tsx b/public/components/ShowTag.tsxindex b00a6c29f..fa3b6f116 100644--- a/public/components/ShowTag.tsx+++ b/public/components/ShowTag.tsx@@ -1,6 +1,6 @@import "./ShowTag.scss"-import React from "react"+import React, { MouseEvent } from "react"import { Tag } from "@fider/models"import { classSet } from "@fider/services"import ShieldCheck from "@fider/assets/images/heroicons-shieldcheck.svg"@@ -24,11 +24,19 @@ export const ShowTag = (props: TagProps) => {"c-tag--circular": props.circular === true,})+ const clickHandler = (event: MouseEvent) => {+ if (!props.link) {+ event.preventDefault()+ }+ }+return (<a- href={props.link && props.tag.slug ? `/?tags=${props.tag.slug}` : undefined}+ // always add an href, so the tag can be selected by keyboard in the TagsSelect+ href={props.link && props.tag.slug ? `/?tags=${props.tag.slug}` : ""}title={`${props.tag.name}${props.tag.isPublic ? "" : " (Private)"}`}className={className}+ onClick={clickHandler}><spanstyle={{diff --git a/public/components/common/Button.scss b/public/components/common/Button.scssindex 73ce38b5e..91c8d7f4f 100644--- a/public/components/common/Button.scss+++ b/public/components/common/Button.scss@@ -62,6 +62,22 @@}}+ &--link {+ border: none;+ color: var(--colors-primary-base);+ background-color: transparent;+ }++ &--no-padding {+ padding: 0;+ font-size: get("font.size.sm");++ svg,+ img {+ height: sizing(4);+ }+ }+&--small {padding: 6px 10px;font-size: 11px;diff --git a/public/components/common/Button.tsx b/public/components/common/Button.tsxindex dc2ad0263..eff731f55 100644--- a/public/components/common/Button.tsx+++ b/public/components/common/Button.tsx@@ -11,8 +11,8 @@ interface ButtonProps {rel?: "nofollow"target?: "_self" | "_blank" | "_parent" | "_top"type?: "button" | "submit"- variant?: "primary" | "danger" | "secondary" | "tertiary"- size?: "small" | "default" | "large"+ variant?: "primary" | "danger" | "secondary" | "tertiary" | "link"+ size?: "small" | "default" | "large" | "no-padding"style?: React.CSSPropertiesonClick?: (event: ButtonClickEvent) => Promise<any> | void}diff --git a/public/pages/ShowPost/components/TagsPanel.scss b/public/components/common/TagsSelect.scsssimilarity index 78%rename from public/pages/ShowPost/components/TagsPanel.scssrename to public/components/common/TagsSelect.scssindex 4debbcec3..f11d11f5b 100644--- a/public/pages/ShowPost/components/TagsPanel.scss+++ b/public/components/common/TagsSelect.scss@@ -19,9 +19,9 @@width: 100%;padding: 0.5rem;border: 1px solid var(--colors-gray-500);- border-radius: 0.25rem;+ border-radius: get("border.radius.small");background-color: var(--colors-white);- cursor: pointer;+ color: var(--colors-gray-900);}.selected-option {@@ -29,7 +29,7 @@align-items: center;margin: 0.25rem;background-color: var(--colors-gray-200);- border-radius: 0.25rem;+ border-radius: get("border.radius.small");color: var(--colors-gray-900);}@@ -48,21 +48,6 @@color: var(--colors-red-500);}-.search-input {- flex-grow: 1;- min-width: 5rem;- margin: 0.25rem;- padding: 0.25rem;- border: none;- background-color: var(--colors-white);- color: var(--colors-black);- outline: none;-}--.search-input:focus {- outline: none;-}-.options-container {position: absolute;z-index: 10;@@ -70,13 +55,18 @@margin-top: 0.25rem;background-color: var(--colors-white);border: 1px solid var(--colors-gray-500);- border-radius: 0.25rem;+ border-radius: get("border.radius.small");max-height: 15rem;overflow-y: auto;}+.search-input {+ margin: spacing(2);+ width: calc(100% - spacing(4));+}+.option-item {- padding: 0.5rem;+ padding: spacing(2);cursor: pointer;}diff --git a/public/components/common/TagsSelect.tsx b/public/components/common/TagsSelect.tsxnew file mode 100644index 000000000..8ccc0bbd6--- /dev/null+++ b/public/components/common/TagsSelect.tsx@@ -0,0 +1,183 @@+import React, { KeyboardEvent as ReactKeyboardEvent, useEffect, useRef, useState } from "react"+import { Tag } from "@fider/models"+import { sortTags } from "@fider/services"+import { Button, ShowTag } from "@fider/components"+import { useFider } from "@fider/hooks"++import { HStack, VStack } from "@fider/components/layout"+import { Trans } from "@lingui/react/macro"+import { i18n } from "@lingui/core"++import "./TagsSelect.scss"++export interface TagsSelectProps {+ tags: Tag[]+ selected: Tag[]+ selectionChanged: (selected: Tag[]) => void+ canEdit: boolean+ asLinks?: boolean+}++export const TagsSelect = (props: TagsSelectProps) => {+ const fider = useFider()+ const [isEditing, setIsEditing] = useState(false)+ const [query, setQuery] = useState("")++ const dropdownRef = useRef<HTMLDivElement>(null)+ const inputRef = useRef<HTMLInputElement>(null)++ const assignOrUnassignTag = async (tag: Tag) => {+ const idx = props.selected.indexOf(tag)+ const next = idx >= 0 ? props.selected.filter((x) => x !== tag) : props.selected.concat(tag)+ props.selectionChanged(next)+ }++ const onSubtitleClick = () => {+ if (props.canEdit) {+ setIsEditing(!isEditing)+ // Immediately focus on the input element when editing starts+ if (inputRef.current) {+ inputRef.current.focus()+ }+ setQuery("")+ }+ }++ const handleOptionClick = (tag: Tag) => {+ assignOrUnassignTag(tag)+ // Keep focus on the input element after selection+ if (inputRef.current) {+ inputRef.current.focus()+ }+ }++ const handleOptionKey = (event: ReactKeyboardEvent, tag: Tag) => {+ if (event.code !== "Enter" && event.code !== "Space") {+ return+ }++ event.preventDefault()+ assignOrUnassignTag(tag)+ if (inputRef.current) {+ inputRef.current.focus()+ }+ }++ const filteredOptions = props.tags.filter(+ (option) => option.name.toLowerCase().includes(query.toLowerCase()) && !props.selected.some((tag) => tag.slug === option.slug)+ )++ const handleEsc = (event: KeyboardEvent | ReactKeyboardEvent) => {+ if (event.code !== "Escape") {+ return+ }++ setIsEditing(false)+ }++ // Close dropdown when clicking outside+ useEffect(() => {+ const handleClickOutside = (event: MouseEvent) => {+ if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {+ setIsEditing(false)+ }+ }++ document.addEventListener("mousedown", handleClickOutside)+ document.addEventListener("keydown", handleEsc)+ return () => {+ document.removeEventListener("mousedown", handleClickOutside)+ document.addEventListener("keydown", handleEsc)+ }+ }, [])++ useEffect(() => {+ if (isEditing && inputRef.current) {+ inputRef.current.focus()+ }+ }, [isEditing])++ if (!props.canEdit && props.selected.length === 0) {+ return null+ }++ const tagsList = (+ <div className="tags-list">+ {props.selected.length > 0 && sortTags(props.selected).map((tag) => <ShowTag key={tag.id} tag={tag} link={props.asLinks} />)}+ {props.canEdit && (+ <Button variant={"link"} size={"no-padding"} onClick={onSubtitleClick}>+ <Trans id="label.edittags">Edit tags</Trans>+ </Button>+ )}+ </div>+ )++ // Dynamic multiselect dropdown for tags selection+ const editTagsList = props.tags.length > 0 && (+ <div className="dropdown-wrapper" ref={dropdownRef}>+ {/* Selected options and search input */}+ <div className="selected-options-container">+ {props.selected.length === 0 && (+ <span className="text-muted">+ <Trans id="labels.notagsselected">No tags selected</Trans>+ </span>+ )}+ {sortTags(props.selected).map((tag) => (+ <div key={tag.id} className="selected-option">+ <ShowTag tag={tag} />+ <button onClick={() => handleOptionClick(tag)} className="remove-button">+ x+ </button>+ </div>+ ))}+ </div>++ {/* Dropdown options after items are filtered */}+ {isEditing && (+ <div className="options-container">+ {/* Search box to enter query string */}+ <input+ type="text"+ value={query}+ ref={inputRef}+ onChange={(e) => setQuery(e.target.value)}+ className="c-input search-input"+ placeholder={i18n._("label.selecttags", { message: "Select Tags..." })}+ onKeyDown={() => handleEsc}+ />+ {filteredOptions.length > 0 ? (+ sortTags(filteredOptions).map((tag) => (+ <div key={tag.id} className="option-item" onClick={() => handleOptionClick(tag)} onKeyDown={(event) => handleOptionKey(event, tag)}>+ <ShowTag tag={tag} />+ </div>+ ))+ ) : (+ <div className="no-options">+ <Trans id="labels.notagsavailable">No tags available</Trans>+ </div>+ )}+ </div>+ )}+ </div>+ )++ if (fider.isReadOnly) {+ return (+ <VStack>+ <HStack spacing={2} className="text-category">+ <Trans id="label.tags">Tags</Trans>+ </HStack>+ {tagsList}+ </VStack>+ )+ }++ return (+ <VStack>+ <HStack spacing={2} align="center" className="text-primary-base text-xs">+ {!isEditing && tagsList}+ {isEditing && editTagsList}+ </HStack>+ </VStack>+ )+}diff --git a/public/components/common/form/ImageUploader.scss b/public/components/common/form/ImageUploader.scssindex 986f9ef59..97ba79d4b 100644--- a/public/components/common/form/ImageUploader.scss+++ b/public/components/common/form/ImageUploader.scss@@ -1,6 +1,8 @@@import "~@fider/assets/styles/variables.scss";.c-image-upload {+ margin-bottom: 0;+input[type="file"] {display: none;}@@ -20,7 +22,12 @@top: 4px;right: 4px;border-radius: 50%;- padding: 4px 6px;+ padding: 0;+ width: 24px;+ height: 24px;+ display: flex;+ justify-content: center;+ align-items: center;}}}diff --git a/public/components/common/form/MultiImageUploader.tsx b/public/components/common/form/MultiImageUploader.tsxindex e9cb8f3d0..148a07ee0 100644--- a/public/components/common/form/MultiImageUploader.tsx+++ b/public/components/common/form/MultiImageUploader.tsx@@ -11,6 +11,7 @@ interface MultiImageUploaderProps {maxUploads: numberbkeys?: string[]onChange?: (uploads: ImageUpload[]) => void+ noPadding?: boolean}interface MultiImageUploaderInstances {@@ -95,6 +96,7 @@ export class MultiImageUploader extends React.Component<MultiImageUploaderProps,"c-form-field": true,"c-multi-image-uploader": true,"m-error": hasError(this.props.field, ctx.error),+ "pt-0": this.props.noPadding,})}><div className="c-multi-image-uploader-instances">{elements}</div>diff --git a/public/models/settings.ts b/public/models/settings.tsindex 1c9314f90..183d708d9 100644--- a/public/models/settings.ts+++ b/public/models/settings.ts@@ -20,6 +20,7 @@ export interface SystemSettings {baseURL: stringassetsURL: stringoauth: OAuthProviderOption[]+ postWithTags: boolean}export interface UserSettings {diff --git a/public/pages/Home/Home.page.tsx b/public/pages/Home/Home.page.tsxindex a8d245308..07fbd43b7 100644--- a/public/pages/Home/Home.page.tsx+++ b/public/pages/Home/Home.page.tsx@@ -78,7 +78,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={2} className="p-4"><Markdown text={fider.session.tenant.welcomeMessage || defaultWelcomeMessage} style="full" />- <PostInput placeholder={fider.session.tenant.invitation || defaultInvitation} onTitleChanged={setTitle} />+ <PostInput tags={props.tags} placeholder={fider.session.tenant.invitation || defaultInvitation} onTitleChanged={setTitle} /></VStack><PoweredByFider slot="home-input" className="sm:hidden md:hidden lg:block mt-3" /></div>diff --git a/public/pages/Home/components/PostInput.tsx b/public/pages/Home/components/PostInput.tsxindex b5b7a9313..bbaef340f 100644--- a/public/pages/Home/components/PostInput.tsx+++ b/public/pages/Home/components/PostInput.tsx@@ -1,19 +1,22 @@import React, { useState, useEffect, useRef } from "react"import { Button, ButtonClickEvent, Input, Form, TextArea, MultiImageUploader } from "@fider/components"import { SignInModal } from "@fider/components"-import { cache, actions, Failure } from "@fider/services"-import { ImageUpload } from "@fider/models"+import { cache, actions, classSet, Failure, querystring } from "@fider/services"+import { ImageUpload, Tag } from "@fider/models"import { useFider } from "@fider/hooks"import { i18n } from "@lingui/core"import { Trans } from "@lingui/react/macro"+import { TagsSelect } from "@fider/components/common/TagsSelect"interface PostInputProps {placeholder: stringonTitleChanged: (title: string) => void+ tags: Tag[]}const CACHE_TITLE_KEY = "PostInput-Title"const CACHE_DESCRIPTION_KEY = "PostInput-Description"+const CACHE_TAGS_KEY = "PostInput-Tags"export const PostInput = (props: PostInputProps) => {const getCachedValue = (key: string): string => {@@ -23,10 +26,25 @@ export const PostInput = (props: PostInputProps) => {return ""}+ const getTagsCachedValue = (): Tag[] => {+ if (!canEditTags) {+ return []+ }++ const cacheValue = getCachedValue(CACHE_TAGS_KEY)+ const urlValue = querystring.get("tags")+ const combined = [...cacheValue.split(","), ...urlValue.split(",")]+ const tagsAsStrings = Array.from(new Set(combined.map((s) => s.trim()).filter((s) => s.length > 0)))++ return props.tags.filter((tag) => tagsAsStrings.includes(tag.slug))+ }+const fider = useFider()+ const canEditTags = fider.session.isAuthenticated && fider.settings.postWithTags && props.tags.length > 0const titleRef = useRef<HTMLInputElement>()const [title, setTitle] = useState(getCachedValue(CACHE_TITLE_KEY))const [description, setDescription] = useState(getCachedValue(CACHE_DESCRIPTION_KEY))+ const [tags, setTags] = useState(getTagsCachedValue())const [isSignInModalOpen, setIsSignInModalOpen] = useState(false)const [attachments, setAttachments] = useState<ImageUpload[]>([])const [error, setError] = useState<Failure | undefined>(undefined)@@ -58,10 +76,15 @@ export const PostInput = (props: PostInputProps) => {const submit = async (event: ButtonClickEvent) => {if (title) {- const result = await actions.createPost(title, description, attachments)+ const result = await actions.createPost(+ title,+ description,+ attachments,+ tags.map((tag) => tag.slug)+ )if (result.ok) {clearError()- cache.session.remove(CACHE_TITLE_KEY, CACHE_DESCRIPTION_KEY)+ cache.session.remove(CACHE_TITLE_KEY, CACHE_DESCRIPTION_KEY, CACHE_TAGS_KEY)location.href = `/posts/${result.data.number}/${result.data.slug}`event.preventEnable()} else if (result.error) {@@ -70,6 +93,11 @@ export const PostInput = (props: PostInputProps) => {}}+ const handleTagsChanged = (newTags: Tag[]) => {+ cache.session.set(CACHE_TAGS_KEY, newTags.map((tag) => tag.slug).join(","))+ setTags(newTags)+ }+const details = () => (<><TextArea@@ -79,7 +107,12 @@ export const PostInput = (props: PostInputProps) => {minRows={5}placeholder={i18n._("home.postinput.description.placeholder", { message: "Describe your suggestion (optional)" })}/>- <MultiImageUploader field="attachments" maxUploads={3} onChange={setAttachments} />+ {canEditTags && (+ <div className={classSet({ "c-form-field": true })}>+ <TagsSelect tags={props.tags} selectionChanged={handleTagsChanged} selected={tags} canEdit={true} />+ </div>+ )}+ <MultiImageUploader field="attachments" maxUploads={3} onChange={setAttachments} noPadding /><Button type="submit" variant="primary" onClick={submit}><Trans id="action.submit">Submit</Trans></Button>diff --git a/public/pages/Home/components/TagsFilter.tsx b/public/pages/Home/components/TagsFilter.tsxdeleted file mode 100644index 4512f6ca8..000000000--- a/public/pages/Home/components/TagsFilter.tsx+++ /dev/null@@ -1,54 +0,0 @@-import React, { useState } from "react"-import { Tag } from "@fider/models"-import { Dropdown, Icon, ShowTag } from "@fider/components"-import IconCheck from "@fider/assets/images/heroicons-check.svg"-import { HStack } from "@fider/components/layout"--import { plural } from "@lingui/core/macro"-import { Trans } from "@lingui/react/macro"-import { i18n } from "@lingui/core"--interface TagsFilterProps {- tags: Tag[]- selected: string[]- selectionChanged: (selected: string[]) => void-}--export const TagsFilter = (props: TagsFilterProps) => {- const [selected, setSelected] = useState<string[]>(props.selected)-- const toggle = (item: Tag) => () => {- const idx = selected.indexOf(item.slug)- const next = idx >= 0 ? selected.splice(idx, 1) && selected : selected.concat(item.slug)- setSelected(next)- props.selectionChanged(next)- }-- const count = selected.length- const label =- count >= 1- ? plural(count, {- one: `# tag`,- other: `# tags`,- })- : i18n._("home.tagsfilter.selected.none", { message: "Any tag" })-- return (- <HStack>- <span>- <Trans id="home.tagsfilter.label.with">with</Trans>- </span>- <Dropdown renderHandle={<div className="text-medium text-xs uppercase rounded-md uppercase bg-gray-100 px-2 py-1">{label}</div>}>- {props.tags.map((t) => (- <Dropdown.ListItem onClick={toggle(t)} key={t.id}>- <HStack spacing={2}>- <Icon sprite={IconCheck} className={`h-4 text-green-600 ${!selected.includes(t.slug) && "invisible"}`} />- <ShowTag tag={t} circular />- <span>{t.name}</span>- </HStack>- </Dropdown.ListItem>- ))}- </Dropdown>- </HStack>- )-}diff --git a/public/pages/ShowPost/ShowPost.page.tsx b/public/pages/ShowPost/ShowPost.page.tsxindex 08408ea42..31ea3ff21 100644--- a/public/pages/ShowPost/ShowPost.page.tsx+++ b/public/pages/ShowPost/ShowPost.page.tsx@@ -29,12 +29,12 @@ import IconX from "@fider/assets/images/heroicons-x.svg"import IconThumbsUp from "@fider/assets/images/heroicons-thumbsup.svg"import { HStack, VStack } from "@fider/components/layout"import { Trans } from "@lingui/react/macro"-import { TagsPanel } from "./components/TagsPanel"import { FollowButton } from "./components/FollowButton"import { VoteSection } from "./components/VoteSection"import { DeletePostModal } from "./components/DeletePostModal"import { ResponseModal } from "./components/ResponseModal"import { VotesPanel } from "./components/VotesPanel"+import { TagsPanel } from "@fider/pages/ShowPost/components/TagsPanel"interface ShowPostPageProps {post: Postdiff --git a/public/pages/ShowPost/components/TagsPanel.tsx b/public/pages/ShowPost/components/TagsPanel.tsxindex ef6ea50bd..57c79655a 100644--- a/public/pages/ShowPost/components/TagsPanel.tsx+++ b/public/pages/ShowPost/components/TagsPanel.tsx@@ -1,14 +1,8 @@-import React, { useEffect, useRef, useState } from "react"+import React, { useState } from "react"import { Post, Tag } from "@fider/models"-import { actions, sortTags } from "@fider/services"-import { ShowTag } from "@fider/components"+import { actions } from "@fider/services"import { useFider } from "@fider/hooks"--import { HStack, VStack } from "@fider/components/layout"-import { Trans } from "@lingui/react/macro"-import { i18n } from "@lingui/core"--import "./TagsPanel.scss"+import { TagsSelect } from "@fider/components/common/TagsSelect"export interface TagsPanelProps {post: Post@@ -19,153 +13,16 @@ export const TagsPanel = (props: TagsPanelProps) => {const fider = useFider()const canEdit = fider.session.isAuthenticated && fider.session.user.isCollaborator && props.tags.length > 0- const [isEditing, setIsEditing] = useState(false)const [assignedTags, setAssignedTags] = useState(props.tags.filter((t) => props.post.tags.indexOf(t.slug) >= 0))- const [query, setQuery] = useState("")-- const dropdownRef = useRef<HTMLDivElement>(null)- const inputRef = useRef<HTMLInputElement>(null)-- const assignOrUnassignTag = async (tag: Tag) => {- const idx = assignedTags.indexOf(tag)- let nextAssignedTags: Tag[] = []-- if (idx >= 0) {- const response = await actions.unassignTag(tag.slug, props.post.number)- if (response.ok) {- nextAssignedTags = [...assignedTags]- nextAssignedTags.splice(idx, 1)- }- } else {- const response = await actions.assignTag(tag.slug, props.post.number)- if (response.ok) {- nextAssignedTags = [...assignedTags, tag]- }- }-- setAssignedTags(nextAssignedTags)- }-- const onSubtitleClick = () => {- if (canEdit) {- setIsEditing(!isEditing)- // Immediately focus on the input element when editing starts- if (inputRef.current) {- inputRef.current.focus()- }- setQuery("")- }- }-- const handleOptionClick = (tag: Tag) => {- assignOrUnassignTag(tag)- // Keep focus on the input element after selection- if (inputRef.current) {- inputRef.current.focus()- }- }-- const filteredOptions = props.tags.filter(- (option) => option.name.toLowerCase().includes(query.toLowerCase()) && !assignedTags.some((tag) => tag.slug === option.slug)- )-- // Close dropdown when clicking outside- useEffect(() => {- const handleClickOutside = (event: { target: any }) => {- if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {- setIsEditing(false)- }- }-- document.addEventListener("mousedown", handleClickOutside)- return () => {- document.removeEventListener("mousedown", handleClickOutside)- }- }, [])-- useEffect(() => {- if (isEditing && inputRef.current) {- inputRef.current.focus()- }- }, [isEditing])-- if (!canEdit && assignedTags.length === 0) {- return null- }-- const tagsList = (- <div className="tags-list">- {assignedTags.length > 0 && sortTags(assignedTags).map((tag) => <ShowTag key={tag.id} tag={tag} link />)}- {canEdit && (- <HStack spacing={1} align="center" className="clickable" onClick={onSubtitleClick}>- <span>- <Trans id="label.edittags">Edit tags</Trans>- </span>- </HStack>- )}- </div>- )-- // Dynamic multiselect dropdown for tags selection- const editTagsList = props.tags.length > 0 && (- <div className="dropdown-wrapper" ref={dropdownRef}>- {/* Selected options and search input */}- <div className="selected-options-container">- {sortTags(assignedTags).map((tag) => (- <div key={tag.id} className="selected-option">- <ShowTag key={tag.id} tag={tag} link />- <button onClick={() => handleOptionClick(tag)} className="remove-button">- x- </button>- </div>- ))}- {/* Search box to enter query string */}- <input- type="text"- value={query}- ref={inputRef}- onChange={(e) => setQuery(e.target.value)}- className="search-input"- placeholder={assignedTags.length ? "" : i18n._("label.selecttags", { message: "Select Tags..." })}- />- </div>- {/* Dropdown options after items are filtered */}- {isEditing && (- <div className="options-container">- {filteredOptions.length > 0 ? (- sortTags(filteredOptions).map((tag) => (- <div key={tag.id} className="option-item" onClick={() => handleOptionClick(tag)}>- <ShowTag key={tag.id} tag={tag} />- </div>- ))- ) : (- <div className="no-options">- <Trans id="labels.notagsavailable">No tags available</Trans>- </div>- )}- </div>- )}- </div>- )+ const assignOrUnassignTag = async (tags: Tag[]) => {+ await Promise.all([+ ...tags.filter((t) => !assignedTags.includes(t)).map((t) => actions.assignTag(t.slug, props.post.number)),+ ...assignedTags.filter((t) => !tags.includes(t)).map((t) => actions.unassignTag(t.slug, props.post.number)),+ ])- if (fider.isReadOnly) {- return (- <VStack>- <HStack spacing={2} className="text-category">- <Trans id="label.tags">Tags</Trans>- </HStack>- {tagsList}- </VStack>- )+ setAssignedTags(tags)}- return (- <VStack>- <HStack spacing={2} align="center" className="text-primary-base text-xs">- {!isEditing && tagsList}- {isEditing && editTagsList}- </HStack>- </VStack>- )+ return <TagsSelect tags={props.tags} selected={assignedTags} canEdit={canEdit} selectionChanged={assignOrUnassignTag} asLinks />}diff --git a/public/services/actions/post.ts b/public/services/actions/post.tsindex 3968a700b..f9ead5736 100644--- a/public/services/actions/post.ts+++ b/public/services/actions/post.ts@@ -106,8 +106,8 @@ interface CreatePostResponse {slug: string}-export const createPost = async (title: string, description: string, attachments: ImageUpload[]): Promise<Result<CreatePostResponse>> => {- return http.post<CreatePostResponse>(`/api/v1/posts`, { title, description, attachments }).then(http.event("post", "create"))+export const createPost = async (title: string, description: string, attachments: ImageUpload[], tags: string[]): Promise<Result<CreatePostResponse>> => {+ return http.post<CreatePostResponse>(`/api/v1/posts`, { title, description, attachments, tags }).then(http.event("post", "create"))}export const updatePost = async (postNumber: number, title: string, description: string, attachments: ImageUpload[]): Promise<Result> => {