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
e265df3d
Commit
e265df3d
authored
5 years ago
by
mo khan
Committed by
Kushal Pandya
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display correct approval status icon next to license
parent
3a13378c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
6 deletions
+40
-6
ee/app/assets/javascripts/vue_shared/license_management/store/utils.js
.../javascripts/vue_shared/license_management/store/utils.js
+10
-6
ee/changelogs/unreleased/7968-case-insensitive-diff.yml
ee/changelogs/unreleased/7968-case-insensitive-diff.yml
+5
-0
ee/spec/javascripts/license_management/store/utils_spec.js
ee/spec/javascripts/license_management/store/utils_spec.js
+25
-0
No files found.
ee/app/assets/javascripts/vue_shared/license_management/store/utils.js
View file @
e265df3d
...
...
@@ -2,6 +2,7 @@ import { n__, sprintf } from '~/locale';
import
{
STATUS_FAILED
,
STATUS_NEUTRAL
,
STATUS_SUCCESS
}
from
'
~/reports/constants
'
;
import
{
LICENSE_APPROVAL_STATUS
}
from
'
ee/vue_shared/license_management/constants
'
;
const
toLowerCase
=
name
=>
name
.
toLowerCase
();
/**
*
* Converts the snake case in license objects to camel case
...
...
@@ -32,8 +33,8 @@ export const normalizeLicense = license => {
*
*/
export
const
byLicenseNameComparator
=
(
a
,
b
)
=>
{
const
x
=
(
a
.
name
||
''
).
toLowerCase
(
);
const
y
=
(
b
.
name
||
''
).
toLowerCase
(
);
const
x
=
toLowerCase
(
a
.
name
||
''
);
const
y
=
toLowerCase
(
b
.
name
||
''
);
if
(
x
===
y
)
{
return
0
;
}
...
...
@@ -49,11 +50,14 @@ export const getIssueStatusFromLicenseStatus = approvalStatus => {
return
STATUS_NEUTRAL
;
};
const
caseInsensitiveMatch
=
(
name
,
otherName
)
=>
toLowerCase
(
name
)
===
toLowerCase
(
otherName
);
const
getLicenseStatusByName
=
(
managedLicenses
=
[],
licenseName
)
=>
managedLicenses
.
find
(
license
=>
license
.
name
===
licenseName
)
||
{};
managedLicenses
.
find
(
license
=>
caseInsensitiveMatch
(
license
.
name
,
licenseName
)
)
||
{};
const
getDependenciesByLicenseName
=
(
dependencies
=
[],
licenseName
)
=>
dependencies
.
filter
(
dependencyItem
=>
dependencyItem
.
license
.
name
===
licenseName
);
dependencies
.
filter
(
dependencyItem
=>
caseInsensitiveMatch
(
dependencyItem
.
license
.
name
,
licenseName
),
);
/**
*
...
...
@@ -89,8 +93,8 @@ export const parseLicenseReportMetrics = (headMetrics, baseMetrics, managedLicen
if
(
!
headLicenses
.
length
&&
!
headDependencies
.
length
)
return
[];
const
knownLicenses
=
baseLicenses
.
map
(
license
=>
license
.
name
.
toLowerCase
(
));
const
identityMap
=
license
=>
knownLicenses
.
includes
(
license
.
name
.
toLowerCase
(
));
const
knownLicenses
=
baseLicenses
.
map
(
license
=>
toLowerCase
(
license
.
name
));
const
identityMap
=
license
=>
knownLicenses
.
includes
(
toLowerCase
(
license
.
name
));
const
mapper
=
license
=>
{
const
{
name
,
count
}
=
license
;
const
{
id
,
approvalStatus
}
=
getLicenseStatusByName
(
managedLicenseList
,
name
);
...
...
This diff is collapsed.
Click to expand it.
ee/changelogs/unreleased/7968-case-insensitive-diff.yml
0 → 100644
View file @
e265df3d
---
title
:
Display appropriate approval status icon next to license
merge_request
:
17613
author
:
type
:
fixed
This diff is collapsed.
Click to expand it.
ee/spec/javascripts/license_management/store/utils_spec.js
View file @
e265df3d
...
...
@@ -69,6 +69,31 @@ describe('utils', () => {
expect
(
result
.
length
).
toBe
(
0
);
});
it
(
'
applies the correct approval status
'
,
()
=>
{
const
policies
=
[{
id
:
1
,
name
:
'
LGPL
'
,
approvalStatus
:
'
blacklisted
'
}];
const
dependency
=
{
license
:
{
name
:
'
lgpl
'
,
url
:
'
http://example.org
'
},
dependency
:
{
name
:
'
geoip
'
},
};
const
headReport
=
{
licenses
:
[{
count
:
1
,
name
:
'
BSD
'
},
{
count
:
1
,
name
:
'
lgpl
'
}],
dependencies
:
[
dependency
],
};
const
baseReport
=
{
licenses
:
[{
count
:
1
,
name
:
'
bsd
'
}],
dependencies
:
[]
};
const
result
=
parseLicenseReportMetrics
(
headReport
,
baseReport
,
policies
);
expect
(
result
.
length
).
toBe
(
1
);
expect
(
result
[
0
]).
toEqual
(
jasmine
.
objectContaining
({
approvalStatus
:
'
blacklisted
'
,
count
:
1
,
status
:
'
failed
'
,
name
:
'
lgpl
'
,
packages
:
[{
name
:
'
geoip
'
}],
}),
);
});
});
describe
(
'
byLicenseNameComparator
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
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