Skip to content

Commit

Permalink
chore: Add support window (#2771)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfbrito authored Nov 13, 2023
1 parent 4de6a75 commit 5a83858
Show file tree
Hide file tree
Showing 33 changed files with 27,342 additions and 3,309 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Thumbs.db
!.yarn/releases
!.yarn/sdks
!.yarn/versions
supportedVersions.jwt
22,835 changes: 22,835 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"productName": "Rocket.Chat",
"name": "rocketchat",
"description": "Official OSX, Windows, and Linux Desktop Clients for Rocket.Chat",
"version": "3.9.9",
"version": "3.9.10",
"author": "Rocket.Chat Support <support@rocket.chat>",
"copyright": "© 2016-2023, Rocket.Chat",
"homepage": "https://rocket.chat",
Expand All @@ -27,13 +27,13 @@
"main": "app/main.js",
"scripts": {
"postinstall": "run-s install-app-deps clean",
"start": "run-s clean build:watch",
"start": "run-s build:watch",
"clean": "rimraf app dist",
"build": "rollup -c",
"build": "yarn build-get-cloud-info && rollup -c ",
"build:watch": "rollup -c -w",
"build-mac": "yarn electron-builder --publish never --mac --universal",
"build-win": "yarn electron-builder --publish never --win",
"build-linux": "yarn electron-builder --publish never --linux",
"build-mac": "yarn build && yarn electron-builder --publish never --mac --universal",
"build-win": "yarn build && yarn electron-builder --publish never --win",
"build-linux": "yarn build && yarn electron-builder --publish never --linux",
"build-assets": "ts-node -O '{\"module\":\"commonjs\"}' src/buildAssets.ts",
"build-assets-win": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" src/buildAssets.ts",
"release": "yarn electron-builder --publish onTagOrDraft --x64",
Expand All @@ -45,7 +45,8 @@
".:lint:tsc": "tsc --noEmit --skipLibCheck",
"lint-fix": "run-s .:lint-fix:eslint .:lint:tsc",
".:lint-fix:eslint": "eslint --fix .",
"workspaces:build": "yarn workspaces foreach -t run build"
"workspaces:build": "yarn workspaces foreach -t run build",
"build-get-cloud-info": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" src/servers/supportedVersions/downloadFromCloud.ts"
},
"dependencies": {
"@bugsnag/js": "^7.16.0",
Expand All @@ -60,11 +61,14 @@
"@rocket.chat/icons": "~0.32.0",
"abort-controller": "^3.0.0",
"axios": "^1.4.0",
"dotenv": "~16.3.1",
"electron-dl": "^3.5.0",
"electron-store": "^8.1.0",
"electron-updater": "^5.3.0",
"ews-javascript-api": "^0.12.0",
"i18next": "^21.6.10",
"jsonwebtoken": "^9.0.1",
"moment": "^2.29.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hook-form": "^7.43.9",
Expand All @@ -75,7 +79,7 @@
"redux": "^4.1.2",
"reselect": "4.1.6",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"semver": "^7.5.4",
"tslib": "^2.3.1"
},
"devDependencies": {
Expand All @@ -98,6 +102,7 @@
"@rollup/plugin-replace": "~3.1.0",
"@types/electron-devtools-installer": "^2.2.1",
"@types/jest": "^27.4.0",
"@types/jsonwebtoken": "^9.0.2",
"@types/meteor": "^2.0.4",
"@types/node": "^17.0.13",
"@types/node-fetch": "^3.0.3",
Expand All @@ -112,7 +117,7 @@
"chokidar": "^3.5.3",
"conventional-changelog-cli": "^2.2.2",
"convert-svg-to-png": "^0.5.0",
"electron": "24.8.5",
"electron": "22.3.27",
"electron-builder": "^23.6.0",
"electron-devtools-installer": "^3.2.0",
"electron-notarize": "^1.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/de-DE.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,4 @@
"unreadMention": "Ungelesene Erwähnungen",
"noUnreadMessage": "Keine ungelesenen Nachrichten"
}
}
}
8 changes: 8 additions & 0 deletions src/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
"remember_credentials": "Remember my credentials",
"cancel": " Cancel",
"submit": "Login"
},
"supportedVersion":{
"title": "Workspace version unsupported"
}
},
"downloads": {
Expand Down Expand Up @@ -298,6 +301,11 @@
"announcement": "Houston, we have a problem",
"reload": "Reload"
},
"unsupportedServer": {
"title": "{{workspaceName}} is running an unsupported version of Rocket.Chat",
"announcement": "An admin needs to update this workspace to a supported version in order to restore access from desktop and mobile apps.",
"moreInformation": "Learn more"
},
"selfxss": {
"title": "Stop!",
"description": "This is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Rocket.Chat feature or \"hack\" someone's account, it is a scam and will give them access to your Rocket.Chat account.",
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/fr.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,4 @@
"unreadMention": "Mentions non lues",
"noUnreadMessage": "Pas de messages non lus"
}
}
}
11 changes: 10 additions & 1 deletion src/i18n/hu.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@
"clearPermittedScreenCaptureServers": {
"title": "Képernyőfelvételi engedélyek törlése",
"description": "Azon képernyőfelvételi engedélyek törlése, amelyek úgy lettek kiválasztva, hogy ne kérdezzenek újra a videohívásoknál."
},
"allowScreenCaptureOnVideoCalls": {
"title": "Képernyőrögzítés engedélyezése videohívásoknál",
"description": "Képernyőrögzítés engedélyezése videohívásoknál. Engedélyt fog kérni minden egyes videohívásnál."
},
"ntlmCredentials": {
"title": "NTLM hitelesítési adatok",
"description": "Egy kiszolgálóhoz való kapcsolódáskor használandó NTLM hitelesítési adatok engedélyezése.",
"domains": "A hitelesítési adatokat használó tartományok, vesszővel elválasztva. Használjon * karaktert az összes tartományra való illesztéshez."
}
}
},
Expand Down Expand Up @@ -335,4 +344,4 @@
"unreadMention": "Olvasatlan említések",
"noUnreadMessage": "Nincsenek olvasatlan üzenetek"
}
}
}
3 changes: 3 additions & 0 deletions src/i18n/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ const getLng = async (): Promise<keyof typeof resources | undefined> => {
return undefined;
};

