Commit 97dfbb9f authored by Tom Quirk's avatar Tom Quirk Committed by Phil Hughes

Minor modifications to wiki "delete page" modal

- make button "secondary" style
- make button text "delete page"
- make modal smaller
- add cancel button to modal
parent e69eba78
<script> <script>
import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { s__, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
export default { export default {
components: { components: {
...@@ -29,12 +29,6 @@ export default { ...@@ -29,12 +29,6 @@ export default {
}, },
}, },
computed: { computed: {
modalId() {
return 'delete-wiki-modal';
},
message() {
return s__('WikiPageConfirmDelete|Are you sure you want to delete this page?');
},
title() { title() {
return sprintf( return sprintf(
s__('WikiPageConfirmDelete|Delete page %{pageTitle}?'), s__('WikiPageConfirmDelete|Delete page %{pageTitle}?'),
...@@ -44,6 +38,17 @@ export default { ...@@ -44,6 +38,17 @@ export default {
false, false,
); );
}, },
primaryProps() {
return {
text: this.$options.i18n.deletePageText,
attributes: { variant: 'danger', 'data-qa-selector': 'confirm_deletion_button' },
};
},
cancelProps() {
return {
text: this.$options.i18n.cancelButtonText,
};
},
}, },
methods: { methods: {
onSubmit() { onSubmit() {
...@@ -51,30 +56,36 @@ export default { ...@@ -51,30 +56,36 @@ export default {
this.$refs.form.submit(); this.$refs.form.submit();
}, },
}, },
i18n: {
deletePageText: s__('WikiPageConfirmDelete|Delete page'),
modalBody: s__('WikiPageConfirmDelete|Are you sure you want to delete this page?'),
cancelButtonText: __('Cancel'),
},
modal: {
modalId: 'delete-wiki-modal',
},
}; };
</script> </script>
<template> <template>
<div class="d-inline-block"> <div class="d-inline-block">
<gl-button <gl-button
v-gl-modal="modalId" v-gl-modal="$options.modal.modalId"
category="primary" category="secondary"
variant="danger" variant="danger"
data-qa-selector="delete_button" data-qa-selector="delete_button"
> >
{{ __('Delete') }} {{ $options.i18n.deletePageText }}
</gl-button> </gl-button>
<gl-modal <gl-modal
:title="title" :title="title"
:action-primary="{ :action-primary="primaryProps"
text: s__('WikiPageConfirmDelete|Delete page'), :action-cancel="cancelProps"
attributes: { variant: 'danger', 'data-qa-selector': 'confirm_deletion_button' }, :modal-id="$options.modal.modalId"
}" size="sm"
:modal-id="modalId"
title-tag="h4"
@ok="onSubmit" @ok="onSubmit"
> >
{{ message }} {{ $options.i18n.modalBody }}
<form ref="form" :action="deleteWikiUrl" method="post" class="js-requires-input"> <form ref="form" :action="deleteWikiUrl" method="post" class="js-requires-input">
<input ref="method" type="hidden" name="_method" value="delete" /> <input ref="method" type="hidden" name="_method" value="delete" />
<input :value="csrfToken" type="hidden" name="authenticity_token" /> <input :value="csrfToken" type="hidden" name="authenticity_token" />
......
---
title: Minor UI improvements to Wiki Delete Page button and modal
merge_request: 45740
author:
type: changed
...@@ -96,12 +96,12 @@ Please note that: ...@@ -96,12 +96,12 @@ Please note that:
## Editing a wiki page ## Editing a wiki page
NOTE: **Note:** You need Developer [permissions](../../permissions.md) or higher to edit a wiki page.
Requires Developer [permissions](../../permissions.md). To do so:
To edit a page, simply click on the **Edit** button. From there on, you can 1. Click the edit icon (**{pencil}**).
change its content. When done, click **Save changes** for the changes to take 1. Edit the content.
effect. 1. Click **Save changes**.
### Adding a table of contents ### Adding a table of contents
...@@ -110,23 +110,34 @@ For an example, see [Table of contents](../../markdown.md#table-of-contents). ...@@ -110,23 +110,34 @@ For an example, see [Table of contents](../../markdown.md#table-of-contents).
## Deleting a wiki page ## Deleting a wiki page
NOTE: **Note:** You need Maintainer [permissions](../../permissions.md) or higher to delete a wiki page.
Requires Maintainer [permissions](../../permissions.md). To do so:
You can find the **Delete** button only when editing a page. Click on it and 1. Open the page you want to delete.
confirm you want the page to be deleted. 1. Click the **Delete page** button.
1. Confirm the deletion.
## Moving a wiki page ## Moving a wiki page
You can move a wiki page from one directory to another by specifying the full You need Developer [permissions](../../permissions.md) or higher to move a wiki page.
path in the wiki page title in the [edit](#editing-a-wiki-page) form. To do so:
1. Click the edit icon (**{pencil}**).
1. Add the new path to the **Title** field.
1. Click **Save changes**.
For example, if you have a wiki page called `about` under `company` and you want to
move it to the wiki's root:
![Moving a page](img/wiki_move_page_1.png) 1. Click the edit icon (**{pencil}**).
1. Change the **Title** from `about` to `/about`.
1. Click **Save changes**.
![After moving a page](img/wiki_move_page_2.png) If you want to do the opposite:
In order to move a wiki page to the root directory, the wiki page title must 1. Click the edit icon (**{pencil}**).
be preceded by the slash (`/`) character. 1. Change the **Title** from `about` to `company/about`.
1. Click **Save changes**.
## Viewing a list of all created wiki pages ## Viewing a list of all created wiki pages
......
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