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
30151395
Commit
30151395
authored
Dec 16, 2021
by
Jannik Lehmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor license_compliance to use provide/inject for static values
parent
8f626a45
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
29 deletions
+15
-29
ee/app/assets/javascripts/license_compliance/components/app.vue
.../assets/javascripts/license_compliance/components/app.vue
+1
-14
ee/app/assets/javascripts/license_compliance/index.js
ee/app/assets/javascripts/license_compliance/index.js
+8
-11
ee/spec/frontend/license_compliance/components/app_spec.js
ee/spec/frontend/license_compliance/components/app_spec.js
+6
-4
No files found.
ee/app/assets/javascripts/license_compliance/components/app.vue
View file @
30151395
...
...
@@ -36,20 +36,7 @@ export default {
LicenseManagement
,
},
mixins
:
[
glFeatureFlagsMixin
()],
props
:
{
emptyStateSvgPath
:
{
type
:
String
,
required
:
true
,
},
sbomSurveySvgPath
:
{
type
:
String
,
required
:
true
,
},
documentationPath
:
{
type
:
String
,
required
:
true
,
},
},
inject
:
[
'
sbomSurveySvgPath
'
,
'
emptyStateSvgPath
'
,
'
documentationPath
'
],
data
()
{
return
{
tabIndex
:
this
.
activeTabIndex
(),
...
...
ee/app/assets/javascripts/license_compliance/index.js
View file @
30151395
...
...
@@ -7,8 +7,6 @@ export default () => {
const
el
=
document
.
querySelector
(
'
#js-licenses-app
'
);
const
{
projectLicensesEndpoint
,
emptyStateSvgPath
,
documentationPath
,
readLicensePoliciesEndpoint
,
writeLicensePoliciesEndpoint
,
projectId
,
...
...
@@ -18,7 +16,6 @@ export default () => {
approvalsDocumentationPath
,
lockedApprovalsRuleName
,
softwareLicenses
,
sbomSurveySvgPath
,
}
=
el
.
dataset
;
const
storeSettings
=
{
...
...
@@ -31,6 +28,12 @@ export default () => {
};
const
store
=
createStore
(
storeSettings
);
const
provide
=
{
sbomSurveySvgPath
:
el
.
dataset
.
sbomSurveySvgPath
,
emptyStateSvgPath
:
el
.
dataset
.
emptyStateSvgPath
,
documentationPath
:
el
.
dataset
.
documentationPath
,
};
store
.
dispatch
(
'
licenseManagement/setIsAdmin
'
,
Boolean
(
writeLicensePoliciesEndpoint
));
store
.
dispatch
(
'
licenseManagement/setAPISettings
'
,
{
apiUrlManageLicenses
:
readLicensePoliciesEndpoint
,
...
...
@@ -45,15 +48,9 @@ export default () => {
components
:
{
LicenseComplianceApp
,
},
provide
:
()
=>
provide
,
render
(
createElement
)
{
return
createElement
(
LicenseComplianceApp
,
{
// none of these can be injected.
props
:
{
sbomSurveySvgPath
,
emptyStateSvgPath
,
documentationPath
,
},
});
return
createElement
(
LicenseComplianceApp
);
},
});
};
ee/spec/frontend/license_compliance/components/app_spec.js
View file @
30151395
...
...
@@ -74,15 +74,17 @@ const createComponent = ({ state, props, options }) => {
wrapper
=
mountFunc
(
LicenseComplianceApp
,
{
propsData
:
{
emptyStateSvgPath
,
documentationPath
,
sbomSurveySvgPath
,
readLicensePoliciesEndpoint
,
...
props
,
},
...
options
,
store
:
fakeStore
,
stubs
:
{
transition
:
stubTransition
()
},
provide
:
{
sbomSurveySvgPath
,
emptyStateSvgPath
,
documentationPath
,
},
});
};
...
...
@@ -190,7 +192,7 @@ describe('Project Licenses', () => {
it
(
'
renders the SbomBannercomponent with the right props
'
,
()
=>
{
const
sbomBanner
=
findSbomBanner
();
expect
(
sbomBanner
.
exists
()).
toBe
(
true
);
expect
(
sbomBanner
.
props
().
sbomSurveySvgPath
).
toEqual
(
wrapper
.
props
()
.
sbomSurveySvgPath
);
expect
(
sbomBanner
.
props
().
sbomSurveySvgPath
).
toEqual
(
wrapper
.
vm
.
sbomSurveySvgPath
);
});
it
(
'
renders a "Detected in project" tab and a "Policies" tab
'
,
()
=>
{
...
...
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