diff --git a/CHANGELOG.md b/CHANGELOG.md index aef741e05..0e378cb3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +## vNext (TBD) + +### Breaking Changes +* Removed all functionality related to Atlas Device Services / Device Sync. + +### Deprecations +* None + +### Enhancements +* None + +### Fixed +* None + +### Internal + + + + + ## 15.2.1 (2024-06-20) ### Fixed diff --git a/package-lock.json b/package-lock.json index 9757f7465..f4ba78510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "react-sortable-hoc": "^2.0.0", "react-virtualized": "^9.22.5", "reactstrap": "^9.2.2", - "realm": "^12.9.0", + "realm": "^20.0.0", "semver": "^7.6.0", "uuid": "^9.0.1" }, @@ -5432,9 +5432,9 @@ } }, "node_modules/detect-libc": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", - "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", "engines": { "node": ">=8" } @@ -12282,9 +12282,9 @@ "dev": true }, "node_modules/node-abi": { - "version": "3.28.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.28.0.tgz", - "integrity": "sha512-fRlDb4I0eLcQeUvGq7IY3xHrSb0c9ummdvDSYWfT9+LKP+3jCKw/tKoqaM7r1BAoiAC6GtwyjaGnOz6B3OtF+A==", + "version": "3.67.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.67.0.tgz", + "integrity": "sha512-bLn/fU/ALVBE9wj+p4Y21ZJWYFjUXLXPi/IewyLZkx3ApxKDNBWCKdReeKOtD8dWpOdDCeMyLh6ZewzcLsG2Nw==", "dependencies": { "semver": "^7.3.5" }, @@ -13931,9 +13931,9 @@ } }, "node_modules/prebuild-install": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", - "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", + "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", "dependencies": { "detect-libc": "^2.0.0", "expand-template": "^2.0.3", @@ -14746,9 +14746,9 @@ } }, "node_modules/realm": { - "version": "12.9.0", - "resolved": "https://registry.npmjs.org/realm/-/realm-12.9.0.tgz", - "integrity": "sha512-K7JblaSaqqFEu8kObgTCo1ITTYnR8rXYBdb5/5VXxD4VNKQVlrnO6Z4GhxDlohubmF8eNvRdC2wlHAsv2aUsOg==", + "version": "20.0.0", + "resolved": "https://registry.npmjs.org/realm/-/realm-20.0.0.tgz", + "integrity": "sha512-kkUFoDZiUD3KJct22apHCkUISXeV4TZM5DBa4Qxw1XncjU9GpuPCTkZo481++coDoy7wcBja9iPSNx57pzSZ3A==", "hasInstallScript": true, "dependencies": { "@realm/fetch": "^0.1.1", @@ -14756,7 +14756,7 @@ "debug": "^4.3.4", "node-machine-id": "^1.1.12", "path-browserify": "^1.0.1", - "prebuild-install": "^7.1.1" + "prebuild-install": "^7.1.2" }, "engines": { "node": ">=18" @@ -24259,9 +24259,9 @@ "dev": true }, "detect-libc": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", - "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==" + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==" }, "detect-node": { "version": "2.1.0", @@ -29497,9 +29497,9 @@ "dev": true }, "node-abi": { - "version": "3.28.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.28.0.tgz", - "integrity": "sha512-fRlDb4I0eLcQeUvGq7IY3xHrSb0c9ummdvDSYWfT9+LKP+3jCKw/tKoqaM7r1BAoiAC6GtwyjaGnOz6B3OtF+A==", + "version": "3.67.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.67.0.tgz", + "integrity": "sha512-bLn/fU/ALVBE9wj+p4Y21ZJWYFjUXLXPi/IewyLZkx3ApxKDNBWCKdReeKOtD8dWpOdDCeMyLh6ZewzcLsG2Nw==", "requires": { "semver": "^7.3.5" } @@ -30721,9 +30721,9 @@ } }, "prebuild-install": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", - "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", + "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", "requires": { "detect-libc": "^2.0.0", "expand-template": "^2.0.3", @@ -31353,16 +31353,16 @@ } }, "realm": { - "version": "12.9.0", - "resolved": "https://registry.npmjs.org/realm/-/realm-12.9.0.tgz", - "integrity": "sha512-K7JblaSaqqFEu8kObgTCo1ITTYnR8rXYBdb5/5VXxD4VNKQVlrnO6Z4GhxDlohubmF8eNvRdC2wlHAsv2aUsOg==", + "version": "20.0.0", + "resolved": "https://registry.npmjs.org/realm/-/realm-20.0.0.tgz", + "integrity": "sha512-kkUFoDZiUD3KJct22apHCkUISXeV4TZM5DBa4Qxw1XncjU9GpuPCTkZo481++coDoy7wcBja9iPSNx57pzSZ3A==", "requires": { "@realm/fetch": "^0.1.1", "bson": "^4.7.2", "debug": "^4.3.4", "node-machine-id": "^1.1.12", "path-browserify": "^1.0.1", - "prebuild-install": "^7.1.1" + "prebuild-install": "^7.1.2" } }, "recast": { diff --git a/package.json b/package.json index 16fc2c44b..73e8429cc 100644 --- a/package.json +++ b/package.json @@ -151,7 +151,7 @@ "react-sortable-hoc": "^2.0.0", "react-virtualized": "^9.22.5", "reactstrap": "^9.2.2", - "realm": "^12.9.0", + "realm": "^20.0.0", "semver": "^7.6.0", "uuid": "^9.0.1" }, diff --git a/src/actions/main/Sender.ts b/src/actions/main/Sender.ts index 16f3558b6..1d0492132 100644 --- a/src/actions/main/Sender.ts +++ b/src/actions/main/Sender.ts @@ -52,10 +52,6 @@ export class Sender extends ActionSender { return this.send(MainActions.ShowRealmBrowser, props); } - public showConnectToServer(url?: string) { - return this.send(MainActions.ShowConnectToServer, url); - } - public clearRendererCache() { return this.send(MainActions.ClearRendererCache); } diff --git a/src/main/Application.ts b/src/main/Application.ts index 223def6fc..f7f731868 100644 --- a/src/main/Application.ts +++ b/src/main/Application.ts @@ -24,10 +24,7 @@ import { CLOUD_PROTOCOL, STUDIO_PROTOCOL } from '../constants'; import * as dataImporter from '../services/data-importer'; import { showError } from '../ui/reusable/errors'; import { RealmLoadingMode } from '../utils/realms'; -import { - IRealmBrowserWindowProps, - IConnectToServerWindowProps, -} from '../windows/WindowProps'; +import { IRealmBrowserWindowProps } from '../windows/WindowProps'; import { removeRendererDirectories } from '../utils'; import { CertificateManager } from './CertificateManager'; @@ -53,9 +50,6 @@ export class Application { [MainActions.ShowOpenLocalRealm]: () => { return this.showOpenLocalRealm(); }, - [MainActions.ShowConnectToServer]: (url?: string) => { - return this.showConnectToServer({ url }); - }, [MainActions.ShowRealmBrowser]: (props: IRealmBrowserWindowProps) => { return this.showRealmBrowser(props); }, @@ -156,27 +150,6 @@ export class Application { return Promise.all(realmsLoaded); } - public showConnectToServer( - props: IConnectToServerWindowProps, - ): Promise { - const { window, existing } = this.windowManager.createWindow({ - type: 'connect-to-server', - props, - }); - - if (existing) { - window.focus(); - return Promise.resolve(); - } else { - return new Promise(resolve => { - window.show(); - window.webContents.once('did-finish-load', () => { - resolve(); - }); - }); - } - } - public showImportData(format: dataImporter.ImportFormat) { // Ask the users for the file names of files to import const paths = dataImporter.showOpenDialog(format); diff --git a/src/main/MainActions.ts b/src/main/MainActions.ts index 7212e3325..76b72c567 100644 --- a/src/main/MainActions.ts +++ b/src/main/MainActions.ts @@ -21,7 +21,6 @@ export enum MainActions { ShowGreeting = 'show-greeting', ShowImportData = 'show-import-data', ShowOpenLocalRealm = 'show-open-local-realm', - ShowConnectToServer = 'show-connect-to-server', ShowRealmBrowser = 'show-realm-browser', ClearRendererCache = 'clear-renderer-cache', } diff --git a/src/ui/ConnectToServer/AnonymousForm.tsx b/src/ui/ConnectToServer/AnonymousForm.tsx deleted file mode 100644 index 6fb41e232..000000000 --- a/src/ui/ConnectToServer/AnonymousForm.tsx +++ /dev/null @@ -1,25 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; - -export const AnonymousForm = () => ( -
- Authenticating anonymously -
-); diff --git a/src/ui/ConnectToServer/ApiKeyForm.tsx b/src/ui/ConnectToServer/ApiKeyForm.tsx deleted file mode 100644 index 799a9f9ee..000000000 --- a/src/ui/ConnectToServer/ApiKeyForm.tsx +++ /dev/null @@ -1,46 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; -import { Input } from 'reactstrap'; - -import { CredentialsFormGroup } from './CredentialsFormGroup'; - -export const ApiKeyForm = ({ - isRequired, - apiKey, - onApiKeyChanged, -}: { - isRequired: boolean; - apiKey: string; - onApiKeyChanged: (e: React.ChangeEvent) => void; -}) => ( -
- - - -
-); diff --git a/src/ui/ConnectToServer/AuthenticationForm.tsx b/src/ui/ConnectToServer/AuthenticationForm.tsx deleted file mode 100644 index 5383441b2..000000000 --- a/src/ui/ConnectToServer/AuthenticationForm.tsx +++ /dev/null @@ -1,95 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; - -import { AnonymousForm } from './AnonymousForm'; -import { ApiKeyForm } from './ApiKeyForm'; -import { AuthenticationMethodSelector } from './AuthenticationMethodSelector'; -import { JwtForm } from './JwtForm'; -import { EmailPasswordForm } from './EmailPasswordForm'; - -import { AuthenticationMethod } from '../../utils/realms'; - -export const AuthenticationForm = ({ - method, - email, - password, - token, - apiKey, - onMethodChanged, - onEmailChanged, - onPasswordChanged, - onTokenChanged, - onApiKeyChanged, -}: { - method: AuthenticationMethod; - email: string; - password: string; - token: string; - apiKey: string; - onMethodChanged: (method: AuthenticationMethod) => void; - onEmailChanged: (e: React.ChangeEvent) => void; - onPasswordChanged: (e: React.ChangeEvent) => void; - onTokenChanged: (e: React.ChangeEvent) => void; - onApiKeyChanged: (e: React.ChangeEvent) => void; -}) => { - let form; - switch (method) { - case AuthenticationMethod.anonymous: - form = ; - break; - case AuthenticationMethod.emailPassword: - form = ( - - ); - break; - case AuthenticationMethod.apiKey: - form = ( - - ); - break; - case AuthenticationMethod.jwt: - form = ( - - ); - break; - } - return ( -
- - {form} -
- ); -}; diff --git a/src/ui/ConnectToServer/AuthenticationMethodSelector.tsx b/src/ui/ConnectToServer/AuthenticationMethodSelector.tsx deleted file mode 100644 index 86a31e93e..000000000 --- a/src/ui/ConnectToServer/AuthenticationMethodSelector.tsx +++ /dev/null @@ -1,87 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; -import { Button } from 'reactstrap'; - -import { AuthenticationMethod } from '../../utils/realms'; - -export type MethodChangedHandler = (method: AuthenticationMethod) => void; - -const AuthenticationMethodButton = ({ - activeMethod, - children, - method, - onMethodChanged, -}: { - activeMethod: AuthenticationMethod; - children: React.ReactNode; - method: AuthenticationMethod; - onMethodChanged: MethodChangedHandler; -}) => ( - -); - -export const AuthenticationMethodSelector = ({ - method, - onMethodChanged, -}: { - method: AuthenticationMethod; - onMethodChanged: MethodChangedHandler; -}) => ( -
- - Anonymous - - - Email & password - - - API Key - - - JWT - -
-); diff --git a/src/ui/ConnectToServer/ConnectToServer.scss b/src/ui/ConnectToServer/ConnectToServer.scss deleted file mode 100644 index dcf24f023..000000000 --- a/src/ui/ConnectToServer/ConnectToServer.scss +++ /dev/null @@ -1,121 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -@import "~realm-studio-styles/variables"; - -.ConnectToServer { - -webkit-app-region: drag; - background: $window-background; - display: flex; - flex-direction: column; - height: 100%; - - input, - button { - -webkit-app-region: no-drag; - } - - &__Top { - display: flex; - flex-direction: column; - flex-grow: 1; - justify-content: flex-start; - padding: $spacer; - padding-bottom: 0; - } - - &__AppIdGroup, - &__ServerUrlGroup { - margin: 0; - } - - &__AuthenticationForm { - background: $white; - display: flex; - flex-basis: 150px; - flex-direction: column; - justify-content: space-around; - margin-top: 1.5 * $spacer; - padding: $spacer; - position: relative; - - &__Payload { - font-family: monospace; - height: 4 * 1.5em; - resize: none; - } - } - - &__AuthenticationMethodSelector { - display: flex; - justify-content: center; - left: 0; - position: absolute; - right: 0; - top: -$spacer; - - &__Btn { - margin: 0 ($spacer * .25); - } - } - - &__CredentialsFormGroup { - margin: $spacer; - } - - &__CredentialsLabelCol { - align-items: center; - display: flex; - justify-content: flex-end; - } - - &__AnonymousForm { - text-align: center; - } - - &__CredentialsLabel { - margin-bottom: 0; - padding-right: $spacer; - } - - &__Controls { - display: flex; - padding: 0 $spacer; - } - - &__SaveCredentials { - flex-grow: 1; - font-size: .8rem; - } - - &__SaveCredentials, - &__Actions { - align-items: center; - display: flex; - height: 100%; - } - - &__Actions { - flex-grow: 1; - justify-content: center; - } - - &__ControlBtn { - margin: $spacer * .25; - } -} diff --git a/src/ui/ConnectToServer/ConnectToServer.tsx b/src/ui/ConnectToServer/ConnectToServer.tsx deleted file mode 100644 index 35d4d8999..000000000 --- a/src/ui/ConnectToServer/ConnectToServer.tsx +++ /dev/null @@ -1,153 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; -import { Button, Form, FormGroup, Input, Label } from 'reactstrap'; - -import { LoadingOverlay } from '../reusable/LoadingOverlay'; -import { AuthenticationMethod } from '../../utils/realms'; -import { AuthenticationForm } from './AuthenticationForm'; - -import './ConnectToServer.scss'; - -export const ConnectToServer = ({ - method, - onCancel, - onSubmit, - onUrlChanged, - onAppIdChanged, - onMethodChanged, - onEmailChanged, - onPasswordChanged, - onApiKeyChanged, - onTokenChanged, - onSaveCredentialsChanged, - appId, - url, - email, - password, - apiKey, - token, - saveCredentials, - isConnecting, -}: { - method: AuthenticationMethod; - onCancel: () => void; - onSubmit: () => void; - onAppIdChanged: (e: React.ChangeEvent) => void; - onUrlChanged: (e: React.ChangeEvent) => void; - onMethodChanged: (method: AuthenticationMethod) => void; - onEmailChanged: (e: React.ChangeEvent) => void; - onPasswordChanged: (e: React.ChangeEvent) => void; - onApiKeyChanged: (e: React.ChangeEvent) => void; - onTokenChanged: (e: React.ChangeEvent) => void; - onSaveCredentialsChanged: (saveCredentials: boolean) => void; - appId: string; - url: string; - email: string; - password: string; - apiKey: string; - token: string; - saveCredentials: boolean; - isConnecting: boolean; -}) => { - return ( -
{ - e.preventDefault(); - onSubmit(); - }} - > -
- - - - - - - - -
- -
- {/* - - - - */} - - - - -
- - - ); -}; diff --git a/src/ui/ConnectToServer/CredentialsFormGroup.tsx b/src/ui/ConnectToServer/CredentialsFormGroup.tsx deleted file mode 100644 index 8d80e92e7..000000000 --- a/src/ui/ConnectToServer/CredentialsFormGroup.tsx +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; -import { Col, FormGroup, Label, Row } from 'reactstrap'; - -export const CredentialsFormGroup = ({ - label, - labelFor, - children, -}: { - label: string; - labelFor: string; - children: React.ReactElement; -}) => ( - - - - - - {children} - - -); diff --git a/src/ui/ConnectToServer/EmailPasswordForm.tsx b/src/ui/ConnectToServer/EmailPasswordForm.tsx deleted file mode 100644 index d322255d8..000000000 --- a/src/ui/ConnectToServer/EmailPasswordForm.tsx +++ /dev/null @@ -1,57 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; -import { Input } from 'reactstrap'; - -import { CredentialsFormGroup } from './CredentialsFormGroup'; - -export const EmailPasswordForm = ({ - email, - password, - onEmailChanged, - onPasswordChanged, -}: { - email: string; - password: string; - onEmailChanged: (e: React.ChangeEvent) => void; - onPasswordChanged: (e: React.ChangeEvent) => void; -}) => ( -
- - - - - - -
-); diff --git a/src/ui/ConnectToServer/JwtForm.tsx b/src/ui/ConnectToServer/JwtForm.tsx deleted file mode 100644 index 5f0809fe0..000000000 --- a/src/ui/ConnectToServer/JwtForm.tsx +++ /dev/null @@ -1,46 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; -import { Input } from 'reactstrap'; - -import { CredentialsFormGroup } from './CredentialsFormGroup'; - -export const JwtForm = ({ - isRequired, - token, - onTokenChanged, -}: { - isRequired: boolean; - token: string; - onTokenChanged: (e: React.ChangeEvent) => void; -}) => ( -
- - - -
-); diff --git a/src/ui/ConnectToServer/index.tsx b/src/ui/ConnectToServer/index.tsx deleted file mode 100644 index da15ec9b8..000000000 --- a/src/ui/ConnectToServer/index.tsx +++ /dev/null @@ -1,309 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -/* -import electron from 'electron'; -import json5 from 'json5'; -*/ -import React from 'react'; -import { App } from 'realm'; -import * as electron from '@electron/remote'; - -import { main } from '../../actions/main'; -import { showError } from '../reusable/errors'; -import { - RealmLoadingMode, - AuthenticationMethod, - hydrateCredentials, - SerializedCredentials, -} from '../../utils/realms'; - -import { ConnectToServer } from './ConnectToServer'; - -const DEFAULT_BASE_URL = 'https://services.cloud.mongodb.com'; -const LEGACY_BASE_URL = 'https://realm.mongodb.com'; - -/* -const MISSING_PARAMS_MESSAGE = - 'Your request did not validate because of missing parameters.'; -const INVALID_PARAMS_MESSAGE = 'Your request parameters did not validate.'; -*/ - -interface IConnectToServerContainerProps { - url?: string; -} - -interface IConnectToServerContainerState { - isConnecting: boolean; - method: AuthenticationMethod; - appId: string; - url: string; - email: string; - password: string; - apiKey: string; - token: string; - saveCredentials: boolean; -} - -class ConnectToServerContainer extends React.Component< - IConnectToServerContainerProps, - IConnectToServerContainerState -> { - public state: IConnectToServerContainerState = { - isConnecting: false, - method: AuthenticationMethod.anonymous, - appId: '', - url: '', - email: '', - password: '', - apiKey: '', - token: '', - saveCredentials: false, - }; - - public render() { - return ; - } - - public componentDidMount() { - const url = this.props.url || this.getLatestUrl(); - this.setState({ - // Use an empty input instead of filling in the default URL - url: url === DEFAULT_BASE_URL || url === LEGACY_BASE_URL ? '' : url, - appId: this.getLatestAppId(), - }); - // this.restoreCredentials(url); - } - - public componentDidUpdate( - prevProps: unknown, - prevState: IConnectToServerContainerState, - ) { - // TODO: XXX - /* - if (this.state.url !== prevState.url) { - this.restoreCredentials(this.state.url); - } - */ - } - - public onCancel = () => { - electron.getCurrentWindow().close(); - }; - - public onSubmit = async () => { - this.setState({ - isConnecting: true, - }); - - try { - const { appId, url } = this.state; - // Use SDK default (passing undefined) on an empty string. - const baseUrl = url || DEFAULT_BASE_URL; - // TODO: Clear test state to invalidate the shared App cache as a work around for - // https://github.com/realm/realm-js/issues/6276 - const app = new App({ id: appId, baseUrl }); - const serializedCredentials = this.serializeCredentials(); - const credentials = hydrateCredentials(serializedCredentials); - await app.logIn(credentials); - - /* - if (this.state.saveCredentials) { - await setCredentials(baseUrl, credentials); - } else { - await unsetCredentials(baseUrl); - } - */ - - this.setLatestUrl(baseUrl); - this.setLatestAppId(appId); - await main.showRealmBrowser({ - realm: { - mode: RealmLoadingMode.Synced, - serverUrl: baseUrl, - appId, - // TODO: Fix this ugly hack by making the credentials serializable - credentials: serializedCredentials, - }, - }); - electron.getCurrentWindow().close(); - } catch (err) { - showError(`Couldn't connect to Atlas App Services`, err, { - 'Failed to fetch': 'Could not reach the server.', - }); - } finally { - this.setState({ - isConnecting: false, - }); - } - }; - - public onAppIdChanged = (e: React.ChangeEvent) => { - this.setState({ - appId: e.target.value, - }); - }; - - public onUrlChanged = (e: React.ChangeEvent) => { - this.setState({ - url: e.target.value, - }); - }; - - public onMethodChanged = (method: AuthenticationMethod) => { - this.setState({ - method, - }); - }; - - public onEmailChanged = (e: React.ChangeEvent) => { - this.setState({ - email: e.target.value, - }); - }; - - public onPasswordChanged = (e: React.ChangeEvent) => { - this.setState({ - password: e.target.value, - }); - }; - - public onApiKeyChanged = (e: React.ChangeEvent) => { - this.setState({ - apiKey: e.target.value, - }); - }; - - public onTokenChanged = (e: React.ChangeEvent) => { - this.setState({ - token: e.target.value, - }); - }; - - public onSaveCredentialsChanged = (saveCredentials: boolean) => { - this.setState({ - saveCredentials, - }); - }; - - private serializeCredentials(): SerializedCredentials { - const { method } = this.state; - switch (method) { - case AuthenticationMethod.anonymous: - return { - method: AuthenticationMethod.anonymous, - payload: {}, - }; - case AuthenticationMethod.emailPassword: - return { - method: AuthenticationMethod.emailPassword, - payload: { - email: this.state.email, - password: this.state.password, - }, - }; - case AuthenticationMethod.apiKey: - return { - method: AuthenticationMethod.apiKey, - payload: { - apiKey: this.state.apiKey, - }, - }; - case AuthenticationMethod.jwt: - return { - method: AuthenticationMethod.jwt, - payload: { - token: this.state.token, - }, - }; - default: - throw new Error(`The method is not supported: ${method}`); - } - } - - /* - private getMethodFromCredentials(credentials: ros.IServerCredentials) { - switch (credentials.kind) { - case 'password': - return AuthenticationMethod.usernamePassword; - case 'token': - return AuthenticationMethod.adminToken; - case 'other': - return AuthenticationMethod.other; - case 'jwt': - return AuthenticationMethod.jwt; - default: - throw new Error('Unexpected authentication method'); - } - } - - private async restoreCredentials(url: string) { - const preparedUrl = this.prepareUrl(url); - const credentials = await getCredentials(preparedUrl); - if (credentials) { - const method = this.getMethodFromCredentials(credentials); - // The default state is to reset everything - const state = { - method, - username: '', - password: '', - token: '', - otherOptions: '', - saveCredentials: true, - providerName: '', - }; - - if (credentials.kind === 'password') { - state.username = credentials.username; - state.password = credentials.password; - } else if (credentials.kind === 'token') { - state.token = credentials.token; - } else if (credentials.kind === 'other') { - state.otherOptions = JSON.stringify(credentials.options, undefined, 2); - } else if (credentials.kind === 'jwt') { - state.token = credentials.token; - state.providerName = credentials.providerName; - } - - this.setState(state); - } else { - this.setState({ - saveCredentials: false, - }); - } - } - */ - - private setLatestUrl(url: string) { - localStorage.setItem('latest-base-url', url); - } - - private getLatestUrl() { - return localStorage.getItem('latest-base-url') || ''; - } - - private setLatestAppId(appId: string) { - localStorage.setItem('latest-app-id', appId); - } - - private getLatestAppId() { - return localStorage.getItem('latest-app-id') || ''; - } -} - -export { ConnectToServerContainer as ConnectToServer }; diff --git a/src/ui/Greeting/Greeting.tsx b/src/ui/Greeting/Greeting.tsx index f1a1e7448..3a40b99a8 100644 --- a/src/ui/Greeting/Greeting.tsx +++ b/src/ui/Greeting/Greeting.tsx @@ -34,13 +34,11 @@ const { app } = remote; export const Greeting = ({ onCheckForUpdates, onOpenLocalRealm, - onConnectToServer, updateStatus, version, }: { onCheckForUpdates: () => void; onOpenLocalRealm: () => void; - onConnectToServer: () => void; updateStatus: IUpdateStatus; version: string; }) => ( @@ -61,11 +59,6 @@ export const Greeting = ({
-
- -
New to realm? diff --git a/src/ui/Greeting/index.tsx b/src/ui/Greeting/index.tsx index 577473d1a..d48cb44a9 100644 --- a/src/ui/Greeting/index.tsx +++ b/src/ui/Greeting/index.tsx @@ -76,10 +76,6 @@ class GreetingContainer extends React.Component< main.showOpenLocalRealm(); }; - public onConnectToServer = () => { - main.showConnectToServer(); - }; - public onCheckForUpdates = () => { main.checkForUpdates(); }; diff --git a/src/ui/RealmBrowser/AddSubscriptionModal/AddSubscriptionModal.scss b/src/ui/RealmBrowser/AddSubscriptionModal/AddSubscriptionModal.scss deleted file mode 100644 index 6f0c065d2..000000000 --- a/src/ui/RealmBrowser/AddSubscriptionModal/AddSubscriptionModal.scss +++ /dev/null @@ -1,30 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2023 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -@import "~realm-studio-styles/variables"; - -.AddSubscriptionsModal { - &__Query { - font-family: $font-family-monospace; - } - - &__Hint { - font-size: .875em; - margin-top: .25rem; - } -} diff --git a/src/ui/RealmBrowser/AddSubscriptionModal/AddSubscriptionModal.tsx b/src/ui/RealmBrowser/AddSubscriptionModal/AddSubscriptionModal.tsx deleted file mode 100644 index 87bbada1d..000000000 --- a/src/ui/RealmBrowser/AddSubscriptionModal/AddSubscriptionModal.tsx +++ /dev/null @@ -1,97 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; -import { - Button, - Form, - FormFeedback, - FormGroup, - Input, - Label, - Modal, - ModalBody, - ModalFooter, - ModalHeader, -} from 'reactstrap'; - -import './AddSubscriptionModal.scss'; - -export const AddSubscriptionModal = ({ - isOpen, - toggle, - onSubmit, - schemaName, - query, - queryError, - onQueryChange, -}: { - isOpen: boolean; - toggle: () => void; - onSubmit: (e: React.FormEvent) => void; - schemaName: string; - query: string; - queryError: string | null; - onQueryChange: (e: React.ChangeEvent) => void; -}) => { - return ( - -
- - Add subscription on {schemaName} - - - - - - {queryError ? ( - {queryError} - ) : ( -
- {!query || query === 'TRUEPREDICATE' ? ( - <> - The TRUEPREDICATE query will match all objects - - ) : ( - <>  - )} -
- )} -
-
- - {' '} - - -
-
- ); -}; diff --git a/src/ui/RealmBrowser/AddSubscriptionModal/index.tsx b/src/ui/RealmBrowser/AddSubscriptionModal/index.tsx deleted file mode 100644 index 779146b65..000000000 --- a/src/ui/RealmBrowser/AddSubscriptionModal/index.tsx +++ /dev/null @@ -1,75 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; - -import { AddSubscriptionModal } from './AddSubscriptionModal'; - -export interface IAddSubscriptionModalProps { - isOpen: boolean; - onAddSubscription: (schemaName: string, queryString: string) => void; - validateQuery: (schemaName: string, queryString: string) => string | null; - schemaName: string; - toggle: () => void; -} - -export interface IAddSubscriptionModalState { - query: string; - queryError: string | null; -} - -const initialState: IAddSubscriptionModalState = { - query: '', - queryError: null, -}; - -class AddSubscriptionModalContainer extends React.Component< - IAddSubscriptionModalProps, - IAddSubscriptionModalState -> { - public state = { ...initialState }; - - public render() { - return ; - } - - public onSubmit = (e: React.FormEvent) => { - e.preventDefault(); - this.props.onAddSubscription( - this.props.schemaName, - // Fallback to selecting all objects - this.state.query || 'TRUEPREDICATE', - ); - this.props.toggle(); - this.setState(initialState); - }; - - public onQueryChange = (e: React.ChangeEvent) => { - const query = e.target.value; - this.setState({ - query, - queryError: this.props.validateQuery( - this.props.schemaName, - // Fallback to selecting all objects - query || 'TRUEPREDICATE', - ), - }); - }; -} - -export { AddSubscriptionModalContainer as AddSubscriptionModal }; diff --git a/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.scss b/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.scss index 22407ea16..faff21c3a 100644 --- a/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.scss +++ b/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.scss @@ -172,12 +172,6 @@ white-space: nowrap; } - &__Subscriptions { - font-size: .8rem; - overflow-y: auto; - padding: $spacer * .25; - } - &__SubscriptionItem { display: flex; font-family: $font-family-monospace; diff --git a/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.tsx b/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.tsx index 8af2aedcf..39ee2ff0c 100644 --- a/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.tsx +++ b/src/ui/RealmBrowser/LeftSidebar/LeftSidebar.tsx @@ -25,7 +25,6 @@ import { ILoadingProgress, Sidebar } from '../../reusable'; import { Focus, IListFocus } from '../focus'; import { ParentObjectFocus } from './ParentObjectFocus'; -import { SubscriptionList } from './SubscriptionList'; import './LeftSidebar.scss'; @@ -55,13 +54,10 @@ export interface ILeftSidebarProps { hiddenClassCount: number; isOpen: boolean; onClassFocussed: ClassFocussedHandler; - onSubscriptionRemoved: (subscription: Realm.App.Sync.Subscription) => void; onToggle: () => void; progress: ILoadingProgress; readOnly: boolean; - subscriptions: Realm.App.Sync.SubscriptionSet | undefined; toggleAddClass: () => void; - toggleAddSubscription: () => void; } export const LeftSidebar = ({ @@ -72,13 +68,10 @@ export const LeftSidebar = ({ hiddenClassCount, isOpen, onClassFocussed, - onSubscriptionRemoved, onToggle, progress, readOnly, - subscriptions, toggleAddClass, - toggleAddSubscription, }: ILeftSidebarProps) => ( Opened as "Read Only"

) : null}
- {(focus?.kind === 'class' || focus?.kind === 'list') && subscriptions && ( - <> -
- subscriptions - -
- sub.objectType === getFocusedSchemaName(focus), - )} - onSubscriptionRemoved={onSubscriptionRemoved} - /> - - )} ); diff --git a/src/ui/RealmBrowser/LeftSidebar/SubscriptionItem.tsx b/src/ui/RealmBrowser/LeftSidebar/SubscriptionItem.tsx deleted file mode 100644 index 91be30b98..000000000 --- a/src/ui/RealmBrowser/LeftSidebar/SubscriptionItem.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React, { useState } from 'react'; -import { Popover, PopoverBody } from 'reactstrap'; -import Realm from 'realm'; - -export type SubscriptionItemProps = { - subscription: Realm.App.Sync.Subscription; - onSubscriptionRemoved: (subscription: Realm.App.Sync.Subscription) => void; -}; - -export function SubscriptionItem({ - subscription, - onSubscriptionRemoved, -}: SubscriptionItemProps) { - const [isHintOpen, setHintOpen] = useState(false); - const hintId = `subscription-hint-${subscription.id.toHexString()}`; - return ( -
  • - - {subscription.queryString} - - - {subscription.queryString === 'TRUEPREDICATE' && ( - <> - setHintOpen(true)} - onMouseLeave={() => setHintOpen(false)} - /> - - This query will match all objects - - - )} - { - onSubscriptionRemoved(subscription); - }} - /> - -
  • - ); -} diff --git a/src/ui/RealmBrowser/LeftSidebar/SubscriptionList.tsx b/src/ui/RealmBrowser/LeftSidebar/SubscriptionList.tsx deleted file mode 100644 index 09d12e40e..000000000 --- a/src/ui/RealmBrowser/LeftSidebar/SubscriptionList.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; - -import { SubscriptionItem } from './SubscriptionItem'; - -export type SubscriptionListProps = { - subscriptions: Realm.App.Sync.Subscription[]; - onSubscriptionRemoved: (subscription: Realm.App.Sync.Subscription) => void; -}; - -export function SubscriptionList({ - subscriptions, - onSubscriptionRemoved, -}: SubscriptionListProps) { - return ( - <> -
      - {subscriptions.length === 0 && Click + to add subscriptions} - {subscriptions.map(subscription => ( - - ))} -
    - - ); -} diff --git a/src/ui/RealmBrowser/LeftSidebar/index.tsx b/src/ui/RealmBrowser/LeftSidebar/index.tsx index 08a03e275..76076e3b4 100644 --- a/src/ui/RealmBrowser/LeftSidebar/index.tsx +++ b/src/ui/RealmBrowser/LeftSidebar/index.tsx @@ -39,9 +39,7 @@ interface ILeftSidebarContainerProps { onToggle: () => void; progress: ILoadingProgress; readOnly?: boolean; - subscriptions: Realm.App.Sync.SubscriptionSet | undefined; toggleAddClass: () => void; - toggleAddSubscription: () => void; } interface ILeftSidebarContainerState { @@ -84,13 +82,10 @@ class LeftSidebarContainer extends React.Component< hiddenClassCount={hiddenClassCount} isOpen={this.props.isOpen} onClassFocussed={this.props.onClassFocussed} - onSubscriptionRemoved={this.onSubscriptionRemoved} onToggle={this.props.onToggle} progress={this.props.progress} readOnly={this.props.readOnly || false} - subscriptions={this.props.subscriptions} toggleAddClass={this.props.toggleAddClass} - toggleAddSubscription={this.props.toggleAddSubscription} /> ); } @@ -129,21 +124,6 @@ class LeftSidebarContainer extends React.Component< return false; } } - - private onSubscriptionRemoved = ( - subscription: Realm.App.Sync.Subscription, - ) => { - const { subscriptions } = this.props; - if (subscriptions) { - subscriptions.update(subs => { - subs.removeSubscription(subscription); - }); - } else { - throw new Error( - 'Failed to delete subscription from a missing list of subscriptions', - ); - } - }; } export { LeftSidebarContainer as LeftSidebar }; diff --git a/src/ui/RealmBrowser/NoSubscriptionsPlaceholder.tsx b/src/ui/RealmBrowser/NoSubscriptionsPlaceholder.tsx deleted file mode 100644 index 42c3b9f08..000000000 --- a/src/ui/RealmBrowser/NoSubscriptionsPlaceholder.tsx +++ /dev/null @@ -1,23 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import React from 'react'; - -export const NoSubscriptionsPlaceholder = () => ( -
    -); diff --git a/src/ui/RealmBrowser/RealmBrowser.scss b/src/ui/RealmBrowser/RealmBrowser.scss index addddf289..bba802c5e 100644 --- a/src/ui/RealmBrowser/RealmBrowser.scss +++ b/src/ui/RealmBrowser/RealmBrowser.scss @@ -440,7 +440,6 @@ } &__NoFocusPlaceholder, - &__NoSubscriptionsPlaceholder, &__EmbeddedFocusPlaceholder { align-items: center; display: flex; @@ -456,13 +455,6 @@ } } - &__NoSubscriptionsPlaceholder { - &::before { - color: $elephant; - content: "Add a subscription to see objects"; - } - } - &__EmbeddedFocusPlaceholder { &::before { color: $elephant; diff --git a/src/ui/RealmBrowser/RealmBrowser.tsx b/src/ui/RealmBrowser/RealmBrowser.tsx index b60679d8f..1fb20cee2 100644 --- a/src/ui/RealmBrowser/RealmBrowser.tsx +++ b/src/ui/RealmBrowser/RealmBrowser.tsx @@ -31,13 +31,11 @@ import { } from '.'; import { AddClassModal } from './AddClassModal'; import { AddPropertyModal } from './AddPropertyModal'; -import { AddSubscriptionModal } from './AddSubscriptionModal'; import { Content, EditMode, HighlightMode } from './Content'; import { EncryptionDialog } from './EncryptionDialog'; import { Focus, IClassFocus } from './focus'; import { LeftSidebar } from './LeftSidebar'; import { NoFocusPlaceholder } from './NoFocusPlaceholder'; -import { NoSubscriptionsPlaceholder } from './NoSubscriptionsPlaceholder'; import { EmbeddedFocusPlaceholder } from './EmbeddedFocusPlaceholder'; import { ImportDialog } from './ImportDialog'; import { JsonViewerDialog } from './JsonViewerDialog'; @@ -67,7 +65,6 @@ export interface IRealmBrowserProps { jsonViewerDialog: null | { value: unknown }; onAddClass: (schema: Realm.ObjectSchema) => void; onAddProperty: (name: string, type: Realm.PropertyType | string) => void; - onAddSubscription: (schemaName: string, query: string) => void; onCancelTransaction: () => void; onClassFocussed: ClassFocussedHandler; onCommitTransaction: () => void; @@ -85,7 +82,6 @@ export interface IRealmBrowserProps { realm?: Realm; toggleAddClass: () => void; toggleAddClassProperty: () => void; - toggleAddSubscription: () => void; validateQuery: (schemaName: string, queryString: string) => string | null; isEmbeddedType: IsEmbeddedTypeChecker; } @@ -104,7 +100,6 @@ export const RealmBrowser = ({ importDialog, isAddClassOpen, isAddPropertyOpen, - isAddSubscriptionOpen, isClassNameAvailable, isEncryptionDialogVisible, isLeftSidebarOpen, @@ -112,7 +107,6 @@ export const RealmBrowser = ({ jsonViewerDialog, onAddClass, onAddProperty, - onAddSubscription, onCancelTransaction, onClassFocussed, onCommitTransaction, @@ -130,14 +124,9 @@ export const RealmBrowser = ({ realm, toggleAddClass, toggleAddClassProperty, - toggleAddSubscription, validateQuery, isEmbeddedType, }: IRealmBrowserProps) => { - const focussedClassMissingSubscriptions = - focus?.kind === 'class' && - realm?.syncSession?.config.flexible && - ![...realm.subscriptions].some(sub => sub.objectType === focus.className); return (
    - {focussedClassMissingSubscriptions ? ( - - ) : focus && realm ? ( + {focus && realm ? ( ) : null} - {focus && focus.kind === 'class' ? ( - - ) : null} - @@ -545,12 +543,6 @@ class RealmBrowserContainer }); }; - private toggleAddSubscription = () => { - this.setState({ - isAddSubscriptionOpen: !this.state.isAddSubscriptionOpen, - }); - }; - private onAddClass = async (schema: Realm.ObjectSchema) => { if (this.realm) { try { @@ -611,19 +603,6 @@ class RealmBrowserContainer } }; - private onAddSubscription = (schemaName: string, queryString: string) => { - const { realm } = this; - if (realm) { - try { - realm.subscriptions.update(subs => { - subs.add(realm.objects(schemaName).filtered(queryString)); - }); - } catch (err) { - showError(`Failed creating subscription on "${schemaName}"`, err); - } - } - }; - private changeFocusIfAllowed(focus: Focus, highlightedObject?: Realm.Object) { const canChangeFocus = this.canChangeFocus(); if (canChangeFocus) { diff --git a/src/ui/reusable/RealmLoadingComponent/index.tsx b/src/ui/reusable/RealmLoadingComponent/index.tsx index 137df7459..803f3aaa7 100644 --- a/src/ui/reusable/RealmLoadingComponent/index.tsx +++ b/src/ui/reusable/RealmLoadingComponent/index.tsx @@ -19,11 +19,7 @@ import Realm from 'realm'; import React from 'react'; -import { - RealmLoadingMode, - RealmToLoad, - hydrateCredentials, -} from '../../../utils/realms'; +import { RealmToLoad } from '../../../utils/realms'; import { ILoadingProgress } from '../LoadingOverlay'; export interface IRealmLoadingComponentState { @@ -113,70 +109,40 @@ export abstract class RealmLoadingComponent< schemaVersion?: number, ): Promise { if (realm) { - if (realm.mode === RealmLoadingMode.Local) { - try { - return new Realm({ - path: realm.path, - encryptionKey: realm.encryptionKey, - disableFormatUpgrade: realm.enableFormatUpgrade ? false : true, - openSyncedRealmLocally: realm.sync, - schema, - schemaVersion, - } satisfies Realm.Configuration & { - openSyncedRealmLocally?: boolean; - } as any); - } catch (error) { - if ( - error instanceof Error && - (error.message.includes('Incompatible histories.') || - error.message.includes('History type not consistent') || - error.message.startsWith( - 'History type (as specified by the Replication implementation passed to the DB constructor) was not consistent across the session', - ) || - error.message.includes( - 'Synchronized Realms cannot be opened in non-sync mode', - )) && - realm.sync !== true - ) { - // Try to open the Realm locally with a sync history mode. - console.log('Trying to open sync Realm as local Realm'); - return this.openRealm( - { ...realm, sync: true }, - schema, - schemaVersion, - ); - } - // Other errors, propagate it. - throw error; - } - } else if (realm.mode === RealmLoadingMode.Synced) { - const app = new Realm.App({ - id: realm.appId, - baseUrl: realm.serverUrl, - }); - const credentials = hydrateCredentials(realm.credentials); - const user = await app.logIn(credentials); - return Realm.open({ + try { + return new Realm({ + path: realm.path, encryptionKey: realm.encryptionKey, - sync: { - user, - flexible: true, - /* - initialSubscriptions: { - update(subs, realm) { - for (const schema of realm.schema) { - const query = realm.objects(schema.name); - subs.add(query); - } - }, - }, - */ - }, + disableFormatUpgrade: realm.enableFormatUpgrade ? false : true, + openSyncedRealmLocally: realm.sync, schema, schemaVersion, - }); - } else { - throw new Error('Unexpected mode'); + } satisfies Realm.Configuration & { + openSyncedRealmLocally?: boolean; + } as any); + } catch (error) { + if ( + error instanceof Error && + (error.message.includes('Incompatible histories.') || + error.message.includes('History type not consistent') || + error.message.startsWith( + 'History type (as specified by the Replication implementation passed to the DB constructor) was not consistent across the session', + ) || + error.message.includes( + 'Synchronized Realms cannot be opened in non-sync mode', + )) && + realm.sync !== true + ) { + // Try to open the Realm locally with a sync history mode. + console.log('Trying to open sync Realm as local Realm'); + return this.openRealm( + { ...realm, sync: true }, + schema, + schemaVersion, + ); + } + // Other errors, propagate it. + throw error; } } else { throw new Error(`Called without a realm to load`); diff --git a/src/utils/realms.ts b/src/utils/realms.ts index c72d41c01..12a3a8533 100644 --- a/src/utils/realms.ts +++ b/src/utils/realms.ts @@ -16,11 +16,8 @@ // //////////////////////////////////////////////////////////////////////////// -import { Credentials } from 'realm'; - export enum RealmLoadingMode { Local = 'local', - Synced = 'synced', } export interface IRealmToLoad { @@ -68,29 +65,4 @@ export type SerializedCredentials = }; }; -export interface ISyncedRealmToLoad extends IRealmToLoad { - mode: RealmLoadingMode.Synced; - serverUrl: string; - appId: string; - credentials: SerializedCredentials; -} - -export type RealmToLoad = ILocalRealmToLoad | ISyncedRealmToLoad; - -export function hydrateCredentials({ - method, - payload, -}: SerializedCredentials): Credentials { - switch (method) { - case AuthenticationMethod.anonymous: - return Credentials.anonymous(); - case AuthenticationMethod.emailPassword: - return Credentials.emailPassword(payload.email, payload.password); - case AuthenticationMethod.apiKey: - return Credentials.apiKey(payload.apiKey); - case AuthenticationMethod.jwt: - return Credentials.jwt(payload.token); - default: - throw new Error(`The method is not supported: ${method}`); - } -} +export type RealmToLoad = ILocalRealmToLoad; diff --git a/src/windows/ConnectToServerWindow.tsx b/src/windows/ConnectToServerWindow.tsx deleted file mode 100644 index 156437772..000000000 --- a/src/windows/ConnectToServerWindow.tsx +++ /dev/null @@ -1,43 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2018 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -import { IWindow } from './Window'; - -export interface IConnectToServerWindowProps { - url?: string; -} - -export const ConnectToServerWindow: IWindow = { - getWindowOptions: () => ({ - title: 'Connect via Atlas Device Sync', - width: 500, - height: 450, - resizable: false, - fullscreenable: false, - autoHideMenuBar: true, - frame: false, - }), - getComponent: () => - import( - /* webpackChunkName: "connect-to-server" */ '../ui/ConnectToServer' - ).then( - // TODO: Fix the props for this to include a type - m => m.ConnectToServer as any, - ), - getTrackedProperties: () => ({}), -}; diff --git a/src/windows/RealmBrowserWindow.tsx b/src/windows/RealmBrowserWindow.tsx index b5755a754..cd7ce6d51 100644 --- a/src/windows/RealmBrowserWindow.tsx +++ b/src/windows/RealmBrowserWindow.tsx @@ -17,7 +17,7 @@ //////////////////////////////////////////////////////////////////////////// import { ImportFormat } from '../services/data-importer'; -import { RealmLoadingMode, RealmToLoad } from '../utils/realms'; +import { RealmToLoad } from '../utils/realms'; import { IWindow } from './Window'; @@ -36,10 +36,7 @@ export interface IRealmBrowserWindowProps { export const RealmBrowserWindow: IWindow = { getWindowOptions: (props: IRealmBrowserWindowProps) => { return { - title: - props.realm.mode === RealmLoadingMode.Local - ? props.realm.path - : props.realm.appId, + title: props.realm.path, width: 900, height: 600, }; @@ -51,15 +48,7 @@ export const RealmBrowserWindow: IWindow = { ), getSingletonKey: (props: IRealmBrowserWindowProps) => { const { realm } = props; - if (realm.mode === RealmLoadingMode.Local) { - return realm.path; - } else { - return [ - realm.appId, - realm.serverUrl, - JSON.stringify(realm.credentials), - ].join('+'); - } + return realm.path; }, getTrackedProperties: (props: IRealmBrowserWindowProps) => ({ mode: props.realm.mode, diff --git a/src/windows/Window.tsx b/src/windows/Window.tsx index 220741bcb..4e2b1d4c0 100644 --- a/src/windows/Window.tsx +++ b/src/windows/Window.tsx @@ -35,7 +35,6 @@ export interface IWindow { import { GreetingWindow } from './GreetingWindow'; import { RealmBrowserWindow } from './RealmBrowserWindow'; -import { ConnectToServerWindow } from './ConnectToServerWindow'; export interface IWindowConstructorOptions extends Partial { @@ -49,8 +48,6 @@ export function getWindowClass(type: WindowType): IWindow { return GreetingWindow; } else if (type === 'realm-browser') { return RealmBrowserWindow; - } else if (type === 'connect-to-server') { - return ConnectToServerWindow; } else { throw new Error(`Unexpected window type: ${type}`); } diff --git a/src/windows/WindowOptions.ts b/src/windows/WindowOptions.ts index c4528509a..c73d8bdbc 100644 --- a/src/windows/WindowOptions.ts +++ b/src/windows/WindowOptions.ts @@ -21,13 +21,11 @@ import qs from 'querystring'; import { IGreetingWindowProps, IRealmBrowserWindowProps, - IConnectToServerWindowProps, WindowProps, } from './WindowProps'; export type WindowType = | 'cloud-authentication' - | 'connect-to-server' | 'graphiql-editor' | 'greeting' | 'realm-browser' @@ -51,15 +49,7 @@ export interface IRealmBrowserWindowOptions extends IWindowOptions { props: IRealmBrowserWindowProps; } -export interface IConnectToServerWindowOptions extends IWindowOptions { - type: 'connect-to-server'; - props: IConnectToServerWindowProps; -} - -export type WindowOptions = - | IGreetingWindowOptions - | IRealmBrowserWindowOptions - | IConnectToServerWindowOptions; +export type WindowOptions = IGreetingWindowOptions | IRealmBrowserWindowOptions; export function getWindowOptions(): WindowOptions { // Strip away the "?" of the location.search diff --git a/src/windows/WindowProps.ts b/src/windows/WindowProps.ts index 0229a5de2..98d868e84 100644 --- a/src/windows/WindowProps.ts +++ b/src/windows/WindowProps.ts @@ -22,15 +22,7 @@ import { IGreetingWindowProps } from './GreetingWindow'; import { IRealmBrowserWindowProps } from './RealmBrowserWindow'; -import { IConnectToServerWindowProps } from './ConnectToServerWindow'; -export { - IGreetingWindowProps, - IRealmBrowserWindowProps, - IConnectToServerWindowProps, -}; +export { IGreetingWindowProps, IRealmBrowserWindowProps }; -export type WindowProps = - | IGreetingWindowProps - | IRealmBrowserWindowProps - | IConnectToServerWindowProps; +export type WindowProps = IGreetingWindowProps | IRealmBrowserWindowProps;