Skip to content

Commit ff8baf2

Browse files
authored
API: use version_schema instead of single_version (#198)
The backend API response changed and `single_version` is deprecated now. Closes #195
1 parent 90b25c8 commit ff8baf2

10 files changed

+32
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
.direnv/
33
.envrc
44
.tool-versions
5+
/coverage/

dist/readthedocs-addons.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/readthedocs-addons.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/_/readthedocs-addons.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"programming_language": {
1515
"code": "words"
1616
},
17-
"single_version": false
17+
"versioning_scheme": "multiple_versions_with_translations"
1818
}
1919
},
2020
"versions": {

src/data-validation.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,15 @@ const addons_flyout = {
167167
properties: {
168168
current: {
169169
type: "object",
170-
required: ["slug", "single_version"],
170+
required: ["slug", "versioning_scheme"],
171171
properties: {
172172
slug: { type: "string" },
173-
single_version: { type: "boolean" },
173+
versioning_scheme: {
174+
enum: [
175+
"multiple_versions_with_translations",
176+
"single_version_without_translations",
177+
],
178+
},
174179
},
175180
},
176181
},
@@ -278,7 +283,12 @@ const addons_notifications = {
278283
type: "object",
279284
properties: {
280285
slug: { type: "string" },
281-
single_version: { type: "boolean" },
286+
versioning_scheme: {
287+
enum: [
288+
"multiple_versions_with_translations",
289+
"single_version_without_translations",
290+
],
291+
},
282292
// TODO: use ajv-formats URI type
283293
repository: {
284294
type: "object",

src/flyout.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ export class FlyoutElement extends LitElement {
6767

6868
renderHeader() {
6969
let version = nothing;
70-
if (!this.config.projects.current.single_version) {
70+
if (
71+
this.config.projects.current.versioning_scheme !==
72+
"single_version_without_translations"
73+
) {
7174
version = html`<span>v: ${this.config.versions.current.slug}</span>`;
7275
}
7376

@@ -177,7 +180,8 @@ export class FlyoutElement extends LitElement {
177180
renderVersions() {
178181
if (
179182
!this.config.addons.flyout.versions.length ||
180-
this.config.projects.current.single_version
183+
this.config.projects.current.versioning_scheme ===
184+
"single_version_without_translations"
181185
) {
182186
return nothing;
183187
}

src/notification.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export class NotificationElement extends LitElement {
6767

6868
if (
6969
config.addons.non_latest_version_warning.enabled &&
70-
!config.projects.current.single_version &&
70+
config.projects.current.versioning_scheme !==
71+
"single_version_without_translations" &&
7172
config.versions.current.type !== "external"
7273
) {
7374
this.calculateStableLatestVersionWarning();

tests/flyout.test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
projects: {
4848
current: {
4949
slug: "project",
50-
single_version: false,
50+
versioning_scheme: "multiple_versions_with_translations",
5151
},
5252
},
5353
versions: {

tests/flyout.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("Flyout addon", () => {
3131
projects: {
3232
current: {
3333
slug: "project",
34-
single_version: false,
34+
versioning_scheme: "multiple_versions_with_translations",
3535
},
3636
},
3737
versions: {
@@ -60,7 +60,7 @@ describe("Flyout addon", () => {
6060
projects: {
6161
current: {
6262
slug: "project",
63-
single_version: false,
63+
versioning_scheme: "multiple_versions_with_translations",
6464
},
6565
},
6666
versions: {

tests/notification.test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
projects: {
3232
current: {
3333
slug: "project",
34-
single_version: false,
34+
versioning_scheme: "multiple_versions_with_translations",
3535
repository: {
3636
url: "https://github.com/readthedocs/addons",
3737
},

0 commit comments

Comments
 (0)