-
Notifications
You must be signed in to change notification settings - Fork 291
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
fix: allow end user to set all url paths (WPB-4676) #16774
Changes from all commits
3b56124
bdb8746
32c950e
f17cd8c
5849270
ecdc368
9f30b9c
ec60e06
345e7a7
ddf23d9
19eb6e0
6114793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,79 +20,55 @@ | |
import {currentLanguage} from './auth/localeConfig'; | ||
import {Config} from './Config'; | ||
|
||
const env = window.wire.env; | ||
|
||
export const URL = { | ||
ACCOUNT: env.URL?.ACCOUNT_BASE, | ||
PRIVACY_POLICY: env.URL?.PRIVACY_POLICY, | ||
SUPPORT: env.URL?.SUPPORT.INDEX, | ||
TEAM_SETTINGS: env.URL?.TEAMS_BASE, | ||
TERMS_OF_USE_PERSONAL: env.URL?.TERMS_OF_USE_PERSONAL, | ||
TERMS_OF_USE_TEAMS: env.URL?.TERMS_OF_USE_TEAMS, | ||
WEBAPP: { | ||
INTERNAL: 'https://wire-webapp-staging.wire.com', | ||
PRODUCTION: env.APP_BASE || 'https://app.wire.com', | ||
STAGING: 'https://wire-webapp-staging.zinfra.io', | ||
}, | ||
WEBSITE: env.URL?.WEBSITE_BASE, | ||
}; | ||
|
||
export const URL_PATH = { | ||
CREATE_TEAM: '/create-team/', | ||
DECRYPT_ERROR_1: '/articles/207948115', | ||
DECRYPT_ERROR_2: '/privacy/error-2/', | ||
MANAGE_SERVICES: '/services/', | ||
MANAGE_TEAM: '/login/', | ||
PASSWORD_RESET: '/forgot/', | ||
PRIVACY_HOW: '/privacy/how/', | ||
PRIVACY_UNVERIFIED_USERS: '/articles/202857164', | ||
PRIVACY_WHY: '/articles/207859815', | ||
SUPPORT_USERNAME: '/support/username/', | ||
} as const; | ||
const URL = Config.getConfig().URL; | ||
|
||
const getTeamSettingsUrl = (path: string = '', utmSource?: string): string | undefined => { | ||
const query = utmSource ? `?utm_source=${utmSource}&utm_term=desktop` : ''; | ||
const teamSettingsUrl = `${URL.TEAM_SETTINGS}${path}${query}`; | ||
return URL.TEAM_SETTINGS ? teamSettingsUrl : undefined; | ||
const teamSettingsUrl = `${URL.TEAMS_BASE}${path}${query}`; | ||
return URL.TEAMS_BASE ? teamSettingsUrl : undefined; | ||
}; | ||
|
||
export const getWebsiteUrl = (path: string = '', pkCampaign?: string): string | undefined => { | ||
if (URL.WEBSITE) { | ||
const getWebsiteUrl = (path: string = '', pkCampaign?: string): string | undefined => { | ||
if (URL.WEBSITE_BASE) { | ||
const query = pkCampaign ? `?pk_campaign=${pkCampaign}&pk_kwd=desktop` : ''; | ||
const websiteUrl = `${URL.WEBSITE}${path}${query}`; | ||
return addLocaleToUrl(URL.WEBSITE ? websiteUrl : undefined); | ||
const websiteUrl = `${URL.WEBSITE_BASE}${path}${query}`; | ||
return addLocaleToUrl(websiteUrl); | ||
} | ||
return undefined; | ||
}; | ||
|
||
const getHelpCenterUrl = (path: (typeof URL_PATH)[keyof typeof URL_PATH]) => { | ||
if (URL.SUPPORT) { | ||
const helpcenterUrl = `${URL.SUPPORT}${path}`; | ||
return addLocaleToHelpCenterUrl(URL.SUPPORT ? helpcenterUrl : undefined); | ||
} | ||
return undefined; | ||
const getAccountPagesUrl = (path: string = ''): string | undefined => { | ||
return URL.ACCOUNT_BASE ? `${URL.ACCOUNT_BASE}${path}` : undefined; | ||
}; | ||
|
||
export const getAccountPagesUrl = (path: string = ''): string | undefined => { | ||
const accountPagesUrl = `${URL.ACCOUNT}${path}`; | ||
return URL.ACCOUNT ? accountPagesUrl : undefined; | ||
}; | ||
const getPrivacyPolicyUrl = (): string | undefined => addLocaleToUrl(URL.PRIVACY_POLICY || undefined); | ||
const getTermsOfUsePersonalUrl = (): string | undefined => addLocaleToUrl(URL.TERMS_OF_USE_PERSONAL || undefined); | ||
const getTermsOfUseTeamUrl = (): string | undefined => addLocaleToUrl(URL.TERMS_OF_USE_TEAMS || undefined); | ||
|
||
export const getPrivacyPolicyUrl = (): string => addLocaleToUrl(URL.PRIVACY_POLICY || undefined); | ||
export const getTermsOfUsePersonalUrl = (): string => addLocaleToUrl(URL.TERMS_OF_USE_PERSONAL || undefined); | ||
export const getTermsOfUseTeamUrl = (): string => addLocaleToUrl(URL.TERMS_OF_USE_TEAMS || undefined); | ||
/** | ||
* Retrieves the URL for managing services with optional UTM parameters. | ||
* UTM parameters are used in online marketing to track the effectiveness of campaigns. | ||
* | ||
* @param utmSource - Optional. The source of the UTM parameters. | ||
* @returns The URL for managing services with optional UTM parameters. | ||
*/ | ||
export const getManageServicesUrl = (utmSource?: string): string | undefined => | ||
getTeamSettingsUrl(URL.URL_PATH.MANAGE_SERVICES, utmSource); | ||
Comment on lines
+55
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hard to find doc on those UTM sources
Do we want to keep that granularity @atomrc ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah!! I do not know about those utms, honestly. But, since we will be tracking team settings usages soonish, I'm guessing those will be used at some point (if they are not currently). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll keep the export of the method and add some JSDoc to make the utmSource thing more transparent, how does that sound? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good to me :) |
||
|
||
export const getManageServicesUrl = (utmSource?: string): string => | ||
getTeamSettingsUrl(URL_PATH.MANAGE_SERVICES, utmSource); | ||
export const getManageTeamUrl = (utmSource?: string): string => getTeamSettingsUrl(URL_PATH.MANAGE_TEAM, utmSource); | ||
/** | ||
* Retrieves the URL for managing team settings with optional UTM parameters. | ||
* UTM parameters are used in online marketing to track the effectiveness of campaigns. | ||
* | ||
* @param utmSource - Optional. The source of the UTM parameters. | ||
* @returns The URL for managing team settings with optional UTM parameters. | ||
*/ | ||
export const getManageTeamUrl = (utmSource?: string): string | undefined => | ||
getTeamSettingsUrl(URL.URL_PATH.MANAGE_TEAM, utmSource); | ||
|
||
export const getCreateTeamUrl = (): string => | ||
Config.getConfig().FEATURE.ENABLE_ACCOUNT_REGISTRATION && `${Config.getConfig().URL.TEAMS_BASE}/register/email`; | ||
export const getDecryptErrorUrl = (): string => getHelpCenterUrl(URL_PATH.DECRYPT_ERROR_1); | ||
export const getPrivacyUnverifiedUsersUrl = (): string => getHelpCenterUrl(URL_PATH.PRIVACY_UNVERIFIED_USERS); | ||
export const getPrivacyWhyUrl = (): string => getHelpCenterUrl(URL_PATH.PRIVACY_WHY); | ||
const getCreateTeamUrl = (): string | undefined => | ||
Config.getConfig().FEATURE.ENABLE_ACCOUNT_REGISTRATION ? `${URL.TEAMS_BASE}${URL.URL_PATH.CREATE_TEAM}` : undefined; | ||
|
||
export const addLocaleToUrl = (url?: string): string => { | ||
export const addLocaleToUrl = (url?: string): string | undefined => { | ||
if (!url) { | ||
return undefined; | ||
} | ||
|
@@ -101,14 +77,11 @@ export const addLocaleToUrl = (url?: string): string => { | |
return url.replace(Config.getConfig().URL.WEBSITE_BASE, `${Config.getConfig().URL.WEBSITE_BASE}/${websiteLanguage}`); | ||
}; | ||
|
||
const addLocaleToHelpCenterUrl = (url?: string): string => { | ||
if (!url) { | ||
return undefined; | ||
} | ||
const language = currentLanguage().slice(0, 2); | ||
const websiteLanguage = language == 'de' ? language : 'en-us'; | ||
return url.replace( | ||
`${Config.getConfig().URL.SUPPORT.INDEX}`, | ||
`${Config.getConfig().URL.SUPPORT.INDEX}/hc/${websiteLanguage}`, | ||
); | ||
export const externalUrl = { | ||
createTeam: getCreateTeamUrl(), | ||
passwordReset: getAccountPagesUrl(URL.URL_PATH?.PASSWORD_RESET), | ||
privacyPolicy: getPrivacyPolicyUrl(), | ||
termsOfUsePersonnal: getTermsOfUsePersonalUrl(), | ||
termsOfUseTeam: getTermsOfUseTeamUrl(), | ||
website: getWebsiteUrl(), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL_SUBPATH
env variables as to be end user configurable