Display slash commands outcome when previewing Markdown
What does this MR do?
This continues the work started in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7497.
- Remove slash commands from Markdown preview and display their outcome next to the text field.
- Introduce new "explanation" block to our slash commands DSL.
- Introduce optional "parse_params" block to slash commands DSL that allows to process a parameter before it is passed to "explanation" or "command" blocks.
- Pass path for previewing Markdown as "data" attribute instead of setting a variable on "window".
Are there points in the code the reviewer needs to double check?
I didn't use shared_examples
for testing InterpretService#explain
, because I don't think that testing the same stuff for Issue
and MergeRequest
makes sense. Instead I'm testing Issue
in roughly half of the specs and MergeRequest
in the rest.
Why was this MR needed?
We don't display slash commands after issue / merge requests / comment is submitted. Hence, we should also remove them from Markdown preview. Having their outcome displayed as well is helpful.
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated [ ] API support added- Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Closes #21531 (closed)
EE MR https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1707
Merge request reports
Activity
The problem that I identified with the current implementation is that it focuses on noteables. Notes are only one of the ways how we can execute slash commands. We also have to support this feature for creating a new issue and creating a new merge request. What's more, not all noteables support slash commands (commit, snippet). Hence, this features should not be tied to notes or noteable at all, it should be tied to issuable.
-
ProjectsController#preview_markdown
- Rename "humanized" to "explanation"
- Skip extracting commands when issue, merge request or comment is edited
- Check that we don't throw errors when user, label, ... does not exist
-
Introduce
parse_params
block to our DSL to avoid duplication between main block and explanation block [ ] Return array of commands and leave it up to the frontend how to present them-
Add tests
-
EE MR for
/weight
-
Reduce duplication in
InterpretService
-
Improve
preview_markdown.js
Edited by username-removed-378947-
added 272 commits
-
2b13b3c9...d576fd82 - 269 commits from branch
master
- ba9bdd5b - Remove slash commands from markdown preview
- 2944f38a - Fix eslint errors
- b8a6bec5 - Minor fixes
Toggle commit list-
2b13b3c9...d576fd82 - 269 commits from branch
mentioned in merge request !7497 (closed)
/cc @smcgivern @DouweM
Currently we set
preview_markdown_path
inapp/views/layouts/project.html.haml
and pass it to JavaScipt as a global variable. This already is a bit hacky, because we have a special case when@project_wiki && @page
.Now we want to have a different behavior when something (issue / merge request / note) is created or edited. In issue page and merge request page we have a form for adding a new note and a form for editing an existing note. So, this can no longer be a global variable.
I think that the best solution is to pass the URL as
data-url
attribute on.js-markdown-preview
element. Every form will decide which URL to use by passing a local variable toprojects/md_preview
partial.While working on I found a bug in group milestones.
added 355 commits
-
b8a6bec5...03611b91 - 351 commits from branch
master
- b97a48dc - Remove slash commands from markdown preview
- 7fce6ee6 - Fix eslint errors
- b65df85d - Minor fixes
- 4b1f52f5 - WIP
Toggle commit list-
b8a6bec5...03611b91 - 351 commits from branch
marked as a Work In Progress from 4b1f52f5
Return array of commands and leave it up to the frontend how to present them
I checked and it's not-so-obvious, because when we render Markdown we wrap the output in a
<p>
element. I didn't find an option to turn if off, so every command would be wrapped. I think that we first should decide on the presentation and then decide what to return from the backend.- Resolved by username-removed-128633
added 182 commits
-
d35d5a01...c5dae616 - 174 commits from branch
master
- 52917499 - Remove slash commands from markdown preview
- 424c5c2d - Fix eslint errors
- 22660679 - Minor fixes
- f157a640 - WIP
- 3319b6c6 - Pass URL for Markdown preview on a per form basis
- 0924f2ba - Tests for Gitlab::SlashCommands::Dsl
- 3f678760 - Add tests for Gitlab::SlashCommands::CommandDefinition#humanize
- f103a1b3 - Start testing InterpretService
Toggle commit list-
d35d5a01...c5dae616 - 174 commits from branch
added 2 commits
added 859 commits
-
626a617a...19dd138c - 846 commits from branch
master
- 010232a3 - Remove slash commands from markdown preview
- 2688bb2d - Fix eslint errors
- b148ce97 - Minor fixes
- e9b23da2 - WIP
- 97cd99a2 - Pass URL for Markdown preview on a per form basis
- 0128749c - Tests for Gitlab::SlashCommands::Dsl
- 05482472 - Add tests for Gitlab::SlashCommands::CommandDefinition#humanize
- 82ad34cd - Start testing InterpretService
- 9ca3215c - Make eslint happy
- 1054e117 - Add more tests for InterpretService
- 110d941c - Add a high level test
- d5574bf4 - Make Rubocop happy
- 276de653 - Check for emoji
Toggle commit list-
626a617a...19dd138c - 846 commits from branch
added 859 commits
-
626a617a...19dd138c - 846 commits from branch
master
- 010232a3 - Remove slash commands from markdown preview
- 2688bb2d - Fix eslint errors
- b148ce97 - Minor fixes
- e9b23da2 - WIP
- 97cd99a2 - Pass URL for Markdown preview on a per form basis
- 0128749c - Tests for Gitlab::SlashCommands::Dsl
- 05482472 - Add tests for Gitlab::SlashCommands::CommandDefinition#humanize
- 82ad34cd - Start testing InterpretService
- 9ca3215c - Make eslint happy
- 1054e117 - Add more tests for InterpretService
- 110d941c - Add a high level test
- d5574bf4 - Make Rubocop happy
- 276de653 - Check for emoji
Toggle commit list-
626a617a...19dd138c - 846 commits from branch
added 859 commits
-
626a617a...19dd138c - 846 commits from branch
master
- 010232a3 - Remove slash commands from markdown preview
- 2688bb2d - Fix eslint errors
- b148ce97 - Minor fixes
- e9b23da2 - WIP
- 97cd99a2 - Pass URL for Markdown preview on a per form basis
- 0128749c - Tests for Gitlab::SlashCommands::Dsl
- 05482472 - Add tests for Gitlab::SlashCommands::CommandDefinition#humanize
- 82ad34cd - Start testing InterpretService
- 9ca3215c - Make eslint happy
- 1054e117 - Add more tests for InterpretService
- 110d941c - Add a high level test
- d5574bf4 - Make Rubocop happy
- 276de653 - Check for emoji
Toggle commit list-
626a617a...19dd138c - 846 commits from branch
added 1 commit
- 823e54cf - Rename "humanized" to "explanation" and "humanize" to "explain"
@rymai you may also be interested in taking a look at this MR.
added 1 commit
- 9b8ec366 - Introduce parse_params block to remove duplication
marked the task Changelog entry added, if necessary as completed
added 114 commits
-
d1da30dd...22c40500 - 113 commits from branch
master
- e502eadf - Display slash commands outcome when previewing Markdown
-
d1da30dd...22c40500 - 113 commits from branch
@axil Please let me know if this requires documenting. We have
doc/user/project/slash_commands.md
, but I think that this feature is easy to discover and quite self-explanatory. What do you think?added 1 commit
- fd5fb135 - Display slash commands outcome when previewing Markdown
@iamphill can you review the frontend changes here? As you can see the presentation of slash commands output is quite minimalistic and, if possible, I'd like to keep it like that in this MR. We can improve it in a follow-up MR, but this one is already quite big.
assigned to @iamphill
@adamniedzielski nice! Looks great & the frontend looks pretty simple as well
Is the backend all reviewed?
@iamphill I will review it!
assigned to @rymai
changed milestone to %9.2
- Resolved by username-removed-378947
- Resolved by username-removed-378947
- Resolved by username-removed-378947
- Resolved by username-removed-378947
- Resolved by username-removed-378947
- Resolved by username-removed-378947
- Resolved by username-removed-378947
@adamniedzielski Awesome work!
assigned to @adamniedzielski
mentioned in issue #30964 (closed)
added 472 commits
-
fd5fb135...1005389f - 471 commits from branch
master
- 420057b1 - Display slash commands outcome when previewing Markdown
-
fd5fb135...1005389f - 471 commits from branch
@rymai This should be ready for your review now.
assigned to @rymai
mentioned in merge request !10810 (merged)
- Resolved by username-removed-378947
@adamniedzielski Thanks, awesome work, I only had one suggestion.
assigned to @adamniedzielski
@adamniedzielski I just noticed that now that https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10810/diffs is merged, this MR will need a rebase.
mentioned in issue #31583 (moved)
added 761 commits
-
420057b1...ef71bf62 - 760 commits from branch
master
- e62f81fb - Display slash commands outcome when previewing Markdown
-
420057b1...ef71bf62 - 760 commits from branch
added 8 commits
-
e62f81fb...2d43f8a2 - 7 commits from branch
master
- b98e66c2 - Display slash commands outcome when previewing Markdown
-
e62f81fb...2d43f8a2 - 7 commits from branch
- Resolved by username-removed-128633
@rymai I followed your suggestion, rebased and added explanation for the board move command that was added in the meantime (
).Please confirm that it's ready to be merged and I'll update the EE MR.
assigned to @rymai
- Resolved by username-removed-378947
- Resolved by username-removed-378947
@adamniedzielski Thanks, I left a few notes, LGTM otherwise!
assigned to @adamniedzielski
added 1 commit
- 579c9b70 - Display slash commands outcome when previewing Markdown
@adamniedzielski Thanks, looks good to me!
assigned to @rymai
@adamniedzielski You can update https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1707, thanks!
There are some legitimate test failures here
.added 1 commit
- 45e4c665 - Display slash commands outcome when previewing Markdown
@rymai I've updated the EE MR.
mentioned in commit 8b336ae1