Open platform to collect and prioritize feedback
Merge branch 'no-page-reloads' into content-moderation
Matt Roberts75266b12d7b2
diff --cc app/const.goindex a0b230ca9,d5b9b8274..4712de971--- a/app/const.go+++ b/app/const.go@@@ -3,11 -3,8 +3,11 @@@ package apimport "errors"// ErrNotFound represents an object not found error- var ErrNotFound = errors.New("Object not found")+ var ErrNotFound = errors.New("object not found")+// ErrCommercialLicenseRequired is used when a commercial feature is accessed without a license+var ErrCommercialLicenseRequired = errors.New("Content moderation requires a commercial license")+// InvitePlaceholder represents the placeholder used by members to invite other usersvar InvitePlaceholder = "%invite%"diff --cc go.modindex cc9783e5e,004f35b72..a2bde14b0--- a/go.mod+++ b/go.mod@@@ -23,9 -24,9 +24,10 @@@ requiregithub.com/prometheus/client_golang v1.12.1github.com/prometheus/client_model v0.2.0github.com/robfig/cron v1.2.0- golang.org/x/crypto v0.24.0- golang.org/x/net v0.26.0- golang.org/x/oauth2 v0.15.0++ github.com/stripe/stripe-go/v83 v83.2.1+ golang.org/x/crypto v0.45.0+ golang.org/x/net v0.47.0+ golang.org/x/oauth2 v0.34.0rogchap.com/v8go v0.7.1-0.20211222173054-943fcf9e74cc)diff --cc go.sumindex 3086e20d9,d17ccce0b..f8f83751c--- a/go.sum+++ b/go.sum@@@ -576,21 -624,11 +624,13 @@@ github.com/stretchr/objx v0.5.2/go.modgithub.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=- github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=- github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=- github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=- github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=- github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=- github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=+ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=+ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=+github.com/stripe/stripe-go/v83 v83.2.1 h1:8WPhpMjr8VyMWKUsCMoVvlWxYazuL5edajKX/RulfbA=+github.com/stripe/stripe-go/v83 v83.2.1/go.mod h1:nRyDcLrJtwPPQUnKAFs9Bt1NnQvNhNiF6V19XHmPISE=github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=- github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c h1:+aPplBwWcHBo6q9xrfWdMrT9o4kltkmmvpemgIjep/8=- github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c/go.mod h1:SbErYREK7xXdsRiigaQiQkI9McGRzYMvlKYaP3Nimdk=- github.com/tdakkota/asciicheck v0.2.0 h1:o8jvnUANo0qXtnslk2d3nMKTFNlOnJjRrNcj0j9qkHM=- github.com/tdakkota/asciicheck v0.2.0/go.mod h1:Qb7Y9EgjCLJGup51gDHFzbI08/gbGhL/UVhYIPWG2rg=github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA=github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0=github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag=diff --cc public/pages/Home/Home.page.tsxindex 146f674e6,d6f0793f9..db5af0416--- a/public/pages/Home/Home.page.tsx+++ b/public/pages/Home/Home.page.tsx@@@ -1,6 -1,6 +1,7 @@@import "./Home.page.scss"import NoDataIllustration from "@fider/assets/images/undraw-no-data.svg"+import IconPlusCircle from "@fider/assets/images/heroicons-pluscircle.svg"+ import IconArrowLeft from "@fider/assets/images/heroicons-arrowleft.svg"import React, { useEffect, useState } from "react"import { Post, Tag, PostStatus } from "@fider/models"@@@ -121,29 -139,43 +168,45 @@@ What can we do better? This is the placisOpen={isShareFeedbackOpen && !fider.isReadOnly}onClose={() => setIsShareFeedbackOpen(false)}/>- <Header hasInert={isShareFeedbackOpen && !fider.isReadOnly} />- <div id="p-home" className="page container" {...(isShareFeedbackOpen && !fider.isReadOnly && { inert: "true" })}>- <div className="p-home__welcome-col">- <VStack spacing={6}>- <div>- {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>+ <Header hasInert={isShareFeedbackOpen && !fider.isReadOnly} />+ {selectedPostId === null ? (+ <div id="p-home" className="page container" {...(isShareFeedbackOpen && !fider.isReadOnly && { inert: "true" })}>+ <div className="p-home__welcome-col">- <VStack spacing={2} className="p-4">- <Markdown text={fider.session.tenant.welcomeMessage || defaultWelcomeMessage} style="full" />- <Button className="c-input" type="submit" variant="secondary" onClick={handleNewPost}>- {fider.session.tenant.invitation || defaultInvitation}- </Button>++ <VStack spacing={6}>++ <div>++ {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>- <div onClick={() => setIsShareFeedbackOpen(true)}>++ <div>+ <PoweredByFider slot="home-input" className="sm:hidden md:hidden lg:block mt-3" />+ </div></div>- </VStack>- <div>- <PoweredByFider slot="home-input" className="sm:hidden md:hidden lg:block mt-3" />- <div className="p-home__posts-col p-4">- {isLonely() ? (- <Lonely />- ) : (- <PostsContainer posts={props.posts} tags={props.tags} countPerStatus={props.countPerStatus} onPostClick={handlePostClick} />- )}++ <div className="p-home__posts-col">++ <button className="p-home__add-idea-btn" onClick={handleNewPost}>++ <HStack spacing={4} align="center">++ <Icon sprite={IconPlusCircle} className="p-home__add-idea-icon" />++ <span>{fider.session.tenant.invitation || defaultInvitation}</span>++ </HStack>++ </button>++ {isLonely() ? <Lonely /> : <PostsContainer posts={props.posts} tags={props.tags} countPerStatus={props.countPerStatus} onPostClick={handlePostClick} />}+ <PoweredByFider slot="home-footer" className="lg:hidden xl:hidden mt-8" />+ </div>+ </div>+ ) : (+ <div className="page container">+ <Button onClick={handleCloseOverlay} variant="link">+ <HStack spacing={2}>+ <Icon sprite={IconArrowLeft} />+ <span className="text-body clickable text-blue-600 hover">+ <Trans id="postdetails.backtoall">Back to all suggestions</Trans>+ </span>+ </HStack>+ </Button>+ <PostDetails postNumber={selectedPostId} /></div>- </div>- <div className="p-home__posts-col">- <button className="p-home__add-idea-btn" onClick={handleNewPost}>- <HStack spacing={4} align="center">- <Icon sprite={IconPlusCircle} className="p-home__add-idea-icon" />- <span>{fider.session.tenant.invitation || defaultInvitation}</span>- </HStack>- </button>- {isLonely() ? <Lonely /> : <PostsContainer posts={props.posts} tags={props.tags} countPerStatus={props.countPerStatus} />}- <PoweredByFider slot="home-footer" className="lg:hidden xl:hidden mt-8" />- </div>+ )}</div></>)diff --cc public/pages/Home/components/ListPosts.tsxindex 0db146a0e,bca042cdd..c24b459fa--- a/public/pages/Home/components/ListPosts.tsx+++ b/public/pages/Home/components/ListPosts.tsx@@@ -11,18 -9,25 +11,26 @@@ interface ListPostsPropstags: Tag[]emptyText: stringminimalView?: boolean+ onPostClick?: (postNumber: number, slug: string) => void}- const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[] }) => {+ const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[]; onPostClick?: (postNumber: number, slug: string) => void }) => {+ const fider = useFider()+ const isModerationEnabled = fider.session.tenant.isModerationEnabled+ const isPending = isModerationEnabled && !props.post.isApproved++ const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {+ if (props.onPostClick) {+ e.preventDefault()+ props.onPostClick(props.post.number, props.post.slug)+ }+ }+return (- <a href={`/posts/${props.post.number}/${props.post.slug}`} className="c-posts-container__post-link">- <HStack spacing={4} align="start" className="c-posts-container__post">- <div>- <VoteCounter post={props.post} />- </div>- <VStack className="w-full" spacing={2}>++ <a href={`/posts/${props.post.number}/${props.post.slug}`} className="c-posts-container__post-link" onClick={handleClick}>+ <VStack className="c-posts-container__post w-full" spacing={4}>{props.post.status !== "open" && (- <div className="mb-2 align-self-start">+ <div className="mb-1 align-self-start"><ResponseLozenge status={props.post.status} response={props.post.response} size={"small"} /></div>)}@@@ -59,20 -54,20 +67,27 @@@)}- const MinimalListPostItem = (props: { post: Post; tags: Tag[] }) => {+ const MinimalListPostItem = (props: { post: Post; tags: Tag[]; onPostClick?: (postNumber: number, slug: string) => void }) => {+ const fider = useFider()+ const isModerationEnabled = fider.session.tenant.isModerationEnabled+ const isPending = isModerationEnabled && !props.post.isApproved++ const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {+ if (props.onPostClick) {+ e.preventDefault()+ props.onPostClick(props.post.number, props.post.slug)+ }+ }+return (- <HStack spacing={4} align="start" className="c-posts-container__post">+ <HStack spacing={4} align="start" className="c-posts-container__post-minimal"><HStack className="w-full" justify="between" align="start">- <a className="text-link" href={`/posts/${props.post.number}/${props.post.slug}`} onClick={handleClick}>- {props.post.title}- </a>+ <HStack spacing={2} align="start" justify="between" className="w-full">- <a className="text-link" href={`/posts/${props.post.number}/${props.post.slug}`}>++ <a className="text-link" href={`/posts/${props.post.number}/${props.post.slug}`} onClick={handleClick}>+ {props.post.title}+ </a>+ {isPending && <span className="text-xs bg-yellow-100 text-yellow-800 px-2 py-1 rounded">pending</span>}+ </HStack>{props.post.status !== "open" ? (<div><ResponseLozenge status={props.post.status} response={props.post.response} size={"micro"} />@@@ -105,11 -100,11 +120,11 @@@ export const ListPosts = (props: ListPo))}</VStack>) : (- <VStack spacing={4} divide>+ <>{props.posts.map((post) => (- <ListPostItem key={post.id} post={post} tags={props.tags.filter((tag) => post.tags.indexOf(tag.slug) >= 0)} />+ <ListPostItem key={post.id} post={post} tags={props.tags.filter((tag) => post.tags.indexOf(tag.slug) >= 0)} onPostClick={props.onPostClick} />))}- </VStack>+ </>)}</>)diff --cc public/pages/Home/components/PostsContainer.tsxindex e37c9a016,9d67a0605..3a81eed01--- a/public/pages/Home/components/PostsContainer.tsx+++ b/public/pages/Home/components/PostsContainer.tsx@@@ -177,21 -168,20 +178,22 @@@ export class PostsContainer extends Rea/></div></div>- <ListPosts- posts={this.state.posts}- tags={this.props.tags}- emptyText={i18n._({ id: "home.postscontainer.label.noresults", message: "No results matched your search, try something different." })}- onPostClick={this.props.onPostClick}- />- {this.state.loading && <Loader />}- {showMoreLink && (- <div className="my-4 ml-4">- <a href={showMoreLink} className="text-primary-base text-medium hover:underline" onClick={this.showMore}>- <Trans id="home.postscontainer.label.viewmore">View more posts</Trans>- </a>- </div>- )}+ <div className="c-posts-container__list">+ <ListPosts+ posts={this.state.posts}+ tags={this.props.tags}+ emptyText={i18n._({ id: "home.postscontainer.label.noresults", message: "No results matched your search, try something different." })}++ onPostClick={this.props.onPostClick}+ />+ {this.state.loading && <Loader />}+ {showMoreLink && (+ <div className="my-4 text-center">+ <a href={showMoreLink} className="text-primary-base text-medium hover:underline" onClick={this.showMore}>+ <Trans id="home.postscontainer.label.viewmore">View more posts</Trans>+ </a>+ </div>+ )}+ </div></div>)}diff --cc public/pages/ShowPost/ShowPost.page.tsxindex 5429320df,66decae29..74b156e4a--- a/public/pages/ShowPost/ShowPost.page.tsx+++ b/public/pages/ShowPost/ShowPost.page.tsx@@@ -1,49 -1,10 +1,49 @@@import "./ShowPost.page.scss"- import React, { useState, useEffect, useCallback } from "react"-import React from "react"++import React, { useCallback, useEffect, useState } from "react"-import { Comment, Post, Tag, Vote } from "@fider/models"-import { Header, PoweredByFider } from "@fider/components"-import { PostDetails } from "@fider/components/PostDetails"+import { Comment, Post, Tag, Vote, CurrentUser, PostStatus } from "@fider/models"+import { actions, cache, clearUrlHash, Failure, Fider, notify, timeAgo } from "@fider/services"+import IconDuplicate from "@fider/assets/images/heroicons-duplicate.svg"+import { i18n } from "@lingui/core"+import IconRSS from "@fider/assets/images/heroicons-rss.svg"+import IconPencil from "@fider/assets/images/heroicons-pencil-alt.svg"+import IconChat from "@fider/assets/images/heroicons-chat-alt-2.svg"++import {+ ResponseDetails,+ Button,+ UserName,+ Moment,+ Markdown,+ Input,+ Form,+ Icon,+ Header,+ PoweredByFider,+ Avatar,+ RSSModal,+ ResponseLozenge,+} from "@fider/components"+import { CommentInput } from "./components/CommentInput"+import { ShowComment } from "./components/ShowComment"+import { VoteSection } from "./components/VoteSection"+import CommentEditor from "@fider/components/common/form/CommentEditor"++import IconX from "@fider/assets/images/heroicons-x.svg"+import IconThumbsUp from "@fider/assets/images/heroicons-thumbsup.svg"+import IconTrash from "@fider/assets/images/heroicons-trash.svg"+import { HStack, VStack } from "@fider/components/layout"+import { Trans } from "@lingui/react/macro"+import { DeletePostModal } from "./components/DeletePostModal"+import { ResponseModal } from "./components/ResponseModal"+import { VotesPanel } from "./components/VotesPanel"+import { TagsPanel } from "@fider/pages/ShowPost/components/TagsPanel"+import { ActionButton } from "./components/ActionButton"+import { t } from "@lingui/macro"+import { useFider } from "@fider/hooks"+import { useAttachments } from "@fider/hooks/useAttachments"+import { FollowButton } from "./components/FollowButton"interface ShowPostPageProps {post: Post