summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pages/projects/shared/web_ide_link/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/pages/projects/shared/web_ide_link/index.js')
-rw-r--r--app/assets/javascripts/pages/projects/shared/web_ide_link/index.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/assets/javascripts/pages/projects/shared/web_ide_link/index.js b/app/assets/javascripts/pages/projects/shared/web_ide_link/index.js
new file mode 100644
index 00000000000..5f08943d211
--- /dev/null
+++ b/app/assets/javascripts/pages/projects/shared/web_ide_link/index.js
@@ -0,0 +1,31 @@
+import Vue from 'vue';
+import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
+import { joinPaths, webIDEUrl } from '~/lib/utils/url_utility';
+import WebIdeButton from '~/vue_shared/components/web_ide_link.vue';
+
+export default ({ el, router }) => {
+ if (!el) return;
+
+ const { projectPath, ref, isBlob, webIdeUrl, ...options } = convertObjectPropsToCamelCase(
+ JSON.parse(el.dataset.options),
+ );
+
+ // eslint-disable-next-line no-new
+ new Vue({
+ el,
+ router,
+ render(h) {
+ return h(WebIdeButton, {
+ props: {
+ isBlob,
+ webIdeUrl: isBlob
+ ? webIdeUrl
+ : webIDEUrl(
+ joinPaths('/', projectPath, 'edit', ref, '-', this.$route?.params.path || '', '/'),
+ ),
+ ...options,
+ },
+ });
+ },
+ });
+};