Skip to content

Commit

Permalink
Merge branch 'develop' into tc-260
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 2, 2022
2 parents c14f829 + 07ea6d1 commit 6ab0c70
Show file tree
Hide file tree
Showing 28 changed files with 381 additions and 307 deletions.
85 changes: 0 additions & 85 deletions apps/meteor/app/analytics/client/loadScript.js

This file was deleted.

122 changes: 122 additions & 0 deletions apps/meteor/app/analytics/client/loadScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';

import { settings } from '../../settings/client';

declare global {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Window {
_paq: [string, ...unknown[]][];
GoogleAnalyticsObject: unknown;
ga: qa;
}

type qa = {
(...args: unknown[]): void;
l: number;
q: unknown[];
};
}

Template.body.onRendered(function () {
this.autorun(() => {
const uid = Meteor.userId();
if (uid) {
window._paq = window._paq || [];
window._paq.push(['setUserId', uid]);
}
});

this.autorun((c) => {
const googleId = settings.get('GoogleAnalytics_enabled') && settings.get('GoogleAnalytics_ID');
if (googleId) {
c.stop();

if (googleId) {
/*eslint-disable */
(function (i, s, o, g, r: 'ga', a?: any, m?: any) {
i['GoogleAnalyticsObject'] = r;
(i[r] =
i[r] ||
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = new Date().getTime());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

window.ga('create', googleId, 'auto');
window.ga('send', 'pageview');
/* eslint-enable */
}
}
});

this.autorun(() => {
const piwikUrl = settings.get('PiwikAnalytics_enabled') && settings.get('PiwikAnalytics_url');

if (!piwikUrl) {
document.getElementById('piwik-analytics')?.remove();
window._paq = [];
return;
}

const piwikSiteId = piwikUrl && settings.get('PiwikAnalytics_siteId');
const piwikPrependDomain = piwikUrl && settings.get('PiwikAnalytics_prependDomain');
const piwikCookieDomain = piwikUrl && settings.get('PiwikAnalytics_cookieDomain');
const piwikDomains = piwikUrl && settings.get('PiwikAnalytics_domains');
const piwikAdditionalTracker = piwikUrl && settings.get('PiwikAdditionalTrackers');
window._paq = window._paq || [];

window._paq.push(['trackPageView']);
window._paq.push(['enableLinkTracking']);
if (piwikPrependDomain) {
window._paq.push(['setDocumentTitle', `${window.location.hostname}/${document.title}`]);
}
const upperLevelDomain = `*.${window.location.hostname.split('.').slice(1).join('.')}`;
if (piwikCookieDomain) {
window._paq.push(['setCookieDomain', upperLevelDomain]);
}
if (piwikDomains) {
// array
const domainsArray = piwikDomains.split(/\n/);
const domains = [];
for (let i = 0; i < domainsArray.length; i++) {
// only push domain if it contains a non whitespace character.
if (/\S/.test(domainsArray[i])) {
domains.push(`*.${domainsArray[i].trim()}`);
}
}
window._paq.push(['setDomains', domains]);
}
(() => {
try {
if (/\S/.test(piwikAdditionalTracker)) {
// piwikAdditionalTracker is not empty or whitespace only
const addTrackers = JSON.parse(piwikAdditionalTracker);
for (let i = 0; i < addTrackers.length; i++) {
const tracker = addTrackers[i];
window._paq.push(['addTracker', `${tracker.trackerURL}js/`, tracker.siteId]);
}
}
} catch (e) {
// parsing JSON faild
console.log('Error while parsing JSON value of "piwikAdditionalTracker": ', e);
}
window._paq.push(['setTrackerUrl', `${piwikUrl}js/`]);
window._paq.push(['setSiteId', Number.parseInt(piwikSiteId)]);
const d = document;
const g = d.createElement('script');
g.setAttribute('id', 'piwik-analytics');
const s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = `${piwikUrl}js/`;
s.parentNode?.insertBefore(g, s);
})();
});
});
12 changes: 11 additions & 1 deletion apps/meteor/app/cors/server/cors.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ WebApp.rawConnectHandlers.use(function (req, res, next) {
]
.filter(Boolean)
.join(' ');
const external = [settings.get('Accounts_OAuth_Apple') && 'https://appleid.cdn-apple.com'].filter(Boolean).join(' ');
const external = [
settings.get('Accounts_OAuth_Apple') && 'https://appleid.cdn-apple.com',
settings.get('PiwikAnalytics_enabled') && settings.get('PiwikAnalytics_url'),
settings.get('GoogleAnalytics_enabled' && 'https://www.google-analytics.com'),
...settings
.get('Extra_CSP_Domains')
.split(/[ \n\,]/gim)
.filter((e) => Boolean(e.trim())),
]
.filter(Boolean)
.join(' ');
res.setHeader(
'Content-Security-Policy',
[
Expand Down
5 changes: 5 additions & 0 deletions apps/meteor/app/lib/server/startup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,11 @@ settingsRegistry.addGroup('General', function () {
type: 'boolean',
});

this.add('Extra_CSP_Domains', '', {
type: 'string',
multiline: true,
});

this.add('Iframe_Restrict_Access', true, {
type: 'boolean',
secret: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
align-items: center;

&.editing {
background-color: var(--message-box-editing-color);
background-color: var(--rcx-color-status-background-warning-2, var(--message-box-editing-color));
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/theme/client/imports/general/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
--message-box-container-border-color: var(--rcx-input-colors-border-color, var(--rcx-color-stroke-light, var(--rcx-color-neutral-500, var(--color-gray-medium))));
--message-box-container-border-width: var(--border);
--message-box-container-border-radius: var(--border-radius);
--message-box-editing-color: var(--rcx-color-status-background-warning, var(--rcx-color-status-warning, #ffecad));
--message-box-editing-color: var(--rcx-color-status-background-warning-2, #fff6d6);
--message-box-popover-title-text-color: var(--rcx-color-font-annotation, var(--rcx-color-neutral-600, var(--color-gray)));
--message-box-popover-title-text-size: 0.75rem;
--message-box-color: var(--rcx-color-font-default, var(--rcx-color-neutral-800, #2f343d));
Expand Down
24 changes: 14 additions & 10 deletions apps/meteor/client/providers/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ const getUser = (): IUser | null => Meteor.user() as IUser | null;
const capitalize = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1);

const config: Record<string, Partial<LoginService>> = {
'facebook': { buttonColor: '#325c99' },
'twitter': { buttonColor: '#02acec' },
'google': { buttonColor: '#dd4b39' },
'github': { buttonColor: '#4c4c4c', title: 'GitHub' },
'github_enterprise': { buttonColor: '#4c4c4c', title: 'GitHub Enterprise' },
'gitlab': { buttonColor: '#373d47', title: 'GitLab' },
'trello': { buttonColor: '#026aa7' },
'meteor-developer': { buttonColor: '#de4f4f', title: 'Meteor' },
'wordpress': { buttonColor: '#1e8cbe', title: 'WordPress' },
'linkedin': { buttonColor: '#1b86bc' },
'apple': { title: 'Apple', icon: 'apple' },
'facebook': { title: 'Facebook', icon: 'facebook' },
'twitter': { title: 'Twitter', icon: 'twitter' },
'google': { title: 'Google', icon: 'google' },
'github': { title: 'Github', icon: 'github' },
'github_enterprise': { title: 'Github Enterprise', icon: 'github' },
'gitlab': { title: 'Gitlab', icon: 'gitlab' },
'dolphin': { title: 'Dolphin', icon: 'dophin' },
'drupal': { title: 'Drupal', icon: 'drupal' },
'nextcloud': { title: 'Nextcloud', icon: 'nextcloud' },
'tokenpass': { title: 'Tokenpass', icon: 'tokenpass' },
'meteor-developer': { title: 'Meteor', icon: 'meteor' },
'wordpress': { title: 'WordPress', icon: 'wordpress' },
'linkedin': { title: 'Linkedin', icon: 'linkedin' },
};

const logout = (): Promise<void> =>
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/client/sidebar/hooks/useSidebarPaletteColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const getStyle = (
${selector} {
--rcx-color-neutral-100: ${toVar(colors.n900)};
--rcx-color-neutral-200: ${toVar(colors.n800)};
--rcx-color-neutral-250: ${toVar(colors.n800)};
--rcx-color-neutral-300: ${toVar(colors.n700)};
--rcx-color-neutral-400: ${toVar(colors.n600)};
--rcx-color-neutral-500: ${toVar(colors.n500)};
Expand Down
19 changes: 11 additions & 8 deletions apps/meteor/client/views/admin/apps/AppsRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@ const AppsRoute = (): ReactElement => {
const appsWhatIsItRoute = useRoute('admin-apps-disabled');
const marketplaceRoute = useRoute('admin-marketplace');

const context = useRouteParameter('context');
const id = useRouteParameter('id');
const page = useRouteParameter('page');

const isMarketplace = !context;

useEffect(() => {
let mounted = true;

if (!context) {
marketplaceRoute.replace({ context: 'all', page: 'list' });
}

const initialize = async (): Promise<void> => {
if (!canManageApps) {
return;
Expand All @@ -40,14 +50,7 @@ const AppsRoute = (): ReactElement => {
return (): void => {
mounted = false;
};
}, [canManageApps, isAppsEngineEnabled, appsWhatIsItRoute, marketplaceRoute]);

const context = useRouteParameter('context');

const isMarketplace = !context;

const id = useRouteParameter('id');
const page = useRouteParameter('page');
}, [canManageApps, isAppsEngineEnabled, appsWhatIsItRoute, marketplaceRoute, context]);

if (!canManageApps) {
return <NotAuthorizedPage />;
Expand Down
7 changes: 0 additions & 7 deletions apps/meteor/client/views/admin/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ registerAdminRoute('/apps/what-is-it', {
registerAdminRoute('/marketplace/:context?/:page?/:id?/:version?/:tab?', {
name: 'admin-marketplace',
component: lazy(() => import('./apps/AppsRoute')),
triggersEnter: [
(context, redirect): void => {
if (!context.params.context) {
redirect('/admin/marketplace/all/list');
}
},
],
});

registerAdminRoute('/info', {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"@react-aria/color": "^3.0.0-beta.15",
"@rocket.chat/agenda": "workspace:^",
"@rocket.chat/api-client": "workspace:^",
"@rocket.chat/apps-engine": "alpha",
"@rocket.chat/apps-engine": "1.36.0-alpha.0.77",
"@rocket.chat/cas-validate": "workspace:^",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/css-in-js": "next",
Expand Down
Loading

0 comments on commit 6ab0c70

Please sign in to comment.