Commit 7ef23713 authored by Tom Quirk's avatar Tom Quirk Committed by Mark Florian

Move help_page_helper to lib/utils

To make this file easier to find,
this commit moves this file to lib/utils.
parent 8e560269
......@@ -371,10 +371,10 @@ You can combine one or more of the following:
#### Linking to `/help` in JavaScript
To link to the documentation from a JavaScript or a Vue component, use the `helpPagePath` function from [`help_page_helper.js`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/helpers/help_page_helper.js):
To link to the documentation from a JavaScript or a Vue component, use the `helpPagePath` function from [`help_page_utility.js`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/lib/utils/help_page_utility.js):
```javascript
import { helpPagePath } from '~/helpers/help_page_helper';
import { helpPagePath } from '~/lib/utils/help_page_helper';
helpPagePath('user/permissions', { anchor: 'anchor-link' })
// evaluates to '/help/user/permissions#anchor-link' for GitLab.com
......
import { helpPagePath } from '~/helpers/help_page_helper';
describe('help page helper', () => {
it.each`
relative_url_root | path | anchor | expected
${undefined} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${''} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${'/'} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${'/gitlab'} | ${'administration/index'} | ${undefined} | ${'/gitlab/help/administration/index'}
${'/gitlab/'} | ${'administration/index'} | ${undefined} | ${'/gitlab/help/administration/index'}
${undefined} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${'/'} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${''} | ${'administration/index.md'} | ${undefined} | ${'/help/administration/index.md'}
${''} | ${'administration/index.md'} | ${'installing-gitlab'} | ${'/help/administration/index.md#installing-gitlab'}
${''} | ${'administration/index'} | ${'installing-gitlab'} | ${'/help/administration/index#installing-gitlab'}
${''} | ${'administration/index'} | ${'#installing-gitlab'} | ${'/help/administration/index#installing-gitlab'}
${''} | ${'/administration/index'} | ${undefined} | ${'/help/administration/index'}
${''} | ${'administration/index/'} | ${undefined} | ${'/help/administration/index/'}
${''} | ${'/administration/index/'} | ${undefined} | ${'/help/administration/index/'}
${'/'} | ${'/administration/index'} | ${undefined} | ${'/help/administration/index'}
`(
'generates correct URL when path is `$path`, relative url is `$relative_url_root` and anchor is `$anchor`',
({ relative_url_root, anchor, path, expected }) => {
window.gon = { relative_url_root };
expect(helpPagePath(path, { anchor })).toBe(expected);
},
);
});
import { helpPagePath } from '~/lib/utils/help_page_utility';
describe('help page helper', () => {
it.each`
relative_url_root | path | anchor | expected
${undefined} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${''} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${'/'} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${'/gitlab'} | ${'administration/index'} | ${undefined} | ${'/gitlab/help/administration/index'}
${'/gitlab/'} | ${'administration/index'} | ${undefined} | ${'/gitlab/help/administration/index'}
${undefined} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${'/'} | ${'administration/index'} | ${undefined} | ${'/help/administration/index'}
${''} | ${'administration/index.md'} | ${undefined} | ${'/help/administration/index.md'}
${''} | ${'administration/index.md'} | ${'installing-gitlab'} | ${'/help/administration/index.md#installing-gitlab'}
${''} | ${'administration/index'} | ${'installing-gitlab'} | ${'/help/administration/index#installing-gitlab'}
${''} | ${'administration/index'} | ${'#installing-gitlab'} | ${'/help/administration/index#installing-gitlab'}
${''} | ${'/administration/index'} | ${undefined} | ${'/help/administration/index'}
${''} | ${'administration/index/'} | ${undefined} | ${'/help/administration/index/'}
${''} | ${'/administration/index/'} | ${undefined} | ${'/help/administration/index/'}
${'/'} | ${'/administration/index'} | ${undefined} | ${'/help/administration/index'}
`(
'generates correct URL when path is `$path`, relative url is `$relative_url_root` and anchor is `$anchor`',
({ relative_url_root, anchor, path, expected }) => {
window.gon = { relative_url_root };
expect(helpPagePath(path, { anchor })).toBe(expected);
},
);
});
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