Commit 37fafa08 authored by Mark Florian's avatar Mark Florian

Revert "Move help_page_helper to lib/utils"

This reverts commit 9a80dadaa797b6f11b125507f18a3af2789b6064.

A util is something which works outside of the project (i.e. could be
ported to another project without relying on any project specific code)
while a helper is something which augments or assists project specific
code. Like a helper which uses a class variable to augment the value.

Since this is specifically about generating help links for the GitLab
product, this therefore is a helper.
parent a059de34
......@@ -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_utility.js`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/lib/utils/help_page_utility.js):
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):
```javascript
import { helpPagePath } from '~/lib/utils/help_page_helper';
import { helpPagePath } from '~/helpers/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