From 2cfaab472da547be51d43924478f8a202f435ac8 Mon Sep 17 00:00:00 2001 From: Opender Singh Date: Mon, 26 Jul 2021 22:05:45 +1200 Subject: [PATCH] Remove the share modal (#3846) --- .../ui/components/dropdowns/sync-dropdown.tsx | 10 - .../ui/components/modals/sync-share-modal.tsx | 186 ------------------ .../app/ui/components/wrapper-debug.tsx | 14 +- .../app/ui/components/wrapper.tsx | 2 - 4 files changed, 1 insertion(+), 211 deletions(-) delete mode 100644 packages/insomnia-app/app/ui/components/modals/sync-share-modal.tsx diff --git a/packages/insomnia-app/app/ui/components/dropdowns/sync-dropdown.tsx b/packages/insomnia-app/app/ui/components/dropdowns/sync-dropdown.tsx index 1c8c481411..51a74c5e7c 100644 --- a/packages/insomnia-app/app/ui/components/dropdowns/sync-dropdown.tsx +++ b/packages/insomnia-app/app/ui/components/dropdowns/sync-dropdown.tsx @@ -25,7 +25,6 @@ import LoginModal from '../modals/login-modal'; import SyncBranchesModal from '../modals/sync-branches-modal'; import SyncDeleteModal from '../modals/sync-delete-modal'; import SyncHistoryModal from '../modals/sync-history-modal'; -import SyncShareModal from '../modals/sync-share-modal'; import SyncStagingModal from '../modals/sync-staging-modal'; import Tooltip from '../tooltip'; @@ -196,10 +195,6 @@ class SyncDropdown extends PureComponent { }); } - static _handleShowSharingModal() { - showModal(SyncShareModal); - } - static _handleShowLoginModal() { showModal(LoginModal); } @@ -523,11 +518,6 @@ class SyncDropdown extends PureComponent { )} - - - Share Settings - - Branches diff --git a/packages/insomnia-app/app/ui/components/modals/sync-share-modal.tsx b/packages/insomnia-app/app/ui/components/modals/sync-share-modal.tsx deleted file mode 100644 index f5a499dea8..0000000000 --- a/packages/insomnia-app/app/ui/components/modals/sync-share-modal.tsx +++ /dev/null @@ -1,186 +0,0 @@ -import { autoBindMethodsForReact } from 'class-autobind-decorator'; -import React, { PureComponent } from 'react'; - -import { AUTOBIND_CFG } from '../../../common/constants'; -import { strings } from '../../../common/strings'; -import type { Workspace } from '../../../models/workspace'; -import { VCS } from '../../../sync/vcs/vcs'; -import { Dropdown, DropdownButton, DropdownDivider, DropdownItem } from '../base/dropdown'; -import Link from '../base/link'; -import Modal from '../base/modal'; -import ModalBody from '../base/modal-body'; -import ModalHeader from '../base/modal-header'; -import PromptButton from '../base/prompt-button'; -import { showModal } from './index'; - -interface Props { - workspace: Workspace; - vcs: VCS; -} - -interface Team { - id: string; - name: string; -} - -interface State { - loading: boolean; - selectedTeam: null | Team; - teams: Team[]; - error: string; -} - -@autoBindMethodsForReact(AUTOBIND_CFG) -class SyncShareModal extends PureComponent { - modal: Modal | null = null; - - state: State = { - selectedTeam: null, - teams: [], - error: '', - loading: false, - } - - _setModalRef(n: Modal) { - this.modal = n; - } - - async _handleChangeTeam(team: Team) { - const { vcs } = this.props; - this.setState({ - loading: true, - }); - - try { - if (team) { - await vcs.shareWithTeam(team.id); - } else { - await vcs.unShareWithTeam(); - } - } catch (err) { - this.setState({ - error: err.message, - loading: false, - }); - } - - this.setState({ - selectedTeam: team, - error: '', - loading: false, - }); - } - - async show() { - const { vcs } = this.props; - this.setState({ - loading: true, - }); - this.modal && this.modal.show(); - - if (!vcs.hasProject()) { - this.setState({ - error: `Please set up sync to be able to share the ${strings.collection.singular.toLowerCase()}`, - loading: false, - }); - return; - } - - let results; - - try { - results = await Promise.all([vcs.teams(), vcs.projectTeams()]); - } catch (err) { - this.setState({ - error: err.message, - loading: false, - }); - return; - } - - const [teams, projectTeams] = results; - this.setState({ - teams, - selectedTeam: projectTeams[0] || null, - error: '', - loading: false, - }); - } - - hide() { - this.modal && this.modal.hide(); - } - - render() { - const { teams, error, selectedTeam, loading } = this.state; - const { workspace } = this.props; - return ( - - Share {strings.collection.singular} - - {error &&

{error}

} -

