Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一杯枸杞茶ya
csdn-workflow
提交
b4f7b1c5
C
csdn-workflow
项目概览
一杯枸杞茶ya
/
csdn-workflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
csdn-workflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b4f7b1c5
编写于
6月 09, 2021
作者:
T
Tomas Vik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: each overview tab gets opened only once
上级
642a28d0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
34 addition
and
6 deletion
+34
-6
src/extension.js
src/extension.js
+1
-1
src/webview_controller.ts
src/webview_controller.ts
+18
-1
test/integration/webview.test.js
test/integration/webview.test.js
+15
-4
未找到文件。
src/extension.js
浏览文件 @
b4f7b1c5
...
...
@@ -77,7 +77,7 @@ const registerCommands = (context, outputChannel) => {
[
USER_COMMANDS
.
INSERT_SNIPPET
]:
insertSnippet
,
[
USER_COMMANDS
.
VALIDATE_CI_CONFIG
]:
ciConfigValidator
.
validate
,
[
USER_COMMANDS
.
REFRESH_SIDEBAR
]:
sidebar
.
refresh
,
[
PROGRAMMATIC_COMMANDS
.
SHOW_RICH_CONTENT
]:
webviewController
.
create
.
bind
(
webviewController
),
[
PROGRAMMATIC_COMMANDS
.
SHOW_RICH_CONTENT
]:
webviewController
.
open
.
bind
(
webviewController
),
[
USER_COMMANDS
.
SHOW_OUTPUT
]:
()
=>
outputChannel
.
show
(),
[
USER_COMMANDS
.
RESOLVE_THREAD
]:
toggleResolved
,
[
USER_COMMANDS
.
UNRESOLVE_THREAD
]:
toggleResolved
,
...
...
src/webview_controller.ts
浏览文件 @
b4f7b1c5
...
...
@@ -48,6 +48,8 @@ class WebviewController {
isDev
=
false
;
openedPanels
:
Record
<
string
,
vscode
.
WebviewPanel
|
undefined
>
=
{};
init
(
context
:
vscode
.
ExtensionContext
,
isDev
:
boolean
)
{
this
.
context
=
context
;
this
.
isDev
=
isDev
;
...
...
@@ -144,7 +146,22 @@ class WebviewController {
:
{
light
:
lightIssueIcon
,
dark
:
darkIssueIcon
};
}
async
create
(
issuable
:
RestIssuable
,
repositoryRoot
:
string
)
{
async
open
(
issuable
:
RestIssuable
,
repositoryRoot
:
string
)
{
const
panelKey
=
`
${
repositoryRoot
}
-
${
issuable
.
id
}
`
;
const
openedPanel
=
this
.
openedPanels
[
panelKey
];
if
(
openedPanel
)
{
openedPanel
.
reveal
();
return
openedPanel
;
}
const
newPanel
=
await
this
.
create
(
issuable
,
repositoryRoot
);
this
.
openedPanels
[
panelKey
]
=
newPanel
;
newPanel
.
onDidDispose
(()
=>
{
this
.
openedPanels
[
panelKey
]
=
undefined
;
});
return
newPanel
;
}
private
async
create
(
issuable
:
RestIssuable
,
repositoryRoot
:
string
)
{
assert
(
this
.
context
);
const
panel
=
this
.
createPanel
(
issuable
);
const
html
=
this
.
replaceResources
(
panel
);
...
...
test/integration/webview.test.js
浏览文件 @
b4f7b1c5
...
...
@@ -10,6 +10,7 @@ const { projectWithIssueDiscussions, note2 } = require('./fixtures/graphql/discu
const
{
getServer
,
createJsonEndpoint
}
=
require
(
'
./test_infrastructure/mock_server
'
);
const
{
GITLAB_URL
}
=
require
(
'
./test_infrastructure/constants
'
);
const
{
getRepositoryRoot
}
=
require
(
'
./test_infrastructure/helpers
'
);
const
waitForMessage
=
(
panel
,
type
)
=>
new
Promise
(
resolve
=>
{
...
...
@@ -82,10 +83,7 @@ describe('GitLab webview', () => {
beforeEach
(
async
()
=>
{
server
.
resetHandlers
();
replacePanelEventSystem
();
webviewPanel
=
await
webviewController
.
create
(
openIssueResponse
,
vscode
.
workspace
.
workspaceFolders
[
0
].
uri
.
fsPath
,
);
webviewPanel
=
await
webviewController
.
open
(
openIssueResponse
,
getRepositoryRoot
());
});
afterEach
(
async
()
=>
{
...
...
@@ -123,4 +121,17 @@ describe('GitLab webview', () => {
assert
.
match
(
webviewPanel
.
webview
.
html
,
new
RegExp
(
r
,
'
gm
'
));
});
});
it
(
'
reveals existing panel instead of creating a new one
'
,
async
()
=>
{
const
revealSpy
=
sandbox
.
spy
(
webviewPanel
,
'
reveal
'
);
const
samePanel
=
await
webviewController
.
open
(
openIssueResponse
,
getRepositoryRoot
());
assert
(
revealSpy
.
called
);
assert
.
strictEqual
(
samePanel
,
webviewPanel
);
});
it
(
'
creates a new panel if the previous one got disposed
'
,
async
()
=>
{
webviewPanel
.
dispose
();
const
newPanel
=
await
webviewController
.
open
(
openIssueResponse
,
getRepositoryRoot
());
assert
.
notStrictEqual
(
newPanel
,
webviewPanel
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录