Skip to content

Commit 4b0bfbc

Browse files
committed
release management api changelog
1 parent 123152e commit 4b0bfbc

6 files changed

Lines changed: 138 additions & 6 deletions

File tree

src/css/changelog.css

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,62 @@ aside.onebox .onebox-body h4 {
150150

151151
/* aside.ondebox -- end */
152152

153+
.rmcl {
154+
display: flex;
155+
flex-direction: column;
156+
gap: .5rem;
157+
margin-bottom: 2rem;
158+
}
159+
160+
.rmcl h3, .rmcl p {
161+
margin: 0;
162+
}
163+
164+
.rmcl-http-method-tag {
165+
background: #666;
166+
border-radius: 3px;
167+
padding: 0 10px;
168+
color: #fff;
169+
display: inline-block;
170+
font-size: 0.75rem;
171+
font-weight: bold;
172+
height: 20px;
173+
line-height: 20px;
174+
text-align: center;
175+
}
176+
.rmcl-http-method-tag.rmcl-http-method-get {
177+
background: #61AFFE;
178+
}
179+
.rmcl-http-method-tag.rmcl-http-method-post {
180+
background: #49CC90;
181+
}
182+
.rmcl-http-method-tag.rmcl-http-method-put {
183+
background: #FAA130;
184+
}
185+
.rmcl-http-method-tag.rmcl-http-method-delete {
186+
background: #F93E3E;
187+
}
188+
.rmcl-http-method-tag.rmcl-http-method-patch {
189+
background: #50E3C2;
190+
}
191+
192+
.rmcl-api-endpoint-url {
193+
font-family: IBM Plex Mono, monospace;
194+
font-size: 1rem;
195+
color: #666;
196+
font-weight: bold;
197+
}
198+
.rmcl-inline-code {
199+
font-family: IBM Plex Mono, monospace;
200+
font-size: .9rem;
201+
color: #666;
202+
background: var(--neutral-95);
203+
border-radius: 3px;
204+
padding: 0 5px;
205+
display: inline-block;
206+
line-height: 1.5;
207+
}
208+
153209
/* skeleton loading */
154210

155211
.changelog-loading {

src/js/changelog-topic.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,17 @@ changelogService.loadTopic(topicSlugId).then((topic) => {
5555
lightboxWrapper.replaceWith(figure);
5656
});
5757

58-
document.getElementById('changelog-topic-leave-feedback-button').href =
59-
`https://discuss.bitrise.io/t/${topic.slug}/${topic.id}`;
60-
document.getElementById('changelog-topic-leave-feedback-button').target = '_blank';
58+
if (topic.id === 0) {
59+
document.querySelector('.changelog-topic-footer > div').textContent = 'Read more on Release Management API';
60+
document.getElementById('changelog-topic-leave-feedback-button').href =
61+
'https://api.bitrise.io/release-management/api-docs/index.html';
62+
document.getElementById('changelog-topic-leave-feedback-button').target = '_blank';
63+
document.getElementById('changelog-topic-leave-feedback-button').textContent = 'API Documentation';
64+
} else {
65+
document.getElementById('changelog-topic-leave-feedback-button').href =
66+
`https://discuss.bitrise.io/t/${topic.slug}/${topic.id}`;
67+
document.getElementById('changelog-topic-leave-feedback-button').target = '_blank';
68+
}
6169
});
6270

