Commit ef9ed59d authored by Justin Ho's avatar Justin Ho

Move checkbox disabled to computed prop

parent 0570f736
......@@ -87,6 +87,9 @@ export default {
'isLoadingJiraIssueTypes',
'loadingJiraIssueTypesErrorMessage',
]),
checkboxDisabled() {
return !this.showFullFeature || this.isInheriting;
},
initialJiraIssueType() {
return this.jiraIssueTypes?.find(({ id }) => id === this.initialIssueTypeId) || {};
},
......@@ -135,7 +138,7 @@ export default {
<gl-form-checkbox
v-model="isJiraVulnerabilitiesEnabled"
data-testid="enable-jira-vulnerabilities"
:disabled="!showFullFeature || isInheriting"
:disabled="checkboxDisabled"
>
{{ $options.i18n.checkbox.label }}
<template #help>
......
......@@ -22,11 +22,14 @@ describe('JiraIssuesFields', () => {
{ id: '3', name: 'epic', description: 'epic' },
];
const createComponent = (mountFn) => ({ props } = {}) => {
const createComponent = (mountFn) => ({ isInheriting = false, props } = {}) => {
return extendedWrapper(
mountFn(JiraIssueCreationVulnerabilities, {
store,
propsData: { ...defaultProps, ...props },
computed: {
isInheriting: () => isInheriting,
},
}),
);
};
......@@ -98,6 +101,16 @@ describe('JiraIssuesFields', () => {
await setEnableJiraVulnerabilitiesChecked(isChecked);
expect(findIssueTypeSection().exists()).toBe(isChecked);
});
describe('when isInheriting = true', () => {
beforeEach(() => {
wrapper = createShallowComponent({ isInheriting: true });
});
it('disables the checkbox', () => {
expect(findEnableJiraVulnerabilities().attributes('disabled')).toBe('true');
});
});
});
describe('when showFullFeature is off', () => {
......
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