diff --git a/app/assets/stylesheets/components/SiteSettings/General/index.scss b/app/assets/stylesheets/components/SiteSettings/General/index.scss index 44af6972..9fa66485 100644 --- a/app/assets/stylesheets/components/SiteSettings/General/index.scss +++ b/app/assets/stylesheets/components/SiteSettings/General/index.scss @@ -4,4 +4,8 @@ scroll-margin-top: 96px; } + + .generalSiteSettingsSubmit { + @extend .mb-4; + } } \ No newline at end of file diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index bc192d93..c59f97c4 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -1,5 +1,6 @@ class BoardsController < ApplicationController include ApplicationHelper + include BoardsHelper before_action :authenticate_user!, only: [:create, :update, :update_order, :destroy] @@ -12,6 +13,7 @@ class BoardsController < ApplicationController def show @board = Board.friendly.find(params[:id]) @page_title = @board.name + @post_statuses_to_show_in_filter = get_post_statuses_to_show_in_filter end def create diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 2b1d5cf6..323119ad 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -1,4 +1,6 @@ class StaticPagesController < ApplicationController + include BoardsHelper + skip_before_action :load_tenant_data, only: [:showcase, :pending_tenant, :blocked_tenant] before_action :allow_iframe_embedding, only: [:embedded_roadmap] @@ -7,6 +9,7 @@ class StaticPagesController < ApplicationController if @board @page_title = @board.name + @post_statuses_to_show_in_filter = get_post_statuses_to_show_in_filter render 'boards/show' else @page_title = t('roadmap.title') diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb new file mode 100644 index 00000000..a35718e1 --- /dev/null +++ b/app/helpers/boards_helper.rb @@ -0,0 +1,9 @@ +module BoardsHelper + def get_post_statuses_to_show_in_filter + if Current.tenant.tenant_setting.hide_unused_statuses_in_filter_by_status + @board.posts.map(&:post_status_id).uniq + else + PostStatus.pluck(:id) << nil + end + end +end \ No newline at end of file diff --git a/app/javascript/components/Board/BoardP.tsx b/app/javascript/components/Board/BoardP.tsx index 89f90a88..9777b2ea 100644 --- a/app/javascript/components/Board/BoardP.tsx +++ b/app/javascript/components/Board/BoardP.tsx @@ -23,6 +23,7 @@ interface Props { currentUserFullName: string; tenantSetting: ITenantSetting; componentRenderedAt: number; + postStatusesToShowInFilter: Array; authenticityToken: string; posts: PostsState; postStatuses: PostStatusesState; @@ -96,6 +97,7 @@ class BoardP extends React.Component { currentUserFullName, tenantSetting, componentRenderedAt, + postStatusesToShowInFilter, authenticityToken, posts, postStatuses, @@ -140,14 +142,19 @@ class BoardP extends React.Component { /> } - 0 && + postStatusesToShowInFilter.includes(postStatus.id))} + areLoading={postStatuses.areLoading} + error={postStatuses.error} - currentFilter={filters.postStatusIds} - handleFilterClick={handlePostStatusFilterChange} - /> + currentFilter={filters.postStatusIds} + handleFilterClick={handlePostStatusFilterChange} + + showNoStatusFilter={postStatusesToShowInFilter.includes(null)} + /> + } { tenantSetting.show_powered_by && } diff --git a/app/javascript/components/Board/PostStatusFilter.tsx b/app/javascript/components/Board/PostStatusFilter.tsx index 3c92f308..f955de81 100644 --- a/app/javascript/components/Board/PostStatusFilter.tsx +++ b/app/javascript/components/Board/PostStatusFilter.tsx @@ -15,6 +15,8 @@ interface Props { handleFilterClick(postStatusId: number): void; currentFilter: Array; + + showNoStatusFilter?: boolean; } const PostStatusFilter = ({ @@ -24,6 +26,8 @@ const PostStatusFilter = ({ handleFilterClick, currentFilter, + + showNoStatusFilter = true, }: Props) => ( { @@ -39,13 +43,18 @@ const PostStatusFilter = ({ /> )) } - handleFilterClick(0)} - isCurrentFilter={currentFilter.includes(0)} - /> + { + showNoStatusFilter && + handleFilterClick(0)} + isCurrentFilter={currentFilter.includes(0)} + /> + } + { areLoading ? : null } { error ? {error} : null } diff --git a/app/javascript/components/Board/index.tsx b/app/javascript/components/Board/index.tsx index 132a890c..73b32489 100644 --- a/app/javascript/components/Board/index.tsx +++ b/app/javascript/components/Board/index.tsx @@ -17,6 +17,7 @@ interface Props { currentUserFullName: string; tenantSetting: ITenantSetting; componentRenderedAt: number; + postStatusesToShowInFilter: Array; authenticityToken: string; } @@ -37,6 +38,7 @@ class BoardRoot extends React.Component { currentUserFullName, tenantSetting, componentRenderedAt, + postStatusesToShowInFilter, authenticityToken, } = this.props; @@ -49,6 +51,7 @@ class BoardRoot extends React.Component { currentUserFullName={currentUserFullName} tenantSetting={tenantSetting} componentRenderedAt={componentRenderedAt} + postStatusesToShowInFilter={postStatusesToShowInFilter} authenticityToken={authenticityToken} /> diff --git a/app/javascript/components/SiteSettings/General/GeneralSiteSettingsP.tsx b/app/javascript/components/SiteSettings/General/GeneralSiteSettingsP.tsx index b4ad7971..98fdfc87 100644 --- a/app/javascript/components/SiteSettings/General/GeneralSiteSettingsP.tsx +++ b/app/javascript/components/SiteSettings/General/GeneralSiteSettingsP.tsx @@ -40,6 +40,7 @@ export interface ISiteSettingsGeneralForm { collapseBoardsInHeader: string; showVoteCount: boolean; showVoteButtonInBoard: boolean; + hideUnusedStatusesInFilterByStatus: boolean; showPoweredBy: boolean; } @@ -69,6 +70,7 @@ interface Props { collapseBoardsInHeader: string, showVoteCount: boolean, showVoteButtonInBoard: boolean, + hideUnusedStatusesInFilterByStatus: boolean, showPoweredBy: boolean, authenticityToken: string ): Promise; @@ -107,6 +109,7 @@ const GeneralSiteSettingsP = ({ collapseBoardsInHeader: originForm.collapseBoardsInHeader, showVoteCount: originForm.showVoteCount, showVoteButtonInBoard: originForm.showVoteButtonInBoard, + hideUnusedStatusesInFilterByStatus: originForm.hideUnusedStatusesInFilterByStatus, showPoweredBy: originForm.showPoweredBy, }, }); @@ -129,6 +132,7 @@ const GeneralSiteSettingsP = ({ data.collapseBoardsInHeader, data.showVoteCount, data.showVoteButtonInBoard, + data.hideUnusedStatusesInFilterByStatus, data.showPoweredBy, authenticityToken ).then(res => { @@ -344,7 +348,7 @@ const GeneralSiteSettingsP = ({ className="selectPicker" >