Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ADD Terms of service link #985

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Grist can be configured in many ways. Here are the main environment variables it
| GRIST_SINGLE_ORG | set to an org "domain" to pin client to that org |
| GRIST_TEMPLATE_ORG | set to an org "domain" to show public docs from that org |
| GRIST_HELP_CENTER | set the help center link ref |
| GRIST_TERMS_OF_SERVICE_URL | if set, adds terms of service link |
| FREE_COACHING_CALL_URL | set the link to the human help (example: email adress or meeting scheduling tool) |
| GRIST_CONTACT_SUPPORT_URL | set the link to contact support on error pages (example: email adress or online form) |
| GRIST_SUPPORT_ANON | if set to 'true', show UI for anonymous access (not shown by default) |
Expand Down
8 changes: 8 additions & 0 deletions app/client/ui/HomeLeftPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ export function createHomeLeftPane(leftPanelOpen: Observable<boolean>, home: Hom
) : null
),
createHelpTools(home.app),
(commonUrls.termsOfService ?
cssPageEntry(
cssPageLink(cssPageIcon('Memo'), cssLinkText(t("Terms of service")),
{ href: commonUrls.termsOfService, target: '_blank' },
testId('dm-tos'),
),
) : null
),
)
)
);
Expand Down
13 changes: 13 additions & 0 deletions app/common/gristUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const commonUrls = {
helpAPI: 'https://support.getgrist.com/api',
freeCoachingCall: getFreeCoachingCallUrl(),
contactSupport: getContactSupportUrl(),
termsOfService: getTermsOfServiceUrl(),
plans: "https://www.getgrist.com/pricing",
sproutsProgram: "https://www.getgrist.com/sprouts-program",
contact: "https://www.getgrist.com/contact",
Expand Down Expand Up @@ -689,6 +690,9 @@ export interface GristLoadConfig {
// Url for support for the browser client to use.
helpCenterUrl?: string;

// Url for terms of service for the browser client to use
termsOfServiceUrl?: string;

// Url for free coaching call scheduling for the browser client to use.
freeCoachingCallUrl?: string;

Expand Down Expand Up @@ -900,6 +904,15 @@ export function getHelpCenterUrl(): string {
}
}

export function getTermsOfServiceUrl(): string|undefined {
if(isClient()) {
const gristConfig: GristLoadConfig = (window as any).gristConfig;
return gristConfig && gristConfig.termsOfServiceUrl || undefined;
} else {
return process.env.GRIST_TERMS_OF_SERVICE_URL || undefined;
}
}

export function getFreeCoachingCallUrl(): string {
const defaultUrl = "https://calendly.com/grist-team/grist-free-coaching-call";
if(isClient()) {
Expand Down
2 changes: 2 additions & 0 deletions app/server/lib/sendAppPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getFreeCoachingCallUrl,
getHelpCenterUrl,
getPageTitleSuffix,
getTermsOfServiceUrl,
GristLoadConfig,
IFeature
} from 'app/common/gristUrls';
Expand Down Expand Up @@ -62,6 +63,7 @@ export function makeGristConfig(options: MakeGristConfigOptions): GristLoadConfi
baseDomain,
singleOrg: process.env.GRIST_SINGLE_ORG,
helpCenterUrl: getHelpCenterUrl(),
termsOfServiceUrl: getTermsOfServiceUrl(),
freeCoachingCallUrl: getFreeCoachingCallUrl(),
contactSupportUrl: getContactSupportUrl(),
pathOnly,
Expand Down
3 changes: 2 additions & 1 deletion static/locales/fr.client.json
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@
"Workspace will be moved to Trash.": "Le dossier va être mis à la corbeille.",
"Manage Users": "Gérer les utilisateurs",
"Access Details": "Détails d'accès",
"Tutorial": "Tutoriel"
"Tutorial": "Tutoriel",
"Terms of service": "CGU"
},
"Importer": {
"Update existing records": "Mettre à jour les enregistrements existants",
Expand Down
37 changes: 37 additions & 0 deletions test/nbrowser/TermsOfService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { assert, driver } from 'mocha-webdriver';
import * as gu from 'test/nbrowser/gristUtils';
import { server, setupTestSuite } from 'test/nbrowser/testUtils';
import { EnvironmentSnapshot } from 'test/server/testUtils';

describe('Terms of service link', function () {
this.timeout(20000);
setupTestSuite({samples: true});

let session: gu.Session;
let oldEnv: EnvironmentSnapshot;

before(async function () {
oldEnv = new EnvironmentSnapshot();
session = await gu.session().teamSite.login();
});

after(async function () {
oldEnv.restore();
await server.restart();
});

it('is visible in home menu', async function () {
process.env.GRIST_TERMS_OF_SERVICE_URL = 'https://example.com/tos';
await server.restart();
await session.loadDocMenu('/');
assert.isTrue(await driver.find('.test-dm-tos').isDisplayed());
assert.equal(await driver.find('.test-dm-tos').getAttribute('href'), 'https://example.com/tos');
});

it('is not visible when environment variable is not set', async function () {
delete process.env.GRIST_TERMS_OF_SERVICE_URL;
await server.restart();
await session.loadDocMenu('/');
assert.isFalse(await driver.find('.test-dm-tos').isPresent());
});
});
Loading