Simplify configuration paths injection

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