-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add option to override react config. #254
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,7 +10,10 @@ const filter = module.exports; | |||||||||||||||||||
* Prepares configuration for component. | ||||||||||||||||||||
*/ | ||||||||||||||||||||
function prepareConfiguration(params = {}) { | ||||||||||||||||||||
const config = { show: { sidebar: true }, sidebar: { showOperations: 'byDefault' } }; | ||||||||||||||||||||
let config = { show: { sidebar: true }, sidebar: { showOperations: 'byDefault' } }; | ||||||||||||||||||||
if (params.config) { | ||||||||||||||||||||
config = {...config, ...JSON.parse(params.config) }; | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+13
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we should merge the
Then operations will be hidden, but sidebar will also hidden, but by default should be showed - only explicit defined
Suggested change
|
||||||||||||||||||||
if (params.sidebarOrganization === 'byTags') { | ||||||||||||||||||||
config.sidebar.showOperations = 'bySpecTags'; | ||||||||||||||||||||
} | ||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,11 @@ | |
"pdf": { | ||
"description": "Set to `true` to get index.pdf generated next to your index.html", | ||
"default": false | ||
}, | ||
"config": { | ||
"description": "Stringified JS object containing options for react, ex: {\"show\":{\"sidebar\":false}}.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix the description from my suggestion. |
||
"default": null, | ||
"required": false | ||
} | ||
}, | ||
"generator": ">=1.7.3 <2.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,14 @@ describe('Filters', () => { | |
const result = stringifyConfiguration(params); | ||
expect(result).toEqual(expected); | ||
}); | ||
|
||
it('should allow override of config', async () => { | ||
const params = { config: '{"show": {"sidebar":false}}' }; | ||
const expected = '{"show":{"sidebar":false},"sidebar":{"showOperations":"byDefault"}}'; | ||
|
||
const result = stringifyConfiguration(params); | ||
expect(result).toEqual(expected); | ||
}); | ||
Comment on lines
+116
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also add one test with checking my proposition with deep merging of the config prop :) |
||
}); | ||
|
||
describe('.renderSpec', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add link to the React component's config shape, something like: