Add roadmap management to Site settings (#123)

This commit is contained in:
Riccardo Graziosi
2022-06-12 15:22:06 +02:00
committed by GitHub
parent db674eaf6a
commit e2065b2c5e
31 changed files with 495 additions and 60 deletions

View File

@@ -1,7 +1,7 @@
import { Action } from 'redux';
import { ThunkAction } from 'redux-thunk';
import IPostStatus from '../../interfaces/IPostStatus';
import IPostStatusJSON from '../../interfaces/json/IPostStatus';
import { State } from '../../reducers/rootReducer';
@@ -13,7 +13,7 @@ interface PostStatusesRequestStartAction {
export const POST_STATUSES_REQUEST_SUCCESS = 'POST_STATUSES_REQUEST_SUCCESS';
interface PostStatusesRequestSuccessAction {
type: typeof POST_STATUSES_REQUEST_SUCCESS;
postStatuses: Array<IPostStatus>;
postStatuses: Array<IPostStatusJSON>;
}
export const POST_STATUSES_REQUEST_FAILURE = 'POST_STATUSES_REQUEST_FAILURE';
@@ -33,7 +33,7 @@ const postStatusesRequestStart = (): PostStatusesRequestActionTypes => ({
});
const postStatusesRequestSuccess = (
postStatuses: Array<IPostStatus>
postStatuses: Array<IPostStatusJSON>
): PostStatusesRequestActionTypes => ({
type: POST_STATUSES_REQUEST_SUCCESS,
postStatuses,

View File

@@ -43,24 +43,34 @@ const postStatusUpdateFailure = (error: string): PostStatusUpdateFailureAction =
error,
});
export const updatePostStatus = (
id: number,
name: string,
color: string,
authenticityToken: string,
): ThunkAction<void, State, null, Action<string>> => async (dispatch) => {
interface UpdatePostStatusParams {
id: number;
name?: string;
color?: string;
showInRoadmap?: boolean;
authenticityToken: string;
}
export const updatePostStatus = ({
id,
name = null,
color = null,
showInRoadmap = null,
authenticityToken,
}: UpdatePostStatusParams): ThunkAction<void, State, null, Action<string>> => async (dispatch) => {
dispatch(postStatusUpdateStart());
const post_status = Object.assign({},
name !== null ? {name} : null,
color !== null ? {color} : null,
showInRoadmap !== null ? {show_in_roadmap: showInRoadmap} : null
);
try {
const res = await fetch(`/post_statuses/${id}`, {
method: 'PATCH',
headers: buildRequestHeaders(authenticityToken),
body: JSON.stringify({
post_status: {
name,
color,
},
}),
body: JSON.stringify({post_status}),
});
const json = await res.json();