2022-06-03 14:58:07 +00:00
|
|
|
import {getLoginOrSignupUrl, urlState} from 'app/client/models/gristUrlState';
|
2021-07-28 19:02:06 +00:00
|
|
|
import {HomeModel} from 'app/client/models/HomeModel';
|
2022-06-03 14:58:07 +00:00
|
|
|
import {productPill} from 'app/client/ui/AppHeader';
|
2020-10-02 15:10:00 +00:00
|
|
|
import * as css from 'app/client/ui/DocMenuCss';
|
|
|
|
import {createDocAndOpen, importDocAndOpen} from 'app/client/ui/HomeLeftPane';
|
2022-06-03 14:58:07 +00:00
|
|
|
import {manageTeamUsersApp} from 'app/client/ui/OpenUserManager';
|
|
|
|
import {bigBasicButton, cssButton} from 'app/client/ui2018/buttons';
|
|
|
|
import {testId, vars} from 'app/client/ui2018/cssVars';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {icon} from 'app/client/ui2018/icons';
|
|
|
|
import {cssLink} from 'app/client/ui2018/links';
|
|
|
|
import {commonUrls} from 'app/common/gristUrls';
|
2022-06-03 14:58:07 +00:00
|
|
|
import {FullUser} from 'app/common/LoginSessionAPI';
|
|
|
|
import * as roles from 'app/common/roles';
|
|
|
|
import {dom, DomContents, styled} from 'grainjs';
|
2020-10-02 15:10:00 +00:00
|
|
|
|
|
|
|
export function buildHomeIntro(homeModel: HomeModel): DomContents {
|
|
|
|
const user = homeModel.app.currentValidUser;
|
|
|
|
if (user) {
|
2022-06-03 14:58:07 +00:00
|
|
|
return homeModel.app.isTeamSite ? makeTeamSiteIntro(homeModel) : makePersonalIntro(homeModel, user);
|
2020-10-02 15:10:00 +00:00
|
|
|
} else {
|
2022-06-03 14:58:07 +00:00
|
|
|
return makeAnonIntro(homeModel);
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-03 14:58:07 +00:00
|
|
|
function makeTeamSiteIntro(homeModel: HomeModel) {
|
|
|
|
const sproutsProgram = cssLink({href: commonUrls.sproutsProgram, target: '_blank'}, 'Sprouts Program');
|
|
|
|
return [
|
|
|
|
css.docListHeader(`Welcome to ${homeModel.app.currentOrgName}`,
|
|
|
|
productPill(homeModel.app.currentOrg, {large: true}),
|
|
|
|
testId('welcome-title')),
|
|
|
|
cssIntroLine('Get started by inviting your team and creating your first Grist document.'),
|
|
|
|
cssIntroLine('Learn more in our ', helpCenterLink(), ', or find an expert via our ', sproutsProgram, '.',
|
|
|
|
testId('welcome-text')),
|
|
|
|
makeCreateButtons(homeModel),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function makePersonalIntro(homeModel: HomeModel, user: FullUser) {
|
|
|
|
return [
|
|
|
|
css.docListHeader(`Welcome to Grist, ${user.name}!`, testId('welcome-title')),
|
|
|
|
cssIntroLine('Get started by creating your first Grist document.'),
|
|
|
|
cssIntroLine('Visit our ', helpCenterLink(), ' to learn more.',
|
|
|
|
testId('welcome-text')),
|
|
|
|
makeCreateButtons(homeModel),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function makeAnonIntro(homeModel: HomeModel) {
|
|
|
|
const signUp = cssLink({href: getLoginOrSignupUrl()}, 'Sign up');
|
|
|
|
return [
|
|
|
|
css.docListHeader(`Welcome to Grist!`, testId('welcome-title')),
|
|
|
|
cssIntroLine('Get started by exploring templates, or creating your first Grist document.'),
|
|
|
|
cssIntroLine(signUp, ' to save your work. Visit our ', helpCenterLink(), ' to learn more.',
|
|
|
|
testId('welcome-text')),
|
|
|
|
makeCreateButtons(homeModel),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function helpCenterLink() {
|
|
|
|
return cssLink({href: commonUrls.help, target: '_blank'}, cssInlineIcon('Help'), 'Help Center');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
function makeCreateButtons(homeModel: HomeModel) {
|
2022-06-03 14:58:07 +00:00
|
|
|
const canManageTeam = homeModel.app.isTeamSite &&
|
|
|
|
roles.canEditAccess(homeModel.app.currentOrg?.access || null);
|
2020-10-02 15:10:00 +00:00
|
|
|
return cssBtnGroup(
|
2022-06-03 14:58:07 +00:00
|
|
|
(canManageTeam ?
|
|
|
|
cssBtn(cssBtnIcon('Help'), 'Invite Team Members', testId('intro-invite'),
|
|
|
|
cssButton.cls('-primary'),
|
|
|
|
dom.on('click', () => manageTeamUsersApp(homeModel.app)),
|
|
|
|
) :
|
|
|
|
cssBtn(cssBtnIcon('FieldTable'), 'Browse Templates', testId('intro-templates'),
|
|
|
|
cssButton.cls('-primary'),
|
|
|
|
urlState().setLinkUrl({homePage: 'templates'}),
|
|
|
|
)
|
|
|
|
),
|
2020-10-02 15:10:00 +00:00
|
|
|
cssBtn(cssBtnIcon('Import'), 'Import Document', testId('intro-import-doc'),
|
|
|
|
dom.on('click', () => importDocAndOpen(homeModel)),
|
|
|
|
),
|
|
|
|
cssBtn(cssBtnIcon('Page'), 'Create Empty Document', testId('intro-create-doc'),
|
|
|
|
dom.on('click', () => createDocAndOpen(homeModel)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const cssParagraph = styled(css.docBlock, `
|
|
|
|
line-height: 1.6;
|
|
|
|
`);
|
|
|
|
|
2022-06-03 14:58:07 +00:00
|
|
|
const cssIntroLine = styled(cssParagraph, `
|
|
|
|
font-size: ${vars.introFontSize};
|
|
|
|
margin-bottom: 8px;
|
|
|
|
`);
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
const cssBtnGroup = styled('div', `
|
|
|
|
display: inline-flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: stretch;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssBtn = styled(bigBasicButton, `
|
2022-06-03 14:58:07 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-02 15:10:00 +00:00
|
|
|
margin-right: 16px;
|
|
|
|
margin-top: 16px;
|
|
|
|
text-align: left;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssBtnIcon = styled(icon, `
|
|
|
|
margin-right: 8px;
|
|
|
|
`);
|
|
|
|
|
2022-06-03 14:58:07 +00:00
|
|
|
const cssInlineIcon = styled(icon, `
|
|
|
|
margin: -2px 4px 2px 4px;
|
|
|
|
`);
|