Add "powered by Astuto" (#298)

This commit is contained in:
Riccardo Graziosi
2024-02-27 18:32:14 +01:00
committed by GitHub
parent ea694508bb
commit a700c07394
15 changed files with 72 additions and 7 deletions

View File

@@ -281,4 +281,14 @@ body {
.staffIcon {
font-size: 24px;
margin: 0 4px;
}
.poweredBy {
@include media-breakpoint-down(sm) { display: none; }
text-align: center;
font-size: 15px;
a { color: var(--astuto-grey); }
a:hover { text-decoration: underline; }
}

View File

@@ -5,15 +5,16 @@ import SearchFilter from './SearchFilter';
import PostStatusFilter from './PostStatusFilter';
import PostList from './PostList';
import Sidebar from '../common/Sidebar';
import SortByFilter from './SortByFilter';
import DateFilter from './DateFilter';
import PoweredByLink from '../common/PoweredByLink';
import IBoard from '../../interfaces/IBoard';
import ITenantSetting from '../../interfaces/ITenantSetting';
import { PostsState } from '../../reducers/postsReducer';
import { PostStatusesState } from '../../reducers/postStatusesReducer';
import SortByFilter from './SortByFilter';
import { SortByFilterValues } from '../../actions/changeFilters';
import DateFilter from './DateFilter';
interface Props {
board: IBoard;
@@ -138,6 +139,8 @@ class BoardP extends React.Component<Props> {
currentFilter={filters.postStatusIds}
handleFilterClick={handlePostStatusFilterChange}
/>
{ tenantSetting.show_powered_by && <PoweredByLink /> }
</Sidebar>
<PostList

View File

@@ -16,6 +16,7 @@ import PostBoardLabel from '../common/PostBoardLabel';
import PostStatusLabel from '../common/PostStatusLabel';
import Comments from '../../containers/Comments';
import Sidebar from '../common/Sidebar';
import PoweredByLink from '../common/PoweredByLink';
import { LikesState } from '../../reducers/likesReducer';
import { CommentsState } from '../../reducers/commentsReducer';
@@ -194,6 +195,8 @@ class PostP extends React.Component<Props> {
isLoggedIn={isLoggedIn}
/>
{ tenantSetting.show_powered_by && <PoweredByLink /> }
</Sidebar>
<div className="postAndCommentsContainer">

View File

@@ -25,6 +25,7 @@ export interface ISiteSettingsGeneralForm {
locale: string;
showVoteCount: boolean;
showVoteButtonInBoard: boolean;
showPoweredBy: boolean;
rootBoardId?: string;
showRoadmapInHeader: boolean;
collapseBoardsInHeader: string;
@@ -48,6 +49,7 @@ interface Props {
collapseBoardsInHeader: string,
showVoteCount: boolean,
showVoteButtonInBoard: boolean,
showPoweredBy: boolean,
authenticityToken: string
): Promise<any>;
}
@@ -73,6 +75,7 @@ const GeneralSiteSettingsP = ({
locale: originForm.locale,
showVoteCount: originForm.showVoteCount,
showVoteButtonInBoard: originForm.showVoteButtonInBoard,
showPoweredBy: originForm.showPoweredBy,
rootBoardId: originForm.rootBoardId,
showRoadmapInHeader: originForm.showRoadmapInHeader,
collapseBoardsInHeader: originForm.collapseBoardsInHeader,
@@ -90,6 +93,7 @@ const GeneralSiteSettingsP = ({
data.collapseBoardsInHeader,
data.showVoteCount,
data.showVoteButtonInBoard,
data.showPoweredBy,
authenticityToken
).then(res => {
if (res?.status !== HttpStatus.OK) return;
@@ -235,6 +239,15 @@ const GeneralSiteSettingsP = ({
<br />
<div className="formGroup">
<div className="checkboxSwitch">
<input {...register('showPoweredBy')} type="checkbox" id="show_powered_by_checkbox" />
<label htmlFor="show_powered_by_checkbox">{ getLabel('tenant_setting', 'show_powered_by') }</label>
</div>
</div>
<br />
<Button onClick={() => null} disabled={!isDirty}>
{I18n.t('common.buttons.update')}
</Button>

View File

@@ -0,0 +1,12 @@
import * as React from 'react';
import I18n from 'i18n-js';
const PoweredByLink = () => (
<div className="poweredBy">
<a href="http://astuto.io/?utm_campaign=poweredby" target="_blank">
{ I18n.t('common.powered_by') } Astuto
</a>
</div>
);
export default PoweredByLink;

View File

@@ -21,6 +21,7 @@ const mapDispatchToProps = (dispatch: any) => ({
collapseBoardsInHeader: TenantSettingCollapseBoardsInHeader,
showVoteCount: boolean,
showVoteButtonInBoard: boolean,
showPoweredBy: boolean,
authenticityToken: string
): Promise<any> {
return dispatch(updateTenant({
@@ -30,6 +31,7 @@ const mapDispatchToProps = (dispatch: any) => ({
brand_display: brandDisplaySetting,
show_vote_count: showVoteCount,
show_vote_button_in_board: showVoteButtonInBoard,
show_powered_by: showPoweredBy,
root_board_id: rootBoardId,
show_roadmap_in_header: showRoadmapInHeader,
collapse_boards_in_header: collapseBoardsInHeader,

View File

@@ -25,6 +25,7 @@ interface ITenantSetting {
show_vote_count?: boolean;
show_vote_button_in_board?: boolean;
show_roadmap_in_header?: boolean;
show_powered_by?: boolean;
collapse_boards_in_header?: TenantSettingCollapseBoardsInHeader;
custom_css?: string;
}

View File

@@ -6,6 +6,7 @@ class TenantSettingPolicy < ApplicationPolicy
:root_board_id,
:show_vote_count,
:show_vote_button_in_board,
:show_powered_by,
:show_roadmap_in_header,
:collapse_boards_in_header,
:custom_css

View File

@@ -11,6 +11,7 @@
brandDisplaySetting: @tenant_setting.brand_display,
showVoteCount: @tenant_setting.show_vote_count,
showVoteButtonInBoard: @tenant_setting.show_vote_button_in_board,
showPoweredBy: @tenant_setting.show_powered_by,
rootBoardId: @tenant_setting.root_board_id.to_s,
showRoadmapInHeader: @tenant_setting.show_roadmap_in_header,
collapseBoardsInHeader: @tenant_setting.collapse_boards_in_header,

View File

@@ -118,6 +118,7 @@ en:
brand_display: 'Display'
show_vote_count: 'Show vote count to users'
show_vote_button_in_board: 'Show vote buttons in board page'
show_powered_by: 'Show "Powered by Astuto"'
root_board_id: 'Root page'
show_roadmap_in_header: 'Show roadmap link in header'
collapse_boards_in_header: 'Collapse boards in header'

View File

@@ -45,6 +45,7 @@ en:
disabled: 'Disabled'
copied: 'Copied!'
user_staff: 'Staff'
powered_by: 'Powered by'
buttons:
new: 'New'
edit: 'Edit'

View File

@@ -0,0 +1,5 @@
class AddShowPoweredByToTenantSetting < ActiveRecord::Migration[6.1]
def change
add_column :tenant_settings, :show_powered_by, :boolean, null: false, default: false
end
end

View File

@@ -0,0 +1,7 @@
class ChangeDefaultTenantSettings < ActiveRecord::Migration[6.1]
def change
change_column_default :tenant_settings, :show_vote_count, true
change_column_default :tenant_settings, :show_vote_button_in_board, true
change_column_default :tenant_settings, :show_powered_by, true
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2024_01_23_125448) do
ActiveRecord::Schema.define(version: 2024_02_27_110058) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -129,12 +129,13 @@ ActiveRecord::Schema.define(version: 2024_01_23_125448) do
t.bigint "tenant_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, 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_count", default: true, null: false
t.boolean "show_vote_button_in_board", default: true, 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.text "custom_css"
t.boolean "show_powered_by", default: true, null: false
t.index ["tenant_id"], name: "index_tenant_settings_on_tenant_id"
end

View File

@@ -21,11 +21,15 @@ RSpec.describe TenantSetting, type: :model do
end
it 'has a setting to show vote count' do
expect(tenant_setting.show_vote_count).to be_falsy
expect(tenant_setting.show_vote_count).to be_truthy
end
it 'has a setting to show vote button in board view' do
expect(tenant_setting.show_vote_button_in_board).to be_falsy
expect(tenant_setting.show_vote_button_in_board).to be_truthy
end
it 'has a setting to show powered by astuto' do
expect(tenant_setting.show_powered_by).to be_truthy
end
it 'has a setting that contains the board id of the root page' do