From 0010bbacefa05fd0384eb68b09aee2c79b827c3e Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 7 Nov 2018 16:53:50 -0500 Subject: [PATCH] Delete unused file --- .../components/modals/sync-staging-modal.js | 308 ------------------ packages/insomnia-sync | 2 +- 2 files changed, 1 insertion(+), 309 deletions(-) delete mode 100644 packages/insomnia-app/app/ui/components/modals/sync-staging-modal.js diff --git a/packages/insomnia-app/app/ui/components/modals/sync-staging-modal.js b/packages/insomnia-app/app/ui/components/modals/sync-staging-modal.js deleted file mode 100644 index 33c81645e..000000000 --- a/packages/insomnia-app/app/ui/components/modals/sync-staging-modal.js +++ /dev/null @@ -1,308 +0,0 @@ -// @flow -import * as React from 'react'; -import autobind from 'autobind-decorator'; -import Modal from '../base/modal'; -import ModalBody from '../base/modal-body'; -import ModalHeader from '../base/modal-header'; -import ModalFooter from '../base/modal-footer'; -import { FileSystemDriver, VCS } from 'insomnia-sync'; -import type { Workspace } from '../../../models/workspace'; -import * as db from '../../../common/database'; -import * as models from '../../../models'; -import TimeFromNow from '../time-from-now'; - -type VCSCommit = { - parent: string, - id: string, - timestamp: number, - message: string, - tree: { - [string]: { - name: string, - hash: string - } - } -}; - -type VCSOperation = 'add' | 'modify' | 'delete'; - -type VCSStageEntry = { - operation: VCSOperation, - hash: string, - name: string, - content: string -}; - -type VCSStage = { - [string]: VCSStageEntry -}; - -type VCSStatus = { - stage: VCSStage, - unstaged: { - [string]: VCSStageEntry & { id: string } - } -}; - -type Props = { - workspace: Workspace -}; - -type State = { - branch: string, - branches: Array, - status: VCSStatus, - message: string, - error: string, - newBranchName: string, - commits: Array -}; - -const WHITE_LIST = { - [models.workspace.type]: true, - [models.request.type]: true, - [models.requestGroup.type]: true, - [models.environment.type]: true -}; - -@autobind -class SyncStagingModal extends React.PureComponent { - modal: ?Modal; - vcs: VCS; - - constructor(props: Props) { - super(props); - this.state = { - branch: '', - branches: [], - newBranchName: '', - commits: [], - status: { - stage: {}, - unstaged: {} - }, - error: '', - message: '' - }; - - const driver = new FileSystemDriver({ directory: '/Users/gschier/Desktop/vcs' }); - this.vcs = new VCS('123', driver); - } - - async componentDidMount() { - await this.show(); - } - - _setModalRef(m: ?Modal) { - this.modal = m; - } - - _handleDone(e: SyntheticEvent) { - this.hide(); - } - - _handleMessageChange(e: SyntheticEvent) { - this.setState({ message: e.currentTarget.value }); - } - - _handleBranchChange(e: SyntheticEvent) { - this.setState({ newBranchName: e.currentTarget.value }); - } - - async _handleChangeBranch(e: SyntheticEvent) { - await this.vcs.checkout(e.currentTarget.value); - await this.updateStatus(); - } - - async _handleCheckoutBranch() { - await this.vcs.checkout(this.state.newBranchName); - await this.updateStatus({ newBranchName: '' }); - } - - async _handleStage(e: SyntheticEvent) { - const id = e.currentTarget.name; - const statusItem = this.state.status.unstaged[id]; - await this.vcs.stage(statusItem); - await this.updateStatus(); - } - - async _handleUnstage(e: SyntheticEvent) { - const id = e.currentTarget.name; - const statusItem = this.state.status.stage[id]; - await this.vcs.unstage(statusItem); - await this.updateStatus(); - } - - async _handleCommit(e: SyntheticEvent) { - const { message } = this.state; - try { - await this.vcs.commit(message); - } catch (err) { - this.setState({ error: err.message }); - return; - } - - await this.updateStatus({ message: '' }); - } - - async updateStatus(newState?: Object) { - const items = []; - const allDocs = await db.withDescendants(this.props.workspace); - const docs = allDocs.filter(d => WHITE_LIST[d.type]); - - for (const doc of docs) { - items.push({ - id: doc._id, - name: (doc: any).name || 'No Name', - content: doc - }); - } - - const status = await this.vcs.status(items); - const commits = await this.vcs.getHistory(); - const branch = await this.vcs.getBranch(); - const branches = await this.vcs.listBranches(); - this.setState({ - status, - commits, - branch, - branches, - error: '', - ...newState - }); - } - - hide() { - this.modal && this.modal.hide(); - } - - async show() { - this.modal && this.modal.show(); - await this.updateStatus(); - } - - render() { - const { branch, branches, newBranchName, status, commits, message, error } = this.state; - return ( - - Stage Files - -
-
- -
-
-
-
- -
- -
-
-
-