Commit 57186535 authored by Justin Ho's avatar Justin Ho

Use provide instead of props for form

- Add Vue app name for Vue dev tools.
- Add optional chaining in computed prop to avoid
console errors on refresh.
parent c543fc16
...@@ -3,6 +3,7 @@ import { GlButton, GlModalDirective, GlSafeHtmlDirective as SafeHtml, GlForm } f ...@@ -3,6 +3,7 @@ import { GlButton, GlModalDirective, GlSafeHtmlDirective as SafeHtml, GlForm } f
import axios from 'axios'; import axios from 'axios';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { mapState, mapActions, mapGetters } from 'vuex'; import { mapState, mapActions, mapGetters } from 'vuex';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { import {
I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE, I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE,
...@@ -41,10 +42,8 @@ export default { ...@@ -41,10 +42,8 @@ export default {
SafeHtml, SafeHtml,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
props: { inject: {
helpHtml: { helpHtml: {
type: String,
required: false,
default: '', default: '',
}, },
}, },
...@@ -82,7 +81,7 @@ export default { ...@@ -82,7 +81,7 @@ export default {
return Boolean(this.isSaving || this.isResetting || this.isTesting); return Boolean(this.isSaving || this.isResetting || this.isTesting);
}, },
form() { form() {
return this.$refs.integrationForm.$el; return this.$refs.integrationForm?.$el;
}, },
}, },
methods: { methods: {
......
...@@ -116,13 +116,13 @@ export default function initIntegrationSettingsForm() { ...@@ -116,13 +116,13 @@ export default function initIntegrationSettingsForm() {
return new Vue({ return new Vue({
el: customSettingsEl, el: customSettingsEl,
name: 'IntegrationEditRoot',
store: createStore(initialState), store: createStore(initialState),
render(createElement) { provide: {
return createElement(IntegrationForm, {
props: {
helpHtml, helpHtml,
}, },
}); render(createElement) {
return createElement(IntegrationForm);
}, },
}); });
} }
...@@ -37,7 +37,7 @@ describe('IntegrationForm', () => { ...@@ -37,7 +37,7 @@ describe('IntegrationForm', () => {
const createComponent = ({ const createComponent = ({
customStateProps = {}, customStateProps = {},
initialState = {}, initialState = {},
props = {}, provide = {},
mountFn = shallowMountExtended, mountFn = shallowMountExtended,
} = {}) => { } = {}) => {
const store = createStore({ const store = createStore({
...@@ -47,7 +47,7 @@ describe('IntegrationForm', () => { ...@@ -47,7 +47,7 @@ describe('IntegrationForm', () => {
dispatch = jest.spyOn(store, 'dispatch').mockImplementation(); dispatch = jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = mountFn(IntegrationForm, { wrapper = mountFn(IntegrationForm, {
propsData: { ...props }, provide,
store, store,
stubs: { stubs: {
OverrideDropdown, OverrideDropdown,
...@@ -300,7 +300,7 @@ describe('IntegrationForm', () => { ...@@ -300,7 +300,7 @@ describe('IntegrationForm', () => {
}); });
}); });
describe('with `helpHtml` prop', () => { describe('with `helpHtml` provided', () => {
const mockTestId = 'jest-help-html-test'; const mockTestId = 'jest-help-html-test';
setHTMLFixture(` setHTMLFixture(`
...@@ -316,7 +316,7 @@ describe('IntegrationForm', () => { ...@@ -316,7 +316,7 @@ describe('IntegrationForm', () => {
const mockHelpHtml = document.querySelector(`[data-testid="${mockTestId}"]`); const mockHelpHtml = document.querySelector(`[data-testid="${mockTestId}"]`);
createComponent({ createComponent({
props: { provide: {
helpHtml: mockHelpHtml.outerHTML, helpHtml: mockHelpHtml.outerHTML,
}, },
}); });
......
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