-
Notifications
You must be signed in to change notification settings - Fork 82
Added organisation name button #141
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Vedansh Saini <[email protected]>
Signed-off-by: Vedansh Saini <[email protected]>
Signed-off-by: Vedansh Saini <[email protected]>
Reviewer's GuideThis PR extends the settings UI with an organisation name input for dynamic GitHub org selection and integrates it into the data‐fetch logic, refactors the caching layer to use a configurable TTL and request queuing (clearing cache on org change), and enhances front‐end styling with dark‐mode support and custom toast notifications. Sequence diagram for organisation name affecting GitHub data fetch and cachesequenceDiagram
actor User
participant SettingsUI as Settings UI
participant Storage as chrome.storage.local
participant Cache as githubCache
participant ScrumHelper as fetchGithubData()
participant GitHub as GitHub API
User->>SettingsUI: Enter organisation name
SettingsUI->>Storage: Save organisationName
SettingsUI->>Cache: Clear githubCache
User->>SettingsUI: Click Generate Report
SettingsUI->>ScrumHelper: Trigger data fetch
ScrumHelper->>Storage: Get organisationName
ScrumHelper->>GitHub: Fetch issues/PRs for organisation
GitHub-->>ScrumHelper: Return data
ScrumHelper->>Cache: Save new data
ScrumHelper->>SettingsUI: Update scrum report
Class diagram for updated caching and settings logicclassDiagram
class SettingsUI {
+organisationName: string
+cacheInput: number
+onOrganisationNameBlur()
+onCacheInputBlur()
}
class githubCache {
+data
+cacheKey
+timestamp
+ttl
+fetching
+queue
+subject
+saveToStorage()
+loadFromStorage()
+clearOnOrgChange()
}
class ScrumHelper {
+fetchGithubData()
+processGithubData()
}
SettingsUI --|> githubCache : clears cache on org change
SettingsUI --|> ScrumHelper : triggers fetch
ScrumHelper --|> githubCache : uses cache
githubCache o-- Storage : persists data
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Preeti9764 - I've reviewed your changes - here's some feedback:
- Include
organisationName
in your cacheKey (e.g.${githubUsername}-${organisationName}-${startingDate}-${endingDate}
) so switching orgs automatically fetches fresh data instead of relying on manual cache clears. - Add basic validation for the organisationName input (e.g. non-empty, valid GitHub org pattern) and provide UI feedback if the entered value is invalid.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Include `organisationName` in your cacheKey (e.g. `${githubUsername}-${organisationName}-${startingDate}-${endingDate}`) so switching orgs automatically fetches fresh data instead of relying on manual cache clears.
- Add basic validation for the organisationName input (e.g. non-empty, valid GitHub org pattern) and provide UI feedback if the entered value is invalid.
## Individual Comments
### Comment 1
<location> `src/scripts/popup.js:430` </location>
<code_context>
});
-
+}
+if (organisationNameInput) {
+ chrome.storage.local.get(['organisationName'], function (result) {
+ if (result.organisationName) {
+ organisationNameInput.value = result.organisationName;
+ } else {
+ organisationNameInput.value = 'fossasia';
+ }
+ });
+ organisationNameInput.addEventListener('blur', function () {
+ let orgValue = this.value.trim() || 'fossasia';
</code_context>
<issue_to_address>
Cache is cleared on every organisation name blur, even if unchanged.
Only clear the cache if the organisation name value has changed to avoid unnecessary invalidations.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
body.classList.add('dark-mode'); | ||
darkModeToggle.src = 'icons/light-mode.png'; | ||
if(settingsIcon) { | ||
if (settingsIcon) { | ||
settingsIcon.src = 'icons/settings-night.png'; // Changed from settings-night.png | ||
} | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (performance): Cache is cleared on every organisation name blur, even if unchanged.
Only clear the cache if the organisation name value has changed to avoid unnecessary invalidations.
function handleLastWeekContributionChange() { | ||
endingDate = getToday(); | ||
startingDate = getLastWeek(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Avoid function declarations, favouring function assignment expressions, inside blocks. (avoid-function-declarations-in-blocks
)
Explanation
Function declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers. Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you should use function expressions, which create functions in-scope.function handleYesterdayContributionChange() { | ||
endingDate = getToday(); | ||
startingDate = getYesterday(); | ||
} | ||
function getLastWeek() { | ||
let today = new Date(); | ||
let lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7); | ||
let lastWeekMonth = lastWeek.getMonth() + 1; | ||
let lastWeekDay = lastWeek.getDate(); | ||
let lastWeekYear = lastWeek.getFullYear(); | ||
let lastWeekDisplayPadded = | ||
('0000' + lastWeekYear.toString()).slice(-4) + | ||
'-' + | ||
('00' + lastWeekMonth.toString()).slice(-2) + | ||
'-' + | ||
('00' + lastWeekDay.toString()).slice(-2); | ||
return lastWeekDisplayPadded; | ||
} | ||
function getYesterday() { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Avoid function declarations, favouring function assignment expressions, inside blocks. (avoid-function-declarations-in-blocks
)
Explanation
Function declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers. Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you should use function expressions, which create functions in-scope.function getLastWeek() { | ||
let today = new Date(); | ||
let lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7); | ||
let lastWeekMonth = lastWeek.getMonth() + 1; | ||
let lastWeekDay = lastWeek.getDate(); | ||
let lastWeekYear = lastWeek.getFullYear(); | ||
let lastWeekDisplayPadded = | ||
('0000' + lastWeekYear.toString()).slice(-4) + | ||
'-' + | ||
('00' + lastWeekMonth.toString()).slice(-2) + | ||
'-' + | ||
('00' + lastWeekDay.toString()).slice(-2); | ||
return lastWeekDisplayPadded; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Avoid function declarations, favouring function assignment expressions, inside blocks. (avoid-function-declarations-in-blocks
)
Explanation
Function declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers. Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you should use function expressions, which create functions in-scope.let project = repository_url.substr(repository_url.lastIndexOf('/') + 1); | ||
let title = item.title; | ||
let number = item.number; | ||
let html_url = item.html_url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring
)
let html_url = item.html_url; | |
let {html_url} = item; |
Explanation
Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.From the Airbnb Javascript Style Guide
function triggerScrumGeneration() { | ||
if (issuesDataProcessed && prsReviewDataProcessed) { | ||
log('Both data sets processed, generating scrum body.'); | ||
writeScrumBody(); | ||
} else { | ||
log('Waiting for all data to be processed before generating scrum.', { | ||
issues: issuesDataProcessed, | ||
reviews: prsReviewDataProcessed, | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Avoid function declarations, favouring function assignment expressions, inside blocks. (avoid-function-declarations-in-blocks
)
Explanation
Function declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers. Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you should use function expressions, which create functions in-scope.} | ||
|
||
function writeGithubIssuesPrs() { | ||
let items = githubIssuesData.items; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring
)
let items = githubIssuesData.items; | |
let {items} = githubIssuesData; |
Explanation
Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.From the Airbnb Javascript Style Guide
} | ||
for (let i = 0; i < items.length; i++) { | ||
let item = items[i]; | ||
let html_url = item.html_url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring
)
let html_url = item.html_url; | |
let {html_url} = item; |
Explanation
Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.From the Airbnb Javascript Style Guide
@hpdang Please share your views on this to ... it will reduce the hectic of making code changes for different organisation users. Thanks! |
📌 Fixes
Fixes #140
📝 Summary of Changes
Added an organisation name input button in the settings for the user to switch organisations easily, and can fetch GitHub activities made for that particular organisation.It is set default to fossasia and user can change it for there org.
📸 Screenshots / Demo (if UI-related)
✅ Checklist
I’ve tested my changes locally
My code follows the project’s code style guidelines
Summary by Sourcery
Enable dynamic organization selection and enhance data fetching and UI styles.
New Features:
Enhancements: