window.gitlist.changeableCommit = () => {
if (!window.gitlist.branches.includes(window.gitlist.branch)) {
let branchInfo;
if (window.gitlist.branches.length === 1) {
branchInfo = `Only the <strong>${window.gitlist.branches.join(', ')}</strong> branch is changeable.`
} else {
branchInfo = `Only the <strong>${window.gitlist.branches.join(', ')}</strong> branches are changeable.`
}
$.snackbar({
htmlAllowed: true,
content: `This commit <strong>${window.gitlist.branch}</strong> is not changeable.<br/>
${branchInfo}
`,
timeout: window.gitlist.snapckbarLongTimeout,
})
return false;
} {
return true
}
}
window.gitlist.preloadCommitValues = (options) => {
const { type } = options
const inputs = {
name: $(`#p3x-gitlist-modal-${ type }-name`),
email: $(`#p3x-gitlist-modal-${ type }-email`),
comment: $(`#p3x-gitlist-modal-${ type }-comment`),
}
for(let inputKey in inputs) {
const input = inputs[inputKey]
//console.log(inputKey, commentCookie)
let cookieName = `p3x-gitlist-commit-${inputKey}`;
if (inputKey === 'comment') {
cookieName = `p3x-gitlist-commit-${type }-${inputKey}`;
}
const cookie = Cookies.get(cookieName)
if (cookie) {
input.val(cookie.trim());
}
input.change(() => {
const val = input.val().trim();
Cookies.set(cookieName, val, window.gitlist.cookieSettings);
input.val(val);
})
}
}
window.gitlist.invalidSnackbarCommit = () => {
$.snackbar({
content: 'The commit form data is invalid..'
})
}