mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 03:07:52 +01:00
Add some header settings (#199)
* Add show_roadmap_in_header setting * Add collapse_boards_in_header setting (thanks @josh-bitovi)
This commit is contained in:
committed by
GitHub
parent
e7335f5622
commit
b2e9031ed6
@@ -11,6 +11,8 @@ import {
|
|||||||
TENANT_SETTING_BRAND_DISPLAY_NAME_ONLY,
|
TENANT_SETTING_BRAND_DISPLAY_NAME_ONLY,
|
||||||
TENANT_SETTING_BRAND_DISPLAY_LOGO_ONLY,
|
TENANT_SETTING_BRAND_DISPLAY_LOGO_ONLY,
|
||||||
TENANT_SETTING_BRAND_DISPLAY_NONE,
|
TENANT_SETTING_BRAND_DISPLAY_NONE,
|
||||||
|
TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_NO_COLLAPSE,
|
||||||
|
TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_ALWAYS_COLLAPSE,
|
||||||
} from '../../../interfaces/ITenantSetting';
|
} from '../../../interfaces/ITenantSetting';
|
||||||
import { DangerText, SmallMutedText } from '../../common/CustomTexts';
|
import { DangerText, SmallMutedText } from '../../common/CustomTexts';
|
||||||
import { getLabel, getValidationMessage } from '../../../helpers/formUtils';
|
import { getLabel, getValidationMessage } from '../../../helpers/formUtils';
|
||||||
@@ -24,6 +26,8 @@ export interface ISiteSettingsGeneralForm {
|
|||||||
showVoteCount: boolean;
|
showVoteCount: boolean;
|
||||||
showVoteButtonInBoard: boolean;
|
showVoteButtonInBoard: boolean;
|
||||||
rootBoardId?: string;
|
rootBoardId?: string;
|
||||||
|
showRoadmapInHeader: boolean;
|
||||||
|
collapseBoardsInHeader: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -40,6 +44,8 @@ interface Props {
|
|||||||
brandDisplaySetting: string,
|
brandDisplaySetting: string,
|
||||||
locale: string,
|
locale: string,
|
||||||
rootBoardId: number,
|
rootBoardId: number,
|
||||||
|
showRoadmapInHeader: boolean,
|
||||||
|
collapseBoardsInHeader: string,
|
||||||
showVoteCount: boolean,
|
showVoteCount: boolean,
|
||||||
showVoteButtonInBoard: boolean,
|
showVoteButtonInBoard: boolean,
|
||||||
authenticityToken: string
|
authenticityToken: string
|
||||||
@@ -68,6 +74,8 @@ const GeneralSiteSettingsP = ({
|
|||||||
showVoteCount: originForm.showVoteCount,
|
showVoteCount: originForm.showVoteCount,
|
||||||
showVoteButtonInBoard: originForm.showVoteButtonInBoard,
|
showVoteButtonInBoard: originForm.showVoteButtonInBoard,
|
||||||
rootBoardId: originForm.rootBoardId,
|
rootBoardId: originForm.rootBoardId,
|
||||||
|
showRoadmapInHeader: originForm.showRoadmapInHeader,
|
||||||
|
collapseBoardsInHeader: originForm.collapseBoardsInHeader,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -78,9 +86,11 @@ const GeneralSiteSettingsP = ({
|
|||||||
data.brandDisplaySetting,
|
data.brandDisplaySetting,
|
||||||
data.locale,
|
data.locale,
|
||||||
Number(data.rootBoardId),
|
Number(data.rootBoardId),
|
||||||
|
data.showRoadmapInHeader,
|
||||||
|
data.collapseBoardsInHeader,
|
||||||
data.showVoteCount,
|
data.showVoteCount,
|
||||||
data.showVoteButtonInBoard,
|
data.showVoteButtonInBoard,
|
||||||
authenticityToken,
|
authenticityToken
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (res?.status !== HttpStatus.OK) return;
|
if (res?.status !== HttpStatus.OK) return;
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -170,6 +180,34 @@ const GeneralSiteSettingsP = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
<h4>{ I18n.t('site_settings.general.subtitle_header') }</h4>
|
||||||
|
|
||||||
|
<div className="formGroup">
|
||||||
|
<div className="checkboxSwitch">
|
||||||
|
<input {...register('showRoadmapInHeader')} type="checkbox" id="show_roadmap_in_header" />
|
||||||
|
<label htmlFor="show_roadmap_in_header">{ getLabel('tenant_setting', 'show_roadmap_in_header') }</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<div className="formGroup">
|
||||||
|
<label htmlFor="collapseBoardsInHeader">{ getLabel('tenant_setting', 'collapse_boards_in_header') }</label>
|
||||||
|
<select
|
||||||
|
{...register('collapseBoardsInHeader')}
|
||||||
|
id="collapseBoardsInHeader"
|
||||||
|
className="selectPicker"
|
||||||
|
>
|
||||||
|
<option value={TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_NO_COLLAPSE}>
|
||||||
|
{ I18n.t('site_settings.general.collapse_boards_in_header_no_collapse') }
|
||||||
|
</option>
|
||||||
|
<option value={TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_ALWAYS_COLLAPSE}>
|
||||||
|
{ I18n.t('site_settings.general.collapse_boards_in_header_always_collapse') }
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<h4>{ I18n.t('site_settings.general.subtitle_visibility') }</h4>
|
||||||
|
|
||||||
<div className="formGroup">
|
<div className="formGroup">
|
||||||
<div className="checkboxSwitch">
|
<div className="checkboxSwitch">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { connect } from "react-redux";
|
|||||||
import GeneralSiteSettingsP from "../components/SiteSettings/General/GeneralSiteSettingsP";
|
import GeneralSiteSettingsP from "../components/SiteSettings/General/GeneralSiteSettingsP";
|
||||||
import { updateTenant } from "../actions/Tenant/updateTenant";
|
import { updateTenant } from "../actions/Tenant/updateTenant";
|
||||||
import { State } from "../reducers/rootReducer";
|
import { State } from "../reducers/rootReducer";
|
||||||
import { TenantSettingBrandDisplay } from "../interfaces/ITenantSetting";
|
import { TenantSettingBrandDisplay, TenantSettingCollapseBoardsInHeader } from "../interfaces/ITenantSetting";
|
||||||
|
|
||||||
const mapStateToProps = (state: State) => ({
|
const mapStateToProps = (state: State) => ({
|
||||||
areUpdating: state.siteSettings.general.areUpdating,
|
areUpdating: state.siteSettings.general.areUpdating,
|
||||||
@@ -17,6 +17,8 @@ const mapDispatchToProps = (dispatch: any) => ({
|
|||||||
brandDisplaySetting: TenantSettingBrandDisplay,
|
brandDisplaySetting: TenantSettingBrandDisplay,
|
||||||
locale: string,
|
locale: string,
|
||||||
rootBoardId: number,
|
rootBoardId: number,
|
||||||
|
showRoadmapInHeader: boolean,
|
||||||
|
collapseBoardsInHeader: TenantSettingCollapseBoardsInHeader,
|
||||||
showVoteCount: boolean,
|
showVoteCount: boolean,
|
||||||
showVoteButtonInBoard: boolean,
|
showVoteButtonInBoard: boolean,
|
||||||
authenticityToken: string
|
authenticityToken: string
|
||||||
@@ -29,6 +31,8 @@ const mapDispatchToProps = (dispatch: any) => ({
|
|||||||
show_vote_count: showVoteCount,
|
show_vote_count: showVoteCount,
|
||||||
show_vote_button_in_board: showVoteButtonInBoard,
|
show_vote_button_in_board: showVoteButtonInBoard,
|
||||||
root_board_id: rootBoardId,
|
root_board_id: rootBoardId,
|
||||||
|
show_roadmap_in_header: showRoadmapInHeader,
|
||||||
|
collapse_boards_in_header: collapseBoardsInHeader,
|
||||||
},
|
},
|
||||||
locale,
|
locale,
|
||||||
authenticityToken,
|
authenticityToken,
|
||||||
|
|||||||
@@ -10,11 +10,22 @@ export type TenantSettingBrandDisplay =
|
|||||||
typeof TENANT_SETTING_BRAND_DISPLAY_LOGO_ONLY |
|
typeof TENANT_SETTING_BRAND_DISPLAY_LOGO_ONLY |
|
||||||
typeof TENANT_SETTING_BRAND_DISPLAY_NONE;
|
typeof TENANT_SETTING_BRAND_DISPLAY_NONE;
|
||||||
|
|
||||||
|
// Collapse boards in header
|
||||||
|
export const TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_NO_COLLAPSE = 'no_collapse';
|
||||||
|
export const TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_ALWAYS_COLLAPSE = 'always_collapse';
|
||||||
|
|
||||||
|
export type TenantSettingCollapseBoardsInHeader =
|
||||||
|
typeof TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_NO_COLLAPSE |
|
||||||
|
typeof TENANT_SETTING_COLLAPSE_BOARDS_IN_HEADER_ALWAYS_COLLAPSE;
|
||||||
|
|
||||||
|
|
||||||
interface ITenantSetting {
|
interface ITenantSetting {
|
||||||
brand_display?: TenantSettingBrandDisplay;
|
brand_display?: TenantSettingBrandDisplay;
|
||||||
root_board_id?: number;
|
root_board_id?: number;
|
||||||
show_vote_count?: boolean;
|
show_vote_count?: boolean;
|
||||||
show_vote_button_in_board?: boolean;
|
show_vote_button_in_board?: boolean;
|
||||||
|
show_roadmap_in_header?: boolean;
|
||||||
|
collapse_boards_in_header?: TenantSettingCollapseBoardsInHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ITenantSetting;
|
export default ITenantSetting;
|
||||||
@@ -9,4 +9,9 @@ class TenantSetting < ApplicationRecord
|
|||||||
:logo_only,
|
:logo_only,
|
||||||
:no_name_no_logo
|
:no_name_no_logo
|
||||||
]
|
]
|
||||||
|
|
||||||
|
enum collapse_boards_in_header: [
|
||||||
|
:no_collapse,
|
||||||
|
:always_collapse
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
class TenantSettingPolicy < ApplicationPolicy
|
class TenantSettingPolicy < ApplicationPolicy
|
||||||
def permitted_attributes_for_update
|
def permitted_attributes_for_update
|
||||||
if user.admin?
|
if user.admin?
|
||||||
[:brand_display, :root_board_id, :show_vote_count, :show_vote_button_in_board]
|
[
|
||||||
|
:brand_display,
|
||||||
|
:root_board_id,
|
||||||
|
:show_vote_count,
|
||||||
|
:show_vote_button_in_board,
|
||||||
|
:show_roadmap_in_header,
|
||||||
|
:collapse_boards_in_header
|
||||||
|
]
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
<% boards.each do |board| %>
|
<% if @tenant_setting.collapse_boards_in_header == 'always_collapse' %>
|
||||||
<li class="nav-item<%= board.id == @board.id ? ' active' : '' unless @board.nil? %>">
|
<li class="navbar-nav nav-item dropdown">
|
||||||
<%= link_to board.name, board_path(board), class: 'nav-link' %>
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
</li>
|
Boards
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<% boards.each do |board| %>
|
||||||
|
<li>
|
||||||
|
<%= link_to board.name, board_path(board), class: 'dropdown-item py-2' %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% else %>
|
||||||
|
<% boards.each do |board| %>
|
||||||
|
<li class="nav-item<%= board.id == @board.id ? ' active' : '' unless @board.nil? %>">
|
||||||
|
<%= link_to board.name, board_path(board), class: 'nav-link' %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -29,6 +29,12 @@
|
|||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="boardsNav">
|
<ul class="boardsNav">
|
||||||
|
<% if @tenant_setting.show_roadmap_in_header %>
|
||||||
|
<li class="nav-item<%= current_page?(roadmap_path) ? ' active' : '' %>">
|
||||||
|
<%= link_to "Roadmap", roadmap_path, class: 'nav-link' %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= render 'layouts/boards_nav_section', boards: @boards unless @boards.nil? %>
|
<%= render 'layouts/boards_nav_section', boards: @boards unless @boards.nil? %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
showVoteCount: @tenant_setting.show_vote_count,
|
showVoteCount: @tenant_setting.show_vote_count,
|
||||||
showVoteButtonInBoard: @tenant_setting.show_vote_button_in_board,
|
showVoteButtonInBoard: @tenant_setting.show_vote_button_in_board,
|
||||||
rootBoardId: @tenant_setting.root_board_id.to_s,
|
rootBoardId: @tenant_setting.root_board_id.to_s,
|
||||||
|
showRoadmapInHeader: @tenant_setting.show_roadmap_in_header,
|
||||||
|
collapseBoardsInHeader: @tenant_setting.collapse_boards_in_header,
|
||||||
locale: @tenant.locale
|
locale: @tenant.locale
|
||||||
},
|
},
|
||||||
boards: @tenant.boards.order(order: :asc),
|
boards: @tenant.boards.order(order: :asc),
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ en:
|
|||||||
show_vote_count: 'Show vote count to users'
|
show_vote_count: 'Show vote count to users'
|
||||||
show_vote_button_in_board: 'Show vote buttons in board page'
|
show_vote_button_in_board: 'Show vote buttons in board page'
|
||||||
root_board_id: 'Root page'
|
root_board_id: 'Root page'
|
||||||
|
show_roadmap_in_header: 'Show roadmap link in header'
|
||||||
|
collapse_boards_in_header: 'Collapse boards in header'
|
||||||
user:
|
user:
|
||||||
email: 'Email'
|
email: 'Email'
|
||||||
full_name: 'Full name'
|
full_name: 'Full name'
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ en:
|
|||||||
brand_setting_name: 'Name only'
|
brand_setting_name: 'Name only'
|
||||||
brand_setting_logo: 'Logo only'
|
brand_setting_logo: 'Logo only'
|
||||||
brand_setting_none: 'None'
|
brand_setting_none: 'None'
|
||||||
|
subtitle_header: 'Header'
|
||||||
|
collapse_boards_in_header_no_collapse: 'Never'
|
||||||
|
collapse_boards_in_header_always_collapse: 'Always'
|
||||||
|
subtitle_visibility: 'Visibility'
|
||||||
show_vote_count_help: 'If you enable this setting, users will be able to see the vote count of posts. This may incentivize users to vote on already popular posts, leading to a snowball effect.'
|
show_vote_count_help: 'If you enable this setting, users will be able to see the vote count of posts. This may incentivize users to vote on already popular posts, leading to a snowball effect.'
|
||||||
show_vote_button_in_board_help: 'If you enable this setting, users will be able to vote posts from the board page. This may incentivize users to vote on more posts, leading to a higher number of votes but of lower significance.'
|
show_vote_button_in_board_help: 'If you enable this setting, users will be able to vote posts from the board page. This may incentivize users to vote on more posts, leading to a higher number of votes but of lower significance.'
|
||||||
boards:
|
boards:
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddShowRoadmapInHeaderToTenantSettings < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :tenant_settings, :show_roadmap_in_header, :boolean, null: false, default: true
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddCollapseBoardsInHeaderToTenantSettings < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :tenant_settings, :collapse_boards_in_header, :integer, null: false, default: 0
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_02_04_171748) do
|
ActiveRecord::Schema.define(version: 2023_02_11_095500) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -132,6 +132,8 @@ ActiveRecord::Schema.define(version: 2023_02_04_171748) do
|
|||||||
t.boolean "show_vote_count", default: false, null: false
|
t.boolean "show_vote_count", default: false, null: false
|
||||||
t.boolean "show_vote_button_in_board", default: false, null: false
|
t.boolean "show_vote_button_in_board", default: false, null: false
|
||||||
t.integer "root_board_id", default: 0, null: false
|
t.integer "root_board_id", default: 0, null: false
|
||||||
|
t.boolean "show_roadmap_in_header", default: true, null: false
|
||||||
|
t.integer "collapse_boards_in_header", default: 0, null: false
|
||||||
t.index ["tenant_id"], name: "index_tenant_settings_on_tenant_id"
|
t.index ["tenant_id"], name: "index_tenant_settings_on_tenant_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -31,4 +31,15 @@ RSpec.describe TenantSetting, type: :model do
|
|||||||
it 'has a setting that contains the board id of the root page' do
|
it 'has a setting that contains the board id of the root page' do
|
||||||
expect(tenant_setting.root_board_id).to eq(0)
|
expect(tenant_setting.root_board_id).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has a setting to show/hide roadmap link in header' do
|
||||||
|
expect(tenant_setting.show_roadmap_in_header).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has a setting to collapse boards in header' do
|
||||||
|
expect(tenant_setting.collapse_boards_in_header).to eq('no_collapse')
|
||||||
|
|
||||||
|
tenant_setting.collapse_boards_in_header = 'always_collapse'
|
||||||
|
expect(tenant_setting).to be_valid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user