(core) Hide 'helpCenter' and 'templates' elements in HomeIntro when requested

Summary:
Removes the relevant links in the intro text and buttons.

Note that the presence of actual "Examples & Templates" section of the page is controlled by whether any templates are available (returned by `getTemplates` api call)

Test Plan: Tested manually

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3473
This commit is contained in:
Dmitry S 2022-06-07 17:14:35 -04:00
parent 007c0f2af0
commit 3b4d936013

View File

@ -8,11 +8,12 @@ import {bigBasicButton, cssButton} from 'app/client/ui2018/buttons';
import {testId, vars} from 'app/client/ui2018/cssVars'; import {testId, vars} from 'app/client/ui2018/cssVars';
import {icon} from 'app/client/ui2018/icons'; import {icon} from 'app/client/ui2018/icons';
import {cssLink} from 'app/client/ui2018/links'; import {cssLink} from 'app/client/ui2018/links';
import {commonUrls} from 'app/common/gristUrls'; import {commonUrls, shouldHideUiElement} from 'app/common/gristUrls';
import {FullUser} from 'app/common/LoginSessionAPI'; import {FullUser} from 'app/common/LoginSessionAPI';
import * as roles from 'app/common/roles'; import * as roles from 'app/common/roles';
import {dom, DomContents, styled} from 'grainjs'; import {dom, DomContents, styled} from 'grainjs';
export function buildHomeIntro(homeModel: HomeModel): DomContents { export function buildHomeIntro(homeModel: HomeModel): DomContents {
const user = homeModel.app.currentValidUser; const user = homeModel.app.currentValidUser;
if (user) { if (user) {
@ -29,8 +30,10 @@ function makeTeamSiteIntro(homeModel: HomeModel) {
productPill(homeModel.app.currentOrg, {large: true}), productPill(homeModel.app.currentOrg, {large: true}),
testId('welcome-title')), testId('welcome-title')),
cssIntroLine('Get started by inviting your team and creating your first Grist document.'), cssIntroLine('Get started by inviting your team and creating your first Grist document.'),
(shouldHideUiElement('helpCenter') ? null :
cssIntroLine('Learn more in our ', helpCenterLink(), ', or find an expert via our ', sproutsProgram, '.', cssIntroLine('Learn more in our ', helpCenterLink(), ', or find an expert via our ', sproutsProgram, '.',
testId('welcome-text')), testId('welcome-text'))
),
makeCreateButtons(homeModel), makeCreateButtons(homeModel),
]; ];
} }
@ -39,8 +42,10 @@ function makePersonalIntro(homeModel: HomeModel, user: FullUser) {
return [ return [
css.docListHeader(`Welcome to Grist, ${user.name}!`, testId('welcome-title')), css.docListHeader(`Welcome to Grist, ${user.name}!`, testId('welcome-title')),
cssIntroLine('Get started by creating your first Grist document.'), cssIntroLine('Get started by creating your first Grist document.'),
(shouldHideUiElement('helpCenter') ? null :
cssIntroLine('Visit our ', helpCenterLink(), ' to learn more.', cssIntroLine('Visit our ', helpCenterLink(), ' to learn more.',
testId('welcome-text')), testId('welcome-text'))
),
makeCreateButtons(homeModel), makeCreateButtons(homeModel),
]; ];
} }
@ -50,7 +55,8 @@ function makeAnonIntro(homeModel: HomeModel) {
return [ return [
css.docListHeader(`Welcome to Grist!`, testId('welcome-title')), css.docListHeader(`Welcome to Grist!`, testId('welcome-title')),
cssIntroLine('Get started by exploring templates, or creating your first Grist document.'), cssIntroLine('Get started by exploring templates, or creating your first Grist document.'),
cssIntroLine(signUp, ' to save your work. Visit our ', helpCenterLink(), ' to learn more.', cssIntroLine(signUp, ' to save your work.',
(shouldHideUiElement('helpCenter') ? null : [' Visit our ', helpCenterLink(), ' to learn more.']),
testId('welcome-text')), testId('welcome-text')),
makeCreateButtons(homeModel), makeCreateButtons(homeModel),
]; ];
@ -72,6 +78,7 @@ function makeCreateButtons(homeModel: HomeModel) {
) : ) :
cssBtn(cssBtnIcon('FieldTable'), 'Browse Templates', testId('intro-templates'), cssBtn(cssBtnIcon('FieldTable'), 'Browse Templates', testId('intro-templates'),
cssButton.cls('-primary'), cssButton.cls('-primary'),
dom.hide(shouldHideUiElement("templates")),
urlState().setLinkUrl({homePage: 'templates'}), urlState().setLinkUrl({homePage: 'templates'}),
) )
), ),