Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow links only for social badges, affects [GitHubMilestone Dependabot] #6159

Merged
merged 5 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ There are three places to get help:
used by developers or which are widely used by developers.
- The left-hand side of a badge should not advertise. It should be a lowercase _noun_
succinctly describing the meaning of the right-hand side.
- Except for badges using the `social` style, logos should be _turned off by
- Except for badges using the `social` style, logos and links should be _turned off by
default_.
- Badges should not obtain data from undocumented or reverse-engineered API endpoints.
- Badges should not obtain data by scraping web pages - these are likely to break frequently.
Expand Down
6 changes: 4 additions & 2 deletions frontend/components/usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,10 @@ export default function Usage({ baseUrl }: { baseUrl: string }): JSX.Element {
<QueryParam
documentation={
<span>
Specify what clicking on the left/right of a badge should do
(esp. for social badge style)
Specify what clicking on the left/right of a badge should do.
Note that this only works when integrating your badge in an
<StyledCode>&lt;object&gt;</StyledCode> HTML tag, but not an
<StyledCode>&lt;img&gt;</StyledCode> tag or a markup language.
</span>
}
key="link"
Expand Down
9 changes: 0 additions & 9 deletions services/dependabot/dependabot.service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const url = require('url')
const Joi = require('joi')
const { BaseJsonService } = require('..')

Expand Down Expand Up @@ -46,19 +45,11 @@ module.exports = class DependabotSemverCompatibility extends BaseJsonService {
})
}

_getLink({ packageManager, dependencyName }) {
const qs = new url.URLSearchParams(
this._getQuery({ packageManager, dependencyName })
)
return `https://dependabot.com/compatibility-score.html?${qs.toString()}`
}

async handle({ packageManager, dependencyName }) {
const json = await this.fetch({ packageManager, dependencyName })
return {
color: json.colour,
message: json.status,
link: this._getLink({ packageManager, dependencyName }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to keep the _getLink() function itself? Seems like we could remove it..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, had missed it, good catch.

}
}
}
13 changes: 4 additions & 9 deletions services/dependabot/dependabot.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
const { isIntegerPercentage } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())

t.create('semver stability (valid)')
.get('/bundler/puma.json')
.expectBadge({
label: 'semver stability',
message: isIntegerPercentage,
link: [
'https://dependabot.com/compatibility-score.html?package-manager=bundler&dependency-name=puma&version-scheme=semver',
],
})
t.create('semver stability (valid)').get('/bundler/puma.json').expectBadge({
label: 'semver stability',
message: isIntegerPercentage,
})

t.create('semver stability (invalid error)')
.get('/invalid-manager/puma.json')
Expand Down
1 change: 0 additions & 1 deletion services/github/github-milestone-detail.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ module.exports = class GithubMilestoneDetail extends GithubAuthV3Service {
label: `${milestone.title} ${label}`,
message: metric(milestoneMetric),
color,
link: [`https://github.com/${user}/${repo}/milestone/${number}`],
}
}

Expand Down
5 changes: 0 additions & 5 deletions services/github/github-milestone-detail.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,34 @@ t.create('Milestone Open Issues')
.expectBadge({
label: 'openWithOneOpenIssue open issues',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/1`],
})

t.create('Milestone Closed Issues')
.get('/issues-closed/MacroPower/milestone-test/3.json')
.expectBadge({
label: 'closedWithOneClosedIssue closed issues',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/3`],
})

t.create('Milestone Total Issues')
.get('/issues-total/MacroPower/milestone-test/2.json')
.expectBadge({
label: 'openWithOneOpenOneClosedIssue issues',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/2`],
})

t.create('Milestone Progress')
.get('/progress/MacroPower/milestone-test/2.json')
.expectBadge({
label: 'openWithOneOpenOneClosedIssue',
message: isMetricOverMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/2`],
})

t.create('Milestone Progress (Percent)')
.get('/progress-percent/MacroPower/milestone-test/2.json')
.expectBadge({
label: 'openWithOneOpenOneClosedIssue',
message: isIntegerPercentage,
link: [`https://github.com/MacroPower/milestone-test/milestone/2`],
})

t.create('Milestones (repo or milestone not found)')
Expand Down
1 change: 0 additions & 1 deletion services/github/github-milestone.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ module.exports = class GithubMilestone extends GithubAuthV3Service {
label: `${label} milestones`,
message: metric(milestoneLength),
color,
link: [`https://github.com/${user}/${repo}/milestones`],
}
}

Expand Down
3 changes: 0 additions & 3 deletions services/github/github-milestone.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@ t.create('All Milestones')
.expectBadge({
label: 'milestones',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestones`],
})

t.create('Open Milestones')
.get('/open/MacroPower/milestone-test.json')
.expectBadge({
label: 'active milestones',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestones`],
})

t.create('Closed Milestones')
.get('/closed/MacroPower/milestone-test.json')
.expectBadge({
label: 'completed milestones',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestones`],
})

t.create('Milestones (repo not found)')
Expand Down
2 changes: 1 addition & 1 deletion spec/SPECIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This document specifies the visual design of Shields badges.
- **semantic**: the purpose of the information provided by a badge should be self-evident
- **non-promotional**: badges should refrain from advertising a service but instead provide value through the badge's information instead
- **concise**: one descriptive word on the left (the key), one piece of data on the right (the value)
- **hyperlinked**: badges can link to a third-party website providing more information, either related to the metadata provided by the badge or about the project the badge was used for (e.g. an open source library)
- **hyperlinked**: badges with style 'social' can link to a third-party website providing more information, either related to the metadata provided by the badge or about the project the badge was used for (e.g. an open source library)

### Example

Expand Down