From e2065b2c5ef72b1e23cffe17fa807795165916d6 Mon Sep 17 00:00:00 2001 From: Riccardo Graziosi <31478034+riggraz@users.noreply.github.com> Date: Sun, 12 Jun 2022 15:22:06 +0200 Subject: [PATCH] Add roadmap management to Site settings (#123) --- app/controllers/post_statuses_controller.rb | 2 +- app/controllers/site_settings_controller.rb | 3 + .../actions/PostStatus/requestPostStatuses.ts | 6 +- .../actions/PostStatus/updatePostStatus.ts | 34 ++-- .../components/Comments/Comment.tsx | 4 +- .../components/Comments/CommentList.tsx | 4 +- .../components/Comments/NewComment.tsx | 8 +- .../components/Post/PostUpdateList.tsx | 4 +- .../SiteSettings/Boards/BoardEditable.tsx | 8 +- .../Boards/BoardsSiteSettingsP.tsx | 8 +- .../PostStatuses/PostStatusEditable.tsx | 11 +- .../PostStatusesSiteSettingsP.tsx | 24 +-- .../Roadmap/RoadmapPostStatus.tsx | 40 +++++ .../Roadmap/RoadmapSiteSettingsP.tsx | 167 ++++++++++++++++++ .../components/SiteSettings/Roadmap/index.tsx | 33 ++++ app/javascript/components/common/DragZone.tsx | 4 +- .../containers/PostStatusesSiteSettings.tsx | 2 +- .../containers/RoadmapSiteSettings.tsx | 30 ++++ app/javascript/interfaces/IPostStatus.ts | 2 + app/javascript/interfaces/json/IPostStatus.ts | 2 + .../reducers/SiteSettings/roadmapReducer.ts | 48 +++++ .../reducers/postStatusesReducer.ts | 9 +- .../reducers/siteSettingsReducer.ts | 17 +- .../SiteSettings/Roadmap/index.scss | 52 ++++++ .../stylesheets/icons/drag_icon.scss | 5 + app/javascript/stylesheets/main.scss | 1 + app/views/site_settings/_menu.html.erb | 1 + app/views/site_settings/roadmap.html.erb | 13 ++ config/locales/en.yml | 6 + config/locales/it.yml | 6 + config/routes.rb | 1 + 31 files changed, 495 insertions(+), 60 deletions(-) create mode 100644 app/javascript/components/SiteSettings/Roadmap/RoadmapPostStatus.tsx create mode 100644 app/javascript/components/SiteSettings/Roadmap/RoadmapSiteSettingsP.tsx create mode 100644 app/javascript/components/SiteSettings/Roadmap/index.tsx create mode 100644 app/javascript/containers/RoadmapSiteSettings.tsx create mode 100644 app/javascript/reducers/SiteSettings/roadmapReducer.ts create mode 100644 app/javascript/stylesheets/components/SiteSettings/Roadmap/index.scss create mode 100644 app/views/site_settings/roadmap.html.erb diff --git a/app/controllers/post_statuses_controller.rb b/app/controllers/post_statuses_controller.rb index 1f245171..7a027c38 100644 --- a/app/controllers/post_statuses_controller.rb +++ b/app/controllers/post_statuses_controller.rb @@ -75,6 +75,6 @@ class PostStatusesController < ApplicationController def post_status_params params .require(:post_status) - .permit(:name, :color) + .permit(:name, :color, :show_in_roadmap) end end diff --git a/app/controllers/site_settings_controller.rb b/app/controllers/site_settings_controller.rb index a6987fcf..1b0b2240 100644 --- a/app/controllers/site_settings_controller.rb +++ b/app/controllers/site_settings_controller.rb @@ -11,4 +11,7 @@ class SiteSettingsController < ApplicationController def post_statuses end + + def roadmap + end end \ No newline at end of file diff --git a/app/javascript/actions/PostStatus/requestPostStatuses.ts b/app/javascript/actions/PostStatus/requestPostStatuses.ts index 21c2eafb..e4e368c1 100644 --- a/app/javascript/actions/PostStatus/requestPostStatuses.ts +++ b/app/javascript/actions/PostStatus/requestPostStatuses.ts @@ -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; + postStatuses: Array; } export const POST_STATUSES_REQUEST_FAILURE = 'POST_STATUSES_REQUEST_FAILURE'; @@ -33,7 +33,7 @@ const postStatusesRequestStart = (): PostStatusesRequestActionTypes => ({ }); const postStatusesRequestSuccess = ( - postStatuses: Array + postStatuses: Array ): PostStatusesRequestActionTypes => ({ type: POST_STATUSES_REQUEST_SUCCESS, postStatuses, diff --git a/app/javascript/actions/PostStatus/updatePostStatus.ts b/app/javascript/actions/PostStatus/updatePostStatus.ts index eef66475..6f21f7dc 100644 --- a/app/javascript/actions/PostStatus/updatePostStatus.ts +++ b/app/javascript/actions/PostStatus/updatePostStatus.ts @@ -43,24 +43,34 @@ const postStatusUpdateFailure = (error: string): PostStatusUpdateFailureAction = error, }); -export const updatePostStatus = ( - id: number, - name: string, - color: string, - authenticityToken: string, -): ThunkAction> => 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> => 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(); diff --git a/app/javascript/components/Comments/Comment.tsx b/app/javascript/components/Comments/Comment.tsx index 1443f1b6..194d5937 100644 --- a/app/javascript/components/Comments/Comment.tsx +++ b/app/javascript/components/Comments/Comment.tsx @@ -81,7 +81,7 @@ const Comment = ({ { isPowerUser ? - + <> handleToggleIsCommentUpdate(id, isPostUpdate)} @@ -103,7 +103,7 @@ const Comment = ({ {I18n.t('common.buttons.delete')} - + : null } diff --git a/app/javascript/components/Comments/CommentList.tsx b/app/javascript/components/Comments/CommentList.tsx index 5568e7c5..e0b081de 100644 --- a/app/javascript/components/Comments/CommentList.tsx +++ b/app/javascript/components/Comments/CommentList.tsx @@ -36,7 +36,7 @@ const CommentList = ({ isPowerUser, userEmail, }: Props) => ( - + <> {comments.map((comment, i) => { if (comment.parentId === parentId) { return ( @@ -77,7 +77,7 @@ const CommentList = ({ ); } else return null; })} - + ); export default CommentList; \ No newline at end of file diff --git a/app/javascript/components/Comments/NewComment.tsx b/app/javascript/components/Comments/NewComment.tsx index 07ebea76..0ed13b09 100644 --- a/app/javascript/components/Comments/NewComment.tsx +++ b/app/javascript/components/Comments/NewComment.tsx @@ -41,11 +41,11 @@ const NewComment = ({ isPowerUser, userEmail, }: Props) => ( - + <>
{ isLoggedIn ? - + <>