Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 18:06:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 18:06:05 +0300
commit05f4b2fb34dbb051b2ce5ddbc801ec42998c019c (patch)
tree0fd7a153f3ed7d00d40e428c08ab81ae3d863afe /app
parent9e27f0d920cc3891fa7644c5cc0bc280c519fb20 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/jobs/store/mutations.js4
-rw-r--r--app/assets/javascripts/jobs/store/state.js1
-rw-r--r--app/assets/javascripts/jobs/store/utils.js106
-rw-r--r--app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue13
-rw-r--r--app/assets/javascripts/vue_shared/components/recaptcha_modal.vue4
-rw-r--r--app/serializers/evidences/author_entity.rb9
-rw-r--r--app/serializers/evidences/issue_entity.rb15
-rw-r--r--app/serializers/evidences/milestone_entity.rb14
-rw-r--r--app/serializers/evidences/project_entity.rb10
-rw-r--r--app/serializers/evidences/release_entity.rb13
-rw-r--r--app/serializers/evidences/release_serializer.rb7
11 files changed, 137 insertions, 59 deletions
diff --git a/app/assets/javascripts/jobs/store/mutations.js b/app/assets/javascripts/jobs/store/mutations.js
index 540c3e2ad69..412ae146ca0 100644
--- a/app/assets/javascripts/jobs/store/mutations.js
+++ b/app/assets/javascripts/jobs/store/mutations.js
@@ -26,8 +26,7 @@ export default {
if (log.append) {
if (isNewJobLogActive()) {
- state.originalTrace = state.originalTrace.concat(log.trace);
- state.trace = updateIncrementalTrace(state.originalTrace, state.trace, log.lines);
+ state.trace = updateIncrementalTrace(log.lines, state.trace);
} else {
state.trace += log.html;
}
@@ -38,7 +37,6 @@ export default {
// html or size. We keep the old value otherwise these
// will be set to `undefined`
if (isNewJobLogActive()) {
- state.originalTrace = log.lines || state.trace;
state.trace = logLinesParser(log.lines) || state.trace;
} else {
state.trace = log.html || state.trace;
diff --git a/app/assets/javascripts/jobs/store/state.js b/app/assets/javascripts/jobs/store/state.js
index 585878f8240..cdc1780f3d6 100644
--- a/app/assets/javascripts/jobs/store/state.js
+++ b/app/assets/javascripts/jobs/store/state.js
@@ -19,7 +19,6 @@ export default () => ({
isScrolledToBottomBeforeReceivingTrace: true,
trace: isNewJobLogActive() ? [] : '',
- originalTrace: [],
isTraceComplete: false,
traceSize: 0,
isTraceSizeVisible: false,
diff --git a/app/assets/javascripts/jobs/store/utils.js b/app/assets/javascripts/jobs/store/utils.js
index 4a7d870674b..12069e0c123 100644
--- a/app/assets/javascripts/jobs/store/utils.js
+++ b/app/assets/javascripts/jobs/store/utils.js
@@ -64,6 +64,30 @@ export const isCollapsibleSection = (acc = [], last = {}, section = {}) =>
section.section === last.line.section;
/**
+ * Returns the lineNumber of the last line in
+ * a parsed log
+ *
+ * @param Array acc
+ * @returns Number
+ */
+export const getIncrementalLineNumber = acc => {
+ let lineNumberValue;
+ const lastIndex = acc.length - 1;
+ const lastElement = acc[lastIndex];
+ const nestedLines = lastElement.lines;
+
+ if (lastElement.isHeader && !nestedLines.length && lastElement.line) {
+ lineNumberValue = lastElement.line.lineNumber;
+ } else if (lastElement.isHeader && nestedLines.length) {
+ lineNumberValue = nestedLines[nestedLines.length - 1].lineNumber;
+ } else {
+ lineNumberValue = lastElement.lineNumber;
+ }
+
+ return lineNumberValue === 0 ? 1 : lineNumberValue + 1;
+};
+
+/**
* Parses the job log content into a structure usable by the template
*
* For collaspible lines (section_header = true):
@@ -75,32 +99,35 @@ export const isCollapsibleSection = (acc = [], last = {}, section = {}) =>
* - adds the index as lineNumber
*
* @param Array lines
- * @param Number lineNumberStart
* @param Array accumulator
* @returns Array parsed log lines
*/
-export const logLinesParser = (lines = [], lineNumberStart, accumulator = []) =>
- lines.reduce((acc, line, index) => {
- const lineNumber = lineNumberStart ? lineNumberStart + index : index;
- const last = acc[acc.length - 1];
-
- // If the object is an header, we parse it into another structure
- if (line.section_header) {
- acc.push(parseHeaderLine(line, lineNumber));
- } else if (isCollapsibleSection(acc, last, line)) {
- // if the object belongs to a nested section, we append it to the new `lines` array of the
- // previously formated header
- last.lines.push(parseLine(line, lineNumber));
- } else if (line.section_duration) {
- // if the line has section_duration, we look for the correct header to add it
- addDurationToHeader(acc, line);
- } else {
- // otherwise it's a regular line
- acc.push(parseLine(line, lineNumber));
- }
+export const logLinesParser = (lines = [], accumulator = []) =>
+ lines.reduce(
+ (acc, line, index) => {
+ const lineNumber = accumulator.length > 0 ? getIncrementalLineNumber(acc) : index;
+
+ const last = acc[acc.length - 1];
+
+ // If the object is an header, we parse it into another structure
+ if (line.section_header) {
+ acc.push(parseHeaderLine(line, lineNumber));
+ } else if (isCollapsibleSection(acc, last, line)) {
+ // if the object belongs to a nested section, we append it to the new `lines` array of the
+ // previously formated header
+ last.lines.push(parseLine(line, lineNumber));
+ } else if (line.section_duration) {
+ // if the line has section_duration, we look for the correct header to add it
+ addDurationToHeader(acc, line);
+ } else {
+ // otherwise it's a regular line
+ acc.push(parseLine(line, lineNumber));
+ }
- return acc;
- }, accumulator);
+ return acc;
+ },
+ [...accumulator],
+ );
/**
* Finds the repeated offset, removes the old one
@@ -113,7 +140,7 @@ export const logLinesParser = (lines = [], lineNumberStart, accumulator = []) =>
* @returns Array
*
*/
-export const findOffsetAndRemove = (newLog, oldParsed) => {
+export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
const cloneOldLog = [...oldParsed];
const lastIndex = cloneOldLog.length - 1;
const last = cloneOldLog[lastIndex];
@@ -140,40 +167,13 @@ export const findOffsetAndRemove = (newLog, oldParsed) => {
* We need to check if that is the case by looking for the offset property
* before parsing the incremental part
*
- * @param array originalTrace
* @param array oldLog
* @param array newLog
*/
-export const updateIncrementalTrace = (originalTrace = [], oldLog = [], newLog = []) => {
- const firstLine = newLog[0];
- const firstLineOffset = firstLine.offset;
+export const updateIncrementalTrace = (newLog, oldParsed = []) => {
+ const parsedLog = findOffsetAndRemove(newLog, oldParsed);
- // We are going to return a new array,
- // let's make a shallow copy to make sure we
- // are not updating the state outside of a mutation first.
- const cloneOldLog = [...oldLog];
-
- const lastIndex = cloneOldLog.length - 1;
- const lastLine = cloneOldLog[lastIndex];
-
- // The last line may be inside a collpasible section
- // If it is, we use the not parsed saved log, remove the last element
- // and parse the first received part togheter with the incremental log
- if (
- lastLine.isHeader &&
- (lastLine.line.offset === firstLineOffset ||
- (lastLine.lines.length &&
- lastLine.lines[lastLine.lines.length - 1].offset === firstLineOffset))
- ) {
- const cloneOriginal = [...originalTrace];
- cloneOriginal.splice(cloneOriginal.length - 1);
- return logLinesParser(cloneOriginal.concat(newLog));
- } else if (lastLine.offset === firstLineOffset) {
- cloneOldLog.splice(lastIndex);
- return cloneOldLog.concat(logLinesParser(newLog, cloneOldLog.length));
- }
- // there are no matches, let's parse the new log and return them together
- return cloneOldLog.concat(logLinesParser(newLog, cloneOldLog.length));
+ return logLinesParser(newLog, parsedLog);
};
export const isNewJobLogActive = () => gon && gon.features && gon.features.jobLogJson;
diff --git a/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
index 407e5a29aa5..5b3c3642290 100644
--- a/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
+++ b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
@@ -5,6 +5,7 @@ import tooltip from '~/vue_shared/directives/tooltip';
import Icon from '~/vue_shared/components/icon.vue';
import eventHub from '~/sidebar/event_hub';
import editForm from './edit_form.vue';
+import recaptchaModalImplementor from '~/vue_shared/mixins/recaptcha_modal_implementor';
export default {
components: {
@@ -14,6 +15,7 @@ export default {
directives: {
tooltip,
},
+ mixins: [recaptchaModalImplementor],
props: {
isConfidential: {
required: true,
@@ -54,9 +56,14 @@ export default {
updateConfidentialAttribute(confidential) {
this.service
.update('issue', { confidential })
+ .then(({ data }) => this.checkForSpam(data))
.then(() => window.location.reload())
- .catch(() => {
- Flash(__('Something went wrong trying to change the confidentiality of this issue'));
+ .catch(error => {
+ if (error.name === 'SpamError') {
+ this.openRecaptcha();
+ } else {
+ Flash(__('Something went wrong trying to change the confidentiality of this issue'));
+ }
});
},
},
@@ -112,5 +119,7 @@ export default {
{{ __('This issue is confidential') }}
</div>
</div>
+
+ <recaptcha-modal v-if="showRecaptcha" :html="recaptchaHTML" @close="closeRecaptcha" />
</div>
</template>
diff --git a/app/assets/javascripts/vue_shared/components/recaptcha_modal.vue b/app/assets/javascripts/vue_shared/components/recaptcha_modal.vue
index 55172649813..25701df33f3 100644
--- a/app/assets/javascripts/vue_shared/components/recaptcha_modal.vue
+++ b/app/assets/javascripts/vue_shared/components/recaptcha_modal.vue
@@ -32,6 +32,10 @@ export default {
mounted() {
eventHub.$on('submit', this.submit);
+
+ if (this.html) {
+ this.appendRecaptchaScript();
+ }
},
beforeDestroy() {
diff --git a/app/serializers/evidences/author_entity.rb b/app/serializers/evidences/author_entity.rb
new file mode 100644
index 00000000000..9023c64dad2
--- /dev/null
+++ b/app/serializers/evidences/author_entity.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module Evidences
+ class AuthorEntity < Grape::Entity
+ expose :id
+ expose :name
+ expose :email
+ end
+end
diff --git a/app/serializers/evidences/issue_entity.rb b/app/serializers/evidences/issue_entity.rb
new file mode 100644
index 00000000000..883256bf38a
--- /dev/null
+++ b/app/serializers/evidences/issue_entity.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Evidences
+ class IssueEntity < Grape::Entity
+ expose :id
+ expose :title
+ expose :description
+ expose :author, using: AuthorEntity
+ expose :state
+ expose :iid
+ expose :confidential
+ expose :created_at
+ expose :due_date
+ end
+end
diff --git a/app/serializers/evidences/milestone_entity.rb b/app/serializers/evidences/milestone_entity.rb
new file mode 100644
index 00000000000..8118cab4403
--- /dev/null
+++ b/app/serializers/evidences/milestone_entity.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Evidences
+ class MilestoneEntity < Grape::Entity
+ expose :id
+ expose :title
+ expose :description
+ expose :state
+ expose :iid
+ expose :created_at
+ expose :due_date
+ expose :issues, using: IssueEntity
+ end
+end
diff --git a/app/serializers/evidences/project_entity.rb b/app/serializers/evidences/project_entity.rb
new file mode 100644
index 00000000000..2a859c2afdc
--- /dev/null
+++ b/app/serializers/evidences/project_entity.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+module Evidences
+ class ProjectEntity < Grape::Entity
+ expose :id
+ expose :name
+ expose :description
+ expose :created_at
+ end
+end
diff --git a/app/serializers/evidences/release_entity.rb b/app/serializers/evidences/release_entity.rb
new file mode 100644
index 00000000000..8916ce67b4c
--- /dev/null
+++ b/app/serializers/evidences/release_entity.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Evidences
+ class ReleaseEntity < Grape::Entity
+ expose :id
+ expose :tag, as: :tag_name
+ expose :name
+ expose :description
+ expose :created_at
+ expose :project, using: ProjectEntity
+ expose :milestones, using: MilestoneEntity
+ end
+end
diff --git a/app/serializers/evidences/release_serializer.rb b/app/serializers/evidences/release_serializer.rb
new file mode 100644
index 00000000000..35a3bbc2275
--- /dev/null
+++ b/app/serializers/evidences/release_serializer.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+module Evidences
+ class ReleaseSerializer < BaseSerializer
+ entity ReleaseEntity
+ end
+end