-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add stories moderation #2928
base: master
Are you sure you want to change the base?
Add stories moderation #2928
Changes from all commits
6245551
5afe3df
beafbfb
3901795
4d4e720
b75968d
8ab4515
8127e09
1643b56
0e5a412
9537d95
d22f80b
6e8a521
ac1afb7
ff97dd5
92a1fbd
80e92dc
b170565
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,19 @@ export type StoryData = { | |
title: string; | ||
content: string; | ||
pinOrder: number | null; | ||
status: StoryStatus; | ||
statusMessage: string; | ||
}; | ||
|
||
export type StoryParams = StoryData; | ||
|
||
export enum StoryStatus { | ||
Draft = 0, | ||
Pending, | ||
Rejected, | ||
Published | ||
} | ||
Comment on lines
+28
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, enum values should be UPPER_SNAKE_CASE (e.g. |
||
|
||
export type StoryListView = StoryData & | ||
StoryMetadata & { | ||
id: number; | ||
|
@@ -53,8 +62,15 @@ export type StoriesAuthState = { | |
readonly role?: StoriesRole; | ||
}; | ||
|
||
export type StoryListViews = { | ||
readonly draft: StoryListView[]; | ||
readonly pending: StoryListView[]; | ||
readonly rejected: StoryListView[]; | ||
readonly published: StoryListView[]; | ||
}; | ||
|
||
export type StoriesState = { | ||
readonly storyList: StoryListView[]; | ||
readonly storyLists: StoryListViews; | ||
readonly currentStoryId: number | null; | ||
readonly currentStory: StoryData | null; | ||
readonly envs: { [key: string]: StoriesEnvState }; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import { store } from 'src/pages/createStore'; | |
|
||
import { Tokens } from '../../../commons/application/types/SessionTypes'; | ||
import { NameUsernameRole } from '../../../pages/academy/adminPanel/subcomponents/AddStoriesUserPanel'; | ||
import { StoryListView, StoryView } from '../StoriesTypes'; | ||
import { StoryListView, StoryStatus, StoryView } from '../StoriesTypes'; | ||
|
||
// Helpers | ||
|
||
|
@@ -75,8 +75,22 @@ export const postNewStoriesUsers = async ( | |
// TODO: Return response JSON directly. | ||
}; | ||
|
||
export const getStories = async (tokens: Tokens): Promise<StoryListView[] | null> => { | ||
const resp = await requestStoryBackend(`/groups/${getStoriesGroupId()}/stories`, 'GET', { | ||
export const getStories = async ( | ||
tokens: Tokens, | ||
status: StoryStatus | null = null | ||
): Promise<StoryListView[] | null> => { | ||
const route = | ||
status === StoryStatus.Draft | ||
? '/draft' | ||
: status === StoryStatus.Pending | ||
? '/pending' | ||
: status === StoryStatus.Rejected | ||
? '/rejected' | ||
: status === StoryStatus.Published | ||
? '/published' | ||
: ''; | ||
Comment on lines
+83
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filters are generally done using a query parameter instead of a different route/path (which would conventionally mean a different resource.) |
||
|
||
const resp = await requestStoryBackend(`/groups/${getStoriesGroupId()}/stories${route}`, 'GET', { | ||
...tokens | ||
}); | ||
if (!resp) { | ||
|
@@ -124,10 +138,12 @@ export const updateStory = async ( | |
id: number, | ||
title: string, | ||
content: string, | ||
pinOrder: number | null | ||
pinOrder: number | null, | ||
status: StoryStatus, | ||
statusMessage: string | ||
): Promise<StoryView | null> => { | ||
const resp = await requestStoryBackend(`/groups/${getStoriesGroupId()}/stories/${id}`, 'PUT', { | ||
body: { title, content, pinOrder }, | ||
body: { title, content, pinOrder, status, statusMessage }, | ||
...tokens | ||
}); | ||
if (!resp) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This design doesn't look right to me. To the user/the frontend, the "listing" of stories should be transparent.
In other words, the FE just makes one "list stories" query, and the backend returns a list of stories that the user has access to. The permissions/different types of stories should be transparent and the frontend can subsequently later filter the story by the status. You are adding a status field inside the story model in the backend but it's not being utilised here at all.