Commit d2b3ed17 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '29816-create-keyboard-shortcut-for-editing-wiki-page' into 'master'

Add keyboard edit shortcut for wiki

Closes #29816

See merge request !10245
parents 423d98d7 ffca1cc2
......@@ -33,6 +33,7 @@
/* global Labels */
/* global Shortcuts */
/* global Sidebar */
/* global ShortcutsWiki */
import Issue from './issue';
......@@ -46,6 +47,7 @@ import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
import BlobForkSuggestion from './blob/blob_fork_suggestion';
import UserCallout from './user_callout';
import { ProtectedTagCreate, ProtectedTagEditList } from './protected_tags';
import ShortcutsWiki from './shortcuts_wiki';
const ShortcutsBlob = require('./shortcuts_blob');
......@@ -416,7 +418,7 @@ const ShortcutsBlob = require('./shortcuts_blob');
break;
case 'wikis':
new gl.Wikis();
shortcut_handler = new ShortcutsNavigation();
shortcut_handler = new ShortcutsWiki();
new ZenMode();
new gl.GLForm($('.wiki-form'));
break;
......
/* eslint-disable class-methods-use-this */
/* global Mousetrap */
/* global ShortcutsNavigation */
import findAndFollowLink from './shortcuts_dashboard_navigation';
export default class ShortcutsWiki extends ShortcutsNavigation {
constructor() {
super();
Mousetrap.bind('e', this.editWiki);
}
editWiki() {
findAndFollowLink('.js-wiki-edit');
}
}
......@@ -318,3 +318,11 @@
%td.shortcut
.key l
%td Change Label
%tbody.hidden-shortcut.wiki{ style: 'display:none' }
%tr
%th
%th Wiki pages
%tr
%td.shortcut
.key e
%td Edit wiki page
......@@ -5,5 +5,5 @@
= link_to namespace_project_wiki_history_path(@project.namespace, @project, @page), class: "btn" do
Page history
- if can?(current_user, :create_wiki, @project) && @page.latest?
= link_to namespace_project_wiki_edit_path(@project.namespace, @project, @page), class: "btn" do
= link_to namespace_project_wiki_edit_path(@project.namespace, @project, @page), class: "btn js-wiki-edit" do
Edit
---
title: Add keyboard edit shotcut for wiki
merge_request: 10245
author: George Andrinopoulos
......@@ -75,3 +75,9 @@ You can see GitLab's keyboard shortcuts by using 'shift + ?'
| <kbd>r</kbd> | Reply (quoting selected text) |
| <kbd>e</kbd> | Edit issue/merge request |
| <kbd>l</kbd> | Change label |
## Wiki pages
| Keyboard Shortcut | Description |
| ----------------- | ----------- |
| <kbd>e</kbd> | Edit wiki page|
require 'spec_helper'
feature 'Wiki shortcuts', :feature, :js do
let(:user) { create(:user) }
let(:project) { create(:empty_project, namespace: user.namespace) }
let(:wiki_page) do
WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute
end
before do
login_as(user)
visit namespace_project_wiki_path(project.namespace, project, wiki_page)
end
scenario 'Visit edit wiki page using "e" keyboard shortcut' do
find('body').native.send_key('e')
expect(find('.wiki-page-title')).to have_content('Edit Page')
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment