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