Skip to content

Commit

Permalink
added HelpCenter to Site Settings (#5594)
Browse files Browse the repository at this point in the history
* added HelpCenter to Site Settings so user can configure their own help center link

* fixed navbar to use non admin useSiteSetting

* removing default help center link to greenlight and hiding nav icon if not set

* added migration for adding help center to setting and site_setting

* fixed rubocop errors for migration

* removed helpcenter migration clash from populate setting and site setting data

* combined HelpCenter migrations for simplicity

---------

Co-authored-by: Ahmad Farhat <[email protected]>
  • Loading branch information
SilentFlameCR and farhatahmad authored Dec 18, 2023
1 parent 5da6789 commit 05b144b
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 9 deletions.
3 changes: 3 additions & 0 deletions app/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
"privacy_policy": "Privacy Policy",
"change_term_links": "Change the terms links that appears at the bottom of the page",
"change_privacy_link": "Change the privacy link that appears at the bottom of the page",
"helpcenter": "Help center",
"change_helpcenter_link": "Change the help center link that appears under the profile dropdown",
"change_url": "Change URL",
"enter_link": "Enter link here"
},
Expand Down Expand Up @@ -398,6 +400,7 @@
"brand_image_updated": "The brand image has been updated.",
"brand_image_deleted": "The brand image has been deleted.",
"privacy_policy_updated": "The privacy policy has been updated.",
"helpcenter_updated": "The help center link has been updated.",
"terms_of_service_updated": "The terms of service have been updated."
},
"recording": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import useSiteSettings from '../../../../hooks/queries/admin/site_settings/useSi

export default function Administration() {
const { t } = useTranslation();
const { data: siteSettings } = useSiteSettings(['Terms', 'PrivacyPolicy']);
const { data: siteSettings } = useSiteSettings(['Terms', 'PrivacyPolicy', 'HelpCenter']);

return (
<>
Expand All @@ -45,6 +45,15 @@ export default function Administration() {
value={siteSettings?.PrivacyPolicy}
/>
</Row>
<Row>
<h6> { t('admin.site_settings.administration.helpcenter') } </h6>
<p className="text-muted"> { t('admin.site_settings.administration.change_helpcenter_link') } </p>
<LinksForm
id="helpForm"
mutation={() => useUpdateSiteSetting('HelpCenter')}
value={siteSettings?.HelpCenter}
/>
</Row>
</>
);
}
28 changes: 20 additions & 8 deletions app/javascript/components/home/NavbarSignedIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ import PropTypes from 'prop-types';
import { ChevronDownIcon } from '@heroicons/react/20/solid';
import useDeleteSession from '../../hooks/mutations/sessions/useDeleteSession';
import Avatar from '../users/user/Avatar';
import useSiteSetting from '../../hooks/queries/site_settings/useSiteSetting';

export default function NavbarSignedIn({ currentUser }) {
const { t } = useTranslation();
const deleteSession = useDeleteSession({ showToast: true });
const { data: helpCenter } = useSiteSetting('HelpCenter');

const adminAccess = () => {
const { permissions } = currentUser;
Expand Down Expand Up @@ -61,10 +63,15 @@ export default function NavbarSignedIn({ currentUser }) {
<IdentificationIcon className="hi-s me-3" />
{t('user.profile.profile')}
</Nav.Link>
<Nav.Link eventKey={2} href="https://docs.bigbluebutton.org/greenlight/v3/install">
<QuestionMarkCircleIcon className="hi-s me-3" />
{t('help_center')}
</Nav.Link>
{
helpCenter
&& (
<Nav.Link eventKey={2} href={helpCenter}>
<QuestionMarkCircleIcon className="hi-s me-3" />
{t('help_center')}
</Nav.Link>
)
}
{
adminAccess()
&& (
Expand Down Expand Up @@ -103,10 +110,15 @@ export default function NavbarSignedIn({ currentUser }) {
<IdentificationIcon className="hi-s me-3" />
{ t('user.profile.profile') }
</NavDropdown.Item>
<NavDropdown.Item href="https://docs.bigbluebutton.org/greenlight/v3/install">
<QuestionMarkCircleIcon className="hi-s me-3" />
{t('help_center')}
</NavDropdown.Item>
{
helpCenter
&& (
<NavDropdown.Item href={helpCenter}>
<QuestionMarkCircleIcon className="hi-s me-3" />
{t('help_center')}
</NavDropdown.Item>
)
}
{
adminAccess()
&& (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export default function useUpdateSiteSetting(name) {
case 'PrivacyPolicy':
toast.success(t('toast.success.site_settings.privacy_policy_updated'));
break;
case 'HelpCenter':
toast.success(t('toast.success.site_settings.helpcenter_updated'));
break;
case 'TermsOfService':
toast.success(t('toast.success.site_settings.terms_of_service_updated'));
break;
Expand Down
1 change: 1 addition & 0 deletions app/services/tenant_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def create_site_settings
provider: @provider },
{ setting: Setting.find_by(name: 'Terms'), value: '', provider: @provider },
{ setting: Setting.find_by(name: 'PrivacyPolicy'), value: '', provider: @provider },
{ setting: Setting.find_by(name: 'HelpCenter'), value: '', provider: @provider },
{ setting: Setting.find_by(name: 'RegistrationMethod'), value: SiteSetting::REGISTRATION_METHODS[:open],
provider: @provider },
{ setting: Setting.find_by(name: 'ShareRooms'), value: 'true', provider: @provider },
Expand Down
20 changes: 20 additions & 0 deletions db/migrate/20231218154727_add_help_center_setting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class AddHelpCenterSetting < ActiveRecord::Migration[7.1]
def up
Setting.create!(name: 'HelpCenter') unless Setting.exists?(name: 'HelpCenter')

return if SiteSetting.exists?(setting: Setting.find_by(name: 'HelpCenter'))

SiteSetting.create!(
setting: Setting.find_by(name: 'HelpCenter'),
value: '',
provider: 'greenlight'
)
end

def down
Setting.find_by(name: 'HelpCenter')&.destroy
SiteSetting.find_by(setting: Setting.find_by(name: 'HelpCenter')).destroy
end
end
1 change: 1 addition & 0 deletions spec/controllers/admin/tenants_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def create_settings_permissions_meetingoptions
Setting.find_or_create_by(name: 'BrandingImage')
Setting.find_or_create_by(name: 'Terms')
Setting.find_or_create_by(name: 'PrivacyPolicy')
Setting.find_or_create_by(name: 'HelpCenter')
Setting.find_or_create_by(name: 'RegistrationMethod')
Setting.find_or_create_by(name: 'ShareRooms')
Setting.find_or_create_by(name: 'PreuploadPresentation')
Expand Down

0 comments on commit 05b144b

Please sign in to comment.