Simplify configuration paths injection

parent 1449cc3c
...@@ -7,9 +7,7 @@ export default { ...@@ -7,9 +7,7 @@ export default {
components: { components: {
GlAlert, GlAlert,
}, },
inject: Object.values(CODE_SNIPPET_SOURCE_SETTINGS).map( inject: ['configurationPaths'],
({ configurationPathInjectKey }) => configurationPathInjectKey,
),
props: { props: {
source: { source: {
type: String, type: String,
...@@ -22,8 +20,7 @@ export default { ...@@ -22,8 +20,7 @@ export default {
return CODE_SNIPPET_SOURCE_SETTINGS[this.source]; return CODE_SNIPPET_SOURCE_SETTINGS[this.source];
}, },
configurationPath() { configurationPath() {
const injectKey = this.settings.configurationPathInjectKey; return this.configurationPaths[this.source];
return this[injectKey];
}, },
}, },
}; };
......
...@@ -5,7 +5,7 @@ export const CODE_SNIPPET_SOURCE_API_FUZZING = 'api_fuzzing'; ...@@ -5,7 +5,7 @@ export const CODE_SNIPPET_SOURCE_API_FUZZING = 'api_fuzzing';
export const CODE_SNIPPET_SOURCES = [CODE_SNIPPET_SOURCE_API_FUZZING]; export const CODE_SNIPPET_SOURCES = [CODE_SNIPPET_SOURCE_API_FUZZING];
export const CODE_SNIPPET_SOURCE_SETTINGS = { export const CODE_SNIPPET_SOURCE_SETTINGS = {
[CODE_SNIPPET_SOURCE_API_FUZZING]: { [CODE_SNIPPET_SOURCE_API_FUZZING]: {
configurationPathInjectKey: 'apiFuzzingConfigurationPath', datasetKey: 'apiFuzzingConfigurationPath',
docsPath: helpPagePath('user/application_security/api_fuzzing/index'), docsPath: helpPagePath('user/application_security/api_fuzzing/index'),
}, },
}; };
...@@ -38,10 +38,10 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => { ...@@ -38,10 +38,10 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
ymlHelpPagePath, ymlHelpPagePath,
} = el?.dataset; } = el?.dataset;
const provideCodeSnippetConfigurationPaths = Object.fromEntries( const configurationPaths = Object.fromEntries(
Object.values(CODE_SNIPPET_SOURCE_SETTINGS).map(({ configurationPathInjectKey }) => [ Object.entries(CODE_SNIPPET_SOURCE_SETTINGS).map(([source, { datasetKey }]) => [
configurationPathInjectKey, source,
el.dataset[configurationPathInjectKey], el.dataset[datasetKey],
]), ]),
); );
...@@ -79,7 +79,7 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => { ...@@ -79,7 +79,7 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
projectPath, projectPath,
projectNamespace, projectNamespace,
ymlHelpPagePath, ymlHelpPagePath,
...provideCodeSnippetConfigurationPaths, configurationPaths,
}, },
render(h) { render(h) {
return h(PipelineEditorApp); return h(PipelineEditorApp);
......
...@@ -18,7 +18,9 @@ describe('EE - CodeSnippetAlert', () => { ...@@ -18,7 +18,9 @@ describe('EE - CodeSnippetAlert', () => {
merge( merge(
{ {
provide: { provide: {
apiFuzzingConfigurationPath, configurationPaths: {
[CODE_SNIPPET_SOURCE_API_FUZZING]: apiFuzzingConfigurationPath,
},
}, },
propsData: { propsData: {
source: CODE_SNIPPET_SOURCE_API_FUZZING, source: CODE_SNIPPET_SOURCE_API_FUZZING,
......
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