Skip to content

Commit

Permalink
revert merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyBlaise99 committed Nov 7, 2023
1 parent 58b7002 commit b296b83
Show file tree
Hide file tree
Showing 12 changed files with 2,062 additions and 237 deletions.
2,112 changes: 1,988 additions & 124 deletions frontend/cypress/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"debug": "cypress open"
},
"devDependencies": {
"cypress": "^13.3.0"
"cypress": "^12.7.0"
}
}
14 changes: 8 additions & 6 deletions frontend/cypress/tests/chartView/chartView_zoomFeature.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@ describe('range changes in chartview should reflect in zoom', () => {
.get('#summary-charts .summary-chart__ramp .ramp')
.first()
.click(120, 20)
.click(185, 20);
.click(200, 20);

cy.get('#tab-zoom')
.should('be.visible');

cy.get('#tab-zoom .ramp .ramp__slice')
.first()
.invoke('attr', 'title')
.should('eq', '[2020-05-23] [#1241] Restore checked file types (#1256): +14 -1 lines ');
.should('eq', '[2020-10-01] [#1312] Conditional run for markbind to gh pages deployment (#1337): +1 -0 lines ');
cy.get('#tab-zoom .ramp .ramp__slice')
.last()
.invoke('attr', 'title')
Expand All @@ -306,7 +306,7 @@ describe('range changes in chartview should reflect in zoom', () => {
cy.get('body').type(zoomKey, { release: false })
.get('#summary-charts .summary-chart__ramp .ramp')
.first()
.click(185, 20)
.click(200, 20)
.click(250, 20);

cy.get('#tab-zoom')
Expand All @@ -319,7 +319,8 @@ describe('range changes in chartview should reflect in zoom', () => {
cy.get('#tab-zoom .ramp .ramp__slice')
.last()
.invoke('attr', 'title')
.should('eq', '[2020-09-27] Add optional check for quotes in diff file regex (#1330): +1 -1 lines ');
.should('eq', '[2020-11-21] [#1345] Authorship: Add last modified '
+ 'date to each LoC if specified (#1348): +165 -76 lines ');
});

// Assumptions: Contributer 'jamessspanggg' is the first result,
Expand All @@ -333,7 +334,7 @@ describe('range changes in chartview should reflect in zoom', () => {
cy.get('body').type(zoomKey, { release: false })
.get('#summary-charts .summary-chart__ramp .ramp')
.first()
.click(185, 20)
.click(200, 20)
.click(225, 20);

cy.get('#tab-zoom')
Expand All @@ -350,6 +351,7 @@ describe('range changes in chartview should reflect in zoom', () => {
cy.get('#tab-zoom .ramp .ramp__slice')
.last()
.invoke('attr', 'title')
.should('eq', '[2020-09-27] Add optional check for quotes in diff file regex (#1330): +1 -1 lines ');
.should('eq', '[2020-11-21] [#1345] Authorship: Add last modified date '
+ 'to each LoC if specified (#1348): +165 -76 lines ');
});
});
25 changes: 7 additions & 18 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@fortawesome/free-solid-svg-icons": "^6.0.0",
"@fortawesome/vue-fontawesome": "^3.0.3",
"@types/minimatch": "^5.1.2",
"@types/seedrandom": "^3.0.5",
"core-js": "^3.6.5",
"highlight.js": "^10.5.0",
"jszip": "^3.5.0",
Expand All @@ -34,7 +33,7 @@
"vue-observe-visibility": "^1.0.0",
"vue-router": "^4.1.6",
"vuex": "^4.0.2",
"zod": "^3.22.3"
"zod": "^3.20.6"
},
"devDependencies": {
"@babel/eslint-parser": "^7.17.0",
Expand Down
83 changes: 33 additions & 50 deletions frontend/src/components/c-ramp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
draggable="false",
v-on:click="rampClick",
v-bind:href="getLink(commit)", target="_blank",
v-bind:title="getContributionMessageByCommit(slice, commit)",
v-bind:title="getContributionMessage(slice, commit)",
v-bind:class="`ramp__slice--color${getRampColor(commit, slice)}`,\
!isBrokenLink(getLink(commit)) ? '' : 'broken-link'",
v-bind:style="{\
Expand All @@ -34,13 +34,11 @@
)
</template>

<script lang='ts'>
import { defineComponent } from 'vue';
<script>
import brokenLinkDisabler from '../mixin/brokenLinkMixin';
import User from '../utils/user';
import { Commit, CommitResult } from '../types/types';
export default defineComponent({
export default {
name: 'c-ramp',
mixins: [brokenLinkDisabler],
props: {
Expand Down Expand Up @@ -87,32 +85,24 @@ export default defineComponent({
},
data() {
return {
rampSize: 0.01 as number,
rampSize: 0.01,
mergeCommitRampSize: this.rampSize * 20,
deletesContributionRampSize: this.rampSize * 20,
};
},
computed: {
mergeCommitRampSize(): number {
return this.rampSize * 20;
},
deletesContributionRampSize(): number {
return this.rampSize * 20;
},
},
methods: {
getLink(commit: CommitResult) {
getLink(commit) {
return window.getCommitLink(commit.repoId, commit.hash);
},
getContributions(commit: CommitResult | Commit) {
getContributions(commit) {
return commit.insertions + commit.deletions;
},
isDeletesContribution(commit: CommitResult | Commit) {
isDeletesContribution(commit) {
return commit.insertions === 0 && commit.deletions > 0;
},
getWidth(slice: CommitResult | Commit) {
// Check if slice contains 'isMergeCommit' attribute
if ('isMergeCommit' in slice && slice.isMergeCommit) {
getWidth(slice) {
if (slice.isMergeCommit) {
return this.mergeCommitRampSize;
}
if (this.getContributions(slice) === 0) {
Expand All @@ -121,36 +111,29 @@ export default defineComponent({
if (this.isDeletesContribution(slice)) {
return this.deletesContributionRampSize;
}
// '+' unary operator here attempts to convert this.avgsize to number, if it is not already one
const newSize = 100 * (slice.insertions / +this.avgsize);
const newSize = 100 * (slice.insertions / this.avgsize);
return Math.max(newSize * this.rampSize, 0.5);
},
getContributionMessageByCommit(slice: Commit, commit: CommitResult) {
return `[${slice.date}] ${commit.messageTitle}: +${commit.insertions} -${commit.deletions} lines `;
},
getContributionMessage(slice: Commit) {
let title = this.tframe === 'day'
? `[${slice.date}] Daily `
: `[${slice.date} till ${slice.endDate}] Weekly `;
getContributionMessage(slice, commit) {
let title = '';
if (this.tframe === 'commit') {
return `[${slice.date}] ${commit.messageTitle}: +${commit.insertions} -${commit.deletions} lines `;
}
title = this.tframe === 'day'
? `[${slice.date}] Daily `
: `[${slice.date} till ${slice.endDate}] Weekly `;
title += `contribution: +${slice.insertions} -${slice.deletions} lines`;
return title;
},
openTabZoom(user: User, slice: Commit, evt: MouseEvent) {
openTabZoom(user, slice, evt) {
// prevent opening of zoom tab when cmd/ctrl click
if (window.isMacintosh ? evt.metaKey : evt.ctrlKey) {
return;
}
const zoomUser = { ...user };
// Calculate total commit result insertion and deletion for the daily/weekly commit selected
zoomUser.commits = user.dailyCommits.map(
(dailyCommit) => ({
insertions: dailyCommit.commitResults.reduce((acc, currCommitResult) => acc + currCommitResult.insertions, 0),
deletions: dailyCommit.commitResults.reduce((acc, currCommitResult) => acc + currCommitResult.deletions, 0),
...dailyCommit,
commitResults: dailyCommit.commitResults.map((commitResult) => ({ ...commitResult, isOpen: true })),
}),
) as Commit[];
zoomUser.commits = user.dailyCommits;
const info = {
zRepo: user.repoName,
Expand All @@ -172,27 +155,27 @@ export default defineComponent({
},
// position for commit granularity
getCommitPos(i: number, total: number) {
getCommitPos(i, total) {
return (((total - i - 1) * window.DAY_IN_MS) / total)
/ (this.getTotalForPos(this.sdate, this.udate) + window.DAY_IN_MS);
},
// position for day granularity
getSlicePos(date: string) {
getSlicePos(date) {
const total = this.getTotalForPos(this.sdate, this.udate);
return (new Date(this.udate).valueOf() - new Date(date).valueOf()) / (total + window.DAY_IN_MS);
return (new Date(this.udate) - new Date(date)) / (total + window.DAY_IN_MS);
},
// get duration in miliseconds between 2 date
getTotalForPos(sinceDate: string, untilDate: string) {
return new Date(untilDate).valueOf() - new Date(sinceDate).valueOf();
getTotalForPos(sinceDate, untilDate) {
return new Date(untilDate) - new Date(sinceDate);
},
getRampColor(commit: CommitResult, slice: Commit) {
getRampColor(commit, slice) {
if (this.isDeletesContribution(commit)) {
return '-deletes';
}
return this.getSliceColor(slice);
},
getSliceColor(slice: Commit) {
getSliceColor(slice) {
if (this.isDeletesContribution(slice)) {
return '-deletes';
}
Expand All @@ -204,7 +187,7 @@ export default defineComponent({
},
// Prevent browser from switching to new tab when clicking ramp
rampClick(evt: MouseEvent) {
rampClick(evt) {
const isKeyPressed = window.isMacintosh ? evt.metaKey : evt.ctrlKey;
if (isKeyPressed) {
evt.preventDefault();
Expand All @@ -219,11 +202,11 @@ export default defineComponent({
return undefined;
},
},
});
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
<style lang="scss" scoped>
@import '../styles/_colors.scss';

/* Ramp */
Expand Down
20 changes: 7 additions & 13 deletions frontend/src/components/c-resizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,24 @@
slot(name="right")
</template>

<script lang='ts'>
<script>
import { mapState } from 'vuex';
import { defineComponent } from 'vue';
const DRAG_BAR_WIDTH = 13.25;
const SCROLL_BAR_WIDTH = 17;
const GUIDE_BAR_WIDTH = 2;
/** The following eslint suppression suppresses a rare false positive case where event cannot be accessed due to
* handler being a lambda function parameter. The explicit lambda function here allows us to easily discern handler's
* parameters, i.e. an event of type MouseEvent.
*/
// eslint-disable-next-line no-unused-vars
const throttledEvent = (delay: number, handler: (event: MouseEvent) => unknown) => {
const throttledEvent = (delay, handler) => {
let lastCalled = 0;
return (event: MouseEvent) => {
return (...args) => {
if (Date.now() - lastCalled > delay) {
lastCalled = Date.now();
handler(event);
handler(...args);
}
};
};
export default defineComponent({
export default {
name: 'c-resizer',
data() {
Expand Down Expand Up @@ -74,7 +68,7 @@ export default defineComponent({
mouseMove() {
if (this.isResizing) {
return throttledEvent(25, (event: MouseEvent) => {
return throttledEvent(25, (event) => {
this.guideWidth = (
Math.min(
Math.max(
Expand Down Expand Up @@ -108,5 +102,5 @@ export default defineComponent({
this.$store.commit('updateTabState', false);
},
},
});
};
</script>
Loading

0 comments on commit b296b83

Please sign in to comment.