Skip to content

Commit

Permalink
fix(plugins): snyk issue fix (#174)
Browse files Browse the repository at this point in the history
snyk issue fix

ARC-149

## Description

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Intermediate change (work in progress)

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration

- [ ] Test A
- [ ] Test B

## Checklist:

- [ ] Performed a self-review of my own code
- [ ] npm test passes on your machine
- [ ] New tests added or existing tests modified to cover all changes
- [ ] Code conforms with the style guide
- [ ] API Documentation in code was updated
- [ ] Any dependent changes have been merged and published in downstream
modules
  • Loading branch information
sadarunnisa-sf authored Jul 3, 2024
1 parent 4fe1c7a commit 6104a28
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions patches/backstage-plugin-snyk+2.0.1.patch
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,44 @@ index 88d2fdb..96c6da8 100644
}
//# sourceMappingURL=index.js.map
diff --git a/node_modules/backstage-plugin-snyk/dist/components/SnykEntityComponent/SnykEntityComponent.js b/node_modules/backstage-plugin-snyk/dist/components/SnykEntityComponent/SnykEntityComponent.js
index 82bd75f..8a0f7be 100644
index 82bd75f..718ee60 100644
--- a/node_modules/backstage-plugin-snyk/dist/components/SnykEntityComponent/SnykEntityComponent.js
+++ b/node_modules/backstage-plugin-snyk/dist/components/SnykEntityComponent/SnykEntityComponent.js
@@ -63,9 +63,10 @@ export const SnykEntityComponent = () => {
const orgId = ((_c = entity === null || entity === void 0 ? void 0 : entity.metadata.annotations) === null || _c === void 0 ? void 0 : _c[SNYK_ANNOTATION_ORG]) || "null";
@@ -60,19 +60,26 @@ export const SnykEntityComponent = () => {
}
const tabs = [];
const snykApi = useApi(snykApiRef);
- const orgId = ((_c = entity === null || entity === void 0 ? void 0 : entity.metadata.annotations) === null || _c === void 0 ? void 0 : _c[SNYK_ANNOTATION_ORG]) || "null";
+ let orgId = ((_c = entity === null || entity === void 0 ? void 0 : entity.metadata.annotations) === null || _c === void 0 ? void 0 : _c[SNYK_ANNOTATION_ORG]) || "null";
+
const { value, loading, error } = useAsync(async () => {
var _a, _b;
+ const orgID = await snykApi.GetSnykOrgId();
const fullProjectList = await snykApi.ProjectsList(orgId, ((_a = entity.metadata.annotations) === null || _a === void 0 ? void 0 : _a[SNYK_ANNOTATION_TARGETNAME]) || ((_b = entity.metadata.annotations) === null || _b === void 0 ? void 0 : _b[SNYK_ANNOTATION_TARGETID]) || '');
const orgSlug = await snykApi.GetOrgSlug(orgId);
- var _a, _b;
- const fullProjectList = await snykApi.ProjectsList(orgId, ((_a = entity.metadata.annotations) === null || _a === void 0 ? void 0 : _a[SNYK_ANNOTATION_TARGETNAME]) || ((_b = entity.metadata.annotations) === null || _b === void 0 ? void 0 : _b[SNYK_ANNOTATION_TARGETID]) || '');
- const orgSlug = await snykApi.GetOrgSlug(orgId);
- return { fullProjectList, orgSlug };
+ return { orgID, fullProjectList, orgSlug };
});
- });
+ var _a, _b;
+ let aggregatedIssuesCount = {
+ critical: 0,
+ high: 0,
+ medium: 0,
+ low: 0,
+ };
+ const orgID = await snykApi.GetSnykOrgId();
+ const fullProjectList = await snykApi.ProjectsList(orgID, ((_a = entity.metadata.annotations) === null || _a === void 0 ? void 0 : _a[SNYK_ANNOTATION_TARGETNAME]) || ((_b = entity.metadata.annotations) === null || _b === void 0 ? void 0 : _b[SNYK_ANNOTATION_TARGETID]) || '');
+ const orgSlug = await snykApi.GetOrgSlug(orgID);
+ return { orgID, fullProjectList, orgSlug };
+ });
if (loading) {
return (React.createElement(Content, null,
@@ -82,7 +83,7 @@ export const SnykEntityComponent = () => {
React.createElement(Progress, null)));
}
else if (error) {
- console.log(error);
return React.createElement(Alert, { severity: "error" }, error.message);
}
const projectList = value === null || value === void 0 ? void 0 : value.fullProjectList;
@@ -82,7 +89,7 @@ export const SnykEntityComponent = () => {
tabs.push({
name: utils.extractTargetShortname(project.attributes.name || "unknown"),
icon: getIconForProjectType(project.attributes.origin || ""),
Expand Down

0 comments on commit 6104a28

Please sign in to comment.