Open platform to collect and prioritize feedback
Pending items moved to a status filter.
Matt Roberts72d0fdd73230
diff --git a/app/handlers/post.go b/app/handlers/post.goindex ced787e70..776d4c03b 100644--- a/app/handlers/post.go+++ b/app/handlers/post.go@@ -36,7 +36,24 @@ func Index() web.HandlerFunc {searchPosts.MyPostsOnly = myPostsOnly}- searchPosts.SetStatusesFromStrings(c.QueryParamAsArray("statuses"))+ // Handle "pending" pseudo-status for moderation filtering+ statusesParam := c.QueryParamAsArray("statuses")+ hasPending := false+ actualStatuses := []string{}+ for _, status := range statusesParam {+ if status == "pending" {+ hasPending = true+ } else {+ actualStatuses = append(actualStatuses, status)+ }+ }++ // Set moderation filter based on pending status+ if hasPending {+ searchPosts.ModerationFilter = "pending"+ }++ searchPosts.SetStatusesFromStrings(actualStatuses)getAllTags := &query.GetAllTags{}countPerStatus := &query.CountPostPerStatus{}diff --git a/public/pages/Home/components/PostFilter.tsx b/public/pages/Home/components/PostFilter.tsxindex 1ad77cd9a..cd6250d12 100644--- a/public/pages/Home/components/PostFilter.tsx+++ b/public/pages/Home/components/PostFilter.tsx@@ -9,7 +9,7 @@ import { FilterState } from "./PostsContainer"import "./PostFilter.scss"-type FilterType = "tag" | "status" | "myVotes" | "noTags" | "myPosts" | "moderation"+type FilterType = "tag" | "status" | "myVotes" | "noTags" | "myPosts"interface OptionItem {value: string | boolean@@ -47,14 +47,11 @@ const FilterStateToFilterItems = (filterState: FilterState): FilterItem[] => {if (filterState.myPosts) {filterItems.push({ type: "myPosts", value: true })}- if (filterState.moderation) {- filterItems.push({ type: "moderation", value: filterState.moderation })- }return filterItems}const FilterItemsToFilterState = (filterItems: FilterItem[]): FilterState => {- const filterState: FilterState = { tags: [], statuses: [], myVotes: false, noTags: false, myPosts: false, moderation: "" }+ const filterState: FilterState = { tags: [], statuses: [], myVotes: false, noTags: false, myPosts: false }filterItems.forEach((i) => {if (i.type === "tag") {filterState.tags.push(i.value as string)@@ -66,8 +63,6 @@ const FilterItemsToFilterState = (filterItems: FilterItem[]): FilterState => {filterState.noTags = true} else if (i.type === "myPosts") {filterState.myPosts = true- } else if (i.type === "moderation") {- filterState.moderation = i.value as string}})return filterState@@ -93,12 +88,6 @@ export const PostFilter = (props: PostFilterProps) => {if (fider.session.isAuthenticated) {options.push({ value: true, label: i18n._({ id: "home.postfilter.option.myvotes", message: "My Votes" }), type: "myVotes" })options.push({ value: true, label: i18n._({ id: "home.postfilter.option.myposts", message: "My Posts" }), type: "myPosts" })-- // Add moderation filter for collaborators and admins- if (fider.session.user.isCollaborator) {- options.push({ value: "pending", label: i18n._({ id: "home.postfilter.moderation.pending", message: "Pending" }), type: "moderation" })- options.push({ value: "approved", label: i18n._({ id: "home.postfilter.moderation.approved", message: "Approved" }), type: "moderation" })- }}PostStatus.All.filter((s) => s.filterable && props.countPerStatus[s.value]).forEach((s) => {@@ -111,6 +100,15 @@ export const PostFilter = (props: PostFilterProps) => {})})+ // Add Pending status for collaborators and admins+ if (fider.session.isAuthenticated && fider.session.user.isCollaborator) {+ options.push({+ label: "Pending",+ value: "pending",+ type: "status",+ })+ }+if (props.tags.length > 0) {options.push({value: true,@@ -179,8 +177,6 @@ export const PostFilter = (props: PostFilterProps) => {<FilterGroupSection title={i18n._({ id: "home.postfilter.label.myactivity", message: "My activity" })} type={["myVotes", "myPosts"]} />- <FilterGroupSection title={i18n._({ id: "home.postfilter.label.moderation", message: "Moderation" })} type={["moderation"]} />-<FilterGroupSection title={i18n._({ id: "home.postfilter.label.status", message: "Status" })} type={["status"]} /><FilterGroupSection title={i18n._({ id: "label.tags", message: "Tags" })} type={["noTags", "tag"]} />diff --git a/public/pages/Home/components/PostsContainer.tsx b/public/pages/Home/components/PostsContainer.tsxindex 93c13deea..c54df549f 100644--- a/public/pages/Home/components/PostsContainer.tsx+++ b/public/pages/Home/components/PostsContainer.tsx@@ -35,7 +35,6 @@ export interface FilterState {myVotes: booleanmyPosts: booleannoTags: boolean- moderation: string}export class PostsContainer extends React.Component<PostsContainerProps, PostsContainerState> {@@ -55,7 +54,6 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsComyVotes: querystring.get("myvotes") === "true",myPosts: querystring.get("myposts") === "true",noTags: querystring.get("notags") === "true",- moderation: querystring.get("moderation") || "",},limit: querystring.getNumber("limit"),}@@ -71,7 +69,6 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsComyvotes: this.state.filterState.myVotes ? "true" : undefined,myposts: this.state.filterState.myPosts ? "true" : undefined,notags: this.state.filterState.noTags ? "true" : undefined,- moderation: this.state.filterState.moderation || undefined,query,view: this.state.view,limit: this.state.limit,@@ -87,7 +84,6 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsCothis.state.filterState.myVotes,this.state.filterState.myPosts,this.state.filterState.noTags,- this.state.filterState.moderation,reset)})@@ -103,13 +99,22 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsComyVotes: boolean,myPosts: boolean,noTags: boolean,- moderation: string,reset: boolean) {window.clearTimeout(this.timer)this.setState({ posts: reset ? undefined : this.state.posts, loading: true })this.timer = window.setTimeout(() => {- actions.searchPosts({ query, view: view, limit, tags, statuses, myVotes, myPosts, noTags, moderation }).then((response) => {+ // Check if "pending" is in the statuses+ const hasPending = statuses.includes("pending")+ // Filter out "pending" from actual statuses to send to API+ const actualStatuses = statuses.filter((s) => s !== "pending")+ // Determine moderation filter+ let moderation = ""+ if (hasPending) {+ moderation = "pending"+ }++ actions.searchPosts({ query, view: view, limit, tags, statuses: actualStatuses, myVotes, myPosts, noTags, moderation }).then((response) => {if (response.ok && this.state.loading) {this.setState({ loading: false, posts: response.data })}