- Collaborate on {workspace.name} with your team. -

-
- - Teams - {selectedTeam ? ( - - {loading ? ( - - ) : ( - - )}{' '} - Shared with {selectedTeam.name}{' '} - - - ) : ( - - - {loading ? ( - - ) : ( - - )}{' '} - Private - - )} - {teams.map(team => ( - - Share with {team.name} - - ))} - {teams.length === 0 && ( - // @ts-expect-error -- TSCONVERSION - - You have no teams - - )} - Other - - Private - - -    - - Manage Teams - -
-
-
- ); - } -} - -export const showSyncShareModal = () => showModal(SyncShareModal); -export default SyncShareModal; diff --git a/packages/insomnia-app/app/ui/components/wrapper-debug.tsx b/packages/insomnia-app/app/ui/components/wrapper-debug.tsx index eafbe638ce..cb237c3451 100644 --- a/packages/insomnia-app/app/ui/components/wrapper-debug.tsx +++ b/packages/insomnia-app/app/ui/components/wrapper-debug.tsx @@ -1,5 +1,4 @@ import { autoBindMethodsForReact } from 'class-autobind-decorator'; -import { Button } from 'insomnia-components'; import React, { Fragment, PureComponent, ReactNode } from 'react'; import { AUTOBIND_CFG, GlobalActivity, SortOrder } from '../../common/constants'; @@ -10,7 +9,6 @@ import { isCollection, isDesign } from '../../models/workspace'; import EnvironmentsDropdown from './dropdowns/environments-dropdown'; import SyncDropdown from './dropdowns/sync-dropdown'; import ErrorBoundary from './error-boundary'; -import { showSyncShareModal } from './modals/sync-share-modal'; import PageLayout from './page-layout'; import GrpcRequestPane from './panes/grpc-request-pane'; import GrpcResponsePane from './panes/grpc-response-pane'; @@ -66,14 +64,9 @@ class WrapperDebug extends PureComponent { const collection = isCollection(activeWorkspace); const design = isDesign(activeWorkspace); - let share: ReactNode = null; let insomniaSync: ReactNode = null; if (isLoggedIn && collection && activeSpace?.remoteId && vcs) { - share = ; - insomniaSync = { - {share} - {sync && {sync}} - - } + gridRight={sync} /> ); } diff --git a/packages/insomnia-app/app/ui/components/wrapper.tsx b/packages/insomnia-app/app/ui/components/wrapper.tsx index 68e1249836..ec4d8dadb8 100644 --- a/packages/insomnia-app/app/ui/components/wrapper.tsx +++ b/packages/insomnia-app/app/ui/components/wrapper.tsx @@ -74,7 +74,6 @@ import SyncBranchesModal from './modals/sync-branches-modal'; import SyncDeleteModal from './modals/sync-delete-modal'; import SyncHistoryModal from './modals/sync-history-modal'; import SyncMergeModal from './modals/sync-merge-modal'; -import SyncShareModal from './modals/sync-share-modal'; import SyncStagingModal from './modals/sync-staging-modal'; import WorkspaceEnvironmentsEditModal from './modals/workspace-environments-edit-modal'; import WorkspaceSettingsModal from './modals/workspace-settings-modal'; @@ -708,7 +707,6 @@ class Wrapper extends PureComponent { /> - ) : null}