6371
if (import.meta.webpackHot) {

src/js/changelog/ChangelogService.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,24 @@ class ChangelogService {
2727
* @returns {Promise<ChangelogTopic>}
2828
*/
2929
async loadTopic(topicSlugId) {
30+
if (topicSlugId.match(/rm-\d+/)) {
31+
const url = `${this.apiBase}/changelog.json`;
32+
const response = await fetch(url);
33+
const json = await response.json();
34+
const topicJson = json.topic_list.topics.filter((topic) => topic.id === 0 && topic.slug === topicSlugId);
35+
if (topicJson.length > 0) {
36+
return new ChangelogTopic(topicJson[0]);
37+
}
38+
}
39+
3040
const url = `${this.apiBase}/changelog/api/t/${topicSlugId}.json`;
3141
const response = await fetch(url);
3242
const json = await response.json();
33-
return new ChangelogTopic(json);
43+
if (!json.errors || json.errors.length === 0) {
44+
return new ChangelogTopic(json);
45+
}
46+
47+
throw new Error(`Topic not found: ${topicSlugId}`);
3448
}
3549
}
3650

src/js/changelog/ChangelogTagFactory.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ class ChangelogTagFactory {
5353
listItemTag.innerHTML = 'Step update';
5454
return listItemTag;
5555
}
56+
if (tags.includes('api-update')) {
57+
const listItemTag = this.tagBlueTemplate.cloneNode(true);
58+
listItemTag.innerHTML = 'API update';
59+
return listItemTag;
60+
}
5661
if (tags.includes('deprecation')) {
5762
const listItemTag = this.tagYelowTemplate.cloneNode(true);
5863
listItemTag.innerHTML = 'Deprecation';

src/js/changelog/ChangelogTopic.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
* created_at: string,
1010
* pinned: boolean,
1111
* tags: string[],
12-
* post_stream: {
12+
* post_stream?: {
1313
* posts: DiscoursePost[]
1414
* }
15+
* changelog?: RMAPIChangelog[]
1516
* }} DiscourseTopic
1617
*/
1718

@@ -22,6 +23,19 @@
2223
* }} DiscoursePost
2324
*/
2425

26+
/**
27+
* @typedef {{
28+
* id: string,
29+
* level: number,
30+
* operation: string,
31+
* operationId: string,
32+
* path: string,
33+
* section: string,
34+
* source: string,
35+
* text: string
36+
* }} RMAPIChangelog
37+
*/
38+
2539
class ChangelogTopic {
2640
/** @param {DiscourseTopic} data */
2741
constructor(data) {
@@ -59,6 +73,9 @@ class ChangelogTopic {
5973

6074
/** @returns {string} */
6175
get webflowUrl() {
76+
if (this.id === 0) {
77+
return `/changelog/${this.slug}`;
78+
}
6279
return `/changelog/${this.slug}/${this.id}`;
6380
}
6481

@@ -77,13 +94,29 @@ class ChangelogTopic {
7794

7895
/** @returns {string} */
7996
get content() {
97+
if (this.data.slug.match(/rm-\d+/) && this.data.changelog) {
98+
return this.data.changelog
99+
.map(
100+
(changelog) => `
101+
<div class='rmcl'>
102+
<h3>${changelog.operationId}</h3>
103+
<div>
104+
<span class="rmcl-http-method-tag rmcl-http-method-${changelog.operation.toLocaleLowerCase()}">${changelog.operation}</span>
105+
<span class="rmcl-api-endpoint-url">${changelog.path}</span>
106+
</div>
107+
<p>${changelog.text.replaceAll(/'([^']+)'/g, '<span class="rmcl-inline-code">$1</span>')}</p>
108+
</div>
109+
`,
110+
)
111+
.join('');
112+
}
80113
return this.posts.length ? this.posts[0].cooked : '';
81114
}
82115

83116
/** @returns {ChangelogTag[]} */
84117
get tags() {
85118
return (this.data.tags || []).filter((tag) =>
86-
['new-feature', 'feature-update', 'step-update', 'deprecation'].includes(tag),
119+
['new-feature', 'feature-update', 'step-update', 'deprecation', 'api-update'].includes(tag),
87120
);
88121
}
89122
}

src/js/changelog/build.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ async function buildChangelog() {
9595
const changelogTopics = await fetchCategory('/c/changelog/6.json');
9696
changelogTopics.forEach((topic) => topics.push(topic));
9797

98+
const releaseManagementPublicApiChangelog = await fetch(
99+
'https://storage.googleapis.com/bitrise-release-management-public-api-docs/changelog.json',
100+
);
101+
(await releaseManagementPublicApiChangelog.json()).forEach((changelogLine) => {
102+
const createdAt = Object.keys(changelogLine)[0];
103+
topics.push({
104+
id: 0,
105+
title: `Release Management Public API Update`,
106+
fancy_title: `Release Management Public API Update`,
107+
slug: `rm-${createdAt.replaceAll(/[- :]/g, '')}`,
108+
created_at: createdAt.replace(/(\d{2})-(\d{2})-(\d{4})(.*)/, '$3-$2-$1$4'),
109+
tags: ['api-update'],
110+
changelog: changelogLine[createdAt],
111+
});
112+
});
113+
98114
topics.sort((a, b) => {
99115
const aDate = new Date(a.created_at);
100116
const bDate = new Date(b.created_at);

0 commit comments

Comments
 (0)