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
712f0771
Commit
712f0771
authored
Oct 17, 2019
by
mo khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split V2Report into a separate file
parent
18f6a39c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
59 deletions
+65
-59
ee/app/assets/javascripts/vue_shared/license_management/report_mapper.js
...avascripts/vue_shared/license_management/report_mapper.js
+1
-59
ee/app/assets/javascripts/vue_shared/license_management/v2_report.js
...ts/javascripts/vue_shared/license_management/v2_report.js
+64
-0
No files found.
ee/app/assets/javascripts/vue_shared/license_management/report_mapper.js
View file @
712f0771
import
{
byLicenseNameComparator
}
from
'
./store/utils
'
;
import
V2Report
from
'
./v2_report
'
;
class
V2Report
{
constructor
(
report
)
{
this
.
report
=
report
;
this
.
licenseMap
=
V2Report
.
createLicenseMap
(
report
.
licenses
);
this
.
licenses
=
report
.
licenses
.
sort
(
byLicenseNameComparator
).
map
(
V2Report
.
mapFromLicense
);
}
toV1Schema
()
{
return
{
licenses
:
this
.
licenses
,
dependencies
:
this
.
report
.
dependencies
.
map
(
v2Dependency
=>
this
.
mapFromDependency
(
v2Dependency
),
),
};
}
combine
(
licenses
,
visitor
)
{
const
reducer
=
(
memo
,
licenseId
)
=>
{
const
license
=
this
.
licenseMap
[
licenseId
];
visitor
(
license
);
if
(
memo
)
return
{
name
:
`
${
memo
.
name
}
,
${
license
.
name
}
`
,
url
:
''
};
return
{
name
:
license
.
name
,
url
:
license
.
url
};
};
return
licenses
.
reduce
(
reducer
,
null
);
}
incrementCountFor
(
licenseName
)
{
const
matchingLicense
=
this
.
licenses
.
find
(
license
=>
license
.
name
===
licenseName
);
if
(
matchingLicense
)
matchingLicense
.
count
+=
1
;
}
mapFromDependency
(
dependency
)
{
const
combinedLicense
=
this
.
combine
(
dependency
.
licenses
,
license
=>
{
this
.
incrementCountFor
(
license
.
name
);
});
return
{
license
:
combinedLicense
,
dependency
:
{
name
:
dependency
.
name
,
url
:
dependency
.
url
,
description
:
dependency
.
description
,
},
};
}
static
mapFromLicense
(
license
)
{
return
{
name
:
license
.
name
,
count
:
0
};
}
static
createLicenseMap
(
licenses
)
{
const
identityMap
=
{};
licenses
.
forEach
(
item
=>
(
identityMap
[
item
.
id
]
=
{
name
:
item
.
name
,
url
:
item
.
url
}));
return
identityMap
;
}
}
const
DEFAULT_VERSION
=
'
1
'
;
const
DEFAULT_VERSION
=
'
1
'
;
...
...
ee/app/assets/javascripts/vue_shared/license_management/v2_report.js
0 → 100644
View file @
712f0771
import
{
byLicenseNameComparator
}
from
'
./store/utils
'
;
export
default
class
V2Report
{
constructor
(
report
)
{
this
.
report
=
report
;
this
.
licenseMap
=
V2Report
.
createLicenseMap
(
report
.
licenses
);
this
.
licenses
=
report
.
licenses
.
sort
(
byLicenseNameComparator
).
map
(
V2Report
.
mapFromLicense
);
}
toV1Schema
()
{
return
{
licenses
:
this
.
licenses
,
dependencies
:
this
.
report
.
dependencies
.
map
(
v2Dependency
=>
this
.
mapFromDependency
(
v2Dependency
),
),
};
}
combine
(
licenses
,
visitor
)
{
const
reducer
=
(
memo
,
licenseId
)
=>
{
const
license
=
this
.
licenseMap
[
licenseId
];
visitor
(
license
);
if
(
memo
)
return
{
name
:
`
${
memo
.
name
}
,
${
license
.
name
}
`
,
url
:
''
};
return
{
name
:
license
.
name
,
url
:
license
.
url
};
};
return
licenses
.
reduce
(
reducer
,
null
);
}
incrementCountFor
(
licenseName
)
{
const
matchingLicense
=
this
.
licenses
.
find
(
license
=>
license
.
name
===
licenseName
);
if
(
matchingLicense
)
matchingLicense
.
count
+=
1
;
}
mapFromDependency
(
dependency
)
{
const
combinedLicense
=
this
.
combine
(
dependency
.
licenses
,
license
=>
{
this
.
incrementCountFor
(
license
.
name
);
});
return
{
license
:
combinedLicense
,
dependency
:
{
name
:
dependency
.
name
,
url
:
dependency
.
url
,
description
:
dependency
.
description
,
},
};
}
static
mapFromLicense
(
license
)
{
return
{
name
:
license
.
name
,
count
:
0
};
}
static
createLicenseMap
(
licenses
)
{
const
identityMap
=
{};
licenses
.
forEach
(
item
=>
{
identityMap
[
item
.
id
]
=
{
name
:
item
.
name
,
url
:
item
.
url
,
};
});
return
identityMap
;
}
}
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