Commit 8df6be82 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch '334790-move-to-constants' into 'master'

Move value to constants

See merge request gitlab-org/gitlab!68011
parents bbc37c0f c164a615
......@@ -8,6 +8,8 @@ import {
COMMIT_LABEL,
TARGET_BRANCH_LABEL,
TOGGLE_CREATE_MR_LABEL,
COMMIT_MESSAGE_SUBJECT_MAX_LENGTH,
COMMIT_MESSAGE_BODY_MAX_LENGTH,
} from '../constants';
const initFormField = ({ value, required = true, skipValidation = false }) => ({
......@@ -122,19 +124,16 @@ export default {
return this.form.fields['commit_message'].value && this.form.fields['branch_name'].value;
},
showHint() {
const commitMessageSubjectMaxLength = 52;
const commitMessageBodyMaxLength = 72;
const splitCommitMessageByLineBreak = this.form.fields['commit_message'].value
.trim()
.split('\n');
const [firstLine, ...otherLines] = splitCommitMessageByLineBreak;
const hasFirstLineExceedMaxLength = firstLine.length > commitMessageSubjectMaxLength;
const hasFirstLineExceedMaxLength = firstLine.length > COMMIT_MESSAGE_SUBJECT_MAX_LENGTH;
const hasOtherLineExceedMaxLength =
Boolean(otherLines.length) &&
otherLines.some((text) => text.length > commitMessageBodyMaxLength);
otherLines.some((text) => text.length > COMMIT_MESSAGE_BODY_MAX_LENGTH);
return (
!this.form.fields['commit_message'].feedback &&
......
......@@ -8,3 +8,6 @@ export const SECONDARY_OPTIONS_TEXT = __('Cancel');
export const COMMIT_LABEL = __('Commit message');
export const TARGET_BRANCH_LABEL = __('Target branch');
export const TOGGLE_CREATE_MR_LABEL = __('Start a new merge request with these changes');
export const COMMIT_MESSAGE_SUBJECT_MAX_LENGTH = 52;
export const COMMIT_MESSAGE_BODY_MAX_LENGTH = 72;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment