Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/search_autocomplete_utils.js')
-rw-r--r--app/assets/javascripts/search_autocomplete_utils.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/assets/javascripts/search_autocomplete_utils.js b/app/assets/javascripts/search_autocomplete_utils.js
new file mode 100644
index 00000000000..a9a0f941e93
--- /dev/null
+++ b/app/assets/javascripts/search_autocomplete_utils.js
@@ -0,0 +1,19 @@
+import { getPagePath } from './lib/utils/common_utils';
+
+export const isInGroupsPage = () => getPagePath() === 'groups';
+
+export const isInProjectPage = () => getPagePath() === 'projects';
+
+export const getProjectSlug = () => {
+ if (isInProjectPage()) {
+ return document?.body?.dataset?.project;
+ }
+ return null;
+};
+
+export const getGroupSlug = () => {
+ if (isInProjectPage() || isInGroupsPage()) {
+ return document?.body?.dataset?.group;
+ }
+ return null;
+};