提交 bea5d9dd 编写于 作者: C Changzheng Liu 提交者: Tomas Vik

feat: add project advanced search options

上级 a7cd3ec1
...@@ -26,9 +26,9 @@ Advanced pipeline actions allow you to view pipeline on GitLab, create a new pip ...@@ -26,9 +26,9 @@ Advanced pipeline actions allow you to view pipeline on GitLab, create a new pip
### Commands ### Commands
- `GitLab: Search project issues - (Supports advanced usage)` - `GitLab: Search project issues (Supports filters)`. [Read more](#search-with-filters)
- `GitLab: Search project merge requests - (Supports advanced usage)` - `GitLab: Search project merge requests (Supports filters)`. [Read more](#search-with-filters)
- Issue and MR search including simple and advanced search. [Read more](#advanced-search). - `GitLab: Project Advanced Search (Issues, MR's, commits, comments...)`. [Read more](#search-with-advanced-search)
- `GitLab: Create snippet` - Create public, internal or private snippet from entire file or selection. [Read more](#create-snippet). - `GitLab: Create snippet` - Create public, internal or private snippet from entire file or selection. [Read more](#create-snippet).
- `GitLab: Compare current branch with master` - Compare your branch with master and view changes on GitLab. [Read more](#compare-with-master). - `GitLab: Compare current branch with master` - Compare your branch with master and view changes on GitLab. [Read more](#compare-with-master).
- `GitLab: Open active file on GitLab` - View active file on GitLab with highlighting active line number and selected text block. [Read more](#open-active-file). - `GitLab: Open active file on GitLab` - View active file on GitLab with highlighting active line number and selected text block. [Read more](#open-active-file).
...@@ -269,13 +269,14 @@ If your current project is a GitLab project, the extension will do the following ...@@ -269,13 +269,14 @@ If your current project is a GitLab project, the extension will do the following
- Show open MR for current branch and show it on the status bar. Clicking this item will open MR on GitLab. - Show open MR for current branch and show it on the status bar. Clicking this item will open MR on GitLab.
- Fetch closing issue of that MR and show it on the status bar. Clicking this item will open Issue on GitLab. - Fetch closing issue of that MR and show it on the status bar. Clicking this item will open Issue on GitLab.
### Advanced Search ### Search
GitLab Workflow extension provides you two types of search. Basic and advanced search. Basic search is quick however advanced search is more powerful which allows you to filter issues by author, assignee, milestone, title etc. GitLab Workflow extension provides you two types of search. Search with filters and Advanced Search.
To use the basic search, in the search input, you can type your search term and hit Enter. This will search issues/MRs against their title and description fields. Example: `Inconsistent line endings for HEX files` or `Pipelines should ignore retried builds`. #### Search with filters
It allows users to search issues/MRs against their title and description fields. In the search input, you can type your search term and hit Enter, for example, `Inconsistent line endings for HEX files` or `Pipelines should ignore retried builds`.
You can perform advanced issue/MR search by using some predefined tokens. Full list below. It can become more powerful by allowing you to filter issues/MRs by author, assignee, milestone, title etc. Below is the full list of supported filter tokens
| Token | Description | Example | | Token | Description | Example |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | --------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
...@@ -300,6 +301,9 @@ You can perform advanced issue/MR search by using some predefined tokens. Full l ...@@ -300,6 +301,9 @@ You can perform advanced issue/MR search by using some predefined tokens. Full l
![_advanced-search.gif](https://gitlab.com/gitlab-org/gitlab-vscode-extension/raw/main/src/assets/_advanced-search.gif) ![_advanced-search.gif](https://gitlab.com/gitlab-org/gitlab-vscode-extension/raw/main/src/assets/_advanced-search.gif)
#### Search with Advanced Search
GitLab provides [Advanced Search feature which is backed by Elasticsearch](https://docs.gitlab.com/ee/integration/elasticsearch.html). Please see [Advanced Search syntax](https://docs.gitlab.com/ee/user/search/advanced_search_syntax.html) for more details.
### Create snippet ### Create snippet
You can create a snippet from selection or entire file. You can also select visibility level of your snippet. You can create a snippet from selection or entire file. You can also select visibility level of your snippet.
......
...@@ -87,11 +87,15 @@ ...@@ -87,11 +87,15 @@
}, },
{ {
"command": "gl.issueSearch", "command": "gl.issueSearch",
"title": "GitLab: Search project issues - (Supports advanced usage)" "title": "GitLab: Search project issues (Supports filters)"
}, },
{ {
"command": "gl.mergeRequestSearch", "command": "gl.mergeRequestSearch",
"title": "GitLab: Search project merge requests - (Supports advanced usage)" "title": "GitLab: Search project merge requests (Supports filters)"
},
{
"command": "gl.projectAdvancedSearch",
"title": "GitLab: Project Advanced Search (Issues, MR's, commits, comments...)"
}, },
{ {
"command": "gl.compareCurrentBranch", "command": "gl.compareCurrentBranch",
......
...@@ -62,6 +62,7 @@ const registerCommands = (context, outputChannel) => { ...@@ -62,6 +62,7 @@ const registerCommands = (context, outputChannel) => {
'gl.pipelineActions': pipelineActionsPicker.showPicker, 'gl.pipelineActions': pipelineActionsPicker.showPicker,
'gl.issueSearch': searchInput.showIssueSearchInput, 'gl.issueSearch': searchInput.showIssueSearchInput,
'gl.mergeRequestSearch': searchInput.showMergeRequestSearchInput, 'gl.mergeRequestSearch': searchInput.showMergeRequestSearchInput,
'gl.projectAdvancedSearch': searchInput.showProjectAdvancedSearchInput,
'gl.compareCurrentBranch': openers.compareCurrentBranch, 'gl.compareCurrentBranch': openers.compareCurrentBranch,
'gl.createSnippet': snippetInput.show, 'gl.createSnippet': snippetInput.show,
'gl.validateCIConfig': ciConfigValidator.validate, 'gl.validateCIConfig': ciConfigValidator.validate,
......
...@@ -686,3 +686,4 @@ exports.getCurrentWorkspaceFolderOrSelectOne = getCurrentWorkspaceFolderOrSelect ...@@ -686,3 +686,4 @@ exports.getCurrentWorkspaceFolderOrSelectOne = getCurrentWorkspaceFolderOrSelect
exports.getAllGitlabProjects = getAllGitlabProjects; exports.getAllGitlabProjects = getAllGitlabProjects;
exports.getCurrenWorkspaceFolder = getCurrentWorkspaceFolder; exports.getCurrenWorkspaceFolder = getCurrentWorkspaceFolder;
exports.fetchLabelEvents = fetchLabelEvents; exports.fetchLabelEvents = fetchLabelEvents;
exports.createGitService = createGitService;
...@@ -86,22 +86,22 @@ const parseQuery = (query, noteableType) => { ...@@ -86,22 +86,22 @@ const parseQuery = (query, noteableType) => {
return queryParams.length ? `?${queryParams.join('&')}` : ''; return queryParams.length ? `?${queryParams.join('&')}` : '';
}; };
async function showSearchInputFor(noteableType) { async function getSearchInput(description) {
const query = await vscode.window.showInputBox({ return await vscode.window.showInputBox({
ignoreFocusOut: true, ignoreFocusOut: true,
placeHolder: 'Search in title or description. (Check project page for advanced usage)', placeHolder: description,
}); });
}
async function showSearchInputFor(noteableType) {
const workspaceFolder = await gitLabService.getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await gitLabService.getCurrentWorkspaceFolderOrSelectOne();
const project = await gitLabService.fetchCurrentProject(workspaceFolder);
const query = await getSearchInput(
'Search in title or description. (Check extension page for search with filters)',
);
const queryString = await parseQuery(query, noteableType); const queryString = await parseQuery(query, noteableType);
const project = await gitLabService.fetchCurrentProjectSwallowError(workspaceFolder);
if (project) { await openers.openUrl(`${project.web_url}/${noteableType}${queryString}`);
openers.openUrl(`${project.web_url}/${noteableType}${queryString}`);
} else {
vscode.window.showErrorMessage('GitLab Workflow: No project found to search issues');
}
} }
async function showIssueSearchInput() { async function showIssueSearchInput() {
...@@ -112,5 +112,23 @@ async function showMergeRequestSearchInput() { ...@@ -112,5 +112,23 @@ async function showMergeRequestSearchInput() {
showSearchInputFor('merge_requests'); showSearchInputFor('merge_requests');
} }
async function showProjectAdvancedSearchInput() {
const workspaceFolder = await gitLabService.getCurrentWorkspaceFolderOrSelectOne();
const project = await gitLabService.fetchCurrentProject(workspaceFolder);
const query = await getSearchInput(
'Project Advanced Search. (Check extension page for Advanced Search)',
);
const queryString = await encodeURIComponent(query);
const instanceUrl = await gitLabService
.createGitService(workspaceFolder)
.fetchCurrentInstanceUrl();
// Select issues tab by default for Advanced Search
await openers.openUrl(
`${instanceUrl}/search?search=${queryString}&project_id=${project.id}&scope=issues`,
);
}
exports.showIssueSearchInput = showIssueSearchInput; exports.showIssueSearchInput = showIssueSearchInput;
exports.showMergeRequestSearchInput = showMergeRequestSearchInput; exports.showMergeRequestSearchInput = showMergeRequestSearchInput;
exports.showProjectAdvancedSearchInput = showProjectAdvancedSearchInput;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册