Unverified Commit 2f49ce7f authored by Sudheer's avatar Sudheer Committed by GitHub
Browse files

MM-26620 Add system console setting to disable ask the community link (#5877)

* MM-26609 Create a new single entry point to get help, with a new "Ask Mattermost Community" menu item

 * Add new icon for user guide help
 * Add e2e tests for click and checking hrefs

* Update snapshots

* Address feedback

* Update snapshots

* Update svg placement

* MM-26620 Add system console setting to disable ask the community button

* Update redux hash

* update en.json

* Change case of text

* Update snapshots

* Update snapshots
parent 47dbf165
......@@ -1459,6 +1459,14 @@ const AdminDefinition = {
isDisabled: it.stateIsFalse('TeamSettings.EnableCustomBrand'),
max_length: Constants.MAX_CUSTOM_BRAND_TEXT_LENGTH,
},
{
type: Constants.SettingsTypes.TYPE_BOOL,
key: 'SupportSettings.EnableAskCommunityLink',
label: t('admin.support.enableAskCommunityTitle'),
label_default: 'Enable Ask Community Link:',
help_text: t('admin.support.enableAskCommunityDesc'),
help_text_default: 'When true, "Ask the community" link appears on the Mattermost user interface and Main Menu, which allows users to join the Mattermost Community to ask questions and help others troubleshoot issues. When false, the link is hidden from users.',
},
{
type: Constants.SettingsTypes.TYPE_TEXT,
key: 'SupportSettings.HelpLink',
......
......@@ -77,3 +77,75 @@ exports[`components/channel_header/components/UserGuideDropdown should match sna
</Menu>
</MenuWrapper>
`;
exports[`components/channel_header/components/UserGuideDropdown should match snapshot for false of enableAskCommunityLink 1`] = `
<MenuWrapper
animationComponent={[Function]}
className="userGuideHelp"
onToggle={[Function]}
>
<button
aria-expanded="true"
className="channel-header__icon"
id="channelHeaderUserGuideButton"
type="button"
>
<OverlayTrigger
defaultOverlayShown={false}
delayShow={500}
overlay={
<Tooltip
bsClass="tooltip"
className="hidden-xs"
id="userGuideHelpTooltip"
placement="right"
>
<FormattedMessage
defaultMessage="Help"
id="channel_header.userHelpGuide"
values={Object {}}
/>
</Tooltip>
}
placement="bottom"
trigger={
Array [
"hover",
"focus",
]
}
>
<UserGuideIcon
className="icon"
/>
</OverlayTrigger>
</button>
<Menu
ariaLabel="Add Channel Dropdown"
id="AddChannelDropdown"
openLeft={true}
openUp={false}
>
<MenuGroup>
<MenuItemExternalLink
id="helpResourcesLink"
show={true}
text="Help resources"
url="helpLink"
/>
<MenuItemExternalLink
id="reportAProblemLink"
show={true}
text="Report a problem"
url="reportAProblemLink"
/>
<MenuItemAction
id="keyboardShortcuts"
onClick={[Function]}
show={true}
text="Keyboard shortcuts"
/>
</MenuGroup>
</Menu>
</MenuWrapper>
`;
......@@ -9,10 +9,11 @@ import {GlobalState} from 'types/store';
import UserGuideDropdown from './user_guide_dropdown';
function mapStateToProps(state: GlobalState) {
const {HelpLink, ReportAProblemLink} = getConfig(state);
const {HelpLink, ReportAProblemLink, EnableAskCommunityLink} = getConfig(state);
return {
helpLink: HelpLink!,
reportAProblemLink: ReportAProblemLink!,
enableAskCommunityLink: EnableAskCommunityLink!,
};
}
......
......@@ -18,6 +18,7 @@ describe('components/channel_header/components/UserGuideDropdown', () => {
const baseProps = {
helpLink: 'helpLink',
reportAProblemLink: 'reportAProblemLink',
enableAskCommunityLink: 'true',
};
test('should match snapshot', () => {
......@@ -28,6 +29,19 @@ describe('components/channel_header/components/UserGuideDropdown', () => {
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot for false of enableAskCommunityLink', () => {
const props = {
...baseProps,
enableAskCommunityLink: 'false',
};
const wrapper = shallowWithIntl(
<UserGuideDropdown {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('Should set state buttonActive on toggle of MenuWrapper', () => {
const wrapper = shallowWithIntl(
<UserGuideDropdown {...baseProps}/>,
......
......@@ -18,6 +18,7 @@ type Props = {
intl: IntlShape;
helpLink: string;
reportAProblemLink: string;
enableAskCommunityLink: string;
};
type State = {
......@@ -48,11 +49,13 @@ class UserGuideDropdown extends React.PureComponent<Props, State> {
return (
<Menu.Group>
<Menu.ItemExternalLink
id='askTheCommunityLink'
url={askTheCommunityUrl}
text={intl.formatMessage({id: 'userGuideHelp.askTheCommunity', defaultMessage: 'Ask the community'})}
/>
{this.props.enableAskCommunityLink === 'true' && (
<Menu.ItemExternalLink
id='askTheCommunityLink'
url={askTheCommunityUrl}
text={intl.formatMessage({id: 'userGuideHelp.askTheCommunity', defaultMessage: 'Ask the community'})}
/>
)}
<Menu.ItemExternalLink
id='helpResourcesLink'
url={this.props.helpLink}
......
......@@ -10,19 +10,28 @@
// Stage: @prod
// Group: @menu
import {getAdminAccount} from '../../support/env';
describe('Main menu', () => {
let testTeam;
let testUser;
let testConfig;
const sysadmin = getAdminAccount();
before(() => {
cy.apiGetConfig().then((response) => {
testConfig = response.body;
});
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
});
cy.apiGetConfig().then((response) => {
testConfig = response.body;
});
cy.apiUpdateConfig({
SupportSettings: {
EnableAskCommunityLink: true,
},
});
});
describe('user help guide', () => {
......@@ -47,5 +56,38 @@ describe('Main menu', () => {
});
});
});
it('Should not have askTheCommunityLink button when system console setting is false', () => {
cy.apiLogin(sysadmin);
// # Update config to turn EnableAskCommunityLink config setting
cy.apiUpdateConfig({
SupportSettings: {
EnableAskCommunityLink: false,
},
});
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.get('#channel-header').should('be.visible').then(() => {
// # Click user help button
cy.get('#channelHeaderUserGuideButton').click();
cy.get('.dropdown-menu').should('be.visible').then(() => {
// * Check that Ask the community button is not visible
cy.get('#askTheCommunityLink').should('be.not.visible');
cy.get('#helpResourcesLink').should('be.visible');
});
});
});
it('Should have askTheCommunityLink system console setting', () => {
cy.apiLogin(sysadmin);
cy.visit('/admin_console/site_config/customization');
// # Click user help button
cy.get('#adminConsoleWrapper').should('be.visible').then(() => {
// * Check that enable ask community div exists
cy.get("div[data-testid='SupportSettings.EnableAskCommunityLink']").scrollIntoView().should('be.visible');
});
});
});
});
......@@ -1638,6 +1638,8 @@
"admin.support.aboutTitle": "About Link:",
"admin.support.emailHelp": "Email address displayed on email notifications and during tutorial for end users to ask support questions.",
"admin.support.emailTitle": "Support Email:",
"admin.support.enableAskCommunityDesc": "When true, \"Ask the community\" link appears on the Mattermost user interface and Main Menu, which allows users to join the Mattermost Community to ask questions and help others troubleshoot issues. When false, the link is hidden from users.",
"admin.support.enableAskCommunityTitle": "Enable Ask Community Link:",
"admin.support.enableTermsOfServiceHelp": "When true, new users must accept the terms of service before accessing any Mattermost teams on desktop, web or mobile. Existing users must accept them after login or a page refresh.\n \nTo update terms of service link displayed in account creation and login pages, go to [Site Configuration > Customization](../site_config/customization).",
"admin.support.enableTermsOfServiceTitle": "Enable Custom Terms of Service:",
"admin.support.helpDesc": "The URL for the Help link on the Mattermost login page, sign-up pages, and Main Menu. If this field is empty, the Help link is hidden from users.",
......
......@@ -18109,8 +18109,8 @@
"integrity": "sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg=="
},
"mattermost-redux": {
"version": "github:mattermost/mattermost-redux#97fd99c0b617831bba22c406bc7ab45239a0dd8f",
"from": "github:mattermost/mattermost-redux#97fd99c0b617831bba22c406bc7ab45239a0dd8f",
"version": "github:mattermost/mattermost-redux#0dd25819636205fbaed0f86cd1cf2dd7434b133e",
"from": "github:mattermost/mattermost-redux#0dd25819636205fbaed0f86cd1cf2dd7434b133e",
"requires": {
"core-js": "3.6.4",
"form-data": "3.0.0",
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment