Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/manifests/chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"scripts/jquery-3.2.1.min.js",
"scripts/emailClientAdapter.js",
"scripts/gitlabHelper.js",
"scripts/utils.js",
"scripts/scrumHelper.js"
]
}
Expand Down
1 change: 1 addition & 0 deletions src/manifests/firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"scripts/jquery-3.2.1.min.js",
"scripts/emailClientAdapter.js",
"scripts/gitlabHelper.js",
"scripts/utils.js",
"scripts/scrumHelper.js"
]
}
Expand Down
1 change: 1 addition & 0 deletions src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ <h4 class="font-semibold text-xl" data-i18n="noteTitle">Note:</h4>
<script src="scripts/jquery-3.2.1.min.js"></script>
<script type="text/javascript" type="text/javascript" src="materialize/js/materialize.min.js"></script>
<script src="scripts/emailClientAdapter.js"></script>
<script src="scripts/utils.js"></script>
<script src="scripts/main.js"></script>
<script src="scripts/gitlabHelper.js"></script>
<script src="scripts/scrumHelper.js"></script>
Expand Down
16 changes: 2 additions & 14 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function handleYesterdayContributionChange() {
if (value) {
startingDateElement.readOnly = true;
endingDateElement.readOnly = true;
endingDateElement.value = getToday();
startingDateElement.value = getYesterday();
endingDateElement.value = window.scrumUtils.getTodayDateString();
startingDateElement.value = window.scrumUtils.getYesterdayDateString();
handleEndingDateChange();
handleStartingDateChange();
labelElement.classList.add('selectedLabel');
Expand All @@ -132,18 +132,6 @@ function handleYesterdayContributionChange() {
}
browser.storage.local.set({ yesterdayContribution: value });
}

function getYesterday() {
const today = new Date();
const yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
return yesterday.toISOString().split('T')[0];
}
function getToday() {
const today = new Date();
return today.toISOString().split('T')[0];
}

function handlePlatformUsernameChange() {
const value = platformUsernameElement.value;
browser.storage.local.get(['platform']).then((result) => {
Expand Down
92 changes: 43 additions & 49 deletions src/scripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@ function setupButtonTooltips() {
}
}

function getToday() {
const today = new Date();
return today.toISOString().split('T')[0];
}

function getYesterday() {
const today = new Date();
const yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
return yesterday.toISOString().split('T')[0];
}

function applyI18n() {
document.querySelectorAll('[data-i18n]').forEach((el) => {
const key = el.getAttribute('data-i18n');
Expand Down Expand Up @@ -344,12 +332,8 @@ document.addEventListener('DOMContentLoaded', () => {
}

githubTokenInput.addEventListener('input', checkTokenForFilter);
githubTokenInput.addEventListener('input', () =>
checkTokenForShowCommits({ persistState: false }),
);
githubTokenInput.addEventListener('input', () =>
checkTokenForMergedPRs({ persistState: false }),
);
githubTokenInput.addEventListener('input', () => checkTokenForShowCommits({ persistState: false }));
githubTokenInput.addEventListener('input', () => checkTokenForMergedPRs({ persistState: false }));

darkModeToggle.addEventListener('click', function () {
body.classList.toggle('dark-mode');
Expand Down Expand Up @@ -501,34 +485,37 @@ document.addEventListener('DOMContentLoaded', () => {
'lastScrumReportUsername',
'githubUsername',
'gitlabUsername',
'platformUsername'
'platformUsername',
]);

let lastScrumReportHtml = storageValues[`${activePlatform}LastScrumReportHtml`];
let lastScrumReportCacheKey = storageValues[`${activePlatform}LastScrumReportCacheKey`];
let lastScrumReportUsername = storageValues[`${activePlatform}LastScrumReportUsername`];

if (storageValues.lastScrumReportHtml && (!storageValues.lastScrumReportPlatform || storageValues.lastScrumReportPlatform === activePlatform) && !lastScrumReportHtml) {
if (
storageValues.lastScrumReportHtml &&
(!storageValues.lastScrumReportPlatform || storageValues.lastScrumReportPlatform === activePlatform) &&
!lastScrumReportHtml
) {
lastScrumReportHtml = storageValues.lastScrumReportHtml;
lastScrumReportCacheKey = storageValues.lastScrumReportCacheKey;
lastScrumReportUsername = storageValues.lastScrumReportUsername;
}

const expectedUsername = activePlatform === 'gitlab'
? (storageValues.gitlabUsername || storageValues.platformUsername)
: (storageValues.githubUsername || storageValues.platformUsername);
const expectedUsername =
activePlatform === 'gitlab'
? storageValues.gitlabUsername || storageValues.platformUsername
: storageValues.githubUsername || storageValues.platformUsername;

const isUsernameMatch = lastScrumReportUsername
const isUsernameMatch = lastScrumReportUsername
? lastScrumReportUsername === expectedUsername
: (lastScrumReportCacheKey && expectedUsername && lastScrumReportCacheKey.startsWith(expectedUsername + '-'));
: lastScrumReportCacheKey && expectedUsername && lastScrumReportCacheKey.startsWith(expectedUsername + '-');

if (age < ttlMs) {
const cacheKey = cache?.cacheKey ?? null;
const reportEmpty = !scrumReport.innerHTML || !scrumReport.innerHTML.trim();

const matches =
(!lastScrumReportCacheKey || lastScrumReportCacheKey === cacheKey) &&
isUsernameMatch;
const matches = (!lastScrumReportCacheKey || lastScrumReportCacheKey === cacheKey) && isUsernameMatch;

if (reportEmpty && lastScrumReportHtml && matches) {
scrumReport.innerHTML = lastScrumReportHtml;
Expand Down Expand Up @@ -658,8 +645,7 @@ document.addEventListener('DOMContentLoaded', () => {
platformUsername.value = result[platformUsernameKey] || '';
checkTokenForShowCommits();
checkTokenForMergedPRs();
},
);
});

// Button setup
const generateBtn = document.getElementById('generateReport');
Expand Down Expand Up @@ -822,8 +808,8 @@ document.addEventListener('DOMContentLoaded', () => {
const endDateInput = document.getElementById('endingDate');

if (items.selectedTimeframe === 'yesterdayContribution') {
startDateInput.value = getYesterday();
endDateInput.value = getToday();
startDateInput.value = window.scrumUtils.getYesterdayDateString();
endDateInput.value = window.scrumUtils.getTodayDateString();
}
startDateInput.readOnly = endDateInput.readOnly = true;

Expand Down Expand Up @@ -983,7 +969,9 @@ document.addEventListener('DOMContentLoaded', () => {
// Show notice instead of applying immediately
const modeLabel = mode === 'popup' ? 'Popup' : 'Side Panel';
if (displayModeNotice && displayModeNoticeText) {
displayModeNoticeText.textContent = chrome?.i18n.getMessage('displayModeNotice', [modeLabel]) || `The extension will open in ${modeLabel} mode on the next launch.`;
displayModeNoticeText.textContent =
chrome?.i18n.getMessage('displayModeNotice', [modeLabel]) ||
`The extension will open in ${modeLabel} mode on the next launch.`;
displayModeNotice.classList.remove('hidden');
}
});
Expand Down Expand Up @@ -1083,7 +1071,9 @@ document.addEventListener('DOMContentLoaded', () => {
} catch {}
if (platform !== 'github') {
// Do not run repo fetch for non-GitHub platforms
if (repoStatus) repoStatus.textContent = chrome?.i18n.getMessage('repoFilteringGithubOnly') || 'Repository filtering is only available for GitHub.';
if (repoStatus)
repoStatus.textContent =
chrome?.i18n.getMessage('repoFilteringGithubOnly') || 'Repository filtering is only available for GitHub.';
return;
}
if (!useRepoFilter.checked) {
Expand Down Expand Up @@ -1172,7 +1162,10 @@ document.addEventListener('DOMContentLoaded', () => {
if (platform !== 'github') {
repoFilterContainer.classList.add('hidden');
useRepoFilter.checked = false;
if (repoStatus) repoStatus.textContent = chrome?.i18n.getMessage('repoFilteringGithubOnly') || 'Repository filtering is only available for GitHub.';
if (repoStatus)
repoStatus.textContent =
chrome?.i18n.getMessage('repoFilteringGithubOnly') ||
'Repository filtering is only available for GitHub.';
return;
}
const enabled = useRepoFilter.checked;
Expand Down Expand Up @@ -1202,7 +1195,8 @@ document.addEventListener('DOMContentLoaded', () => {
});
checkTokenForFilter();
if (enabled) {
repoStatus.textContent = chrome?.i18n.getMessage('loadingReposAutomatically') || 'Loading repos automatically...';
repoStatus.textContent =
chrome?.i18n.getMessage('loadingReposAutomatically') || 'Loading repos automatically...';

try {
const cacheData = await browser.storage.local.get(['repoCache']);
Expand Down Expand Up @@ -1351,7 +1345,9 @@ document.addEventListener('DOMContentLoaded', () => {
platform = items.platform || 'github';
} catch {}
if (platform !== 'github') {
if (repoStatus) repoStatus.textContent = chrome?.i18n.getMessage('repoLoadingGithubOnly') || 'Repository loading is only available for GitHub.';
if (repoStatus)
repoStatus.textContent =
chrome?.i18n.getMessage('repoLoadingGithubOnly') || 'Repository loading is only available for GitHub.';
return;
}
console.log('window.fetchUserRepositories exists:', !!window.fetchUserRepositories);
Expand Down Expand Up @@ -1391,7 +1387,9 @@ document.addEventListener('DOMContentLoaded', () => {
platform = items.platform || 'github';
} catch (e) {}
if (platform !== 'github') {
if (repoStatus) repoStatus.textContent = chrome?.i18n.getMessage('repoFetchingGithubOnly') || 'Repository fetching is only available for GitHub.';
if (repoStatus)
repoStatus.textContent =
chrome?.i18n.getMessage('repoFetchingGithubOnly') || 'Repository fetching is only available for GitHub.';
return;
}
console.log('[POPUP-DEBUG] performRepoFetch called.');
Expand Down Expand Up @@ -1694,11 +1692,11 @@ platformSelect.addEventListener('change', () => {
const platform = platformSelect.value;
browser.storage.local.set({ platform }).then(() => {
const scrumReport = document.getElementById('scrumReport');
if(scrumReport){
if (scrumReport) {
scrumReport.innerHTML = '';
}
const generateBtn = document.getElementById('generateReport');
if(typeof bootstrapScrumReportOnPopupLoad === 'function'){
if (typeof bootstrapScrumReportOnPopupLoad === 'function') {
bootstrapScrumReportOnPopupLoad(generateBtn);
}
});
Expand Down Expand Up @@ -1728,11 +1726,7 @@ const platformSelectHidden = document.getElementById('platformSelect');

function buildScrumSubjectFromPopup() {
const projectName = document.getElementById('projectName')?.value?.trim() || '';
const now = new Date();
const dateCode =
String(now.getFullYear()) + String(now.getMonth() + 1).padStart(2, '0') + String(now.getDate()).padStart(2, '0');

return `[Scrum]${projectName ? ' - ' + projectName : ''} - ${dateCode}`;
return window.scrumUtils.buildScrumSubject(projectName);
}

function setPlatformDropdown(value) {
Expand All @@ -1754,10 +1748,10 @@ function setPlatformDropdown(value) {
platformSelectHidden.value = value;
browser.storage.local.set({ platform: value }).then(() => {
const scrumReport = document.getElementById('scrumReport');
if(scrumReport) scrumReport.innerHTML = '';
if (scrumReport) scrumReport.innerHTML = '';

const generateBtn = document.getElementById('generateReport');
if(typeof bootstrapScrumReportOnPopupLoad === 'function'){
if (typeof bootstrapScrumReportOnPopupLoad === 'function') {
bootstrapScrumReportOnPopupLoad(generateBtn);
}
});
Expand Down Expand Up @@ -2009,8 +2003,8 @@ function toggleRadio(radio) {
console.log('Toggling radio:', radio.id);

if (radio.id === 'yesterdayContribution') {
startDateInput.value = getYesterday();
endDateInput.value = getToday();
startDateInput.value = window.scrumUtils.getYesterdayDateString();
endDateInput.value = window.scrumUtils.getTodayDateString();
}

startDateInput.readOnly = endDateInput.readOnly = true;
Expand Down
Loading
Loading