mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Some minor updates to sync beta
This commit is contained in:
parent
7c18b629de
commit
17efc27e7c
@ -782,6 +782,11 @@ export default class VCS {
|
||||
parent
|
||||
created
|
||||
author
|
||||
authorAccount {
|
||||
firstName
|
||||
lastName
|
||||
email
|
||||
}
|
||||
name
|
||||
description
|
||||
state {
|
||||
@ -821,6 +826,21 @@ export default class VCS {
|
||||
mutation ($projectId: ID!, $snapshots: [SnapshotInput!]!, $branchName: String!) {
|
||||
snapshotsCreate(project: $projectId, snapshots: $snapshots, branch: $branchName) {
|
||||
id
|
||||
parent
|
||||
created
|
||||
author
|
||||
authorAccount {
|
||||
firstName
|
||||
lastName
|
||||
email
|
||||
}
|
||||
name
|
||||
description
|
||||
state {
|
||||
blob
|
||||
key
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
@ -832,6 +852,9 @@ export default class VCS {
|
||||
'snapshotsPush',
|
||||
);
|
||||
|
||||
// Store them in case something has changed
|
||||
await this._storeSnapshots(snapshotsCreate);
|
||||
|
||||
console.log('[sync] Pushed snapshots', snapshotsCreate.map(s => s.id).join(', '));
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import PromptButton from '../base/prompt-button';
|
||||
import HelpTooltip from '../help-tooltip';
|
||||
import type { Snapshot } from '../../../sync/types';
|
||||
import VCS from '../../../sync/vcs';
|
||||
import * as session from '../../../account/session';
|
||||
|
||||
type Props = {
|
||||
workspace: Workspace,
|
||||
@ -66,6 +67,34 @@ class SyncHistoryModal extends React.PureComponent<Props, State> {
|
||||
await this.refreshState();
|
||||
}
|
||||
|
||||
static renderAuthorName(snapshot: Snapshot) {
|
||||
let name = '';
|
||||
let email = '';
|
||||
|
||||
if (snapshot.authorAccount) {
|
||||
const { firstName, lastName } = snapshot.authorAccount;
|
||||
name += `${firstName} ${lastName}`;
|
||||
email = snapshot.authorAccount.email;
|
||||
}
|
||||
|
||||
if (snapshot.author === session.getAccountId()) {
|
||||
name += ' (you)';
|
||||
}
|
||||
|
||||
if (name) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
{name}{' '}
|
||||
<HelpTooltip info delay={500}>
|
||||
{email}
|
||||
</HelpTooltip>
|
||||
</React.Fragment>
|
||||
);
|
||||
} else {
|
||||
return '--';
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { branch, history } = this.state;
|
||||
|
||||
@ -79,7 +108,8 @@ class SyncHistoryModal extends React.PureComponent<Props, State> {
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="text-left">Message</th>
|
||||
<th className="text-left">Time</th>
|
||||
<th className="text-left">When</th>
|
||||
<th className="text-left">Author</th>
|
||||
<th className="text-right">Objects</th>
|
||||
<th className="text-right">
|
||||
Restore
|
||||
@ -104,6 +134,7 @@ class SyncHistoryModal extends React.PureComponent<Props, State> {
|
||||
intervalSeconds={30}
|
||||
/>
|
||||
</td>
|
||||
<td className="text-left">{SyncHistoryModal.renderAuthorName(snapshot)}</td>
|
||||
<td className="text-right">{snapshot.state.length}</td>
|
||||
<td className="text-right">
|
||||
<PromptButton
|
||||
|
@ -75,7 +75,9 @@ class SyncStagingModal extends React.PureComponent<Props, State> {
|
||||
const { status } = this.state;
|
||||
const id = e.currentTarget.name;
|
||||
|
||||
const newStage = status.stage[id]
|
||||
const isStaged = !!status.stage[id];
|
||||
|
||||
const newStage = isStaged
|
||||
? await vcs.unstage(status.stage, [status.stage[id]])
|
||||
: await vcs.stage(status.stage, [status.unstaged[id]]);
|
||||
|
||||
@ -281,7 +283,7 @@ class SyncStagingModal extends React.PureComponent<Props, State> {
|
||||
return (
|
||||
<tr key={key} className="table--no-outline-row">
|
||||
<td>
|
||||
<label className="no-pad">
|
||||
<label className="no-pad wide">
|
||||
<input
|
||||
className="space-right"
|
||||
type="checkbox"
|
||||
|
@ -855,25 +855,17 @@ class App extends PureComponent {
|
||||
this._updateDocumentTitle();
|
||||
|
||||
// Update VCS
|
||||
this._updateVCS(this.props.activeWorkspace);
|
||||
await this._updateVCS(this.props.activeWorkspace);
|
||||
|
||||
db.onChange(async changes => {
|
||||
let needsRefresh = false;
|
||||
|
||||
for (const change of changes) {
|
||||
const [
|
||||
_, // eslint-disable-line no-unused-vars
|
||||
doc,
|
||||
fromSync,
|
||||
] = change;
|
||||
const [type, doc, fromSync] = change;
|
||||
|
||||
const { vcs } = this.state;
|
||||
const { activeRequest } = this.props;
|
||||
|
||||
// No active request, so we don't need to force refresh anything
|
||||
if (!activeRequest) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Force refresh if environment changes
|
||||
// TODO: Only do this for environments in this workspace (not easy because they're nested)
|
||||
if (doc.type === models.environment.type) {
|
||||
@ -882,10 +874,15 @@ class App extends PureComponent {
|
||||
}
|
||||
|
||||
// Force refresh if sync changes the active request
|
||||
if (fromSync && doc._id === activeRequest._id) {
|
||||
if (fromSync && activeRequest && doc._id === activeRequest._id) {
|
||||
needsRefresh = true;
|
||||
console.log('[App] Forcing update from request change', change);
|
||||
}
|
||||
|
||||
// Delete VCS project if workspace deleted
|
||||
if (vcs && doc.type === models.workspace.type && type === db.CHANGE_REMOVE) {
|
||||
await vcs.removeProjectsForRoot(doc._id);
|
||||
}
|
||||
}
|
||||
|
||||
if (needsRefresh) {
|
||||
|
Loading…
Reference in New Issue
Block a user