Commit 3663b86c authored by Tom Quirk's avatar Tom Quirk

Render integration help in Vue

parent dcbe3b42
<script> <script>
import { mapState, mapActions, mapGetters } from 'vuex'; import { mapState, mapActions, mapGetters } from 'vuex';
import { GlButton, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlModalDirective, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import { integrationLevels } from '../constants'; import { integrationLevels } from '../constants';
...@@ -28,9 +28,17 @@ export default { ...@@ -28,9 +28,17 @@ export default {
GlButton, GlButton,
}, },
directives: { directives: {
'gl-modal': GlModalDirective, GlModal: GlModalDirective,
SafeHtml,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
props: {
helpHtml: {
type: String,
required: false,
default: '',
},
},
computed: { computed: {
...mapGetters(['currentKey', 'propsSource', 'isDisabled']), ...mapGetters(['currentKey', 'propsSource', 'isDisabled']),
...mapState([ ...mapState([
...@@ -80,6 +88,9 @@ export default { ...@@ -80,6 +88,9 @@ export default {
this.fetchResetIntegration(); this.fetchResetIntegration();
}, },
}, },
helpHtmlConfig: {
ADD_TAGS: ['use'], // to support icon SVGs
},
}; };
</script> </script>
...@@ -92,6 +103,10 @@ export default { ...@@ -92,6 +103,10 @@ export default {
:learn-more-path="propsSource.learnMorePath" :learn-more-path="propsSource.learnMorePath"
@change="setOverride" @change="setOverride"
/> />
<!-- helpHtml is trusted input -->
<div v-if="helpHtml" v-safe-html:[$options.helpHtmlConfig]="helpHtml"></div>
<active-checkbox v-if="propsSource.showActive" :key="`${currentKey}-active-checkbox`" /> <active-checkbox v-if="propsSource.showActive" :key="`${currentKey}-active-checkbox`" />
<jira-trigger-fields <jira-trigger-fields
v-if="isJira" v-if="isJira"
......
...@@ -80,21 +80,29 @@ export default (el, defaultEl) => { ...@@ -80,21 +80,29 @@ export default (el, defaultEl) => {
} }
const props = parseDatasetToProps(el.dataset); const props = parseDatasetToProps(el.dataset);
const initialState = { const initialState = {
defaultState: null, defaultState: null,
customState: props, customState: props,
}; };
if (defaultEl) { if (defaultEl) {
initialState.defaultState = Object.freeze(parseDatasetToProps(defaultEl.dataset)); initialState.defaultState = Object.freeze(parseDatasetToProps(defaultEl.dataset));
} }
// Here, we capture the "helpHtml", so we can pass it to the Vue component
// to position it where ever it wants.
// Because this node is a _child_ of `el`, it will be removed when the Vue component is mounted,
// so we don't need to manually remove it.
const helpHtml = el.querySelector('.js-integration-help-html')?.innerHTML;
return new Vue({ return new Vue({
el, el,
store: createStore(initialState), store: createStore(initialState),
render(createElement) { render(createElement) {
return createElement(IntegrationForm); return createElement(IntegrationForm, {
props: {
helpHtml,
},
});
}, },
}); });
}; };
= form_errors(integration) = form_errors(integration)
- if lookup_context.template_exists?('help', "projects/services/#{integration.to_param}", true)
= render "projects/services/#{integration.to_param}/help", subject: integration
- elsif integration.help.present?
.info-well
.well-segment
= markdown integration.help
.service-settings .service-settings
- if @default_integration - if @default_integration
.js-vue-default-integration-settings{ data: integration_form_data(@default_integration, group: @group) } .js-vue-default-integration-settings{ data: integration_form_data(@default_integration, group: @group) }
.js-vue-integration-settings{ data: integration_form_data(integration, group: @group) } .js-vue-integration-settings{ data: integration_form_data(integration, group: @group) }
.js-integration-help-html
-# All content below will be repositioned in Vue
- if lookup_context.template_exists?('help', "projects/services/#{integration.to_param}", true)
= render "projects/services/#{integration.to_param}/help", subject: integration
- elsif integration.help.present?
.info-well
.well-segment
= markdown integration.help
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