Commit 762f7f4c authored by Scott Hampton's avatar Scott Hampton

Use provide and inject for HAML props

These HAML properties don't need to be props
since they are not reactive. We can use provide
and inject to get these props down to the child
components without having to pass props all
the way down.
parent 2023f9f1
...@@ -28,14 +28,10 @@ export default { ...@@ -28,14 +28,10 @@ export default {
directives: { directives: {
GlModalDirective, GlModalDirective,
}, },
props: { inject: {
groupAnalyticsCoverageReportsPath: { groupAnalyticsCoverageReportsPath: {
type: String, type: String,
required: true, default: '',
},
groupFullPath: {
type: String,
required: true,
}, },
}, },
data() { data() {
...@@ -173,7 +169,6 @@ export default { ...@@ -173,7 +169,6 @@ export default {
<select-projects-dropdown <select-projects-dropdown
ref="projectsDropdown" ref="projectsDropdown"
class="gl-w-half" class="gl-w-half"
:group-full-path="groupFullPath"
@projects-query-error="projectsQueryError" @projects-query-error="projectsQueryError"
@select-all-projects="selectAllProjects" @select-all-projects="selectAllProjects"
@select-project="selectProject" @select-project="selectProject"
......
...@@ -7,16 +7,6 @@ export default { ...@@ -7,16 +7,6 @@ export default {
components: { components: {
DownloadTestCoverage, DownloadTestCoverage,
}, },
inject: {
groupAnalyticsCoverageReportsPath: {
type: String,
default: '',
},
groupFullPath: {
type: String,
default: '',
},
},
text: { text: {
codeCoverageHeader: s__('RepositoriesAnalytics|Test Code Coverage'), codeCoverageHeader: s__('RepositoriesAnalytics|Test Code Coverage'),
}, },
...@@ -28,9 +18,6 @@ export default { ...@@ -28,9 +18,6 @@ export default {
<h4 data-testid="test-coverage-header"> <h4 data-testid="test-coverage-header">
{{ $options.text.codeCoverageHeader }} {{ $options.text.codeCoverageHeader }}
</h4> </h4>
<download-test-coverage <download-test-coverage />
:group-analytics-coverage-reports-path="groupAnalyticsCoverageReportsPath"
:group-full-path="groupFullPath"
/>
</div> </div>
</template> </template>
...@@ -26,10 +26,10 @@ export default { ...@@ -26,10 +26,10 @@ export default {
directives: { directives: {
GlModalDirective, GlModalDirective,
}, },
props: { inject: {
groupFullPath: { groupFullPath: {
type: String, type: String,
required: true, default: '',
}, },
}, },
apollo: { apollo: {
......
...@@ -23,9 +23,8 @@ describe('Download test coverage component', () => { ...@@ -23,9 +23,8 @@ describe('Download test coverage component', () => {
.vm.$emit('click'); .vm.$emit('click');
const findAlert = () => wrapper.find(GlAlert); const findAlert = () => wrapper.find(GlAlert);
const defaultProps = { const injectedProperties = {
groupAnalyticsCoverageReportsPath: '/coverage.csv?ref_path=refs/heads/master', groupAnalyticsCoverageReportsPath: '/coverage.csv?ref_path=refs/heads/master',
groupFullPath: 'gitlab-org',
}; };
const createComponent = () => { const createComponent = () => {
...@@ -38,8 +37,8 @@ describe('Download test coverage component', () => { ...@@ -38,8 +37,8 @@ describe('Download test coverage component', () => {
selectedProjectIds: [], selectedProjectIds: [],
}; };
}, },
propsData: { provide: {
...defaultProps, ...injectedProperties,
}, },
stubs: { GlDropdown, GlDropdownItem, GlModal, SelectProjectsDropdown }, stubs: { GlDropdown, GlDropdownItem, GlModal, SelectProjectsDropdown },
}); });
...@@ -76,7 +75,7 @@ describe('Download test coverage component', () => { ...@@ -76,7 +75,7 @@ describe('Download test coverage component', () => {
describe('when selecting a project', () => { describe('when selecting a project', () => {
// Due to the fake_date helper, we can always expect today's date to be 2020-07-06 // Due to the fake_date helper, we can always expect today's date to be 2020-07-06
// and the default date 30 days ago to be 2020-06-06 // and the default date 30 days ago to be 2020-06-06
const groupAnalyticsCoverageReportsPathWithDates = `${defaultProps.groupAnalyticsCoverageReportsPath}&start_date=2020-06-06&end_date=2020-07-06`; const groupAnalyticsCoverageReportsPathWithDates = `${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-06&end_date=2020-07-06`;
describe('with all projects selected', () => { describe('with all projects selected', () => {
it('renders primary action as a link with no project_ids param', () => { it('renders primary action as a link with no project_ids param', () => {
...@@ -138,11 +137,11 @@ describe('Download test coverage component', () => { ...@@ -138,11 +137,11 @@ describe('Download test coverage component', () => {
describe('when selecting a date range', () => { describe('when selecting a date range', () => {
it.each` it.each`
date | expected date | expected
${7} | ${`${defaultProps.groupAnalyticsCoverageReportsPath}&start_date=2020-06-29&end_date=2020-07-06`} ${7} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-29&end_date=2020-07-06`}
${14} | ${`${defaultProps.groupAnalyticsCoverageReportsPath}&start_date=2020-06-22&end_date=2020-07-06`} ${14} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-22&end_date=2020-07-06`}
${30} | ${`${defaultProps.groupAnalyticsCoverageReportsPath}&start_date=2020-06-06&end_date=2020-07-06`} ${30} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-06&end_date=2020-07-06`}
${60} | ${`${defaultProps.groupAnalyticsCoverageReportsPath}&start_date=2020-05-07&end_date=2020-07-06`} ${60} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-05-07&end_date=2020-07-06`}
${90} | ${`${defaultProps.groupAnalyticsCoverageReportsPath}&start_date=2020-04-07&end_date=2020-07-06`} ${90} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-04-07&end_date=2020-07-06`}
`( `(
'updates CSV path to have the start date be $date days before today', 'updates CSV path to have the start date be $date days before today',
({ date, expected }) => { ({ date, expected }) => {
......
...@@ -7,18 +7,8 @@ const localVue = createLocalVue(); ...@@ -7,18 +7,8 @@ const localVue = createLocalVue();
describe('Group repository analytics app', () => { describe('Group repository analytics app', () => {
let wrapper; let wrapper;
const injectedProperties = {
groupAnalyticsCoverageReportsPath: '/coverage.csv?ref_path=refs/heads/master',
groupFullPath: 'gitlab-org',
};
const createComponent = () => { const createComponent = () => {
wrapper = shallowMount(GroupRepositoryAnalytics, { wrapper = shallowMount(GroupRepositoryAnalytics, { localVue });
localVue,
provide: {
...injectedProperties,
},
});
}; };
beforeEach(() => { beforeEach(() => {
......
...@@ -36,7 +36,7 @@ describe('Select projects dropdown component', () => { ...@@ -36,7 +36,7 @@ describe('Select projects dropdown component', () => {
...data, ...data,
}; };
}, },
propsData: { provide: {
groupFullPath: 'gitlab-org', groupFullPath: 'gitlab-org',
}, },
mocks: { mocks: {
......
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