export let getLanguage = 'en';

class I18nService extends Service {
private async initializeAsync(): Promise<void> {
const lng = await getLng();
getLanguage = lng || 'en';

this.t = await i18next.init({
lng,
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
"dontAskAgain": "Sempre permitir a captura de tela por video chamadas neste servidor",
"yes": "Permitir",
"no": "Cancelar"
},
"supportedVersion":{
"title": "Versão de workspace não suportada"
}
},
"downloads": {
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/ru.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,4 @@
"unreadMention": "Непрочитанные упоминания",
"noUnreadMessage": "Нет непрочитанных сообщений"
}
}
}
38 changes: 31 additions & 7 deletions src/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const resolveWithExponentialBackoff = <T>(
if (maxRetries === 0) {
throw error;
}

console.log(
'[Rocket.Chat Desktop] Inject resolveWithExponentialBackoff - retrying in 1 seconds'
);
return new Promise<T>((resolve) => {
setTimeout(() => {
resolve(
Expand Down Expand Up @@ -84,18 +86,18 @@ const start = async () => {
: 'meteor/konecty:user-presence';

const settingsModulePath = (() => {
if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
return '/app/settings/client/index.ts';
// if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
// return '/app/settings/client';
if (versionIsGreaterOrEqualsTo(serverInfo.version, '5.0.0'))
return '/app/settings/client';
return '/app/settings/client/index.ts';
return '/app/settings';
})();

const utilsModulePath = (() => {
if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
return '/app/utils/client/index.ts';
// if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
// return '/app/utils/client';
if (versionIsGreaterOrEqualsTo(serverInfo.version, '5.0.0'))
return '/app/utils/client';
return '/app/utils/client/index.ts';
return '/app/utils';
})();

Expand Down Expand Up @@ -171,6 +173,28 @@ const start = async () => {
window.RocketChatDesktop.setOutlookExchangeUrl(outlookExchangeUrl, userId);
});

Tracker.autorun(() => {
const userToken = Meteor._localStorage.getItem('Meteor.loginToken');
const userId = Meteor.userId();
const outlookCalendarEnabled = settings.get('Outlook_Calendar_Enabled');
const outlookExchangeUrl = settings.get('Outlook_Calendar_Exchange_Url');
console.log(
'[Rocket.Chat Desktop] outlookCalendarEnabled',
outlookCalendarEnabled
);
console.log('[Rocket.Chat Desktop] userToken', userToken);
console.log('[Rocket.Chat Desktop] userId', userId);
console.log('[Rocket.Chat Desktop] outlookExchangeUrl', outlookExchangeUrl);
if (!userToken || !userId || !outlookCalendarEnabled || !outlookExchangeUrl)
return;
console.log(
'[Rocket.Chat Desktop] window.RocketChatDesktop.setUserToken fired'
);
window.RocketChatDesktop.setUserToken(userToken, userId);

window.RocketChatDesktop.setOutlookExchangeUrl(outlookExchangeUrl, userId);
});

Tracker.autorun(() => {
const siteName = settings.get('Site_Name');
window.RocketChatDesktop.setTitle(siteName);
Expand Down
1 change: 1 addition & 0 deletions src/ipc/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type ChannelToArgsMap = {
'certificatesManager/remove': (domain: string) => void;
'server-view/get-url': () => Server['url'] | undefined;
'server-view/ready': () => void;
'server-view/open-url-on-browser': (url: string) => void;
'video-call-window/open-window': (url: string) => void;
'video-call-window/open-url': (url: string) => void;
'video-call-window/web-contents-id': (webContentsId: number) => void;
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { setupNotifications } from './notifications/main';
import { startOutlookCalendarUrlHandler } from './outlookCalendar/ipc';
import { setupScreenSharing } from './screenSharing/main';
import { setupServers } from './servers/main';
import { checkSupportedVersionServers } from './servers/supportedVersions/main';
import { setupSpellChecking } from './spellChecking/main';
import { createMainReduxStore } from './store';
import { handleCertificatesManager } from './ui/components/CertificatesManager/main';
Expand Down Expand Up @@ -97,6 +98,7 @@ const start = async (): Promise<void> => {
handleJitsiDesktopCapturerGetSources();
handleDesktopCapturerGetSources();
startOutlookCalendarUrlHandler();
checkSupportedVersionServers();

await processDeepLinksInArgs();
};
Expand Down
4 changes: 4 additions & 0 deletions src/public/main.css
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
@import '../node_modules/@rocket.chat/fuselage/dist/fuselage.css';

:root {
--rcx-color-surface-overlay: rgba(47, 52, 61, 0.5)
}
7 changes: 7 additions & 0 deletions src/servers/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { OutlookCredentials } from '../outlookCalendar/type';
import type { SupportedVersions } from './supportedVersions/types';

export type Server = {
url: string;
Expand All @@ -18,6 +19,12 @@ export type Server = {
gitCommitHash?: string;
allowedRedirects?: string[];
outlookCredentials?: OutlookCredentials;
version?: string;
uniqueID?: string;
isSupportedVersion?: boolean;
supportedVersionsSource?: 'server' | 'cloud' | 'builtin';
supportedVersions?: SupportedVersions;
expirationMessageLastTimeShown?: Date;
};

export const enum ServerUrlResolutionStatus {
Expand Down
14 changes: 14 additions & 0 deletions src/servers/preload/uniqueID.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dispatch } from '../../store';
import { WEBVIEW_SERVER_UNIQUE_ID_UPDATED } from '../../ui/actions';
import type { Server } from '../common';
import { getServerUrl } from './urls';

export const setWorkspaceUID = (uniqueID: Server['uniqueID']): void => {
dispatch({
type: WEBVIEW_SERVER_UNIQUE_ID_UPDATED,
payload: {
url: getServerUrl(),
uniqueID,
},
});
};
14 changes: 14 additions & 0 deletions src/servers/preload/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dispatch } from '../../store';
import { WEBVIEW_SERVER_VERSION_UPDATED } from '../../ui/actions';
import type { Server } from '../common';
import { getServerUrl } from './urls';

export const setVersion = (version: Server['version']): void => {
dispatch({
type: WEBVIEW_SERVER_VERSION_UPDATED,
payload: {
url: getServerUrl(),
version,
},
});
};
44 changes: 43 additions & 1 deletion src/servers/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ import {
WEBVIEW_ATTACHED,
WEBVIEW_GIT_COMMIT_HASH_CHANGED,
WEBVIEW_ALLOWED_REDIRECTS_CHANGED,
WEBVIEW_SERVER_SUPPORTED_VERSIONS_UPDATED,
WEBVIEW_SERVER_UNIQUE_ID_UPDATED,
WEBVIEW_SERVER_IS_SUPPORTED_VERSION,
WEBVIEW_SERVER_VERSION_UPDATED,
SUPPORTED_VERSION_DIALOG_DISMISS,
WEBVIEW_SIDEBAR_CUSTOM_THEME_CHANGED,
WEBVIEW_SERVER_SUPPORTED_VERSIONS_SOURCE_UPDATED,
} from '../ui/actions';
import { SERVERS_LOADED } from './actions';
import type { Server } from './common';
Expand Down Expand Up @@ -53,7 +59,13 @@ type ServersActionTypes =
| ActionOf<typeof WEBVIEW_DID_FAIL_LOAD>
| ActionOf<typeof WEBVIEW_READY>
| ActionOf<typeof WEBVIEW_ATTACHED>
| ActionOf<typeof OUTLOOK_CALENDAR_SAVE_CREDENTIALS>;
| ActionOf<typeof OUTLOOK_CALENDAR_SAVE_CREDENTIALS>
| ActionOf<typeof WEBVIEW_SERVER_SUPPORTED_VERSIONS_UPDATED>
| ActionOf<typeof WEBVIEW_SERVER_UNIQUE_ID_UPDATED>
| ActionOf<typeof WEBVIEW_SERVER_IS_SUPPORTED_VERSION>
| ActionOf<typeof WEBVIEW_SERVER_VERSION_UPDATED>
| ActionOf<typeof SUPPORTED_VERSION_DIALOG_DISMISS>
| ActionOf<typeof WEBVIEW_SERVER_SUPPORTED_VERSIONS_SOURCE_UPDATED>;

const upsert = (state: Server[], server: Server): Server[] => {
const index = state.findIndex(({ url }) => url === server.url);
Expand Down Expand Up @@ -107,6 +119,36 @@ export const servers: Reducer<Server[], ServersActionTypes> = (
return upsert(state, { url, title });
}

case WEBVIEW_SERVER_SUPPORTED_VERSIONS_UPDATED: {
const { url, supportedVersions } = action.payload;
return upsert(state, { url, supportedVersions });
}

case WEBVIEW_SERVER_SUPPORTED_VERSIONS_SOURCE_UPDATED: {
const { url, supportedVersionsSource } = action.payload;
return upsert(state, { url, supportedVersionsSource });
}

case SUPPORTED_VERSION_DIALOG_DISMISS: {
const { url } = action.payload;
return upsert(state, { url, expirationMessageLastTimeShown: new Date() });
}

case WEBVIEW_SERVER_UNIQUE_ID_UPDATED: {
const { url, uniqueID } = action.payload;
return upsert(state, { url, uniqueID });
}

case WEBVIEW_SERVER_IS_SUPPORTED_VERSION: {
const { url, isSupportedVersion } = action.payload;
return upsert(state, { url, isSupportedVersion });
}

case WEBVIEW_SERVER_VERSION_UPDATED: {
const { url, version } = action.payload;
return upsert(state, { url, version });
}

case WEBVIEW_UNREAD_CHANGED: {
const { url, badge } = action.payload;
return upsert(state, { url, badge });
Expand Down
Loading

0 comments on commit 5a83858

Please sign in to comment.