Skip to content

Commit 94302db

Browse files
committed
checkbox in UI
Signed-off-by: Vedansh Saini <[email protected]>
1 parent bafecf4 commit 94302db

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

src/popup.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@ <h4>Your Github Token</h4>
138138
</button>
139139
</div>
140140
<input id="githubToken" type="password" class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2 pr-10" placeholder="Required for making authenticated requests">
141+
142+
<div class="col s12 my-4">
143+
<div class="flex items-center gap-2">
144+
<input type="checkbox" id="showCommits" checked class="form-checkbox h-4 w-4 text-blue-600">
145+
<label id="showCommitsLabel" for="showCommits" class="text-gray-700 font-medium text-sm">Show last 5 commits in Open PRs</label> <span class="tooltip-container">
146+
<i class="fa fa-question-circle question-icon"></i>
147+
<span class="tooltip-bubble">
148+
Github Token required.
149+
</span>
150+
</span>
151+
</div>
152+
</div>
153+
141154
<p class="text-sm font-medium">Enter cache TTL <span class="text-sm font-normal">(in minutes)</span>
142155
<span class="tooltip-container">
143156
<i class="fa fa-question-circle question-icon"></i>
@@ -148,6 +161,7 @@ <h4>Your Github Token</h4>
148161
</p>
149162
<input type="text" id="cacheInput" class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2" placeholder="Write Cache TTL in minutes (Default 10 minutes)">
150163
</div>
164+
151165
<div class="">
152166
<button id="refreshCache" class="w-full mt-3 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded flex items-center justify-center gap-2 transition-colors duration-200">
153167
<i class="fa fa-refresh"></i>

src/scripts/main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ let startingDateElement = document.getElementById('startingDate');
99
let endingDateElement = document.getElementById('endingDate');
1010
let showOpenLabelElement = document.getElementById('showOpenLabel');
1111
let userReasonElement = document.getElementById('userReason');
12+
let showCommitsElement = document.getElementById('showCommits');
1213

1314
function handleBodyOnLoad() {
1415
chrome.storage.local.get(
@@ -25,6 +26,7 @@ function handleBodyOnLoad() {
2526
'yesterdayContribution',
2627
'cacheInput',
2728
'githubToken',
29+
'showCommits',
2830
],
2931
(items) => {
3032
if (items.githubUsername) {
@@ -78,6 +80,12 @@ function handleBodyOnLoad() {
7880
yesterdayContributionElement.checked = true;
7981
handleYesterdayContributionChange();
8082
}
83+
if (items.showCommits){
84+
showCommitsElement.checked = items.showCommits;
85+
} else {
86+
showCommitsElement.checked = false;
87+
handleShowCommitsChange();
88+
}
8189
},
8290
);
8391
}
@@ -242,12 +250,18 @@ function handleUserReasonChange() {
242250
let value = userReasonElement.value;
243251
chrome.storage.local.set({ userReason: value });
244252
}
253+
254+
function handleShowCommitsChange() {
255+
let value = showCommitsElement.checked;
256+
chrome.storage.local.set({ showCommits: value });
257+
}
245258
enableToggleElement.addEventListener('change', handleEnableChange);
246259
githubUsernameElement.addEventListener('keyup', handleGithubUsernameChange);
247260
githubTokenElement.addEventListener('keyup', handleGithubTokenChange);
248261
cacheInputElement.addEventListener('keyup', handleCacheInputChange);
249262
projectNameElement.addEventListener('keyup', handleProjectNameChange);
250263
startingDateElement.addEventListener('change', handleStartingDateChange);
264+
showCommitsElement.addEventListener('change', handleShowCommitsChange);
251265
endingDateElement.addEventListener('change', handleEndingDateChange);
252266
lastWeekContributionElement.addEventListener('change', handleLastWeekContributionChange);
253267
yesterdayContributionElement.addEventListener('change', handleYesterdayContributionChange);

src/scripts/scrumHelper.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function allIncluded(outputTarget = 'email') {
2525
let prsReviewDataProcessed = false;
2626
let showOpenLabel = true;
2727
let showClosedLabel = true;
28+
let showCommits = false;
2829
let userReason = '';
2930

3031
let pr_merged_button =
@@ -54,7 +55,8 @@ function allIncluded(outputTarget = 'email') {
5455
'yesterdayContribution',
5556
'userReason',
5657
'githubCache',
57-
'cacheInput'
58+
'cacheInput',
59+
'showCommits',
5860
],
5961
(items) => {
6062
console.log("Storage items received:", items);
@@ -120,6 +122,11 @@ function allIncluded(outputTarget = 'email') {
120122
pr_merged_button = '';
121123
issue_closed_button = '';
122124
}
125+
if(items.showCommits !== undefined) {
126+
showCommits = items.showCommits;
127+
} else {
128+
showCommits = false; // Default value
129+
}
123130
if (items.userReason) {
124131
userReason = items.userReason;
125132
}
@@ -771,7 +778,7 @@ ${userReason}`;
771778
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a> ${pr_merged_button}</li>`;
772779
} else if (item.state === 'open') {
773780
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a> ${pr_unmerged_button}`;
774-
if (item._lastCommits && item._lastCommits.length) {
781+
if (showCommits && item._lastCommits && item._lastCommits.length) {
775782
item._lastCommits.forEach(commit => {
776783
li += `<li style="list-style: disc; margin: 0 0 0 20px; padding: 0; color: #666;"><span style="color:#2563eb;">${commit.messageHeadline}</span><span style="color:#666; font-size: 11px;"> (${commit.author?.user?.login || commit.author?.name || 'unknown'}, ${new Date(commit.committedDate).toLocaleString()})</span></li>`;
777784
});
@@ -902,6 +909,17 @@ ${userReason}`;
902909
}
903910

904911
async function forceGithubDataRefresh() {
912+
let showCommits = false;
913+
914+
await new Promise(resolve => {
915+
chrome.storage.local.get('showCommits', (result) => {
916+
if (result.showCommits !== undefined) {
917+
showCommits = result.showCommits;
918+
}
919+
resolve();
920+
});
921+
});
922+
905923
if(typeof githubCache !== 'undefined') {
906924
githubCache.data = null;
907925
githubCache.cacheKey = null;
@@ -915,6 +933,8 @@ async function forceGithubDataRefresh() {
915933
chrome.storage.local.remove('githubCache', resolve);
916934
});
917935

936+
chrome.storage.local.set({ showCommits: showCommits });
937+
918938
hasInjectedContent = false;
919939

920940
return {success: true};

0 commit comments

Comments
 (0)