1
0
Fork 0
forked from forgejo/forgejo

JS refactors (#22227)

- Replace all default exports with named exports, except for Vue SFCs
- Remove names from Vue SFCs, they are automatically inferred from the
filename
- Misc whitespace-related tweaks
This commit is contained in:
silverwind 2022-12-23 17:03:11 +01:00 committed by GitHub
parent 71ca3067bc
commit 2cf0cf0de1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 47 additions and 89 deletions

View file

@ -18,7 +18,6 @@
import {CalendarHeatmap} from 'vue3-calendar-heatmap';
export default {
name: 'ActivityHeatmap',
components: {CalendarHeatmap},
props: {
values: {

View file

@ -46,19 +46,13 @@ const luminance = (colorString) => {
const luminanceThreshold = 0.179;
export default {
name: 'ContextPopup',
components: {
SvgIcon,
},
components: {SvgIcon},
data: () => ({
loading: false,
issue: null,
i18nErrorOccurred: i18n.error_occurred,
i18nErrorMessage: null,
}),
computed: {
createdAt() {
return new Date(this.issue.created_at).toLocaleDateString(undefined, {year: 'numeric', month: 'short', day: 'numeric'});
@ -107,7 +101,6 @@ export default {
});
}
},
mounted() {
this.$refs.root.addEventListener('us-load-context-popup', (e) => {
const data = e.detail;
@ -116,7 +109,6 @@ export default {
}
});
},
methods: {
load(data) {
this.loading = true;

View file

@ -27,12 +27,9 @@ import {doLoadMoreFiles} from '../features/repo-diff.js';
const {pageData} = window.config;
export default {
name: 'DiffFileList',
data: () => {
return pageData.diffFileInfo;
},
watch: {
fileListIsVisible(newValue) {
if (newValue === true) {
@ -44,15 +41,12 @@ export default {
}
}
},
mounted() {
document.getElementById('show-file-list-btn').addEventListener('click', this.toggleFileList);
},
unmounted() {
document.getElementById('show-file-list-btn').removeEventListener('click', this.toggleFileList);
},
methods: {
toggleFileList() {
this.fileListIsVisible = !this.fileListIsVisible;

View file

@ -21,15 +21,12 @@ const {pageData} = window.config;
const LOCAL_STORAGE_KEY = 'diff_file_tree_visible';
export default {
name: 'DiffFileTree',
components: {DiffFileTreeItem},
data: () => {
const fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) === 'true';
pageData.diffFileInfo.fileTreeIsVisible = fileTreeIsVisible;
return pageData.diffFileInfo;
},
computed: {
fileTree() {
const result = [];
@ -94,7 +91,6 @@ export default {
return result;
}
},
mounted() {
// ensure correct buttons when we are mounted to the dom
this.adjustToggleButton(this.fileTreeIsVisible);
@ -125,7 +121,7 @@ export default {
doLoadMoreFiles(this.link, this.diffEnd, () => {
this.isLoadingNewData = false;
});
}
},
},
};
</script>

View file

@ -43,11 +43,7 @@
import {SvgIcon} from '../svg.js';
export default {
name: 'DiffFileTreeItem',
components: {
SvgIcon,
},
components: {SvgIcon},
props: {
item: {
type: Object,
@ -59,7 +55,6 @@ export default {
default: true
}
},
data: () => ({
collapsed: false,
}),

View file

@ -111,11 +111,7 @@ import {SvgIcon} from '../svg.js';
const {csrfToken, pageData} = window.config;
export default {
name: 'PullRequestMergeForm',
components: {
SvgIcon,
},
components: {SvgIcon},
data: () => ({
csrfToken,
mergeForm: pageData.pullRequestMergeForm,
@ -137,20 +133,17 @@ export default {
showMergeStyleMenu: false,
showActionForm: false,
}),
computed: {
mergeButtonStyleClass() {
if (this.mergeForm.allOverridableChecksOk) return 'green';
return this.autoMergeWhenSucceed ? 'blue' : 'red';
}
},
watch: {
mergeStyle(val) {
this.mergeStyleDetail = this.mergeForm.mergeStyles.find((e) => e.name === val);
}
},
created() {
this.mergeStyleAllowedCount = this.mergeForm.mergeStyles.reduce((v, msd) => v + (msd.allowed ? 1 : 0), 0);
@ -158,15 +151,12 @@ export default {
if (!mergeStyle) mergeStyle = this.mergeForm.mergeStyles.find((e) => e.allowed)?.name;
this.switchMergeStyle(mergeStyle, !this.mergeForm.canMergeNow);
},
mounted() {
document.addEventListener('mouseup', this.hideMergeStyleMenu);
},
unmounted() {
document.removeEventListener('mouseup', this.hideMergeStyleMenu);
},
methods: {
hideMergeStyleMenu() {
this.showMergeStyleMenu = false;