Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
08363ffc
Commit
08363ffc
authored
Mar 04, 2021
by
Jiaan Louw
Committed by
Kushal Pandya
Mar 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update add forms submit btn text to "Add framework"
- Adds a submitButtonText prop to the shared form
parent
23c99671
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
13 deletions
+56
-13
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/create_form.vue
...settings/compliance_frameworks/components/create_form.vue
+6
-3
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/edit_form.vue
...s/settings/compliance_frameworks/components/edit_form.vue
+6
-3
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/list.vue
...groups/settings/compliance_frameworks/components/list.vue
+4
-0
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/shared_form.vue
...settings/compliance_frameworks/components/shared_form.vue
+5
-2
ee/spec/frontend/groups/settings/compliance_frameworks/components/create_form_spec.js
...ings/compliance_frameworks/components/create_form_spec.js
+12
-2
ee/spec/frontend/groups/settings/compliance_frameworks/components/edit_form_spec.js
...ttings/compliance_frameworks/components/edit_form_spec.js
+3
-2
ee/spec/frontend/groups/settings/compliance_frameworks/components/list_spec.js
...ps/settings/compliance_frameworks/components/list_spec.js
+9
-0
ee/spec/frontend/groups/settings/compliance_frameworks/components/shared_form_spec.js
...ings/compliance_frameworks/components/shared_form_spec.js
+11
-1
No files found.
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/create_form.vue
View file @
08363ffc
<
script
>
<
script
>
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
SAVE_ERROR
}
from
'
../constants
'
;
import
{
SAVE_ERROR
}
from
'
../constants
'
;
import
createComplianceFrameworkMutation
from
'
../graphql/queries/create_compliance_framework.mutation.graphql
'
;
import
createComplianceFrameworkMutation
from
'
../graphql/queries/create_compliance_framework.mutation.graphql
'
;
import
{
initialiseFormData
}
from
'
../utils
'
;
import
{
initialiseFormData
}
from
'
../utils
'
;
...
@@ -41,6 +42,7 @@ export default {
...
@@ -41,6 +42,7 @@ export default {
},
},
methods
:
{
methods
:
{
setError
(
error
,
userFriendlyText
)
{
setError
(
error
,
userFriendlyText
)
{
this
.
saving
=
false
;
this
.
errorMessage
=
userFriendlyText
;
this
.
errorMessage
=
userFriendlyText
;
Sentry
.
captureException
(
error
);
Sentry
.
captureException
(
error
);
},
},
...
@@ -70,16 +72,16 @@ export default {
...
@@ -70,16 +72,16 @@ export default {
if
(
error
)
{
if
(
error
)
{
this
.
setError
(
new
Error
(
error
),
error
);
this
.
setError
(
new
Error
(
error
),
error
);
}
else
{
}
else
{
this
.
saving
=
false
;
visitUrl
(
this
.
groupEditPath
);
visitUrl
(
this
.
groupEditPath
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
setError
(
e
,
SAVE_ERROR
);
this
.
setError
(
e
,
SAVE_ERROR
);
}
}
this
.
saving
=
false
;
},
},
},
},
i18n
:
{
submitButtonText
:
s__
(
'
ComplianceFrameworks|Add framework
'
),
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -91,6 +93,7 @@ export default {
...
@@ -91,6 +93,7 @@ export default {
:description.sync=
"formData.description"
:description.sync=
"formData.description"
:pipeline-configuration-full-path.sync=
"formData.pipelineConfigurationFullPath"
:pipeline-configuration-full-path.sync=
"formData.pipelineConfigurationFullPath"
:color.sync=
"formData.color"
:color.sync=
"formData.color"
:submit-button-text=
"$options.i18n.submitButtonText"
@
submit=
"onSubmit"
@
submit=
"onSubmit"
/>
/>
</form-status>
</form-status>
...
...
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/edit_form.vue
View file @
08363ffc
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
convertToGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
{
convertToGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
FETCH_ERROR
,
SAVE_ERROR
}
from
'
../constants
'
;
import
{
FETCH_ERROR
,
SAVE_ERROR
}
from
'
../constants
'
;
import
getComplianceFrameworkQuery
from
'
../graphql/queries/get_compliance_framework.query.graphql
'
;
import
getComplianceFrameworkQuery
from
'
../graphql/queries/get_compliance_framework.query.graphql
'
;
...
@@ -104,6 +105,7 @@ export default {
...
@@ -104,6 +105,7 @@ export default {
Sentry
.
captureException
(
error
);
Sentry
.
captureException
(
error
);
},
},
setSavingError
(
error
,
userFriendlyText
)
{
setSavingError
(
error
,
userFriendlyText
)
{
this
.
saving
=
false
;
this
.
saveErrorMessage
=
userFriendlyText
;
this
.
saveErrorMessage
=
userFriendlyText
;
Sentry
.
captureException
(
error
);
Sentry
.
captureException
(
error
);
},
},
...
@@ -133,16 +135,16 @@ export default {
...
@@ -133,16 +135,16 @@ export default {
if
(
error
)
{
if
(
error
)
{
this
.
setSavingError
(
new
Error
(
error
),
error
);
this
.
setSavingError
(
new
Error
(
error
),
error
);
}
else
{
}
else
{
this
.
saving
=
false
;
visitUrl
(
this
.
groupEditPath
);
visitUrl
(
this
.
groupEditPath
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
setSavingError
(
e
,
SAVE_ERROR
);
this
.
setSavingError
(
e
,
SAVE_ERROR
);
}
}
this
.
saving
=
false
;
},
},
},
},
i18n
:
{
submitButtonText
:
__
(
'
Save changes
'
),
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -155,6 +157,7 @@ export default {
...
@@ -155,6 +157,7 @@ export default {
:description.sync=
"formData.description"
:description.sync=
"formData.description"
:pipeline-configuration-full-path.sync=
"formData.pipelineConfigurationFullPath"
:pipeline-configuration-full-path.sync=
"formData.pipelineConfigurationFullPath"
:color.sync=
"formData.color"
:color.sync=
"formData.color"
:submit-button-text=
"$options.i18n.submitButtonText"
@
submit=
"onSubmit"
@
submit=
"onSubmit"
/>
/>
</form-status>
</form-status>
...
...
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/list.vue
View file @
08363ffc
...
@@ -98,6 +98,9 @@ export default {
...
@@ -98,6 +98,9 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
dismissAlertMessage
()
{
this
.
message
=
null
;
},
markForDeletion
(
framework
)
{
markForDeletion
(
framework
)
{
this
.
markedForDeletion
=
framework
;
this
.
markedForDeletion
=
framework
;
this
.
$refs
.
modal
.
show
();
this
.
$refs
.
modal
.
show
();
...
@@ -140,6 +143,7 @@ export default {
...
@@ -140,6 +143,7 @@ export default {
class=
"gl-mt-5"
class=
"gl-mt-5"
:variant=
"alertVariant"
:variant=
"alertVariant"
:dismissible=
"alertDismissible"
:dismissible=
"alertDismissible"
@
dismiss=
"dismissAlertMessage"
>
>
{{
alertMessage
}}
{{
alertMessage
}}
</gl-alert>
</gl-alert>
...
...
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/shared_form.vue
View file @
08363ffc
...
@@ -47,6 +47,10 @@ export default {
...
@@ -47,6 +47,10 @@ export default {
required
:
false
,
required
:
false
,
default
:
null
,
default
:
null
,
},
},
submitButtonText
:
{
type
:
String
,
required
:
true
,
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -141,7 +145,6 @@ export default {
...
@@ -141,7 +145,6 @@ export default {
'
ComplianceFrameworks|Could not find this configuration location, please try a different location
'
,
'
ComplianceFrameworks|Could not find this configuration location, please try a different location
'
,
),
),
colorInputLabel
:
__
(
'
Background color
'
),
colorInputLabel
:
__
(
'
Background color
'
),
submitBtnText
:
__
(
'
Save changes
'
),
cancelBtnText
:
__
(
'
Cancel
'
),
cancelBtnText
:
__
(
'
Cancel
'
),
},
},
};
};
...
@@ -223,7 +226,7 @@ export default {
...
@@ -223,7 +226,7 @@ export default {
class=
"js-no-auto-disable"
class=
"js-no-auto-disable"
data-testid=
"submit-btn"
data-testid=
"submit-btn"
:disabled=
"disableSubmitBtn"
:disabled=
"disableSubmitBtn"
>
{{
$options.i18n.submitBt
nText }}
</gl-button
>
{{
submitButto
nText }}
</gl-button
>
>
<gl-button
:href=
"groupEditPath"
data-testid=
"cancel-btn"
>
{{
<gl-button
:href=
"groupEditPath"
data-testid=
"cancel-btn"
>
{{
$options.i18n.cancelBtnText
$options.i18n.cancelBtnText
...
...
ee/spec/frontend/groups/settings/compliance_frameworks/components/create_form_spec.js
View file @
08363ffc
...
@@ -67,6 +67,16 @@ describe('CreateForm', () => {
...
@@ -67,6 +67,16 @@ describe('CreateForm', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
describe
(
'
initialized
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
();
});
it
(
'
sets the submit button text on the form
'
,
()
=>
{
expect
(
findForm
().
props
(
'
submitButtonText
'
)).
toBe
(
'
Add framework
'
);
});
});
describe
(
'
loading
'
,
()
=>
{
describe
(
'
loading
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
();
wrapper
=
createComponent
();
...
@@ -120,13 +130,13 @@ describe('CreateForm', () => {
...
@@ -120,13 +130,13 @@ describe('CreateForm', () => {
expect
(
captureExceptionSpy
).
toHaveBeenCalledWith
(
sentrySaveError
);
expect
(
captureExceptionSpy
).
toHaveBeenCalledWith
(
sentrySaveError
);
});
});
it
(
'
saves inputted values
and redirects
'
,
async
()
=>
{
it
(
'
saves inputted values
, redirects and continues to show loading while redirecting
'
,
async
()
=>
{
wrapper
=
createComponent
([[
createComplianceFrameworkMutation
,
create
]]);
wrapper
=
createComponent
([[
createComplianceFrameworkMutation
,
create
]]);
await
submitForm
(
name
,
description
,
pipelineConfigurationFullPath
,
color
);
await
submitForm
(
name
,
description
,
pipelineConfigurationFullPath
,
color
);
expect
(
create
).
toHaveBeenCalledWith
(
creationProps
);
expect
(
create
).
toHaveBeenCalledWith
(
creationProps
);
expect
(
findFormStatus
().
props
(
'
loading
'
)).
toBe
(
fals
e
);
expect
(
findFormStatus
().
props
(
'
loading
'
)).
toBe
(
tru
e
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
propsData
.
groupEditPath
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
propsData
.
groupEditPath
);
});
});
});
});
...
...
ee/spec/frontend/groups/settings/compliance_frameworks/components/edit_form_spec.js
View file @
08363ffc
...
@@ -104,6 +104,7 @@ describe('EditForm', () => {
...
@@ -104,6 +104,7 @@ describe('EditForm', () => {
name
:
frameworkFoundResponse
.
name
,
name
:
frameworkFoundResponse
.
name
,
pipelineConfigurationFullPath
:
frameworkFoundResponse
.
pipelineConfigurationFullPath
,
pipelineConfigurationFullPath
:
frameworkFoundResponse
.
pipelineConfigurationFullPath
,
pipelineConfigurationFullPathEnabled
:
true
,
pipelineConfigurationFullPathEnabled
:
true
,
submitButtonText
:
'
Save changes
'
,
});
});
expect
(
findForm
().
exists
()).
toBe
(
true
);
expect
(
findForm
().
exists
()).
toBe
(
true
);
});
});
...
@@ -183,7 +184,7 @@ describe('EditForm', () => {
...
@@ -183,7 +184,7 @@ describe('EditForm', () => {
expect
(
Sentry
.
captureException
.
mock
.
calls
[
0
][
0
]).
toStrictEqual
(
sentrySaveError
);
expect
(
Sentry
.
captureException
.
mock
.
calls
[
0
][
0
]).
toStrictEqual
(
sentrySaveError
);
});
});
it
(
'
saves inputted values
and redirects
'
,
async
()
=>
{
it
(
'
saves inputted values
, redirects and continues to show loading while redirecting
'
,
async
()
=>
{
wrapper
=
createComponent
([
wrapper
=
createComponent
([
[
getComplianceFrameworkQuery
,
fetchOne
],
[
getComplianceFrameworkQuery
,
fetchOne
],
[
updateComplianceFrameworkMutation
,
update
],
[
updateComplianceFrameworkMutation
,
update
],
...
@@ -192,7 +193,7 @@ describe('EditForm', () => {
...
@@ -192,7 +193,7 @@ describe('EditForm', () => {
await
submitForm
(
name
,
description
,
pipelineConfigurationFullPath
,
color
);
await
submitForm
(
name
,
description
,
pipelineConfigurationFullPath
,
color
);
expect
(
update
).
toHaveBeenCalledWith
(
updateProps
);
expect
(
update
).
toHaveBeenCalledWith
(
updateProps
);
expect
(
findFormStatus
().
props
(
'
loading
'
)).
toBe
(
fals
e
);
expect
(
findFormStatus
().
props
(
'
loading
'
)).
toBe
(
tru
e
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
propsData
.
groupEditPath
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
propsData
.
groupEditPath
);
});
});
});
});
...
...
ee/spec/frontend/groups/settings/compliance_frameworks/components/list_spec.js
View file @
08363ffc
import
{
GlAlert
,
GlButton
,
GlLoadingIcon
,
GlTab
,
GlTabs
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlButton
,
GlLoadingIcon
,
GlTab
,
GlTabs
}
from
'
@gitlab/ui
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
DeleteModal
from
'
ee/groups/settings/compliance_frameworks/components/delete_modal.vue
'
;
import
DeleteModal
from
'
ee/groups/settings/compliance_frameworks/components/delete_modal.vue
'
;
...
@@ -256,6 +257,14 @@ describe('List', () => {
...
@@ -256,6 +257,14 @@ describe('List', () => {
expect
(
findAlert
().
props
(
'
variant
'
)).
toBe
(
'
info
'
);
expect
(
findAlert
().
props
(
'
variant
'
)).
toBe
(
'
info
'
);
expect
(
findAlert
().
text
()).
toBe
(
'
Compliance framework deleted successfully
'
);
expect
(
findAlert
().
text
()).
toBe
(
'
Compliance framework deleted successfully
'
);
});
});
it
(
'
can dismiss the alert message
'
,
async
()
=>
{
findAlert
().
vm
.
$emit
(
'
dismiss
'
);
await
nextTick
();
expect
(
findAlert
().
exists
()).
toBe
(
false
);
});
});
});
});
});
});
});
...
...
ee/spec/frontend/groups/settings/compliance_frameworks/components/shared_form_spec.js
View file @
08363ffc
...
@@ -10,7 +10,11 @@ import { GlFormGroup, GlFormInput } from '../stubs';
...
@@ -10,7 +10,11 @@ import { GlFormGroup, GlFormInput } from '../stubs';
describe
(
'
SharedForm
'
,
()
=>
{
describe
(
'
SharedForm
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
defaultPropsData
=
{
groupEditPath
:
'
group-1
'
,
pipelineConfigurationFullPathEnabled
:
true
};
const
defaultPropsData
=
{
groupEditPath
:
'
group-1
'
,
pipelineConfigurationFullPathEnabled
:
true
,
submitButtonText
:
'
Save changes
'
,
};
const
findForm
=
()
=>
wrapper
.
findComponent
(
GlForm
);
const
findForm
=
()
=>
wrapper
.
findComponent
(
GlForm
);
const
findNameGroup
=
()
=>
wrapper
.
find
(
'
[data-testid="name-input-group"]
'
);
const
findNameGroup
=
()
=>
wrapper
.
find
(
'
[data-testid="name-input-group"]
'
);
...
@@ -65,6 +69,12 @@ describe('SharedForm', () => {
...
@@ -65,6 +69,12 @@ describe('SharedForm', () => {
expect
(
findNameGroup
().
text
()).
toContain
(
'
Use :: to create a scoped set (eg. SOX::AWS)
'
);
expect
(
findNameGroup
().
text
()).
toContain
(
'
Use :: to create a scoped set (eg. SOX::AWS)
'
);
});
});
it
(
'
sets the submit button text from the property
'
,
()
=>
{
wrapper
=
createComponent
();
expect
(
findSubmitBtn
().
text
()).
toBe
(
defaultPropsData
.
submitButtonText
);
});
it
.
each
([
true
,
false
])(
it
.
each
([
true
,
false
])(
'
renders the pipeline configuration correctly when enabled is %s
'
,
'
renders the pipeline configuration correctly when enabled is %s
'
,
(
enabled
)
=>
{
(
enabled
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment