提交 eeaaa17d 编写于 作者: S Sandeep Somavarapu

- show resolved content on click

- action to show full content
上级 d23e8a3c
......@@ -120,6 +120,21 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
async stop(): Promise<void> { }
async getRemoteContent(ref?: string, fragment?: string): Promise<string | null> {
const content = await super.getRemoteContent(ref);
if (content !== null && fragment) {
const syncData = this.parseSyncData(content);
if (syncData) {
switch (fragment) {
case 'extensions':
return syncData.content;
}
}
return null;
}
return content;
}
accept(content: string): Promise<void> {
throw new Error('Extensions: Conflicts should not occur');
}
......
......@@ -104,6 +104,21 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
async stop(): Promise<void> { }
async getRemoteContent(ref?: string, fragment?: string): Promise<string | null> {
let content = await super.getRemoteContent(ref);
if (content !== null && fragment) {
const syncData = this.parseSyncData(content);
if (syncData) {
switch (fragment) {
case 'globalState':
return syncData.content;
}
}
return null;
}
return content;
}
accept(content: string): Promise<void> {
throw new Error('UI State: Conflicts should not occur');
}
......
......@@ -81,13 +81,34 @@ export class UserDataSyncHistoryViewContribution implements IWorkbenchContributi
registerAction2(class extends Action2 {
constructor() {
super({
id: 'workbench.actions.openRef',
title: localize('workbench.action.openRef', "Open Ref"),
id: 'workbench.actions.sync.resolveResourceRef',
title: localize('workbench.actions.sync.resolveResourceRef', "Resolve Resource Ref"),
});
}
async run(accessor: ServicesAccessor, resource: URI): Promise<void> {
async run(accessor: ServicesAccessor, handle: TreeViewItemHandleArg): Promise<void> {
const editorService = accessor.get(IEditorService);
let resource = URI.parse(handle.$treeItemHandle);
const result = resolveSyncResource(resource);
if (result) {
resource = resource.with({ fragment: result.resourceKey });
await editorService.openEditor({ resource });
}
}
});
registerAction2(class extends Action2 {
constructor() {
super({
id: 'workbench.actions.sync.resolveResourceRefCompletely',
title: localize('workbench.actions.sync.resolveResourceRefCompletely', "Show full content"),
menu: {
id: MenuId.ViewItemContext,
when: ContextKeyExpr.and(ContextKeyEqualsExpr.create('view', that.viewId), ContextKeyExpr.regex('viewItem', /syncref-.*/i))
},
});
}
async run(accessor: ServicesAccessor, handle: TreeViewItemHandleArg): Promise<void> {
const editorService = accessor.get(IEditorService);
await editorService.openEditor({ resource });
await editorService.openEditor({ resource: URI.parse(handle.$treeItemHandle) });
}
});
registerAction2(class extends Action2 {
......@@ -107,15 +128,8 @@ export class UserDataSyncHistoryViewContribution implements IWorkbenchContributi
const resource = URI.parse(handle.$treeItemHandle);
const result = resolveSyncResource(resource);
if (result) {
let leftResource: URI;
let rightResource: URI;
if (result.resourceKey === 'settings') {
leftResource = resource.with({ fragment: 'settings' });
rightResource = environmentService.settingsResource;
} else {
leftResource = resource.with({ fragment: 'keybindings' });
rightResource = environmentService.keybindingsResource;
}
const leftResource: URI = resource.with({ fragment: result.resourceKey });
const rightResource: URI = result.resourceKey === 'settings' ? environmentService.settingsResource : environmentService.keybindingsResource;
await editorService.openEditor({
leftResource,
rightResource,
......@@ -157,12 +171,12 @@ class UserDataSyncHistoryViewDataProvider implements ITreeViewDataProvider {
if (resourceKey) {
const refs = await this.userDataSyncStoreService.getAllRefs(resourceKey);
return refs.map(ref => {
const resourceUri = toSyncResource(resourceKey, ref);
const handle = toSyncResource(resourceKey, ref).toString();
return {
handle: resourceUri.toString(),
handle,
collapsibleState: TreeItemCollapsibleState.None,
label: { label: ref },
command: { id: 'workbench.actions.openRef', title: '', arguments: [resourceUri] },
command: { id: 'workbench.actions.sync.resolveResourceRef', title: '', arguments: [<TreeViewItemHandleArg>{ $treeItemHandle: handle, $treeViewId: '' }] },
themeIcon: FileThemeIcon,
contextValue: `syncref-${resourceKey}`
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册