diff options
204 files changed, 3960 insertions, 4690 deletions
diff --git a/.flayignore b/.flayignore index e2d0a2e50c5..b63ce4c4df0 100644 --- a/.flayignore +++ b/.flayignore @@ -3,4 +3,5 @@ lib/gitlab/sanitizers/svg/whitelist.rb lib/gitlab/diff/position_tracer.rb app/policies/project_policy.rb app/models/concerns/relative_positioning.rb +app/workers/stuck_merge_jobs_worker.rb lib/gitlab/redis/*.rb diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 1b58cc10180..ae6dd4e2032 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -0.27.0 +0.29.0 @@ -390,8 +390,18 @@ gem 'health_check', '~> 2.6.0' gem 'vmstat', '~> 2.3.0' gem 'sys-filesystem', '~> 1.1.6' +# SSH host key support +gem 'net-ssh', '~> 4.1.0' + +# Required for ED25519 SSH host key support +group :ed25519 do + gem 'rbnacl-libsodium' + gem 'rbnacl', '~> 3.2' + gem 'bcrypt_pbkdf', '~> 1.0' +end + # Gitaly GRPC client -gem 'gitaly', '~> 0.24.0' +gem 'gitaly', '~> 0.26.0' gem 'toml-rb', '~> 0.3.15', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 04d17d54636..948ba02a72c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,6 +75,7 @@ GEM babosa (1.0.2) base32 (0.3.2) bcrypt (3.1.11) + bcrypt_pbkdf (1.0.0) benchmark-ips (2.3.0) better_errors (2.1.1) coderay (>= 1.0.0) @@ -269,7 +270,7 @@ GEM po_to_json (>= 1.0.0) rails (>= 3.2.0) gherkin-ruby (0.3.2) - gitaly (0.24.0) + gitaly (0.26.0) google-protobuf (~> 3.1) grpc (~> 1.0) github-linguist (4.7.6) @@ -475,6 +476,7 @@ GEM mustermann (~> 1.0.0) mysql2 (0.4.5) net-ldap (0.16.0) + net-ssh (4.1.0) netrc (0.11.0) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) @@ -662,6 +664,10 @@ GEM rake (12.0.0) rblineprof (0.3.6) debugger-ruby_core_source (~> 1.3) + rbnacl (3.4.0) + ffi + rbnacl-libsodium (1.0.11) + rbnacl (>= 3.0.1) rdoc (4.2.2) json (~> 1.4) re2 (1.1.1) @@ -924,6 +930,7 @@ DEPENDENCIES awesome_print (~> 1.2.0) babosa (~> 1.0.2) base32 (~> 0.3.0) + bcrypt_pbkdf (~> 1.0) benchmark-ips (~> 2.3.0) better_errors (~> 2.1.0) binding_of_caller (~> 0.7.2) @@ -975,7 +982,7 @@ DEPENDENCIES gettext (~> 3.2.2) gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails_js (~> 1.2.0) - gitaly (~> 0.24.0) + gitaly (~> 0.26.0) github-linguist (~> 4.7.0) gitlab-flowdock-git-hook (~> 1.0.1) gitlab-markup (~> 1.5.1) @@ -1016,6 +1023,7 @@ DEPENDENCIES mousetrap-rails (~> 1.4.6) mysql2 (~> 0.4.5) net-ldap + net-ssh (~> 4.1.0) nokogiri (~> 1.6.7, >= 1.6.7.2) oauth2 (~> 1.4) octokit (~> 4.6.2) @@ -1062,6 +1070,8 @@ DEPENDENCIES rainbow (~> 2.2) raindrops (~> 0.18) rblineprof (~> 0.3.6) + rbnacl (~> 3.2) + rbnacl-libsodium rdoc (~> 4.2) re2 (~> 1.1.1) recaptcha (~> 3.0) diff --git a/app/assets/javascripts/boards/components/issue_card_inner.js b/app/assets/javascripts/boards/components/issue_card_inner.js index daef01bc93d..d3de1830895 100644 --- a/app/assets/javascripts/boards/components/issue_card_inner.js +++ b/app/assets/javascripts/boards/components/issue_card_inner.js @@ -97,9 +97,8 @@ gl.issueBoards.IssueCardInner = Vue.extend({ return `Avatar for ${assignee.name}`; }, showLabel(label) { - if (!this.list) return true; - - return !this.list.label || label.id !== this.list.label.id; + if (!this.list || !label) return true; + return true; }, filterByLabel(label, e) { if (!this.updateFilters) return; diff --git a/app/assets/javascripts/build.js b/app/assets/javascripts/build.js index b3d3bbcf84f..940326dcd33 100644 --- a/app/assets/javascripts/build.js +++ b/app/assets/javascripts/build.js @@ -164,7 +164,6 @@ window.Build = (function () { Build.prototype.initSidebar = function () { this.$sidebar = $('.js-build-sidebar'); - this.$sidebar.niceScroll(); }; Build.prototype.getBuildTrace = function () { diff --git a/app/assets/javascripts/build_variables.js b/app/assets/javascripts/build_variables.js index 99082b412e2..c955a9ac2ea 100644 --- a/app/assets/javascripts/build_variables.js +++ b/app/assets/javascripts/build_variables.js @@ -2,7 +2,7 @@ $(function() { $('.reveal-variables').off('click').on('click', function() { - $('.js-build').toggle().niceScroll(); + $('.js-build-variables').toggle(); $(this).hide(); }); }); diff --git a/app/assets/javascripts/commons/bootstrap.js b/app/assets/javascripts/commons/bootstrap.js index 389587a2596..c11b7d5f340 100644 --- a/app/assets/javascripts/commons/bootstrap.js +++ b/app/assets/javascripts/commons/bootstrap.js @@ -3,13 +3,13 @@ import $ from 'jquery'; // bootstrap jQuery plugins import 'bootstrap-sass/assets/javascripts/bootstrap/affix'; import 'bootstrap-sass/assets/javascripts/bootstrap/alert'; +import 'bootstrap-sass/assets/javascripts/bootstrap/button'; import 'bootstrap-sass/assets/javascripts/bootstrap/dropdown'; import 'bootstrap-sass/assets/javascripts/bootstrap/modal'; import 'bootstrap-sass/assets/javascripts/bootstrap/tab'; import 'bootstrap-sass/assets/javascripts/bootstrap/transition'; import 'bootstrap-sass/assets/javascripts/bootstrap/tooltip'; import 'bootstrap-sass/assets/javascripts/bootstrap/popover'; -import 'bootstrap-sass/assets/javascripts/bootstrap/button'; // custom jQuery functions $.fn.extend({ diff --git a/app/assets/javascripts/commons/jquery.js b/app/assets/javascripts/commons/jquery.js index b53f6284afc..b93e94a3c97 100644 --- a/app/assets/javascripts/commons/jquery.js +++ b/app/assets/javascripts/commons/jquery.js @@ -6,6 +6,5 @@ import 'vendor/jquery.endless-scroll'; import 'vendor/jquery.caret'; import 'vendor/jquery.atwho'; import 'vendor/jquery.scrollTo'; -import 'vendor/jquery.nicescroll'; import 'vendor/jquery.waitforimages'; import 'select2/select2'; diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 726c7e85232..265e304b957 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -580,7 +580,6 @@ import UserFeatureHelper from './helpers/user_feature_helper'; shortcut_handler = new ShortcutsWiki(); new ZenMode(); new gl.GLForm($('.wiki-form'), true); - new Sidebar(); break; case 'snippets': shortcut_handler = new ShortcutsNavigation(); diff --git a/app/assets/javascripts/new_sidebar.js b/app/assets/javascripts/new_sidebar.js index 3a3e6b14ec4..930218dd1f5 100644 --- a/app/assets/javascripts/new_sidebar.js +++ b/app/assets/javascripts/new_sidebar.js @@ -45,8 +45,10 @@ export default class NewNavSidebar { toggleCollapsedSidebar(collapsed) { this.$sidebar.toggleClass('sidebar-icons-only', collapsed); - this.$page.toggleClass('page-with-new-sidebar', !collapsed); - this.$page.toggleClass('page-with-icon-sidebar', collapsed); + if (this.$sidebar.length) { + this.$page.toggleClass('page-with-new-sidebar', !collapsed); + this.$page.toggleClass('page-with-icon-sidebar', collapsed); + } NewNavSidebar.setCollapsedCookie(collapsed); } diff --git a/app/assets/javascripts/project_select.js b/app/assets/javascripts/project_select.js index ebcefc819f5..1b4ed6be90a 100644 --- a/app/assets/javascripts/project_select.js +++ b/app/assets/javascripts/project_select.js @@ -1,5 +1,6 @@ /* eslint-disable func-names, space-before-function-paren, wrap-iife, prefer-arrow-callback, no-var, comma-dangle, object-shorthand, one-var, one-var-declaration-per-line, no-else-return, quotes, max-len */ import Api from './api'; +import ProjectSelectComboButton from './project_select_combo_button'; (function() { this.ProjectSelect = (function() { @@ -58,7 +59,8 @@ import Api from './api'; if (this.includeGroups) { placeholder += " or group"; } - return $(select).select2({ + + $(select).select2({ placeholder: placeholder, minimumInputLength: 0, query: (function(_this) { @@ -96,21 +98,18 @@ import Api from './api'; }; })(this), id: function(project) { - return project.web_url; + return JSON.stringify({ + name: project.name, + url: project.web_url, + }); }, text: function(project) { return project.name_with_namespace || project.name; }, dropdownCssClass: "ajax-project-dropdown" }); - }); - - $('.new-project-item-select-button').on('click', function() { - $('.project-item-select', this.parentNode).select2('open'); - }); - $('.project-item-select').on('click', function() { - window.location = `${$(this).val()}/${this.dataset.relativePath}`; + return new ProjectSelectComboButton(select); }); } diff --git a/app/assets/javascripts/project_select_combo_button.js b/app/assets/javascripts/project_select_combo_button.js new file mode 100644 index 00000000000..f799d9d619a --- /dev/null +++ b/app/assets/javascripts/project_select_combo_button.js @@ -0,0 +1,85 @@ +import AccessorUtilities from './lib/utils/accessor'; + +export default class ProjectSelectComboButton { + constructor(select) { + this.projectSelectInput = $(select); + this.newItemBtn = $('.new-project-item-link'); + this.newItemBtnBaseText = this.newItemBtn.data('label'); + this.itemType = this.deriveItemTypeFromLabel(); + this.groupId = this.projectSelectInput.data('groupId'); + + this.bindEvents(); + this.initLocalStorage(); + } + + bindEvents() { + this.projectSelectInput.siblings('.new-project-item-select-button') + .on('click', this.openDropdown); + + this.projectSelectInput.on('change', () => this.selectProject()); + } + + initLocalStorage() { + const localStorageIsSafe = AccessorUtilities.isLocalStorageAccessSafe(); + + if (localStorageIsSafe) { + const itemTypeKebabed = this.newItemBtnBaseText.toLowerCase().split(' ').join('-'); + + this.localStorageKey = ['group', this.groupId, itemTypeKebabed, 'recent-project'].join('-'); + this.setBtnTextFromLocalStorage(); + } + } + + openDropdown() { + $(this).siblings('.project-item-select').select2('open'); + } + + selectProject() { + const selectedProjectData = JSON.parse(this.projectSelectInput.val()); + const projectUrl = `${selectedProjectData.url}/${this.projectSelectInput.data('relativePath')}`; + const projectName = selectedProjectData.name; + + const projectMeta = { + url: projectUrl, + name: projectName, + }; + + this.setNewItemBtnAttributes(projectMeta); + this.setProjectInLocalStorage(projectMeta); + } + + setBtnTextFromLocalStorage() { + const cachedProjectData = this.getProjectFromLocalStorage(); + + this.setNewItemBtnAttributes(cachedProjectData); + } + + setNewItemBtnAttributes(project) { + if (project) { + this.newItemBtn.attr('href', project.url); + this.newItemBtn.text(`${this.newItemBtnBaseText} in ${project.name}`); + this.newItemBtn.enable(); + } else { + this.newItemBtn.text(`Select project to create ${this.itemType}`); + this.newItemBtn.disable(); + } + } + + deriveItemTypeFromLabel() { + // label is either 'New issue' or 'New merge request' + return this.newItemBtnBaseText.split(' ').slice(1).join(' '); + } + + getProjectFromLocalStorage() { + const projectString = localStorage.getItem(this.localStorageKey); + + return JSON.parse(projectString); + } + + setProjectInLocalStorage(projectMeta) { + const projectString = JSON.stringify(projectMeta); + + localStorage.setItem(this.localStorageKey, projectString); + } +} + diff --git a/app/assets/javascripts/projects/project_import_gitlab_project.js b/app/assets/javascripts/projects/project_import_gitlab_project.js new file mode 100644 index 00000000000..c34927499fc --- /dev/null +++ b/app/assets/javascripts/projects/project_import_gitlab_project.js @@ -0,0 +1,14 @@ +import '../lib/utils/url_utility'; + +const bindEvents = () => { + const path = gl.utils.getParameterValues('path')[0]; + + // get the path url and append it in the inputS + $('.js-path-name').val(path); +}; + +document.addEventListener('DOMContentLoaded', bindEvents); + +export default { + bindEvents, +}; diff --git a/app/assets/javascripts/projects/project_new.js b/app/assets/javascripts/projects/project_new.js index 1dc1dbf356d..985521aef34 100644 --- a/app/assets/javascripts/projects/project_new.js +++ b/app/assets/javascripts/projects/project_new.js @@ -1,7 +1,7 @@ let hasUserDefinedProjectPath = false; const deriveProjectPathFromUrl = ($projectImportUrl, $projectPath) => { - if ($projectImportUrl.attr('disabled') || hasUserDefinedProjectPath) { + if (hasUserDefinedProjectPath) { return; } @@ -27,8 +27,6 @@ const deriveProjectPathFromUrl = ($projectImportUrl, $projectPath) => { const bindEvents = () => { const $newProjectForm = $('#new_project'); - const importBtnTooltip = 'Please enter a valid project name.'; - const $importBtnWrapper = $('.import_gitlab_project'); const $projectImportUrl = $('#project_import_url'); const $projectPath = $('#project_path'); @@ -50,31 +48,15 @@ const bindEvents = () => { $('.btn_import_gitlab_project').attr('href', `${importHref}?namespace_id=${$('#project_namespace_id').val()}&path=${$projectPath.val()}`); }); - $('.btn_import_gitlab_project').attr('disabled', !$projectPath.val().trim().length); - $importBtnWrapper.attr('title', importBtnTooltip); - $newProjectForm.on('submit', () => { $projectPath.val($projectPath.val().trim()); }); $projectPath.on('keyup', () => { hasUserDefinedProjectPath = $projectPath.val().trim().length > 0; - if (hasUserDefinedProjectPath) { - $('.btn_import_gitlab_project').attr('disabled', false); - $importBtnWrapper.attr('title', ''); - $importBtnWrapper.removeClass('has-tooltip'); - } else { - $('.btn_import_gitlab_project').attr('disabled', true); - $importBtnWrapper.addClass('has-tooltip'); - } }); - $projectImportUrl.disable(); $projectImportUrl.keyup(() => deriveProjectPathFromUrl($projectImportUrl, $projectPath)); - - $('.import_git').on('click', () => { - $projectImportUrl.attr('disabled', !$projectImportUrl.attr('disabled')); - }); }; document.addEventListener('DOMContentLoaded', bindEvents); diff --git a/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue new file mode 100644 index 00000000000..422c02c7b7e --- /dev/null +++ b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue @@ -0,0 +1,82 @@ +<script> +/* global Flash */ +import editForm from './edit_form.vue'; + +export default { + components: { + editForm, + }, + props: { + isConfidential: { + required: true, + type: Boolean, + }, + isEditable: { + required: true, + type: Boolean, + }, + service: { + required: true, + type: Object, + }, + }, + data() { + return { + edit: false, + }; + }, + computed: { + faEye() { + const eye = this.isConfidential ? 'fa-eye-slash' : 'fa-eye'; + return { + [eye]: true, + }; + }, + }, + methods: { + toggleForm() { + this.edit = !this.edit; + }, + updateConfidentialAttribute(confidential) { + this.service.update('issue', { confidential }) + .then(() => location.reload()) + .catch(() => new Flash('Something went wrong trying to change the confidentiality of this issue')); + }, + }, +}; +</script> + +<template> + <div class="block confidentiality"> + <div class="sidebar-collapsed-icon"> + <i class="fa" :class="faEye" aria-hidden="true" data-hidden="true"></i> + </div> + <div class="title hide-collapsed"> + Confidentiality + <a + v-if="isEditable" + class="pull-right confidential-edit" + href="#" + @click.prevent="toggleForm" + > + Edit + </a> + </div> + <div class="value confidential-value hide-collapsed"> + <editForm + v-if="edit" + :toggle-form="toggleForm" + :is-confidential="isConfidential" + :update-confidential-attribute="updateConfidentialAttribute" + /> + <div v-if="!isConfidential" class="no-value confidential-value"> + <i class="fa fa-eye is-not-confidential"></i> + None + </div> + <div v-else class="value confidential-value hide-collapsed"> + <i aria-hidden="true" data-hidden="true" class="fa fa-eye-slash is-confidential"></i> + This issue is confidential + </div> + </div> + </div> +</template> diff --git a/app/assets/javascripts/sidebar/components/confidential/edit_form.vue b/app/assets/javascripts/sidebar/components/confidential/edit_form.vue new file mode 100644 index 00000000000..d578b663a54 --- /dev/null +++ b/app/assets/javascripts/sidebar/components/confidential/edit_form.vue @@ -0,0 +1,47 @@ +<script> +import editFormButtons from './edit_form_buttons.vue'; + +export default { + components: { + editFormButtons, + }, + props: { + isConfidential: { + required: true, + type: Boolean, + }, + toggleForm: { + required: true, + type: Function, + }, + updateConfidentialAttribute: { + required: true, + type: Function, + }, + }, +}; +</script> + +<template> + <div class="dropdown open"> + <div class="dropdown-menu confidential-warning-message"> + <div> + <p v-if="!isConfidential"> + You are going to turn on the confidentiality. This means that only team members with + <strong>at least Reporter access</strong> + are able to see and leave comments on the issue. + </p> + <p v-else> + You are going to turn off the confidentiality. This means + <strong>everyone</strong> + will be able to see and leave a comment on this issue. + </p> + <edit-form-buttons + :is-confidential="isConfidential" + :toggle-form="toggleForm" + :update-confidential-attribute="updateConfidentialAttribute" + /> + </div> + </div> + </div> +</template> diff --git a/app/assets/javascripts/sidebar/components/confidential/edit_form_buttons.vue b/app/assets/javascripts/sidebar/components/confidential/edit_form_buttons.vue new file mode 100644 index 00000000000..97af4a3f505 --- /dev/null +++ b/app/assets/javascripts/sidebar/components/confidential/edit_form_buttons.vue @@ -0,0 +1,45 @@ +<script> +export default { + props: { + isConfidential: { + required: true, + type: Boolean, + }, + toggleForm: { + required: true, + type: Function, + }, + updateConfidentialAttribute: { + required: true, + type: Function, + }, + }, + computed: { + onOrOff() { + return this.isConfidential ? 'Turn Off' : 'Turn On'; + }, + updateConfidentialBool() { + return !this.isConfidential; + }, + }, +}; +</script> + +<template> + <div class="confidential-warning-message-actions"> + <button + type="button" + class="btn btn-default append-right-10" + @click="toggleForm" + > + Cancel + </button> + <button + type="button" + class="btn btn-close" + @click.prevent="updateConfidentialAttribute(updateConfidentialBool)" + > + {{ onOrOff }} + </button> + </div> +</template> diff --git a/app/assets/javascripts/sidebar/sidebar_bundle.js b/app/assets/javascripts/sidebar/sidebar_bundle.js index a9df66748c5..9edded3ead6 100644 --- a/app/assets/javascripts/sidebar/sidebar_bundle.js +++ b/app/assets/javascripts/sidebar/sidebar_bundle.js @@ -1,6 +1,7 @@ import Vue from 'vue'; import sidebarTimeTracking from './components/time_tracking/sidebar_time_tracking'; import sidebarAssignees from './components/assignees/sidebar_assignees'; +import confidential from './components/confidential/confidential_issue_sidebar.vue'; import Mediator from './sidebar_mediator'; @@ -10,13 +11,28 @@ function domContentLoaded() { mediator.fetch(); const sidebarAssigneesEl = document.querySelector('#js-vue-sidebar-assignees'); - + const confidentialEl = document.querySelector('#js-confidential-entry-point'); // Only create the sidebarAssignees vue app if it is found in the DOM // We currently do not use sidebarAssignees for the MR page if (sidebarAssigneesEl) { new Vue(sidebarAssignees).$mount(sidebarAssigneesEl); } + if (confidentialEl) { + const dataNode = document.getElementById('js-confidential-issue-data'); + const initialData = JSON.parse(dataNode.innerHTML); + + const ConfidentialComp = Vue.extend(confidential); + + new ConfidentialComp({ + propsData: { + isConfidential: initialData.is_confidential, + isEditable: initialData.is_editable, + service: mediator.service, + }, + }).$mount(confidentialEl); + } + new Vue(sidebarTimeTracking).$mount('#issuable-time-tracker'); } diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_locked.js b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merging.js index a12f418e1af..f6d1a4feeb2 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_locked.js +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merging.js @@ -1,7 +1,7 @@ import statusIcon from '../mr_widget_status_icon'; export default { - name: 'MRWidgetLocked', + name: 'MRWidgetMerging', props: { mr: { type: Object, required: true }, }, @@ -13,7 +13,7 @@ export default { <status-icon status="loading" /> <div class="media-body"> <h4> - This merge request is in the process of being merged, during which time it is locked and cannot be closed + This merge request is in the process of being merged </h4> <section class="mr-info-list"> <p> diff --git a/app/assets/javascripts/vue_merge_request_widget/dependencies.js b/app/assets/javascripts/vue_merge_request_widget/dependencies.js index 546a3f625c7..49340c232c8 100644 --- a/app/assets/javascripts/vue_merge_request_widget/dependencies.js +++ b/app/assets/javascripts/vue_merge_request_widget/dependencies.js @@ -19,7 +19,7 @@ export { default as WidgetRelatedLinks } from './components/mr_widget_related_li export { default as MergedState } from './components/states/mr_widget_merged'; export { default as FailedToMerge } from './components/states/mr_widget_failed_to_merge'; export { default as ClosedState } from './components/states/mr_widget_closed'; -export { default as LockedState } from './components/states/mr_widget_locked'; +export { default as MergingState } from './components/states/mr_widget_merging'; export { default as WipState } from './components/states/mr_widget_wip'; export { default as ArchivedState } from './components/states/mr_widget_archived'; export { default as ConflictsState } from './components/states/mr_widget_conflicts'; diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js index 577d77f09a6..0042c48816f 100644 --- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js +++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js @@ -8,7 +8,7 @@ import { WidgetRelatedLinks, MergedState, ClosedState, - LockedState, + MergingState, WipState, ArchivedState, ConflictsState, @@ -212,7 +212,7 @@ export default { 'mr-widget-related-links': WidgetRelatedLinks, 'mr-widget-merged': MergedState, 'mr-widget-closed': ClosedState, - 'mr-widget-locked': LockedState, + 'mr-widget-merging': MergingState, 'mr-widget-failed-to-merge': FailedToMerge, 'mr-widget-wip': WipState, 'mr-widget-archived': ArchivedState, diff --git a/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js b/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js index fddafb0ddfa..fbea764b739 100644 --- a/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js +++ b/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js @@ -73,6 +73,7 @@ export default class MergeRequestStore { this.canCancelAutomaticMerge = !!data.cancel_merge_when_pipeline_succeeds_path; this.hasSHAChanged = this.sha !== data.diff_head_sha; this.canBeMerged = data.can_be_merged || false; + this.mergeOngoing = data.merge_ongoing; // Cherry-pick and Revert actions related this.canCherryPickInCurrentMR = currentUser.can_cherry_pick_on_current_merge_request || false; @@ -94,6 +95,11 @@ export default class MergeRequestStore { } setState(data) { + if (this.mergeOngoing) { + this.state = 'merging'; + return; + } + if (this.isOpen) { this.state = getStateKey.call(this, data); } else { @@ -104,9 +110,6 @@ export default class MergeRequestStore { case 'closed': this.state = 'closed'; break; - case 'locked': - this.state = 'locked'; - break; default: this.state = null; } diff --git a/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js b/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js index 605dd3a1ff4..9074a064a6d 100644 --- a/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js +++ b/app/assets/javascripts/vue_merge_request_widget/stores/state_maps.js @@ -1,7 +1,7 @@ const stateToComponentMap = { merged: 'mr-widget-merged', closed: 'mr-widget-closed', - locked: 'mr-widget-locked', + merging: 'mr-widget-merging', conflicts: 'mr-widget-conflicts', missingBranch: 'mr-widget-missing-branch', workInProgress: 'mr-widget-wip', @@ -20,7 +20,7 @@ const stateToComponentMap = { }; const statesToShowHelpWidget = [ - 'locked', + 'merging', 'conflicts', 'workInProgress', 'readyToMerge', diff --git a/app/assets/javascripts/wikis.js b/app/assets/javascripts/wikis.js index 00676bcb0b3..51ed2b4fd15 100644 --- a/app/assets/javascripts/wikis.js +++ b/app/assets/javascripts/wikis.js @@ -1,6 +1,5 @@ /* global Breakpoints */ -import 'vendor/jquery.nicescroll'; import './breakpoints'; export default class Wikis { @@ -8,7 +7,6 @@ export default class Wikis { this.bp = Breakpoints.get(); this.sidebarEl = document.querySelector('.js-wiki-sidebar'); this.sidebarExpanded = false; - $(this.sidebarEl).niceScroll(); const sidebarToggles = document.querySelectorAll('.js-sidebar-wiki-toggle'); for (let i = 0; i < sidebarToggles.length; i += 1) { diff --git a/app/assets/stylesheets/framework/avatar.scss b/app/assets/stylesheets/framework/avatar.scss index cb41df8a88d..486d88efbc5 100644 --- a/app/assets/stylesheets/framework/avatar.scss +++ b/app/assets/stylesheets/framework/avatar.scss @@ -100,6 +100,8 @@ margin: 0; align-self: center; } + + &.s40 { min-width: 40px; min-height: 40px; } } .avatar-counter { diff --git a/app/assets/stylesheets/framework/layout.scss b/app/assets/stylesheets/framework/layout.scss index bab56174c4c..bd0367f86dd 100644 --- a/app/assets/stylesheets/framework/layout.scss +++ b/app/assets/stylesheets/framework/layout.scss @@ -109,16 +109,8 @@ body { } } - -/* The following prevents side effects related to iOS Safari's implementation of -webkit-overflow-scrolling: touch, -which is applied to the body by jquery.nicescroling plugin to force hardware acceleration for momentum scrolling. Side -effects are commonly related to inconsisent z-index behavior (e.g. tooltips). By applying the following to direct children -of the body element here, we negate cascading side effects but allow momentum scrolling to be applied to the body */ - -.navbar, -.page-gutter, -.page-with-sidebar { - -webkit-overflow-scrolling: auto; +.page-with-sidebar > .content-wrapper { + min-height: calc(100vh - #{$header-height}); } .with-performance-bar .page-with-sidebar { diff --git a/app/assets/stylesheets/framework/nav.scss b/app/assets/stylesheets/framework/nav.scss index 88e7ba117d5..d386ac5ba9c 100644 --- a/app/assets/stylesheets/framework/nav.scss +++ b/app/assets/stylesheets/framework/nav.scss @@ -251,7 +251,6 @@ // Applies on /dashboard/issues .project-item-select-holder { - display: block; margin: 0; } } @@ -283,6 +282,31 @@ } } +.project-item-select-holder.btn-group { + display: flex; + max-width: 350px; + overflow: hidden; + + @media(max-width: $screen-xs-max) { + width: 100%; + max-width: none; + } + + .new-project-item-link { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + .new-project-item-select-button { + width: 32px; + } +} + +.new-project-item-select-button .fa-caret-down { + margin-left: 2px; +} + .layout-nav { width: 100%; background: $gray-light; diff --git a/app/assets/stylesheets/framework/sidebar.scss b/app/assets/stylesheets/framework/sidebar.scss index 09b60ad1676..40e8a928e6e 100644 --- a/app/assets/stylesheets/framework/sidebar.scss +++ b/app/assets/stylesheets/framework/sidebar.scss @@ -78,15 +78,12 @@ .right-sidebar { border-left: 1px solid $border-color; + height: calc(100% - #{$header-height}); &.affix { position: fixed; top: $header-height; } - - &:not(.affix-top) { - min-height: 100%; - } } .with-performance-bar .right-sidebar.affix { diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index 7e64a793f14..3c109a5a929 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -637,3 +637,11 @@ $perf-bar-bucket-bg: #111; $perf-bar-bucket-color: #ccc; $perf-bar-bucket-box-shadow-from: rgba($white-light, .2); $perf-bar-bucket-box-shadow-to: rgba($black, .25); + + +/* +Project Templates Icons +*/ +$rails: #c00; +$node: #353535; +$java: #70ad51; diff --git a/app/assets/stylesheets/new_sidebar.scss b/app/assets/stylesheets/new_sidebar.scss index 10c9c97df0e..76dccd2df56 100644 --- a/app/assets/stylesheets/new_sidebar.scss +++ b/app/assets/stylesheets/new_sidebar.scss @@ -15,7 +15,9 @@ $new-sidebar-width: 220px; $new-sidebar-collapsed-width: 50px; .page-with-new-sidebar { - padding-left: $new-sidebar-collapsed-width; + @media (min-width: $screen-md-min) { + padding-left: $new-sidebar-collapsed-width; + } @media (min-width: $screen-lg-min) { padding-left: $new-sidebar-width; @@ -24,7 +26,7 @@ $new-sidebar-collapsed-width: 50px; // Override position: absolute .right-sidebar { position: fixed; - height: 100%; + height: calc(100% - #{$header-height}); } .issues-bulk-update.right-sidebar.right-sidebar-expanded .issuable-sidebar-header { @@ -49,10 +51,6 @@ $new-sidebar-collapsed-width: 50px; align-items: center; padding: 10px 16px 10px 10px; color: $gl-text-color; - - @media (max-width: $screen-xs-max) { - padding-right: 30px; - } } &:hover, @@ -77,26 +75,6 @@ $new-sidebar-collapsed-width: 50px; overflow: hidden; text-overflow: ellipsis; } - - .close-nav-button { - display: none; - position: absolute; - top: 0; - right: 0; - height: 100%; - background-color: transparent; - border: 0; - padding: 0 10px; - color: $gl-text-color-secondary; - - @media (max-width: $screen-xs-max) { - display: block; - } - - &:hover { - color: $gl-text-color; - } - } } .settings-avatar { @@ -339,21 +317,19 @@ $new-sidebar-collapsed-width: 50px; // Collapsed nav -.toggle-sidebar-button { +.toggle-sidebar-button, +.close-nav-button { width: $new-sidebar-width - 2px; position: fixed; bottom: 0; padding: 16px; background-color: $gray-normal; + border: 0; border-top: 2px solid $border-color; color: $gl-text-color-secondary; display: flex; align-items: center; - @media (max-width: $screen-xs-max) { - display: none; - } - i { font-size: 20px; margin-right: 8px; @@ -369,6 +345,13 @@ $new-sidebar-collapsed-width: 50px; } } +.toggle-sidebar-button { + @media (max-width: $screen-xs-max) { + display: none; + } +} + + .sidebar-icons-only { .context-header { height: 60px; @@ -400,6 +383,7 @@ $new-sidebar-collapsed-width: 50px; .toggle-sidebar-button { width: $new-sidebar-collapsed-width - 2px; + padding: 16px 18px; .collapse-text, .fa-angle-double-left { @@ -415,6 +399,10 @@ $new-sidebar-collapsed-width: 50px; // Mobile nav +.close-nav-button { + display: none; +} + .toggle-mobile-nav { display: none; background-color: transparent; @@ -434,6 +422,12 @@ $new-sidebar-collapsed-width: 50px; } } +@media (max-width: $screen-xs-max) { + .close-nav-button { + display: flex; + } +} + .mobile-overlay { display: none; diff --git a/app/assets/stylesheets/pages/boards.scss b/app/assets/stylesheets/pages/boards.scss index 6039cda96d8..e5b467a2691 100644 --- a/app/assets/stylesheets/pages/boards.scss +++ b/app/assets/stylesheets/pages/boards.scss @@ -165,6 +165,7 @@ .board-title { padding-top: ($gl-padding - 3px); + padding-bottom: $gl-padding; } } } @@ -178,6 +179,7 @@ position: relative; margin: 0; padding: $gl-padding; + padding-bottom: ($gl-padding + 3px); font-size: 1em; border-bottom: 1px solid $border-color; } diff --git a/app/assets/stylesheets/pages/builds.scss b/app/assets/stylesheets/pages/builds.scss index 28c99d8e57c..486424fb729 100644 --- a/app/assets/stylesheets/pages/builds.scss +++ b/app/assets/stylesheets/pages/builds.scss @@ -235,8 +235,18 @@ display: none; } + .sidebar-container { + width: calc(100% + 100px); + padding-right: 100px; + height: 100%; + overflow-y: scroll; + overflow-x: hidden; + -webkit-overflow-scrolling: touch; + } + .blocks-container { padding: 0 $gl-padding; + width: 289px; } .block { @@ -259,7 +269,15 @@ padding: 16px 0; } + .trigger-build-variables { + margin: 0; + overflow-x: auto; + -ms-overflow-style: scrollbar; + -webkit-overflow-scrolling: touch; + } + .trigger-build-variable { + font-weight: normal; color: $code-color; } @@ -326,6 +344,7 @@ border-top: 1px solid $border-color; border-bottom: 1px solid $border-color; max-height: 300px; + width: 289px; overflow: auto; svg { diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index 88343bd0113..b78db402c13 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -5,6 +5,30 @@ margin-right: auto; } +.is-confidential { + color: $orange-600; + background-color: $orange-50; + border-radius: 3px; + padding: 5px; + margin: 0 3px 0 -4px; +} + +.is-not-confidential { + border-radius: 3px; + padding: 5px; + margin: 0 3px 0 -4px; +} + +.confidentiality { + .is-not-confidential { + margin: auto; + } + + .is-confidential { + margin: auto; + } +} + .limit-container-width { .detail-page-header, .page-content-header, diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss index cdb1e65e4be..c90642178fc 100644 --- a/app/assets/stylesheets/pages/note_form.scss +++ b/app/assets/stylesheets/pages/note_form.scss @@ -104,40 +104,51 @@ } .confidential-issue-warning { - background-color: $gray-normal; - border-radius: 3px; + color: $orange-600; + background-color: $orange-50; + border-radius: $border-radius-default $border-radius-default 0 0; + border: 1px solid $border-gray-normal; padding: 3px 12px; margin: auto; - margin-top: 0; - text-align: center; - font-size: 12px; align-items: center; +} - @media (max-width: $screen-md-max) { - // On smaller devices the warning becomes the fourth item in the list, - // rather than centering, and grows to span the full width of the - // comment area. - order: 4; - margin: 6px auto; - width: 100%; +.confidential-value { + .fa { + background-color: inherit; } +} - .fa { - margin-right: 8px; +.confidential-warning-message { + line-height: 1.5; + padding: 16px; + + .confidential-warning-message-actions { + display: flex; + + button { + flex-grow: 1; + } } } +.not-confidential { + padding: 0; + border-top: none; +} + .right-sidebar-expanded { - .confidential-issue-warning { - // When the sidebar is open the warning becomes the fourth item in the list, - // rather than centering, and grows to span the full width of the - // comment area. - order: 4; - margin: 6px auto; - width: 100%; + .md-area { + border-radius: 0; + border-top: none; } } +.right-sidebar-collapsed { + .confidential-issue-warning { + border-bottom: none; + } +} .discussion-form { padding: $gl-padding-top $gl-padding $gl-padding; diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index 73603f20ef6..276465488e7 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -7,7 +7,8 @@ } .new_project, -.edit-project { +.edit-project, +.import-project { .sharing-and-permissions { .header { @@ -457,6 +458,7 @@ a.deploy-project-label { } } +.project-template, .project-import { .form-group { margin-bottom: 5px; @@ -471,7 +473,44 @@ a.deploy-project-label { .btn { padding: 8px; - margin-left: 10px; + margin-right: 10px; + } + + .blank-option { + min-width: 70px; + } + + .btn-template-icon { + height: 24px; + width: inherit; + display: block; + margin: 0 auto 4px; + font-size: 24px; + + @media (min-width: $screen-xs-max) { + top: 0; + } + } + + @media (max-width: $screen-xs-max) { + .btn-template-icon { + display: inline-block; + height: 14px; + font-size: 14px; + margin: 0; + } + } + + .icon-rails path { + fill: $rails; + } + + .icon-node-express path { + fill: $node; + } + + .icon-java-spring path { + fill: $java; } > div { @@ -481,6 +520,97 @@ a.deploy-project-label { } } +.project-templates-buttons .btn:last-child { + margin-right: 0; +} + +.create-project-options { + display: flex; + + @media (max-width: $screen-xs-max) { + display: block; + } + + .first-column { + @media(min-width: $screen-xs-min) { + max-width: 50%; + padding-right: 30px; + } + + @media(max-width: $screen-xs-max) { + max-width: 100%; + width: 100%; + } + } + + .second-column { + @media(min-width: $screen-xs-min) { + width: 50%; + flex: 1; + padding-left: 30px; + position: relative; + } + + @media(max-width: $screen-xs-max) { + max-width: 100%; + width: 100%; + padding-left: 0; + position: relative; + } + + // Mobile + @media (max-width: $screen-xs-max) { + padding-top: 30px; + } + + &::before { + content: "OR"; + position: absolute; + left: 0; + top: 40%; + z-index: 10; + padding: 8px 0; + text-align: center; + background-color: $white-light; + color: $gl-text-color-tertiary; + transform: translateX(-50%); + font-size: 12px; + font-weight: bold; + line-height: 20px; + + // Mobile + @media (max-width: $screen-xs-max) { + left: 50%; + top: 10px; + transform: translateY(-50%); + padding: 0 8px; + } + } + + &::after { + content: ""; + position: absolute; + background-color: $border-color; + bottom: 0; + left: 0; + right: auto; + height: 100%; + width: 1px; + top: 0; + + // Mobile + @media (max-width: $screen-xs-max) { + top: 10px; + left: 10px; + right: 10px; + height: 1px; + width: auto; + } + } + } +} + + .project-stats { font-size: 0; text-align: center; diff --git a/app/assets/stylesheets/pages/wiki.scss b/app/assets/stylesheets/pages/wiki.scss index 45c21c5d274..fa6bdd297eb 100644 --- a/app/assets/stylesheets/pages/wiki.scss +++ b/app/assets/stylesheets/pages/wiki.scss @@ -95,12 +95,22 @@ } .right-sidebar.wiki-sidebar { - padding: $gl-padding 0; + padding: 0; &.right-sidebar-collapsed { display: none; } + .sidebar-container { + padding: $gl-padding 0; + width: calc(100% + 100px); + padding-right: 100px; + height: 100%; + overflow-y: scroll; + overflow-x: hidden; + -webkit-overflow-scrolling: touch; + } + .blocks-container { padding: 0 $gl-padding; } diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb index 36d246d185b..510813846a4 100644 --- a/app/controllers/import/gitlab_projects_controller.rb +++ b/app/controllers/import/gitlab_projects_controller.rb @@ -12,15 +12,7 @@ class Import::GitlabProjectsController < Import::BaseController return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive." }) end - import_upload_path = Gitlab::ImportExport.import_upload_path(filename: project_params[:file].original_filename) - - FileUtils.mkdir_p(File.dirname(import_upload_path)) - FileUtils.copy_entry(project_params[:file].path, import_upload_path) - - @project = Gitlab::ImportExport::ProjectCreator.new(project_params[:namespace_id], - current_user, - import_upload_path, - project_params[:path]).execute + @project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute if @project.saved? redirect_to( diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 323d5d26eb6..b4213574561 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -34,12 +34,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController if @user.two_factor_enabled? prompt_for_two_factor(@user) else - log_audit_event(@user, with: :ldap) + log_audit_event(@user, with: oauth['provider']) sign_in_and_redirect(@user) end else - flash[:alert] = "Access denied for your LDAP account." - redirect_to new_user_session_path + fail_ldap_login end end @@ -123,9 +122,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController sign_in_and_redirect(@user) end else - error_message = @user.errors.full_messages.to_sentence - - return redirect_to omniauth_error_path(oauth['provider'], error: error_message) + fail_login end end @@ -145,6 +142,18 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController def oauth @oauth ||= request.env['omniauth.auth'] end + + def fail_login + error_message = @user.errors.full_messages.to_sentence + + return redirect_to omniauth_error_path(oauth['provider'], error: error_message) + end + + def fail_ldap_login + flash[:alert] = 'Access denied for your LDAP account.' + + redirect_to new_user_session_path + end def log_audit_event(user, options = {}) AuditEventService.new(user, user, options) diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index d361e661d0e..4de814d0ca8 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -67,11 +67,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo @noteable = @merge_request @commits_count = @merge_request.commits_count - if @merge_request.locked_long_ago? - @merge_request.unlock_mr - @merge_request.close - end - labels set_pipeline_variables diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ce0938ffe99..8dfe0f51709 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -337,6 +337,7 @@ class ProjectsController < Projects::ApplicationController :runners_token, :tag_list, :visibility_level, + :template_name, project_feature_attributes: %i[ builds_access_level diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 22f637946d9..bcee81bdc15 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -306,6 +306,10 @@ module ApplicationHelper cookies["new_nav"] == "true" end + def collapsed_sidebar? + cookies["sidebar_collapsed"] == "true" + end + def show_new_repo? cookies["new_repo"] == "true" && body_data_page != 'projects:show' end diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 0e068d4b51c..4b51269533c 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -19,7 +19,8 @@ module AvatarsHelper class: %W[avatar has-tooltip s#{avatar_size}].push(*options[:css_class]), alt: "#{user_name}'s avatar", title: user_name, - data: data_attributes + data: data_attributes, + lazy: true ) end diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 1f7db9b2eb8..d4a91e533c1 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -47,14 +47,6 @@ module GitlabRoutingHelper project_pipeline_path(pipeline.project, pipeline.id, *args) end - def milestone_path(entity, *args) - if entity.is_group_milestone? - group_milestone_path(entity.group, entity, *args) - elsif entity.is_project_milestone? - project_milestone_path(entity.project, entity, *args) - end - end - def issue_url(entity, *args) project_issue_url(entity.project, entity, *args) end @@ -67,14 +59,6 @@ module GitlabRoutingHelper project_pipeline_url(pipeline.project, pipeline.id, *args) end - def milestone_url(entity, *args) - if entity.is_group_milestone? - group_milestone_url(entity.group, entity, *args) - elsif entity.is_project_milestone? - project_milestone_url(entity.project, entity, *args) - end - end - def pipeline_job_url(pipeline, build, *args) project_job_url(pipeline.project, build.id, *args) end diff --git a/app/helpers/milestones_routing_helper.rb b/app/helpers/milestones_routing_helper.rb new file mode 100644 index 00000000000..766d5262018 --- /dev/null +++ b/app/helpers/milestones_routing_helper.rb @@ -0,0 +1,17 @@ +module MilestonesRoutingHelper + def milestone_path(milestone, *args) + if milestone.is_group_milestone? + group_milestone_path(milestone.group, milestone, *args) + elsif milestone.is_project_milestone? + project_milestone_path(milestone.project, milestone, *args) + end + end + + def milestone_url(milestone, *args) + if milestone.is_group_milestone? + group_milestone_url(milestone.group, milestone, *args) + elsif milestone.is_project_milestone? + project_milestone_url(milestone.project, milestone, *args) + end + end +end diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index b1205b8529b..b63b3b70903 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -2,6 +2,7 @@ module NavHelper def page_with_sidebar_class class_name = page_gutter_class class_name << 'page-with-new-sidebar' if defined?(@new_sidebar) && @new_sidebar + class_name << 'page-with-icon-sidebar' if collapsed_sidebar? && @new_sidebar class_name end diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 935ffe343ff..3731b7c8577 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -16,6 +16,7 @@ module Issuable include TimeTrackable include Importable include Editable + include AfterCommitQueue # This object is used to gather issuable meta data for displaying # upvotes, downvotes, notes and closing merge requests count for issues and merge requests diff --git a/app/models/conversational_development_index/metric.rb b/app/models/conversational_development_index/metric.rb index f42f516f99a..0bee62f954f 100644 --- a/app/models/conversational_development_index/metric.rb +++ b/app/models/conversational_development_index/metric.rb @@ -13,9 +13,7 @@ module ConversationalDevelopmentIndex end def percentage_score(feature) - return 100 if leader_score(feature).zero? - - 100 * instance_score(feature) / leader_score(feature) + self["percentage_#{feature}"] end end end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 8ca850b6d96..e83b11f7668 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -8,6 +8,7 @@ class MergeRequest < ActiveRecord::Base include CreatedAtFilterable ignore_column :position + ignore_column :locked_at belongs_to :target_project, class_name: "Project" belongs_to :source_project, class_name: "Project" @@ -61,16 +62,6 @@ class MergeRequest < ActiveRecord::Base transition locked: :opened end - after_transition any => :locked do |merge_request, transition| - merge_request.locked_at = Time.now - merge_request.save - end - - after_transition locked: (any - :locked) do |merge_request, transition| - merge_request.locked_at = nil - merge_request.save - end - state :opened state :closed state :merged @@ -392,6 +383,12 @@ class MergeRequest < ActiveRecord::Base 'Source project is not a fork of the target project' end + def merge_ongoing? + return false unless merge_jid + + Gitlab::SidekiqStatus.num_running([merge_jid]) > 0 + end + def closed_without_fork? closed? && source_project_missing? end @@ -725,12 +722,6 @@ class MergeRequest < ActiveRecord::Base end end - def locked_long_ago? - return false unless locked? - - locked_at.nil? || locked_at < (Time.now - 1.day) - end - def has_ci? has_ci_integration = source_project.try(:ci_service) uses_gitlab_ci = all_pipelines.any? diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 48d00764965..01e0d0155a3 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -149,7 +149,9 @@ class Milestone < ActiveRecord::Base end ## - # Returns the String necessary to reference this Milestone in Markdown + # Returns the String necessary to reference this Milestone in Markdown. Group + # milestones only support name references, and do not support cross-project + # references. # # format - Symbol format to use (default: :iid, optional: :name) # @@ -161,12 +163,16 @@ class Milestone < ActiveRecord::Base # Milestone.first.to_reference(same_namespace_project) # => "gitlab-ce%1" # def to_reference(from_project = nil, format: :iid, full: false) - return if is_group_milestone? + return if is_group_milestone? && format != :name format_reference = milestone_format_reference(format) reference = "#{self.class.reference_prefix}#{format_reference}" - "#{project.to_reference(from_project, full: full)}#{reference}" + if project + "#{project.to_reference(from_project, full: full)}#{reference}" + else + reference + end end def reference_link_text(from_project = nil) diff --git a/app/models/project.rb b/app/models/project.rb index 09b1305739c..e7baba2ef08 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -75,6 +75,7 @@ class Project < ActiveRecord::Base attr_accessor :new_default_branch attr_accessor :old_path_with_namespace + attr_accessor :template_name attr_writer :pipeline_status alias_attribute :title, :name @@ -163,7 +164,7 @@ class Project < ActiveRecord::Base has_many :todos has_many :notification_settings, as: :source, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent - has_one :import_data, class_name: 'ProjectImportData' + has_one :import_data, class_name: 'ProjectImportData', inverse_of: :project, autosave: true has_one :project_feature has_one :statistics, class_name: 'ProjectStatistics' @@ -192,6 +193,7 @@ class Project < ActiveRecord::Base accepts_nested_attributes_for :variables, allow_destroy: true accepts_nested_attributes_for :project_feature + accepts_nested_attributes_for :import_data delegate :name, to: :owner, allow_nil: true, prefix: true delegate :count, to: :forks, prefix: true @@ -588,8 +590,6 @@ class Project < ActiveRecord::Base project_import_data.credentials ||= {} project_import_data.credentials = project_import_data.credentials.merge(credentials) end - - project_import_data.save end def import? diff --git a/app/models/project_import_data.rb b/app/models/project_import_data.rb index 37730474324..6da6632f4f2 100644 --- a/app/models/project_import_data.rb +++ b/app/models/project_import_data.rb @@ -1,7 +1,7 @@ require 'carrierwave/orm/activerecord' class ProjectImportData < ActiveRecord::Base - belongs_to :project + belongs_to :project, inverse_of: :import_data attr_encrypted :credentials, key: Gitlab::Application.secrets.db_key_base, marshal: true, diff --git a/app/models/repository.rb b/app/models/repository.rb index f86a0869b01..3b5d0e00c70 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -130,17 +130,13 @@ class Repository return [] end - ref ||= root_ref - - args = %W( - log #{ref} --pretty=%H --skip #{offset} - --max-count #{limit} --grep=#{query} --regexp-ignore-case - ) - args = args.concat(%W(-- #{path})) if path.present? - - git_log_results = run_git(args).first.lines - - git_log_results.map { |c| commit(c.chomp) }.compact + raw_repository.gitaly_migrate(:commits_by_message) do |is_enabled| + if is_enabled + find_commits_by_message_by_gitaly(query, ref, path, limit, offset) + else + find_commits_by_message_by_shelling_out(query, ref, path, limit, offset) + end + end end def find_branch(name, fresh_repo: true) @@ -1184,4 +1180,25 @@ class Repository def circuit_breaker @circuit_breaker ||= Gitlab::Git::Storage::CircuitBreaker.for_storage(project.repository_storage) end + + def find_commits_by_message_by_shelling_out(query, ref, path, limit, offset) + ref ||= root_ref + + args = %W( + log #{ref} --pretty=%H --skip #{offset} + --max-count #{limit} --grep=#{query} --regexp-ignore-case + ) + args = args.concat(%W(-- #{path})) if path.present? + + git_log_results = run_git(args).first.lines + + git_log_results.map { |c| commit(c.chomp) }.compact + end + + def find_commits_by_message_by_gitaly(query, ref, path, limit, offset) + raw_repository + .gitaly_commit_client + .commits_by_message(query, revision: ref, path: path, limit: limit, offset: offset) + .map { |c| commit(c) } + end end diff --git a/app/serializers/merge_request_entity.rb b/app/serializers/merge_request_entity.rb index 7f17f2bf604..07650ce6f20 100644 --- a/app/serializers/merge_request_entity.rb +++ b/app/serializers/merge_request_entity.rb @@ -2,7 +2,6 @@ class MergeRequestEntity < IssuableEntity include RequestAwareEntity expose :in_progress_merge_commit_sha - expose :locked_at expose :merge_commit_sha expose :merge_error expose :merge_params @@ -32,6 +31,7 @@ class MergeRequestEntity < IssuableEntity expose :head_pipeline, with: PipelineDetailsEntity, as: :pipeline # Booleans + expose :merge_ongoing?, as: :merge_ongoing expose :work_in_progress?, as: :work_in_progress expose :source_branch_exists?, as: :source_branch_exists expose :mergeable_discussions_state?, as: :mergeable_discussions_state diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index b951e8d0c9f..fc87bd6a659 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -30,6 +30,7 @@ module Ci # with StateMachines::InvalidTransition or StaleObjectError when doing run! or save method. build.runner_id = runner.id build.run! + register_success(build) return Result.new(build, true) rescue StateMachines::InvalidTransition, ActiveRecord::StaleObjectError @@ -46,6 +47,7 @@ module Ci end end + register_failure Result.new(nil, valid) end @@ -81,5 +83,27 @@ module Ci def shared_runner_build_limits_feature_enabled? ENV['DISABLE_SHARED_RUNNER_BUILD_MINUTES_LIMIT'].to_s != 'true' end + + def register_failure + failed_attempt_counter.increase + attempt_counter.increase + end + + def register_success(job) + job_queue_duration_seconds.observe({ shared_runner: @runner.shared? }, Time.now - job.created_at) + attempt_counter.increase + end + + def failed_attempt_counter + @failed_attempt_counter ||= Gitlab::Metrics.counter(:job_register_attempts_failed_total, "Counts the times a runner tries to register a job") + end + + def attempt_counter + @attempt_counter ||= Gitlab::Metrics.counter(:job_register_attempts_total, "Counts the times a runner tries to register a job") + end + + def job_queue_duration_seconds + @job_queue_duration_seconds ||= Gitlab::Metrics.histogram(:job_queue_duration_seconds, 'Request handling execution time') + end end end diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 760a15e3ed0..b84a6fd2b7d 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -2,11 +2,8 @@ class IssuableBaseService < BaseService private def create_milestone_note(issuable) - milestone = issuable.milestone - return if milestone && milestone.is_group_milestone? - SystemNoteService.change_milestone( - issuable, issuable.project, current_user, milestone) + issuable, issuable.project, current_user, issuable.milestone) end def create_labels_note(issuable, old_labels) @@ -182,7 +179,6 @@ class IssuableBaseService < BaseService if params.present? && create_issuable(issuable, params, label_ids: label_ids) after_create(issuable) - issuable.create_cross_references!(current_user) execute_hooks(issuable) invalidate_cache_counts(issuable, users: issuable.assignees) end diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 718a7ac1f22..9114f0ccc81 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -15,11 +15,14 @@ module Issues def before_create(issue) spam_check(issue, current_user) issue.move_to_end + + user = current_user + issue.run_after_commit do + NewIssueWorker.perform_async(issue.id, user.id) + end end def after_create(issuable) - event_service.open_issue(issuable, current_user) - notification_service.new_issue(issuable, current_user) todo_service.new_issue(issuable, current_user) user_agent_detail_service.create resolve_discussions_with_issue(issuable) diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb index 5414fa79def..7d539fa49e6 100644 --- a/app/services/merge_requests/create_service.rb +++ b/app/services/merge_requests/create_service.rb @@ -16,9 +16,15 @@ module MergeRequests create(merge_request) end + def before_create(merge_request) + user = current_user + merge_request.run_after_commit do + NewMergeRequestWorker.perform_async(merge_request.id, user.id) + end + end + def after_create(issuable) event_service.open_mr(issuable, current_user) - notification_service.new_merge_request(issuable, current_user) todo_service.new_merge_request(issuable, current_user) issuable.cache_merge_request_closes_issues!(current_user) update_merge_requests_head_pipeline(issuable) diff --git a/app/services/projects/autocomplete_service.rb b/app/services/projects/autocomplete_service.rb index fc85f398935..724a77c873a 100644 --- a/app/services/projects/autocomplete_service.rb +++ b/app/services/projects/autocomplete_service.rb @@ -5,7 +5,15 @@ module Projects end def milestones - @project.milestones.active.reorder(due_date: :asc, title: :asc).select([:iid, :title]) + finder_params = { + project_ids: [@project.id], + state: :active, + order: { due_date: :asc, title: :asc } + } + + finder_params[:group_ids] = [@project.group.id] if @project.group + + MilestonesFinder.new(finder_params).execute.select([:iid, :title]) end def merge_requests diff --git a/app/services/projects/create_from_template_service.rb b/app/services/projects/create_from_template_service.rb new file mode 100644 index 00000000000..87d9ed7a0e6 --- /dev/null +++ b/app/services/projects/create_from_template_service.rb @@ -0,0 +1,15 @@ +module Projects + class CreateFromTemplateService < BaseService + def initialize(user, params) + @current_user, @params = user, params.dup + end + + def execute + params[:file] = Gitlab::ProjectTemplate.find(params[:template_name]).file + + GitlabProjectsImportService.new(@current_user, @params).execute + ensure + params[:file]&.close + end + end +end diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index e874a2d8789..48578b6d9e5 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -5,6 +5,10 @@ module Projects end def execute + if @params[:template_name]&.present? + return ::Projects::CreateFromTemplateService.new(current_user, params).execute + end + forked_from_project_id = params.delete(:forked_from_project_id) import_data = params.delete(:import_data) @skip_wiki = params.delete(:skip_wiki) diff --git a/app/services/projects/gitlab_projects_import_service.rb b/app/services/projects/gitlab_projects_import_service.rb new file mode 100644 index 00000000000..4ca6414b73b --- /dev/null +++ b/app/services/projects/gitlab_projects_import_service.rb @@ -0,0 +1,36 @@ +# This service is an adapter used to for the GitLab Import feature, and +# creating a project from a template. +# The latter will under the hood just import an archive supplied by GitLab. +module Projects + class GitlabProjectsImportService + attr_reader :current_user, :params + + def initialize(user, params) + @current_user, @params = user, params.dup + end + + def execute + FileUtils.mkdir_p(File.dirname(import_upload_path)) + FileUtils.copy_entry(file.path, import_upload_path) + + Gitlab::ImportExport::ProjectCreator.new(params[:namespace_id], + current_user, + import_upload_path, + params[:path]).execute + end + + private + + def import_upload_path + @import_upload_path ||= Gitlab::ImportExport.import_upload_path(filename: tmp_filename) + end + + def tmp_filename + "#{SecureRandom.hex}_#{params[:path]}" + end + + def file + params[:file] + end + end +end diff --git a/app/services/projects/import_service.rb b/app/services/projects/import_service.rb index 50ec3651515..c3bf0031409 100644 --- a/app/services/projects/import_service.rb +++ b/app/services/projects/import_service.rb @@ -34,8 +34,12 @@ module Projects def import_repository raise Error, 'Blocked import URL.' if Gitlab::UrlBlocker.blocked_url?(project.import_url) + # We should return early for a GitHub import because the new GitHub + # importer fetch the project repositories for us. + return if project.github_import? + begin - if project.github_import? || project.gitea_import? + if project.gitea_import? fetch_repository else clone_repository @@ -55,7 +59,7 @@ module Projects end def fetch_repository - project.create_repository + project.ensure_repository project.repository.add_remote(project.import_type, project.import_url) project.repository.set_remote_as_mirror(project.import_type) project.repository.fetch_remote(project.import_type, forced: true) diff --git a/app/services/projects/update_pages_service.rb b/app/services/projects/update_pages_service.rb index 749a1cc56d8..5038155ca31 100644 --- a/app/services/projects/update_pages_service.rb +++ b/app/services/projects/update_pages_service.rb @@ -33,8 +33,10 @@ module Projects success end rescue => e + register_failure error(e.message) ensure + register_attempt build.erase_artifacts! unless build.has_expiring_artifacts? end @@ -168,5 +170,21 @@ module Projects def sha build.sha end + + def register_attempt + pages_deployments_total_counter.increase + end + + def register_failure + pages_deployments_failed_total_counter.increase + end + + def pages_deployments_total_counter + @pages_deployments_total_counter ||= Gitlab::Metrics.counter(:pages_deployments_total, "Counter of GitLab Pages deployments triggered") + end + + def pages_deployments_failed_total_counter + @pages_deployments_failed_total_counter ||= Gitlab::Metrics.counter(:pages_deployments_failed_total, "Counter of GitLab Pages deployments which failed") + end end end diff --git a/app/services/submit_usage_ping_service.rb b/app/services/submit_usage_ping_service.rb index 17857ca62f2..14171bce782 100644 --- a/app/services/submit_usage_ping_service.rb +++ b/app/services/submit_usage_ping_service.rb @@ -1,6 +1,16 @@ class SubmitUsagePingService URL = 'https://version.gitlab.com/usage_data'.freeze + METRICS = %w[leader_issues instance_issues percentage_issues leader_notes instance_notes + percentage_notes leader_milestones instance_milestones percentage_milestones + leader_boards instance_boards percentage_boards leader_merge_requests + instance_merge_requests percentage_merge_requests leader_ci_pipelines + instance_ci_pipelines percentage_ci_pipelines leader_environments instance_environments + percentage_environments leader_deployments instance_deployments percentage_deployments + leader_projects_prometheus_active instance_projects_prometheus_active + percentage_projects_prometheus_active leader_service_desk_issues instance_service_desk_issues + percentage_service_desk_issues].freeze + include Gitlab::CurrentSettings def execute @@ -27,15 +37,7 @@ class SubmitUsagePingService return unless response['conv_index'].present? ConversationalDevelopmentIndex::Metric.create!( - response['conv_index'].slice( - 'leader_issues', 'instance_issues', 'leader_notes', 'instance_notes', - 'leader_milestones', 'instance_milestones', 'leader_boards', 'instance_boards', - 'leader_merge_requests', 'instance_merge_requests', 'leader_ci_pipelines', - 'instance_ci_pipelines', 'leader_environments', 'instance_environments', - 'leader_deployments', 'instance_deployments', 'leader_projects_prometheus_active', - 'instance_projects_prometheus_active', 'leader_service_desk_issues', - 'instance_service_desk_issues' - ) + response['conv_index'].slice(*METRICS) ) end end diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 2dbee9c246e..1763f64a4e4 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -142,7 +142,8 @@ module SystemNoteService # # Returns the created Note object def change_milestone(noteable, project, author, milestone) - body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project)}" + format = milestone&.is_group_milestone? ? :name : :iid + body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}" create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone')) end diff --git a/app/views/import/gitlab_projects/new.html.haml b/app/views/import/gitlab_projects/new.html.haml index 767dffb5589..008e8287aa3 100644 --- a/app/views/import/gitlab_projects/new.html.haml +++ b/app/views/import/gitlab_projects/new.html.haml @@ -1,25 +1,43 @@ - page_title "GitLab Import" - header_title "Projects", root_path +- content_for :page_specific_javascripts do + = webpack_bundle_tag 'project_import_gl' + %h3.page-title = icon('gitlab') Import an exported GitLab project %hr -= form_tag import_gitlab_project_path, class: 'form-horizontal', multipart: true do - %p - Project will be imported as - %strong - #{@namespace.name}/#{@path} += form_tag import_gitlab_project_path, class: 'new_project', multipart: true do + .row + .form-group.col-xs-12.col-sm-6 + = label_tag :namespace_id, 'Project path', class: 'label-light' + .form-group + .input-group + - if current_user.can_select_namespace? + .input-group-addon + = root_url + = select_tag :namespace_id, namespaces_options(namespace_id_from(params) || :current_user, display_path: true, extra_group: namespace_id_from(params)), class: 'select2 js-select-namespace', tabindex: 1 - %p - To move or copy an entire GitLab project from another GitLab installation to this one, navigate to the original project's settings page, generate an export file, and upload it here. - .form-group - = hidden_field_tag :namespace_id, @namespace.id - = hidden_field_tag :path, @path - = label_tag :file, class: 'control-label' do - %span GitLab project export - .col-sm-10 - = file_field_tag :file, class: '' + - else + .input-group-addon.static-namespace + #{root_url}#{current_user.username}/ + = hidden_field_tag :namespace_id, value: current_user.namespace_id + .form-group.col-xs-12.col-sm-6.project-path + = label_tag :path, 'Project name', class: 'label-light' + = text_field_tag :path, nil, placeholder: "my-awesome-project", class: "js-path-name form-control", tabindex: 2, autofocus: true, required: true - .form-actions - = submit_tag 'Import project', class: 'btn btn-create' + .row + .form-group.col-md-12 + To move or copy an entire GitLab project from another GitLab installation to this one, navigate to the original project's settings page, generate an export file, and upload it here. + .row + .form-group.col-sm-12 + = hidden_field_tag :namespace_id, @namespace.id + = hidden_field_tag :path, @path + = label_tag :file, 'GitLab project export', class: 'label-light' + .form-group + = file_field_tag :file, class: '' + .row + .form-actions + = submit_tag 'Import project', class: 'btn btn-create' + = link_to 'Cancel', new_project_path, class: 'btn btn-cancel' diff --git a/app/views/layouts/nav/_new_admin_sidebar.html.haml b/app/views/layouts/nav/_new_admin_sidebar.html.haml index 06cfa509ebf..0b4a9d92bea 100644 --- a/app/views/layouts/nav/_new_admin_sidebar.html.haml +++ b/app/views/layouts/nav/_new_admin_sidebar.html.haml @@ -1,12 +1,9 @@ -.nav-sidebar +.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } .context-header = link_to admin_root_path, title: 'Admin Overview' do .avatar-container.s40.settings-avatar = icon('wrench') .project-title Admin Area - = button_tag class: 'close-nav-button', type: 'button' do - %span.sr-only Close sidebar - = icon ('times') %ul.sidebar-top-level-items = nav_link(controller: %w(dashboard admin projects users groups jobs runners cohorts), html_options: {class: 'home'}) do = link_to admin_root_path, title: 'Overview', class: 'shortcuts-tree' do diff --git a/app/views/layouts/nav/_new_group_sidebar.html.haml b/app/views/layouts/nav/_new_group_sidebar.html.haml index 4a04b27b3d9..c7dabbd8237 100644 --- a/app/views/layouts/nav/_new_group_sidebar.html.haml +++ b/app/views/layouts/nav/_new_group_sidebar.html.haml @@ -1,13 +1,10 @@ -.nav-sidebar +.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } .context-header = link_to group_path(@group), title: @group.name do .avatar-container.s40.group-avatar = image_tag group_icon(@group), class: "avatar s40 avatar-tile" .group-title = @group.name - = button_tag class: 'close-nav-button', type: 'button' do - %span.sr-only Close sidebar - = icon ('times') %ul.sidebar-top-level-items = nav_link(path: ['groups#show', 'groups#activity', 'groups#subgroups'], html_options: { class: 'home' }) do = link_to group_path(@group), title: 'Group overview' do diff --git a/app/views/layouts/nav/_new_profile_sidebar.html.haml b/app/views/layouts/nav/_new_profile_sidebar.html.haml index df869fef604..edae009a28e 100644 --- a/app/views/layouts/nav/_new_profile_sidebar.html.haml +++ b/app/views/layouts/nav/_new_profile_sidebar.html.haml @@ -1,12 +1,9 @@ -.nav-sidebar +.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } .context-header = link_to profile_path, title: 'Profile Settings' do .avatar-container.s40.settings-avatar = icon('user') .project-title User Settings - = button_tag class: 'close-nav-button', type: 'button' do - %span.sr-only Close sidebar - = icon ('times') %ul.sidebar-top-level-items = nav_link(path: 'profiles#show', html_options: {class: 'home'}) do = link_to profile_path, title: 'Profile Settings' do diff --git a/app/views/layouts/nav/_new_project_sidebar.html.haml b/app/views/layouts/nav/_new_project_sidebar.html.haml index 4b7209fa69e..e0477c29ebe 100644 --- a/app/views/layouts/nav/_new_project_sidebar.html.haml +++ b/app/views/layouts/nav/_new_project_sidebar.html.haml @@ -1,4 +1,4 @@ -.nav-sidebar +.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } - can_edit = can?(current_user, :admin_project, @project) .context-header = link_to project_path(@project), title: @project.name do @@ -6,9 +6,6 @@ = project_icon(@project, alt: @project.name, class: 'avatar s40 avatar-tile') .project-title = @project.name - = button_tag class: 'close-nav-button', type: 'button' do - %span.sr-only Close sidebar - = icon ('times') %ul.sidebar-top-level-items = nav_link(path: ['projects#show', 'projects#activity', 'cycle_analytics#show'], html_options: { class: 'home' }) do = link_to project_path(@project), title: 'Project overview', class: 'shortcuts-project' do @@ -219,7 +216,7 @@ = link_to project_settings_members_path(@project), title: 'Members', class: 'shortcuts-tree' do .nav-icon-container = custom_icon('members') - %span + %span.nav-item-name Members = render 'shared/sidebar_toggle_button' diff --git a/app/views/projects/_md_preview.html.haml b/app/views/projects/_md_preview.html.haml index d0698285f84..6e13bf47ff6 100644 --- a/app/views/projects/_md_preview.html.haml +++ b/app/views/projects/_md_preview.html.haml @@ -1,5 +1,12 @@ - referenced_users = local_assigns.fetch(:referenced_users, nil) +- if defined?(@issue) && @issue.confidential? + %li.confidential-issue-warning + = confidential_icon(@issue) + %span This is a confidential issue. Your comment will not be visible to the public. +- else + %li.confidential-issue-warning.not-confidential + .md-area .md-header %ul.nav-links.clearfix @@ -10,11 +17,6 @@ %a.js-md-preview-button{ href: "#md-preview-holder", tabindex: -1 } Preview - - if defined?(@issue) && @issue.confidential? - %li.confidential-issue-warning - = icon('warning') - %span This is a confidential issue. Your comment will not be visible to the public. - %li.pull-right .toolbar-group = markdown_toolbar_button({ icon: "bold fw", data: { "md-tag" => "**" }, title: "Add bold text" }) diff --git a/app/views/projects/_project_templates.html.haml b/app/views/projects/_project_templates.html.haml new file mode 100644 index 00000000000..21baf35f2ac --- /dev/null +++ b/app/views/projects/_project_templates.html.haml @@ -0,0 +1,10 @@ +.project-templates-buttons.import-buttons{ data: { toggle: "buttons" } } + .btn.blank-option.active + %input{ type: "radio", autocomplete: "off", name: "project_templates", id: "blank", checked: "true" } + = icon('file-o', class: 'btn-template-icon') + Blank + - Gitlab::ProjectTemplate.all.each do |template| + .btn + %input{ type: "radio", autocomplete: "off", name: "project_templates", id: template.name } + = custom_icon(template.logo) + = template.title diff --git a/app/views/projects/boards/components/_board.html.haml b/app/views/projects/boards/components/_board.html.haml index 539ee087b14..64f5f6d7ba0 100644 --- a/app/views/projects/boards/components/_board.html.haml +++ b/app/views/projects/boards/components/_board.html.haml @@ -6,8 +6,16 @@ %i.fa.fa-fw.board-title-expandable-toggle{ "v-if": "list.isExpandable", ":class": "{ \"fa-caret-down\": list.isExpanded, \"fa-caret-right\": !list.isExpanded && list.position === -1, \"fa-caret-left\": !list.isExpanded && list.position !== -1 }", "aria-hidden": "true" } - %span.has-tooltip{ ":title" => '(list.label ? list.label.description : "")', - data: { container: "body", placement: "bottom" } } + + %span.has-tooltip{ "v-if": "list.type !== \"label\"", + ":title" => '(list.label ? list.label.description : "")' } + {{ list.title }} + + %span.has-tooltip{ "v-if": "list.type === \"label\"", + ":title" => '(list.label ? list.label.description : "")', + data: { container: "body", placement: "bottom" }, + class: "label color-label title", + ":style" => "{ backgroundColor: (list.label && list.label.color ? list.label.color : null), color: (list.label && list.label.color ? list.label.text_color : \"#2e2e2e\") }" } {{ list.title }} .issue-count-badge.pull-right.clearfix{ "v-if" => 'list.type !== "blank"' } %span.issue-count-badge-count.pull-left{ ":class" => '{ "has-btn": list.type !== "closed" && !disabled }' } diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index a57844f974e..ad5befc6ee5 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -19,7 +19,8 @@ = icon('angle-double-left') .issuable-meta - = confidential_icon(@issue) + - if @issue.confidential + = icon('eye-slash', class: 'is-confidential') = issuable_meta(@issue, @project, "Issue") .issuable-actions diff --git a/app/views/projects/jobs/_sidebar.html.haml b/app/views/projects/jobs/_sidebar.html.haml index f2db71e8838..99f4b30d085 100644 --- a/app/views/projects/jobs/_sidebar.html.haml +++ b/app/views/projects/jobs/_sidebar.html.haml @@ -1,101 +1,101 @@ - builds = @build.pipeline.builds.to_a %aside.right-sidebar.right-sidebar-expanded.build-sidebar.js-build-sidebar.js-right-sidebar{ data: { "offset-top" => "101", "spy" => "affix" } } - .blocks-container - .block - %strong - = @build.name - %a.gutter-toggle.pull-right.visible-xs-block.visible-sm-block.js-sidebar-build-toggle{ href: "#", 'aria-label': 'Toggle Sidebar', role: 'button' } - = icon('angle-double-right') - - #js-details-block-vue - - - if can?(current_user, :read_build, @project) && (@build.artifacts? || @build.artifacts_expired?) + .sidebar-container + .blocks-container .block - .title - Job artifacts - - if @build.artifacts_expired? - %p.build-detail-row - The artifacts were removed - #{time_ago_with_tooltip(@build.artifacts_expire_at)} - - elsif @build.has_expiring_artifacts? - %p.build-detail-row - The artifacts will be removed in - %span.js-artifacts-remove= @build.artifacts_expire_at + %strong + = @build.name + %a.gutter-toggle.pull-right.visible-xs-block.visible-sm-block.js-sidebar-build-toggle{ href: "#", 'aria-label': 'Toggle Sidebar', role: 'button' } + = icon('angle-double-right') - - if @build.artifacts? - .btn-group.btn-group-justified{ role: :group } - - if @build.has_expiring_artifacts? && can?(current_user, :update_build, @build) - = link_to keep_project_job_artifacts_path(@project, @build), class: 'btn btn-sm btn-default', method: :post do - Keep + #js-details-block-vue - = link_to download_project_job_artifacts_path(@project, @build), rel: 'nofollow', download: '', class: 'btn btn-sm btn-default' do - Download + - if can?(current_user, :read_build, @project) && (@build.artifacts? || @build.artifacts_expired?) + .block + .title + Job artifacts + - if @build.artifacts_expired? + %p.build-detail-row + The artifacts were removed + #{time_ago_with_tooltip(@build.artifacts_expire_at)} + - elsif @build.has_expiring_artifacts? + %p.build-detail-row + The artifacts will be removed in + %span.js-artifacts-remove= @build.artifacts_expire_at - - if @build.artifacts_metadata? - = link_to browse_project_job_artifacts_path(@project, @build), class: 'btn btn-sm btn-default' do - Browse + - if @build.artifacts? + .btn-group.btn-group-justified{ role: :group } + - if @build.has_expiring_artifacts? && can?(current_user, :update_build, @build) + = link_to keep_project_job_artifacts_path(@project, @build), class: 'btn btn-sm btn-default', method: :post do + Keep - - if @build.trigger_request - .build-widget.block - %h4.title - Trigger + = link_to download_project_job_artifacts_path(@project, @build), rel: 'nofollow', download: '', class: 'btn btn-sm btn-default' do + Download - %p - %span.build-light-text Token: - #{@build.trigger_request.trigger.short_token} + - if @build.artifacts_metadata? + = link_to browse_project_job_artifacts_path(@project, @build), class: 'btn btn-sm btn-default' do + Browse + + - if @build.trigger_request + .build-widget.block + %h4.title + Trigger - - if @build.trigger_request.variables %p - %button.btn.group.btn-group-justified.reveal-variables Reveal Variables + %span.build-light-text Token: + #{@build.trigger_request.trigger.short_token} + - if @build.trigger_request.variables + %p + %button.btn.group.btn-group-justified.reveal-variables Reveal Variables - - @build.trigger_request.variables.each do |key, value| - .hide.js-build - .js-build-variable.trigger-build-variable= key - .js-build-value.trigger-build-value= value + %dl.js-build-variables.trigger-build-variables.hide + - @build.trigger_request.variables.each do |key, value| + %dt.js-build-variable.trigger-build-variable= key + %dd.js-build-value.trigger-build-value= value - %div{ class: (@build.pipeline.stages_count > 1 ? "block" : "block-last") } - %p - Commit - = link_to @build.pipeline.short_sha, project_commit_path(@project, @build.pipeline.sha), class: 'commit-sha link-commit' - = clipboard_button(text: @build.pipeline.short_sha, title: "Copy commit SHA to clipboard") - - if @build.merge_request - in - = link_to "#{@build.merge_request.to_reference}", merge_request_path(@build.merge_request), class: 'link-commit' + %div{ class: (@build.pipeline.stages_count > 1 ? "block" : "block-last") } + %p + Commit + = link_to @build.pipeline.short_sha, project_commit_path(@project, @build.pipeline.sha), class: 'commit-sha link-commit' + = clipboard_button(text: @build.pipeline.short_sha, title: "Copy commit SHA to clipboard") + - if @build.merge_request + in + = link_to "#{@build.merge_request.to_reference}", merge_request_path(@build.merge_request), class: 'link-commit' - %p.build-light-text.append-bottom-0 - #{@build.pipeline.git_commit_title} + %p.build-light-text.append-bottom-0 + #{@build.pipeline.git_commit_title} - - if @build.pipeline.stages_count > 1 - .dropdown.build-dropdown - %div - %span{ class: "ci-status-icon-#{@build.pipeline.status}" } - = ci_icon_for_status(@build.pipeline.status) - Pipeline - = link_to "##{@build.pipeline.id}", project_pipeline_path(@project, @build.pipeline), class: 'link-commit' - from - = link_to "#{@build.pipeline.ref}", project_branch_path(@project, @build.pipeline.ref), class: 'link-commit' - %button.dropdown-menu-toggle{ type: 'button', 'data-toggle' => 'dropdown' } - %span.stage-selection More - = icon('chevron-down') - %ul.dropdown-menu - - @build.pipeline.legacy_stages.each do |stage| - %li - %a.stage-item= stage.name + - if @build.pipeline.stages_count > 1 + .block-last.dropdown.build-dropdown + %div + %span{ class: "ci-status-icon-#{@build.pipeline.status}" } + = ci_icon_for_status(@build.pipeline.status) + Pipeline + = link_to "##{@build.pipeline.id}", project_pipeline_path(@project, @build.pipeline), class: 'link-commit' + from + = link_to "#{@build.pipeline.ref}", project_branch_path(@project, @build.pipeline.ref), class: 'link-commit' + %button.dropdown-menu-toggle{ type: 'button', 'data-toggle' => 'dropdown' } + %span.stage-selection More + = icon('chevron-down') + %ul.dropdown-menu + - @build.pipeline.legacy_stages.each do |stage| + %li + %a.stage-item= stage.name - .builds-container - - HasStatus::ORDERED_STATUSES.each do |build_status| - - builds.select{|build| build.status == build_status}.each do |build| - .build-job{ class: sidebar_build_class(build, @build), data: { stage: build.stage } } - = link_to project_job_path(@project, build) do - = icon('arrow-right') - %span{ class: "ci-status-icon-#{build.status}" } - = ci_icon_for_status(build.status) - %span - - if build.name - = build.name - - else - = build.id - - if build.retried? - %i.fa.fa-refresh.has-tooltip{ data: { container: 'body', placement: 'bottom' }, title: 'Job was retried' } + .builds-container + - HasStatus::ORDERED_STATUSES.each do |build_status| + - builds.select{|build| build.status == build_status}.each do |build| + .build-job{ class: sidebar_build_class(build, @build), data: { stage: build.stage } } + = link_to project_job_path(@project, build) do + = icon('arrow-right') + %span{ class: "ci-status-icon-#{build.status}" } + = ci_icon_for_status(build.status) + %span + - if build.name + = build.name + - else + = build.id + - if build.retried? + %i.fa.fa-refresh.has-tooltip{ data: { container: 'body', placement: 'bottom' }, title: 'Job was retried' } diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index 25109f0f414..e3bbebbcf4c 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -17,8 +17,68 @@ - if import_sources_enabled? %p Create or Import your project from popular Git services - .col-lg-9 + .col-lg-9.js-toggle-container = form_for @project, html: { class: 'new_project' } do |f| + .create-project-options + .first-column + .project-template + .form-group + = f.label :template_project, class: 'label-light' do + Create from template + = link_to icon('question-circle'), help_page_path("public_access/public_access"), aria: { label: "What’s included in a template?" }, title: "What’s included in a template?", class: 'has-tooltip', data: { placement: 'top'} + %div + = render 'project_templates', f: f + .second-column + - if import_sources_enabled? + .project-import + .form-group.clearfix + = f.label :visibility_level, class: 'label-light' do #the label here seems wrong + Import project from + .col-sm-12.import-buttons + %div + - if github_import_enabled? + = link_to new_import_github_path, class: 'btn import_github' do + = icon('github', text: 'GitHub') + %div + - if bitbucket_import_enabled? + = link_to status_import_bitbucket_path, class: "btn import_bitbucket #{'how_to_import_link' unless bitbucket_import_configured?}" do + = icon('bitbucket', text: 'Bitbucket') + - unless bitbucket_import_configured? + = render 'bitbucket_import_modal' + %div + - if gitlab_import_enabled? + = link_to status_import_gitlab_path, class: "btn import_gitlab #{'how_to_import_link' unless gitlab_import_configured?}" do + = icon('gitlab', text: 'GitLab.com') + - unless gitlab_import_configured? + = render 'gitlab_import_modal' + %div + - if google_code_import_enabled? + = link_to new_import_google_code_path, class: 'btn import_google_code' do + = icon('google', text: 'Google Code') + %div + - if fogbugz_import_enabled? + = link_to new_import_fogbugz_path, class: 'btn import_fogbugz' do + = icon('bug', text: 'Fogbugz') + %div + - if gitea_import_enabled? + = link_to new_import_gitea_url, class: 'btn import_gitea' do + = custom_icon('go_logo') + Gitea + %div + - if git_import_enabled? + %button.btn.js-toggle-button.import_git{ type: "button" } + = icon('git', text: 'Repo by URL') + .import_gitlab_project.has-tooltip{ data: { container: 'body' } } + = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit' do + = icon('gitlab', text: 'GitLab export') + + .row + .col-lg-12 + .js-toggle-content.hide + %hr + = render "shared/import_form", f: f + %hr + .row .form-group.col-xs-12.col-sm-6 = f.label :namespace_id, class: 'label-light' do @@ -45,53 +105,6 @@ Want to house several dependent projects under the same namespace? = link_to "Create a group", new_group_path - - if import_sources_enabled? - .project-import.js-toggle-container - .form-group.clearfix - = f.label :visibility_level, class: 'label-light' do - Import project from - .col-sm-12.import-buttons - %div - - if github_import_enabled? - = link_to new_import_github_path, class: 'btn import_github' do - = icon('github', text: 'GitHub') - %div - - if bitbucket_import_enabled? - = link_to status_import_bitbucket_path, class: "btn import_bitbucket #{'how_to_import_link' unless bitbucket_import_configured?}" do - = icon('bitbucket', text: 'Bitbucket') - - unless bitbucket_import_configured? - = render 'bitbucket_import_modal' - %div - - if gitlab_import_enabled? - = link_to status_import_gitlab_path, class: "btn import_gitlab #{'how_to_import_link' unless gitlab_import_configured?}" do - = icon('gitlab', text: 'GitLab.com') - - unless gitlab_import_configured? - = render 'gitlab_import_modal' - %div - - if google_code_import_enabled? - = link_to new_import_google_code_path, class: 'btn import_google_code' do - = icon('google', text: 'Google Code') - %div - - if fogbugz_import_enabled? - = link_to new_import_fogbugz_path, class: 'btn import_fogbugz' do - = icon('bug', text: 'FogBugz') - %div - - if gitea_import_enabled? - = link_to new_import_gitea_url, class: 'btn import_gitea' do - = custom_icon('go_logo') - Gitea - %div - - if git_import_enabled? - %button.btn.js-toggle-button.import_git{ type: "button" } - = icon('git', text: 'Repo by URL') - .import_gitlab_project.has-tooltip{ data: { container: 'body' } } - - if gitlab_project_import_enabled? - = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit' do - = icon('gitlab', text: 'GitLab export') - - .js-toggle-content.hide - = render "shared/import_form", f: f - .form-group = f.label :description, class: 'label-light' do Project description diff --git a/app/views/projects/wikis/_sidebar.html.haml b/app/views/projects/wikis/_sidebar.html.haml index e71ce1f357f..f7283ae4739 100644 --- a/app/views/projects/wikis/_sidebar.html.haml +++ b/app/views/projects/wikis/_sidebar.html.haml @@ -1,21 +1,22 @@ %aside.right-sidebar.right-sidebar-expanded.wiki-sidebar.js-wiki-sidebar.js-right-sidebar{ data: { "offset-top" => "50", "spy" => "affix" } } - .block.wiki-sidebar-header.append-bottom-default - %a.gutter-toggle.pull-right.visible-xs-block.visible-sm-block.js-sidebar-wiki-toggle{ href: "#" } - = icon('angle-double-right') + .sidebar-container + .block.wiki-sidebar-header.append-bottom-default + %a.gutter-toggle.pull-right.visible-xs-block.visible-sm-block.js-sidebar-wiki-toggle{ href: "#" } + = icon('angle-double-right') - - git_access_url = project_wikis_git_access_path(@project) - = link_to git_access_url, class: active_nav_link?(path: 'wikis#git_access') ? 'active' : '' do - = succeed ' ' do - = icon('cloud-download') - Clone repository + - git_access_url = project_wikis_git_access_path(@project) + = link_to git_access_url, class: active_nav_link?(path: 'wikis#git_access') ? 'active' : '' do + = succeed ' ' do + = icon('cloud-download') + Clone repository - .blocks-container - .block.block-first - %ul.wiki-pages - = render @sidebar_wiki_entries, context: 'sidebar' + .blocks-container + .block.block-first + %ul.wiki-pages + = render @sidebar_wiki_entries, context: 'sidebar' - .block - = link_to project_wikis_pages_path(@project), class: 'btn btn-block' do - More Pages + .block + = link_to project_wikis_pages_path(@project), class: 'btn btn-block' do + More Pages = render 'projects/wikis/new' diff --git a/app/views/shared/_import_form.html.haml b/app/views/shared/_import_form.html.haml index 1c7c73be933..873179339dc 100644 --- a/app/views/shared/_import_form.html.haml +++ b/app/views/shared/_import_form.html.haml @@ -1,16 +1,16 @@ .form-group.import-url-data - = f.label :import_url, class: 'control-label' do + = f.label :import_url, class: 'label-light' do %span Git repository URL - .col-sm-10 - = f.text_field :import_url, autocomplete: 'off', class: 'form-control', placeholder: 'https://username:password@gitlab.company.com/group/project.git' - .well.prepend-top-20 - %ul - %li - The repository must be accessible over <code>http://</code>, <code>https://</code> or <code>git://</code>. - %li - If your HTTP repository is not publicly accessible, add authentication information to the URL: <code>https://username:password@gitlab.company.com/group/project.git</code>. - %li - The import will time out after 15 minutes. For repositories that take longer, use a clone/push combination. - %li - To migrate an SVN repository, check out #{link_to "this document", help_page_path('workflow/importing/migrating_from_svn')}. + = f.text_field :import_url, autocomplete: 'off', class: 'form-control', placeholder: 'https://username:password@gitlab.company.com/group/project.git' + + .well.prepend-top-20 + %ul + %li + The repository must be accessible over <code>http://</code>, <code>https://</code> or <code>git://</code>. + %li + If your HTTP repository is not publicly accessible, add authentication information to the URL: <code>https://username:password@gitlab.company.com/group/project.git</code>. + %li + The import will time out after 15 minutes. For repositories that take longer, use a clone/push combination. + %li + To migrate an SVN repository, check out #{link_to "this document", help_page_path('workflow/importing/migrating_from_svn')}. diff --git a/app/views/shared/_new_project_item_select.html.haml b/app/views/shared/_new_project_item_select.html.haml index b417e83cdb6..96502d7ce93 100644 --- a/app/views/shared/_new_project_item_select.html.haml +++ b/app/views/shared/_new_project_item_select.html.haml @@ -1,6 +1,7 @@ - if any_projects?(@projects) - .project-item-select-holder + .project-item-select-holder.btn-group.pull-right + %a.btn.btn-new.new-project-item-link{ href: '', data: { label: local_assigns[:label] } } + = icon('spinner spin') = project_select_tag :project_path, class: "project-item-select", data: { include_groups: local_assigns[:include_groups], order_by: 'last_activity_at', relative_path: local_assigns[:path] }, with_feature_enabled: local_assigns[:with_feature_enabled] - %a.btn.btn-new.new-project-item-select-button - = local_assigns[:label] + %button.btn.btn-new.new-project-item-select-button = icon('caret-down') diff --git a/app/views/shared/_sidebar_toggle_button.html.haml b/app/views/shared/_sidebar_toggle_button.html.haml index e70faad4894..eb5ddb0dde4 100644 --- a/app/views/shared/_sidebar_toggle_button.html.haml +++ b/app/views/shared/_sidebar_toggle_button.html.haml @@ -2,3 +2,7 @@ = icon('angle-double-left') = icon('angle-double-right') %span.collapse-text Collapse sidebar + += button_tag class: 'close-nav-button', type: 'button' do + = icon ('times') + %span.collapse-text Close sidebar diff --git a/app/views/shared/icons/_java_spring.svg b/app/views/shared/icons/_java_spring.svg new file mode 100644 index 00000000000..508349aa456 --- /dev/null +++ b/app/views/shared/icons/_java_spring.svg @@ -0,0 +1,6 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" class="btn-template-icon icon-java-spring"> + <g fill="none" fill-rule="evenodd"> + <rect width="32" height="32"/> + <path fill="#70AD51" d="M5.46647617,27.9932117 C6.0517027,28.4658996 6.91159892,28.3777063 7.38425926,27.7914452 C7.85922261,27.2048452 7.76991326,26.3449044 7.18398981,25.8699411 C6.59874295,25.3956543 5.74015536,25.4869934 5.26383884,26.0722403 C4.81393367,26.6267596 4.87238621,27.4284565 5.37913494,27.9159868 L5.11431334,27.6818383 C1.97157151,24.7616933 0,20.5966301 0,15.9782542 C0,7.16842834 7.16775175,0 15.9796074,0 C20.4586065,0 24.5113565,1.8565519 27.4145869,4.8362365 C28.0749348,3.93840692 28.6466499,2.93435335 29.115524,1.82069284 C31.1513712,7.93770658 32.3482517,13.0811131 31.909824,17.1311567 C31.3178113,25.4044499 24.4017495,31.9585382 15.9796074,31.9585382 C12.0682639,31.9585382 8.48438805,30.5444735 5.7042963,28.2034861 L5.46647617,27.9932117 Z M29.0471888,23.0106888 C33.0546075,17.6737787 30.8211972,9.04527781 28.9612624,3.529749 C27.3029502,6.98304378 23.2217836,9.62375882 19.6981239,10.4613722 C16.3950312,11.2482417 13.4715032,10.6021021 10.4153644,11.7780085 C3.44517575,14.457289 3.55613585,22.7698242 7.39373146,24.6365249 C7.39711439,24.6392312 7.62444728,24.7616933 7.62174094,24.7576338 C7.62309411,24.7562806 13.2658211,23.6358542 16.3862356,22.4843049 C20.9450718,20.7996058 25.9524846,16.6494275 27.5986182,11.8273993 C26.723116,16.8415779 22.4179995,21.6669891 18.093262,23.8828081 C15.7908399,25.0648038 14.0005934,25.3279957 10.2123886,26.6385428 C9.74892722,26.798217 9.38492397,26.9538318 9.38492397,26.9538318 C10.3463526,26.7948341 11.301692,26.7420604 11.301692,26.7420604 C16.6954354,26.4869875 25.1087819,28.2582896 29.0471888,23.0106888 Z"/> + </g> +</svg> diff --git a/app/views/shared/icons/_node_express.svg b/app/views/shared/icons/_node_express.svg new file mode 100644 index 00000000000..f2c94319f19 --- /dev/null +++ b/app/views/shared/icons/_node_express.svg @@ -0,0 +1,6 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="27" height="32" viewBox="0 0 27 32" class="btn-template-icon icon-node-express"> + <g fill="none" fill-rule="evenodd" transform="translate(-3)"> + <rect width="32" height="32"/> + <path fill="#353535" d="M4.19170065,16.2667139 C4.23142421,18.3323387 4.47969269,20.2489714 4.93651356,22.0166696 C5.39333443,23.7843677 6.09841693,25.3236323 7.05178222,26.6345096 C8.00514751,27.9453869 9.23655921,28.9781838 10.7460543,29.7329313 C12.2555493,30.4876788 14.1026668,30.8650469 16.2874623,30.8650469 C19.5050701,30.8650469 22.1764391,30.0209341 24.3016492,28.3326831 C26.4268593,26.644432 27.7476477,24.1120935 28.2640539,20.7355914 L29.4557545,20.7355914 C29.0187954,24.3107112 27.6086304,27.0813875 25.2252172,29.0477034 C22.841804,31.0140194 19.9023051,31.9971626 16.4066324,31.9971626 C14.0232191,32.0368861 11.9874175,31.659518 10.2991665,30.8650469 C8.61091547,30.0705759 7.23054269,28.9484023 6.15800673,27.4984926 C5.08547078,26.0485829 4.29101162,24.3404957 3.77460543,22.3741798 C3.25819923,20.4078639 3,18.2926164 3,16.0283738 C3,13.4860664 3.3773681,11.2218578 4.13211562,9.23568007 C4.88686314,7.24950238 5.87993709,5.57120741 7.11136726,4.20074481 C8.34279742,2.8302822 9.77282391,1.78755456 11.4014896,1.07253059 C13.0301553,0.357506621 14.6985195,0 16.4066324,0 C18.7900456,0 20.8457087,0.456814016 22.5736832,1.37045575 C24.3016578,2.28409749 25.7118228,3.4956477 26.8042206,5.00514275 C27.8966183,6.51463779 28.6910775,8.24258646 29.1876219,10.1890406 C29.6841663,12.1354947 29.8927118,14.1613656 29.8132647,16.2667139 L4.19170065,16.2667139 Z M28.6215641,15.0750133 C28.6215641,13.2080062 28.3633648,11.4304039 27.8469586,9.74215285 C27.3305524,8.05390181 26.5658855,6.57422163 25.5529349,5.30306791 C24.5399843,4.03191419 23.2787803,3.0289095 21.7692853,2.29402376 C20.2597903,1.55913801 18.5119801,1.19170065 16.5258024,1.19170065 C14.8574132,1.19170065 13.2982871,1.50948432 11.8483774,2.14506118 C10.3984676,2.78063804 9.12733299,3.70419681 8.03493526,4.9157652 C6.94253754,6.12733359 6.05870172,7.58715229 5.38340131,9.2952651 C4.70810089,11.0033779 4.31087132,12.9299414 4.19170065,15.0750133 L28.6215641,15.0750133 Z"/> + </g> +</svg> diff --git a/app/views/shared/icons/_rails.svg b/app/views/shared/icons/_rails.svg new file mode 100644 index 00000000000..0bb09a705df --- /dev/null +++ b/app/views/shared/icons/_rails.svg @@ -0,0 +1,6 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="32" height="20" viewBox="0 0 32 20" class="btn-template-icon icon-rails"> + <g fill="none" fill-rule="evenodd" transform="translate(0 -6)"> + <rect width="32" height="32"/> + <path fill="#C00" fill-rule="nonzero" d="M0.984615385,25.636044 C0.984615385,25.636044 1.40659341,21.4725275 4.36043956,16.5494505 C7.31428571,11.6263736 12.3498901,7.8989011 16.4430769,7.53318681 C24.5872527,6.71736264 31.9015385,14.0175824 31.9015385,14.0175824 C31.9015385,14.0175824 31.6624176,14.1863736 31.4092308,14.3973626 C23.4197802,8.48967033 18.5389011,11.2747253 17.0057143,12.0202198 C9.97274725,15.9446154 12.0967033,25.636044 12.0967033,25.636044 L0.984615385,25.636044 Z M24.1371429,8.32087912 C23.687033,8.13802198 23.2369231,7.96923077 22.7727473,7.81450549 L22.829011,6.88615385 C23.7151648,7.13934066 24.0668132,7.30813187 24.1934066,7.37846154 L24.1371429,8.32087912 Z M22.8008791,11.3028571 C23.250989,11.330989 23.7151648,11.3872527 24.1934066,11.4857143 L24.1371429,12.3578022 C23.672967,12.2593407 23.2087912,12.2030769 22.7446154,12.189011 L22.8008791,11.3028571 Z M17.5964835,6.91428571 C17.1885714,6.91428571 16.7806593,6.92835165 16.3727473,6.97054945 L16.1054945,6.14065934 C16.5696703,6.0843956 17.0197802,6.05626374 17.4558242,6.05626374 L17.7371429,6.91428571 C17.6949451,6.91428571 17.6386813,6.91428571 17.5964835,6.91428571 Z M18.2716484,12.0905495 C18.6232967,11.9358242 19.0312088,11.7810989 19.5094505,11.6404396 L19.8189011,12.5687912 C19.410989,12.6953846 19.0030769,12.8641758 18.5951648,13.0610989 L18.2716484,12.0905495 Z M11.8857143,8.39120879 C11.52,8.57406593 11.1683516,8.78505495 10.8026374,9.01010989 L10.1556044,8.02549451 C10.5353846,7.80043956 10.9010989,7.60351648 11.2527473,7.42065934 L11.8857143,8.39120879 Z M14.7692308,14.7208791 C15.0224176,14.3973626 15.3178022,14.0738462 15.6413187,13.7784615 L16.2742857,14.7349451 C15.9648352,15.0584615 15.6835165,15.381978 15.4443956,15.7336264 L14.7692308,14.7208791 Z M12.7296703,19.2501099 C12.8421978,18.7437363 12.9687912,18.2232967 13.1516484,17.7028571 L14.1643956,18.5046154 C14.0237363,19.0531868 13.9252747,19.6017582 13.869011,20.1503297 L12.7296703,19.2501099 Z M6.56879121,12.5687912 C6.23120879,12.9204396 5.90769231,13.3002198 5.61230769,13.68 L4.52923077,12.7516484 C4.85274725,12.4 5.2043956,12.0483516 5.57010989,11.6967033 L6.56879121,12.5687912 Z M2.32087912,18.8562637 C2.09582418,19.3767033 1.80043956,20.0659341 1.61758242,20.5441758 L0,19.9534066 C0.140659341,19.5736264 0.436043956,18.8703297 0.703296703,18.2654945 L2.32087912,18.8562637 Z M12.5186813,22.8228571 L14.0378022,23.3714286 C14.1221978,24.0325275 14.2487912,24.6514286 14.3753846,25.2 L12.6874725,24.5951648 C12.6171429,24.1731868 12.5468132,23.5683516 12.5186813,22.8228571 Z"/> + </g> +</svg> diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index e7510c1d1ec..c2de6926460 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -115,6 +115,10 @@ - if can? current_user, :admin_label, @project and @project = render partial: "shared/issuable/label_page_create" + - if issuable.has_attribute?(:confidential) + %script#js-confidential-issue-data{ type: "application/json" }= { is_confidential: @issue.confidential, is_editable: can_edit_issuable }.to_json.html_safe + #js-confidential-entry-point + = render "shared/issuable/participants", participants: issuable.participants(current_user) - if current_user - subscribed = issuable.subscribed?(current_user, @project) diff --git a/app/views/shared/issuable/_user_dropdown_item.html.haml b/app/views/shared/issuable/_user_dropdown_item.html.haml index a82c01c6dc2..c18e4975bb8 100644 --- a/app/views/shared/issuable/_user_dropdown_item.html.haml +++ b/app/views/shared/issuable/_user_dropdown_item.html.haml @@ -3,7 +3,8 @@ %li.filter-dropdown-item{ class: ('js-current-user' if user == current_user) } %button.btn.btn-link.dropdown-user{ type: :button } - = user_avatar_without_link(user: user, lazy: avatar[:lazy], url: avatar[:url], size: 30) + .avatar-container.s40 + = user_avatar_without_link(user: user, lazy: avatar[:lazy], url: avatar[:url], size: 40).gsub('/images/{{avatar_url}}','{{avatar_url}}').html_safe .dropdown-user-details %span = user.name diff --git a/app/workers/concerns/new_issuable.rb b/app/workers/concerns/new_issuable.rb new file mode 100644 index 00000000000..3fd472bf0c1 --- /dev/null +++ b/app/workers/concerns/new_issuable.rb @@ -0,0 +1,23 @@ +module NewIssuable + attr_reader :issuable, :user + + def ensure_objects_found(issuable_id, user_id) + @issuable = issuable_class.find_by(id: issuable_id) + unless @issuable + log_error(issuable_class, issuable_id) + return false + end + + @user = User.find_by(id: user_id) + unless @user + log_error(User, user_id) + return false + end + + true + end + + def log_error(record_class, record_id) + Rails.logger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job") + end +end diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb index 48e2da338f6..c3b58df92c1 100644 --- a/app/workers/merge_worker.rb +++ b/app/workers/merge_worker.rb @@ -7,6 +7,8 @@ class MergeWorker current_user = User.find(current_user_id) merge_request = MergeRequest.find(merge_request_id) + merge_request.update_column(:merge_jid, jid) + MergeRequests::MergeService.new(merge_request.target_project, current_user, params) .execute(merge_request) end diff --git a/app/workers/new_issue_worker.rb b/app/workers/new_issue_worker.rb new file mode 100644 index 00000000000..19a778ad522 --- /dev/null +++ b/app/workers/new_issue_worker.rb @@ -0,0 +1,17 @@ +class NewIssueWorker + include Sidekiq::Worker + include DedicatedSidekiqQueue + include NewIssuable + + def perform(issue_id, user_id) + return unless ensure_objects_found(issue_id, user_id) + + EventCreateService.new.open_issue(issuable, user) + NotificationService.new.new_issue(issuable, user) + issuable.create_cross_references!(user) + end + + def issuable_class + Issue + end +end diff --git a/app/workers/new_merge_request_worker.rb b/app/workers/new_merge_request_worker.rb new file mode 100644 index 00000000000..3c8a68016ff --- /dev/null +++ b/app/workers/new_merge_request_worker.rb @@ -0,0 +1,17 @@ +class NewMergeRequestWorker + include Sidekiq::Worker + include DedicatedSidekiqQueue + include NewIssuable + + def perform(merge_request_id, user_id) + return unless ensure_objects_found(merge_request_id, user_id) + + EventCreateService.new.open_mr(issuable, user) + NotificationService.new.new_merge_request(issuable, user) + issuable.create_cross_references!(user) + end + + def issuable_class + MergeRequest + end +end diff --git a/app/workers/stuck_merge_jobs_worker.rb b/app/workers/stuck_merge_jobs_worker.rb new file mode 100644 index 00000000000..7843179d77c --- /dev/null +++ b/app/workers/stuck_merge_jobs_worker.rb @@ -0,0 +1,34 @@ +class StuckMergeJobsWorker + include Sidekiq::Worker + include CronjobQueue + + def perform + stuck_merge_requests.find_in_batches(batch_size: 100) do |group| + jids = group.map(&:merge_jid) + + # Find the jobs that aren't currently running or that exceeded the threshold. + completed_jids = Gitlab::SidekiqStatus.completed_jids(jids) + + if completed_jids.any? + completed_ids = group.select { |merge_request| completed_jids.include?(merge_request.merge_jid) }.map(&:id) + + apply_current_state!(completed_jids, completed_ids) + end + end + end + + private + + def apply_current_state!(completed_jids, completed_ids) + merge_requests = MergeRequest.where(id: completed_ids) + + merge_requests.where.not(merge_commit_sha: nil).update_all(state: :merged) + merge_requests.where(merge_commit_sha: nil).update_all(state: :opened) + + Rails.logger.info("Updated state of locked merge jobs. JIDs: #{completed_jids.join(', ')}") + end + + def stuck_merge_requests + MergeRequest.select('id, merge_jid').with_state(:locked).where.not(merge_jid: nil).reorder(nil) + end +end diff --git a/changelogs/unreleased/31207-clean-locked-merge-requests.yml b/changelogs/unreleased/31207-clean-locked-merge-requests.yml new file mode 100644 index 00000000000..1f52987baef --- /dev/null +++ b/changelogs/unreleased/31207-clean-locked-merge-requests.yml @@ -0,0 +1,4 @@ +--- +title: Unlock stuck merge request and set the proper state +merge_request: 13207 +author: diff --git a/changelogs/unreleased/32844-issuables-performance.yml b/changelogs/unreleased/32844-issuables-performance.yml new file mode 100644 index 00000000000..e9b21c1aa45 --- /dev/null +++ b/changelogs/unreleased/32844-issuables-performance.yml @@ -0,0 +1,4 @@ +--- +title: Move some code from services to workers in order to improve performance +merge_request: 13326 +author: diff --git a/changelogs/unreleased/33874_confi.yml b/changelogs/unreleased/33874_confi.yml new file mode 100644 index 00000000000..940753d9aaa --- /dev/null +++ b/changelogs/unreleased/33874_confi.yml @@ -0,0 +1,5 @@ +--- +title: Update confidential issue UI - add confidential visibility and settings to + sidebar +merge_request: +author: diff --git a/changelogs/unreleased/35483-improve-mobile-sidebar.yml b/changelogs/unreleased/35483-improve-mobile-sidebar.yml new file mode 100644 index 00000000000..eb3dab1da9e --- /dev/null +++ b/changelogs/unreleased/35483-improve-mobile-sidebar.yml @@ -0,0 +1,4 @@ +--- +title: Improve mobile sidebar +merge_request: +author: diff --git a/changelogs/unreleased/35761-convdev-perc.yml b/changelogs/unreleased/35761-convdev-perc.yml new file mode 100644 index 00000000000..319c4d18219 --- /dev/null +++ b/changelogs/unreleased/35761-convdev-perc.yml @@ -0,0 +1,4 @@ +--- +title: Store & use ConvDev percentages returned by the Version app +merge_request: +author: diff --git a/changelogs/unreleased/github.yml b/changelogs/unreleased/github.yml new file mode 100644 index 00000000000..585b9b13b65 --- /dev/null +++ b/changelogs/unreleased/github.yml @@ -0,0 +1,4 @@ +--- +title: Reduce memory usage of the GitHub importer +merge_request: 12886 +author: diff --git a/changelogs/unreleased/group-milestone-references-system-notes.yml b/changelogs/unreleased/group-milestone-references-system-notes.yml new file mode 100644 index 00000000000..58215352305 --- /dev/null +++ b/changelogs/unreleased/group-milestone-references-system-notes.yml @@ -0,0 +1,4 @@ +--- +title: Support Markdown references, autocomplete, and quick actions for group milestones +merge_request: +author: diff --git a/changelogs/unreleased/group-new-issue.yml b/changelogs/unreleased/group-new-issue.yml new file mode 100644 index 00000000000..5480a44526b --- /dev/null +++ b/changelogs/unreleased/group-new-issue.yml @@ -0,0 +1,4 @@ +--- +title: Cache recent projects for group-level new resource creation. +merge_request: !13058 +author: diff --git a/changelogs/unreleased/pawel-add-sidekiq-metrics-endpoint-32145.yml b/changelogs/unreleased/pawel-add-sidekiq-metrics-endpoint-32145.yml new file mode 100644 index 00000000000..71eabdc16d2 --- /dev/null +++ b/changelogs/unreleased/pawel-add-sidekiq-metrics-endpoint-32145.yml @@ -0,0 +1,4 @@ +--- +title: Add Prometheus metrics exporter to Sidekiq +merge_request: 13082 +author: diff --git a/changelogs/unreleased/zj-project-templates.yml b/changelogs/unreleased/zj-project-templates.yml new file mode 100644 index 00000000000..ab6e0f2d5f2 --- /dev/null +++ b/changelogs/unreleased/zj-project-templates.yml @@ -0,0 +1,4 @@ +--- +title: Projects can be created from templates +merge_request: 13108 +author: diff --git a/config/application.rb b/config/application.rb index f7145566262..47887bf8596 100644 --- a/config/application.rb +++ b/config/application.rb @@ -181,7 +181,11 @@ module Gitlab end end + # We add the MilestonesRoutingHelper because we know that this does not + # conflict with the methods defined in `project_url_helpers`, and we want + # these methods available in the same places. Gitlab::Routing.add_helpers(project_url_helpers) + Gitlab::Routing.add_helpers(MilestonesRoutingHelper) end end end diff --git a/config/dependency_decisions.yml b/config/dependency_decisions.yml index 59c7050a14d..ca5b941aebf 100644 --- a/config/dependency_decisions.yml +++ b/config/dependency_decisions.yml @@ -398,3 +398,9 @@ :why: https://github.com/remy/undefsafe/blob/master/LICENSE :versions: [] :when: 2017-04-10 06:30:00.002555000 Z +- - :approve + - thunky + - :who: Mike Greiling + :why: https://github.com/mafintosh/thunky/blob/master/README.md#license + :versions: [] + :when: 2017-08-07 05:56:09.907045000 Z diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 45ab4e1a851..e73db08fcac 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -590,6 +590,12 @@ production: &base ip_whitelist: - 127.0.0.0/8 + # Sidekiq exporter is webserver built in to Sidekiq to expose Prometheus metrics + sidekiq_exporter: + # enabled: true + # address: localhost + # port: 3807 + # # 5. Extra customization # ========================== diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 7a43bf939ea..2699173fc61 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -395,6 +395,10 @@ Settings.cron_jobs['remove_old_web_hook_logs_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['remove_old_web_hook_logs_worker']['cron'] ||= '40 0 * * *' Settings.cron_jobs['remove_old_web_hook_logs_worker']['job_class'] = 'RemoveOldWebHookLogsWorker' +Settings.cron_jobs['stuck_merge_jobs_worker'] ||= Settingslogic.new({}) +Settings.cron_jobs['stuck_merge_jobs_worker']['cron'] ||= '0 */2 * * *' +Settings.cron_jobs['stuck_merge_jobs_worker']['job_class'] = 'StuckMergeJobsWorker' + # # GitLab Shell # @@ -524,6 +528,10 @@ Settings.webpack.dev_server['port'] ||= 3808 Settings['monitoring'] ||= Settingslogic.new({}) Settings.monitoring['ip_whitelist'] ||= ['127.0.0.1/8'] Settings.monitoring['unicorn_sampler_interval'] ||= 10 +Settings.monitoring['sidekiq_exporter'] ||= Settingslogic.new({}) +Settings.monitoring.sidekiq_exporter['enabled'] ||= false +Settings.monitoring.sidekiq_exporter['address'] ||= 'localhost' +Settings.monitoring.sidekiq_exporter['port'] ||= 3807 # # Testing settings diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index a2f8421f5d7..54c797e0714 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -10,3 +10,9 @@ Prometheus::Client.configure do |config| config.multiprocess_files_dir ||= Rails.root.join('tmp/prometheus_multiproc_dir') end end + +Sidekiq.configure_server do |config| + config.on(:startup) do + Gitlab::Metrics::SidekiqMetricsExporter.instance.start + end +end diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 7496bfa4fbb..83abc83c9f0 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -23,6 +23,8 @@ - [update_merge_requests, 3] - [process_commit, 3] - [new_note, 2] + - [new_issue, 2] + - [new_merge_request, 2] - [build, 2] - [pipeline, 2] - [gitlab_shell, 2] diff --git a/config/webpack.config.js b/config/webpack.config.js index e2a4cade2e4..8e1b80cd39f 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -3,7 +3,7 @@ var fs = require('fs'); var path = require('path'); var webpack = require('webpack'); -var StatsPlugin = require('stats-webpack-plugin'); +var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin; var CopyWebpackPlugin = require('copy-webpack-plugin'); var CompressionPlugin = require('compression-webpack-plugin'); var NameAllModulesPlugin = require('name-all-modules-plugin'); @@ -61,6 +61,7 @@ var config = { pipelines_details: './pipelines/pipeline_details_bundle.js', pipelines_times: './pipelines/pipelines_times.js', profile: './profile/profile_bundle.js', + project_import_gl: './projects/project_import_gitlab_project.js', project_new: './projects/project_new.js', prometheus_metrics: './prometheus_metrics', protected_branches: './protected_branches', @@ -138,12 +139,18 @@ var config = { plugins: [ // manifest filename must match config.webpack.manifest_filename // webpack-rails only needs assetsByChunkName to function properly - new StatsPlugin('manifest.json', { - chunkModules: false, - source: false, - chunks: false, - modules: false, - assets: true + new StatsWriterPlugin({ + filename: 'manifest.json', + transform: function(data, opts) { + var stats = opts.compiler.getStats().toJson({ + chunkModules: false, + source: false, + chunks: false, + modules: false, + assets: true + }); + return JSON.stringify(stats, null, 2); + } }), // prevent pikaday from including moment.js @@ -283,6 +290,7 @@ if (IS_DEV_SERVER) { config.devServer = { host: DEV_SERVER_HOST, port: DEV_SERVER_PORT, + disableHostCheck: true, headers: { 'Access-Control-Allow-Origin': '*' }, stats: 'errors-only', hot: DEV_SERVER_LIVERELOAD, diff --git a/db/migrate/20170731175128_add_percentages_to_conv_dev.rb b/db/migrate/20170731175128_add_percentages_to_conv_dev.rb new file mode 100644 index 00000000000..1819bfc96bb --- /dev/null +++ b/db/migrate/20170731175128_add_percentages_to_conv_dev.rb @@ -0,0 +1,32 @@ +class AddPercentagesToConvDev < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = false + + def up + add_column_with_default :conversational_development_index_metrics, :percentage_boards, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_ci_pipelines, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_deployments, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_environments, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_issues, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_merge_requests, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_milestones, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_notes, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_projects_prometheus_active, :float, allow_null: false, default: 0 + add_column_with_default :conversational_development_index_metrics, :percentage_service_desk_issues, :float, allow_null: false, default: 0 + end + + def down + remove_column :conversational_development_index_metrics, :percentage_boards + remove_column :conversational_development_index_metrics, :percentage_ci_pipelines + remove_column :conversational_development_index_metrics, :percentage_deployments + remove_column :conversational_development_index_metrics, :percentage_environments + remove_column :conversational_development_index_metrics, :percentage_issues + remove_column :conversational_development_index_metrics, :percentage_merge_requests + remove_column :conversational_development_index_metrics, :percentage_milestones + remove_column :conversational_development_index_metrics, :percentage_notes + remove_column :conversational_development_index_metrics, :percentage_projects_prometheus_active + remove_column :conversational_development_index_metrics, :percentage_service_desk_issues + end +end diff --git a/db/migrate/20170731183033_add_merge_jid_to_merge_requests.rb b/db/migrate/20170731183033_add_merge_jid_to_merge_requests.rb new file mode 100644 index 00000000000..a7d8f2f3604 --- /dev/null +++ b/db/migrate/20170731183033_add_merge_jid_to_merge_requests.rb @@ -0,0 +1,7 @@ +class AddMergeJidToMergeRequests < ActiveRecord::Migration + DOWNTIME = false + + def change + add_column :merge_requests, :merge_jid, :string + end +end diff --git a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb new file mode 100644 index 00000000000..9af76c94bf3 --- /dev/null +++ b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb @@ -0,0 +1,30 @@ +class CalculateConvDevIndexPercentages < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + + class ConversationalDevelopmentIndexMetric < ActiveRecord::Base + self.table_name = 'conversational_development_index_metrics' + + METRICS = %w[boards ci_pipelines deployments environments issues merge_requests milestones notes + projects_prometheus_active service_desk_issues] + end + + def up + ConversationalDevelopmentIndexMetric.find_each do |conv_dev_index| + update = [] + + ConversationalDevelopmentIndexMetric::METRICS.each do |metric| + instance_score = conv_dev_index["instance_#{metric}"].to_f + leader_score = conv_dev_index["leader_#{metric}"].to_f + + percentage = leader_score.zero? ? 0.0 : (instance_score / leader_score) * 100 + update << "percentage_#{metric} = '#{percentage}'" + end + + execute("UPDATE conversational_development_index_metrics SET #{update.join(',')} WHERE id = #{conv_dev_index.id}") + end + end + + def down + end +end diff --git a/db/post_migrate/20170807160457_remove_locked_at_column_from_merge_requests.rb b/db/post_migrate/20170807160457_remove_locked_at_column_from_merge_requests.rb new file mode 100644 index 00000000000..ea3d1fb3e02 --- /dev/null +++ b/db/post_migrate/20170807160457_remove_locked_at_column_from_merge_requests.rb @@ -0,0 +1,11 @@ +class RemoveLockedAtColumnFromMergeRequests < ActiveRecord::Migration + DOWNTIME = false + + def up + remove_column :merge_requests, :locked_at + end + + def down + add_column :merge_requests, :locked_at, :datetime_with_timezone + end +end diff --git a/db/schema.rb b/db/schema.rb index f2f35acef95..ed3cf70bcdd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170803130232) do +ActiveRecord::Schema.define(version: 20170807160457) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -451,6 +451,16 @@ ActiveRecord::Schema.define(version: 20170803130232) do t.float "instance_service_desk_issues", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.float "percentage_boards", default: 0.0, null: false + t.float "percentage_ci_pipelines", default: 0.0, null: false + t.float "percentage_deployments", default: 0.0, null: false + t.float "percentage_environments", default: 0.0, null: false + t.float "percentage_issues", default: 0.0, null: false + t.float "percentage_merge_requests", default: 0.0, null: false + t.float "percentage_milestones", default: 0.0, null: false + t.float "percentage_notes", default: 0.0, null: false + t.float "percentage_projects_prometheus_active", default: 0.0, null: false + t.float "percentage_service_desk_issues", default: 0.0, null: false end create_table "deploy_keys_projects", force: :cascade do |t| @@ -840,7 +850,6 @@ ActiveRecord::Schema.define(version: 20170803130232) do t.integer "target_project_id", null: false t.integer "iid" t.text "description" - t.datetime "locked_at" t.integer "updated_by_id" t.text "merge_error" t.text "merge_params" @@ -858,6 +867,7 @@ ActiveRecord::Schema.define(version: 20170803130232) do t.integer "last_edited_by_id" t.integer "head_pipeline_id" t.boolean "ref_fetched" + t.string "merge_jid" end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree diff --git a/doc/development/rake_tasks.md b/doc/development/rake_tasks.md index 42bb5e8619c..bfd80aab6a4 100644 --- a/doc/development/rake_tasks.md +++ b/doc/development/rake_tasks.md @@ -146,3 +146,20 @@ If new emoji are added, the spritesheet may change size. To compensate for such changes, first generate the `emoji.png` spritesheet with the above Rake task, then check the dimensions of the new spritesheet and update the `SPRITESHEET_WIDTH` and `SPRITESHEET_HEIGHT` constants accordingly. + +## Updating project templates + +Starting a project from a template needs this project to be exported. On a +up to date master branch with run: + +``` +gdk run db +# In a new terminal window +bundle exec rake gitlab:update_project_templates +git checkout -b update-project-templates +git add vendor/project_templates +git commit +git push -u origin update-project-templates +``` + +Now create a merge request and merge that to master. diff --git a/doc/user/markdown.md b/doc/user/markdown.md index 0d29b471d52..b42b8f0a525 100644 --- a/doc/user/markdown.md +++ b/doc/user/markdown.md @@ -248,7 +248,7 @@ GFM will recognize the following: | `~123` | label by ID | | `~bug` | one-word label by name | | `~"feature request"` | multi-word label by name | -| `%123` | milestone by ID | +| `%123` | project milestone by ID | | `%v1.23` | one-word milestone by name | | `%"release candidate"` | multi-word milestone by name | | `9ba12248` | specific commit | @@ -262,7 +262,7 @@ GFM also recognizes certain cross-project references: |:----------------------------------------|:------------------------| | `namespace/project#123` | issue | | `namespace/project!123` | merge request | -| `namespace/project%123` | milestone | +| `namespace/project%123` | project milestone | | `namespace/project$123` | snippet | | `namespace/project@9ba12248` | specific commit | | `namespace/project@9ba12248...b19a04f5` | commit range comparison | @@ -274,7 +274,7 @@ It also has a shorthand version to reference other projects from the same namesp |:------------------------------|:------------------------| | `project#123` | issue | | `project!123` | merge request | -| `project%123` | milestone | +| `project%123` | project milestone | | `project$123` | snippet | | `project@9ba12248` | specific commit | | `project@9ba12248...b19a04f5` | commit range comparison | diff --git a/doc/user/project/integrations/webhooks.md b/doc/user/project/integrations/webhooks.md index c03a2df9a72..47eb0b34f66 100644 --- a/doc/user/project/integrations/webhooks.md +++ b/doc/user/project/integrations/webhooks.md @@ -438,7 +438,6 @@ X-Gitlab-Event: Note Hook "iid": 1, "description": "Et voluptas corrupti assumenda temporibus. Architecto cum animi eveniet amet asperiores. Vitae numquam voluptate est natus sit et ad id.", "position": 0, - "locked_at": null, "source":{ "name":"Gitlab Test", "description":"Aut reprehenderit ut est.", diff --git a/doc/user/project/milestones/index.md b/doc/user/project/milestones/index.md index 23ffde4e8bd..876b98a4dc5 100644 --- a/doc/user/project/milestones/index.md +++ b/doc/user/project/milestones/index.md @@ -56,4 +56,5 @@ total merge requests and issues. ## Quick actions -[Quick actions](../quick_actions.md) are available for assigning and removing project milestones only. [In the future](https://gitlab.com/gitlab-org/gitlab-ce/issues/34778), this will also apply to group milestones. +[Quick actions](../quick_actions.md) are available for assigning and removing +project and group milestones. diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb index 685b43605ae..ef4578aabd6 100644 --- a/lib/banzai/filter/abstract_reference_filter.rb +++ b/lib/banzai/filter/abstract_reference_filter.rb @@ -54,42 +54,42 @@ module Banzai self.class.references_in(*args, &block) end + # Implement in child class + # Example: project.merge_requests.find def find_object(project, id) - # Implement in child class - # Example: project.merge_requests.find end - def find_object_cached(project, id) - if RequestStore.active? - cache = find_objects_cache[object_class][project.id] + # Override if the link reference pattern produces a different ID (global + # ID vs internal ID, for instance) to the regular reference pattern. + def find_object_from_link(project, id) + find_object(project, id) + end - get_or_set_cache(cache, id) { find_object(project, id) } - else + # Implement in child class + # Example: project_merge_request_url + def url_for_object(object, project) + end + + def find_object_cached(project, id) + cached_call(:banzai_find_object, id, path: [object_class, project.id]) do find_object(project, id) end end - def project_from_ref_cached(ref) - if RequestStore.active? - cache = project_refs_cache - - get_or_set_cache(cache, ref) { project_from_ref(ref) } - else - project_from_ref(ref) + def find_object_from_link_cached(project, id) + cached_call(:banzai_find_object_from_link, id, path: [object_class, project.id]) do + find_object_from_link(project, id) end end - def url_for_object(object, project) - # Implement in child class - # Example: project_merge_request_url + def project_from_ref_cached(ref) + cached_call(:banzai_project_refs, ref) do + project_from_ref(ref) + end end def url_for_object_cached(object, project) - if RequestStore.active? - cache = url_for_object_cache[object_class][project.id] - - get_or_set_cache(cache, object) { url_for_object(object, project) } - else + cached_call(:banzai_url_for_object, object, path: [object_class, project.id]) do url_for_object(object, project) end end @@ -120,7 +120,7 @@ module Banzai if link == inner_html && inner_html =~ /\A#{link_pattern}/ replace_link_node_with_text(node, link) do - object_link_filter(inner_html, link_pattern) + object_link_filter(inner_html, link_pattern, link_reference: true) end next @@ -128,7 +128,7 @@ module Banzai if link =~ /\A#{link_pattern}\z/ replace_link_node_with_href(node, link) do - object_link_filter(link, link_pattern, link_content: inner_html) + object_link_filter(link, link_pattern, link_content: inner_html, link_reference: true) end next @@ -146,15 +146,26 @@ module Banzai # text - String text to replace references in. # pattern - Reference pattern to match against. # link_content - Original content of the link being replaced. + # link_reference - True if this was using the link reference pattern, + # false otherwise. # # Returns a String with references replaced with links. All links # have `gfm` and `gfm-OBJECT_NAME` class names attached for styling. - def object_link_filter(text, pattern, link_content: nil) + def object_link_filter(text, pattern, link_content: nil, link_reference: false) references_in(text, pattern) do |match, id, project_ref, namespace_ref, matches| project_path = full_project_path(namespace_ref, project_ref) project = project_from_ref_cached(project_path) - if project && object = find_object_cached(project, id) + if project + object = + if link_reference + find_object_from_link_cached(project, id) + else + find_object_cached(project, id) + end + end + + if object title = object_link_title(object) klass = reference_class(object_sym) @@ -297,15 +308,17 @@ module Banzai RequestStore[:banzai_project_refs] ||= {} end - def find_objects_cache - RequestStore[:banzai_find_objects_cache] ||= Hash.new do |hash, key| - hash[key] = Hash.new { |h, k| h[k] = {} } - end - end + def cached_call(request_store_key, cache_key, path: []) + if RequestStore.active? + cache = RequestStore[request_store_key] ||= Hash.new do |hash, key| + hash[key] = Hash.new { |h, k| h[k] = {} } + end - def url_for_object_cache - RequestStore[:banzai_url_for_object] ||= Hash.new do |hash, key| - hash[key] = Hash.new { |h, k| h[k] = {} } + cache = cache.dig(*path) if path.any? + + get_or_set_cache(cache, cache_key) { yield } + else + yield end end diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb index 45c033d32a8..4fc5f211e84 100644 --- a/lib/banzai/filter/milestone_reference_filter.rb +++ b/lib/banzai/filter/milestone_reference_filter.rb @@ -8,8 +8,15 @@ module Banzai Milestone end + # Links to project milestones contain the IID, but when we're handling + # 'regular' references, we need to use the global ID to disambiguate + # between group and project milestones. def find_object(project, id) - project.milestones.find_by(iid: id) + find_milestone_with_finder(project, id: id) + end + + def find_object_from_link(project, iid) + find_milestone_with_finder(project, iid: iid) end def references_in(text, pattern = Milestone.reference_pattern) @@ -22,7 +29,7 @@ module Banzai milestone = find_milestone($~[:project], $~[:namespace], $~[:milestone_iid], $~[:milestone_name]) if milestone - yield match, milestone.iid, $~[:project], $~[:namespace], $~ + yield match, milestone.id, $~[:project], $~[:namespace], $~ else match end @@ -36,7 +43,8 @@ module Banzai return unless project milestone_params = milestone_params(milestone_id, milestone_name) - project.milestones.find_by(milestone_params) + + find_milestone_with_finder(project, milestone_params) end def milestone_params(iid, name) @@ -47,15 +55,27 @@ module Banzai end end + def find_milestone_with_finder(project, params) + finder_params = { project_ids: [project.id], order: nil } + + # We don't support IID lookups for group milestones, because IIDs can + # clash between group and project milestones. + if project.group && !params[:iid] + finder_params[:group_ids] = [project.group.id] + end + + MilestonesFinder.new(finder_params).execute.find_by(params) + end + def url_for_object(milestone, project) - h = Gitlab::Routing.url_helpers - h.project_milestone_url(project, milestone, - only_path: context[:only_path]) + Gitlab::Routing + .url_helpers + .milestone_url(milestone, only_path: context[:only_path]) end def object_link_text(object, matches) milestone_link = escape_once(super) - reference = object.project.to_reference(project) + reference = object.project&.to_reference(project) if reference.present? "#{milestone_link} <i>in #{reference}</i>".html_safe diff --git a/lib/declarative_policy/runner.rb b/lib/declarative_policy/runner.rb index b5c615da4e3..56afd1f1392 100644 --- a/lib/declarative_policy/runner.rb +++ b/lib/declarative_policy/runner.rb @@ -76,6 +76,8 @@ module DeclarativePolicy @state = State.new steps_by_score do |step, score| + return if !debug && @state.prevented? + passed = nil case step.action when :enable then @@ -93,10 +95,7 @@ module DeclarativePolicy # been prevented. unless @state.prevented? passed = step.pass? - if passed - @state.prevent! - return unless debug - end + @state.prevent! if passed end debug << inspect_step(step, score, passed) if debug @@ -141,13 +140,14 @@ module DeclarativePolicy end steps = Set.new(@steps) + remaining_enablers = steps.count { |s| s.enable? } loop do return if steps.empty? # if the permission hasn't yet been enabled and we only have # prevent steps left, we short-circuit the state here - @state.prevent! if !@state.enabled? && steps.all?(&:prevent?) + @state.prevent! if !@state.enabled? && remaining_enablers == 0 lowest_score = Float::INFINITY next_step = nil @@ -162,6 +162,8 @@ module DeclarativePolicy steps.delete(next_step) + remaining_enablers -= 1 if next_step.enable? + yield next_step, lowest_score end end diff --git a/lib/github/client.rb b/lib/github/client.rb index e65d908d232..9c476df7d46 100644 --- a/lib/github/client.rb +++ b/lib/github/client.rb @@ -1,13 +1,16 @@ module Github class Client + TIMEOUT = 60 + attr_reader :connection, :rate_limit def initialize(options) - @connection = Faraday.new(url: options.fetch(:url)) do |faraday| - faraday.options.open_timeout = options.fetch(:timeout, 60) - faraday.options.timeout = options.fetch(:timeout, 60) + @connection = Faraday.new(url: options.fetch(:url, root_endpoint)) do |faraday| + faraday.options.open_timeout = options.fetch(:timeout, TIMEOUT) + faraday.options.timeout = options.fetch(:timeout, TIMEOUT) faraday.authorization 'token', options.fetch(:token) faraday.adapter :net_http + faraday.ssl.verify = verify_ssl end @rate_limit = RateLimit.new(connection) @@ -19,5 +22,32 @@ module Github Github::Response.new(connection.get(url, query)) end + + private + + def root_endpoint + custom_endpoint || github_endpoint + end + + def custom_endpoint + github_omniauth_provider.dig('args', 'client_options', 'site') + end + + def verify_ssl + # If there is no config, we're connecting to github.com + # and we should verify ssl. + github_omniauth_provider.fetch('verify_ssl', true) + end + + def github_endpoint + OmniAuth::Strategies::GitHub.default_options[:client_options][:site] + end + + def github_omniauth_provider + @github_omniauth_provider ||= + Gitlab.config.omniauth.providers + .find { |provider| provider.name == 'github' } + .to_h + end end end diff --git a/lib/github/import.rb b/lib/github/import.rb index cea4be5460b..4cc01593ef4 100644 --- a/lib/github/import.rb +++ b/lib/github/import.rb @@ -41,13 +41,16 @@ module Github self.reset_callbacks :validate end - attr_reader :project, :repository, :repo, :options, :errors, :cached, :verbose + attr_reader :project, :repository, :repo, :repo_url, :wiki_url, + :options, :errors, :cached, :verbose - def initialize(project, options) + def initialize(project, options = {}) @project = project @repository = project.repository @repo = project.import_source - @options = options + @repo_url = project.import_url + @wiki_url = project.import_url.sub(/\.git\z/, '.wiki.git') + @options = options.reverse_merge(token: project.import_data&.credentials&.fetch(:user)) @verbose = options.fetch(:verbose, false) @cached = Hash.new { |hash, key| hash[key] = Hash.new } @errors = [] @@ -65,6 +68,8 @@ module Github fetch_pull_requests puts 'Fetching issues...'.color(:aqua) if verbose fetch_issues + puts 'Fetching releases...'.color(:aqua) if verbose + fetch_releases puts 'Cloning wiki repository...'.color(:aqua) if verbose fetch_wiki_repository puts 'Expiring repository cache...'.color(:aqua) if verbose @@ -72,6 +77,7 @@ module Github true rescue Github::RepositoryFetchError + expire_repository_cache false ensure keep_track_of_errors @@ -81,23 +87,21 @@ module Github def fetch_repository begin - project.create_repository unless project.repository.exists? - project.repository.add_remote('github', "https://#{options.fetch(:token)}@github.com/#{repo}.git") + project.ensure_repository + project.repository.add_remote('github', repo_url) project.repository.set_remote_as_mirror('github') project.repository.fetch_remote('github', forced: true) - rescue Gitlab::Shell::Error => e - error(:project, "https://github.com/#{repo}.git", e.message) + rescue Gitlab::Git::Repository::NoRepository, Gitlab::Shell::Error => e + error(:project, repo_url, e.message) raise Github::RepositoryFetchError end end def fetch_wiki_repository - wiki_url = "https://#{options.fetch(:token)}@github.com/#{repo}.wiki.git" - wiki_path = "#{project.full_path}.wiki" + return if project.wiki.repository_exists? - unless project.wiki.repository_exists? - gitlab_shell.import_repository(project.repository_storage_path, wiki_path, wiki_url) - end + wiki_path = "#{project.disk_path}.wiki" + gitlab_shell.import_repository(project.repository_storage_path, wiki_path, wiki_url) rescue Gitlab::Shell::Error => e # GitHub error message when the wiki repo has not been created, # this means that repo has wiki enabled, but have no pages. So, @@ -309,7 +313,7 @@ module Github next unless representation.valid? release = ::Release.find_or_initialize_by(project_id: project.id, tag: representation.tag) - next unless relese.new_record? + next unless release.new_record? begin release.description = representation.description @@ -337,7 +341,7 @@ module Github def user_id(user, fallback_id = nil) return unless user.present? - return cached[:user_ids][user.id] if cached[:user_ids].key?(user.id) + return cached[:user_ids][user.id] if cached[:user_ids][user.id].present? gitlab_user_id = user_id_by_external_uid(user.id) || user_id_by_email(user.email) @@ -367,7 +371,7 @@ module Github end def expire_repository_cache - repository.expire_content_cache + repository.expire_content_cache if project.repository_exists? end def keep_track_of_errors diff --git a/lib/gitlab/daemon.rb b/lib/gitlab/daemon.rb new file mode 100644 index 00000000000..dfd17e35707 --- /dev/null +++ b/lib/gitlab/daemon.rb @@ -0,0 +1,62 @@ +module Gitlab + class Daemon + def self.initialize_instance(*args) + raise "#{name} singleton instance already initialized" if @instance + @instance = new(*args) + Kernel.at_exit(&@instance.method(:stop)) + @instance + end + + def self.instance + @instance ||= initialize_instance + end + + attr_reader :thread + + def thread? + !thread.nil? + end + + def initialize + @mutex = Mutex.new + end + + def enabled? + true + end + + def start + return unless enabled? + + @mutex.synchronize do + return thread if thread? + + @thread = Thread.new { start_working } + end + end + + def stop + @mutex.synchronize do + return unless thread? + + stop_working + + if thread + thread.wakeup if thread.alive? + thread.join + @thread = nil + end + end + end + + private + + def start_working + raise NotImplementedError + end + + def stop_working + # no-ops + end + end +end diff --git a/lib/gitlab/git/blob.rb b/lib/gitlab/git/blob.rb index db6cfc9671f..77b81d2d437 100644 --- a/lib/gitlab/git/blob.rb +++ b/lib/gitlab/git/blob.rb @@ -20,66 +20,7 @@ module Gitlab if is_enabled find_by_gitaly(repository, sha, path) else - find_by_rugged(repository, sha, path) - end - end - end - - def find_by_gitaly(repository, sha, path) - path = path.sub(/\A\/*/, '') - path = '/' if path.empty? - name = File.basename(path) - entry = Gitlab::GitalyClient::CommitService.new(repository).tree_entry(sha, path, MAX_DATA_DISPLAY_SIZE) - return unless entry - - case entry.type - when :COMMIT - new( - id: entry.oid, - name: name, - size: 0, - data: '', - path: path, - commit_id: sha - ) - when :BLOB - new( - id: entry.oid, - name: name, - size: entry.size, - data: entry.data.dup, - mode: entry.mode.to_s(8), - path: path, - commit_id: sha, - binary: binary?(entry.data) - ) - end - end - - def find_by_rugged(repository, sha, path) - commit = repository.lookup(sha) - root_tree = commit.tree - - blob_entry = find_entry_by_path(repository, root_tree.oid, path) - - return nil unless blob_entry - - if blob_entry[:type] == :commit - submodule_blob(blob_entry, path, sha) - else - blob = repository.lookup(blob_entry[:oid]) - - if blob - new( - id: blob.oid, - name: blob_entry[:name], - size: blob.size, - data: blob.content(MAX_DATA_DISPLAY_SIZE), - mode: blob_entry[:filemode].to_s(8), - path: path, - commit_id: sha, - binary: blob.binary? - ) + find_by_rugged(repository, sha, path, limit: MAX_DATA_DISPLAY_SIZE) end end end @@ -109,6 +50,21 @@ module Gitlab detect && detect[:type] == :binary end + # Returns an array of Blob instances, specified in blob_references as + # [[commit_sha, path], [commit_sha, path], ...]. If blob_size_limit < 0 then the + # full blob contents are returned. If blob_size_limit >= 0 then each blob will + # contain no more than limit bytes in its data attribute. + # + # Keep in mind that this method may allocate a lot of memory. It is up + # to the caller to limit the number of blobs and blob_size_limit. + # + def batch(repository, blob_references, blob_size_limit: nil) + blob_size_limit ||= MAX_DATA_DISPLAY_SIZE + blob_references.map do |sha, path| + find_by_rugged(repository, sha, path, limit: blob_size_limit) + end + end + private # Recursive search of blob id by path @@ -153,6 +109,66 @@ module Gitlab commit_id: sha ) end + + def find_by_gitaly(repository, sha, path) + path = path.sub(/\A\/*/, '') + path = '/' if path.empty? + name = File.basename(path) + entry = Gitlab::GitalyClient::CommitService.new(repository).tree_entry(sha, path, MAX_DATA_DISPLAY_SIZE) + return unless entry + + case entry.type + when :COMMIT + new( + id: entry.oid, + name: name, + size: 0, + data: '', + path: path, + commit_id: sha + ) + when :BLOB + new( + id: entry.oid, + name: name, + size: entry.size, + data: entry.data.dup, + mode: entry.mode.to_s(8), + path: path, + commit_id: sha, + binary: binary?(entry.data) + ) + end + end + + def find_by_rugged(repository, sha, path, limit:) + commit = repository.lookup(sha) + root_tree = commit.tree + + blob_entry = find_entry_by_path(repository, root_tree.oid, path) + + return nil unless blob_entry + + if blob_entry[:type] == :commit + submodule_blob(blob_entry, path, sha) + else + blob = repository.lookup(blob_entry[:oid]) + + if blob + new( + id: blob.oid, + name: blob_entry[:name], + size: blob.size, + # Rugged::Blob#content is expensive; don't call it if we don't have to. + data: limit.zero? ? '' : blob.content(limit), + mode: blob_entry[:filemode].to_s(8), + path: path, + commit_id: sha, + binary: blob.binary? + ) + end + end + end end def initialize(options) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 1005a819f95..f246393cfbc 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -282,7 +282,14 @@ module Gitlab # Return repo size in megabytes def size - size = popen(%w(du -sk), path).first.strip.to_i + size = gitaly_migrate(:repository_size) do |is_enabled| + if is_enabled + size_by_gitaly + else + size_by_shelling_out + end + end + (size.to_f / 1024).round(2) end @@ -299,6 +306,21 @@ module Gitlab # # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/446 def log(options) + default_options = { + limit: 10, + offset: 0, + path: nil, + follow: false, + skip_merges: false, + disable_walk: false, + after: nil, + before: nil + } + + options = default_options.merge(options) + options[:limit] ||= 0 + options[:offset] ||= 0 + raw_log(options).map { |c| Commit.decorate(c) } end @@ -712,20 +734,6 @@ module Gitlab end def raw_log(options) - default_options = { - limit: 10, - offset: 0, - path: nil, - follow: false, - skip_merges: false, - disable_walk: false, - after: nil, - before: nil - } - - options = default_options.merge(options) - options[:limit] ||= 0 - options[:offset] ||= 0 actual_ref = options[:ref] || root_ref begin sha = sha_from_ref(actual_ref) @@ -942,6 +950,14 @@ module Gitlab gitaly_ref_client.tags end + def size_by_shelling_out + popen(%w(du -sk), path).first.strip.to_i + end + + def size_by_gitaly + gitaly_repository_client.repository_size + end + def count_commits_by_gitaly(options) gitaly_commit_client.commit_count(options[:ref], options) end diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index ac6817e6d0e..3f577ac8530 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -135,6 +135,20 @@ module Gitlab consume_commits_response(response) end + def commits_by_message(query, revision: '', path: '', limit: 1000, offset: 0) + request = Gitaly::CommitsByMessageRequest.new( + repository: @gitaly_repo, + query: query, + revision: revision.to_s.force_encoding(Encoding::ASCII_8BIT), + path: path.to_s.force_encoding(Encoding::ASCII_8BIT), + limit: limit.to_i, + offset: offset.to_i + ) + + response = GitalyClient.call(@repository.storage, :commit_service, :commits_by_message, request) + consume_commits_response(response) + end + def languages(ref = nil) request = Gitaly::CommitLanguagesRequest.new(repository: @gitaly_repo, revision: ref || '') response = GitalyClient.call(@repository.storage, :commit_service, :commit_languages, request) diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index 13e75b256a7..79ce784f2f2 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -27,6 +27,11 @@ module Gitlab request = Gitaly::RepackIncrementalRequest.new(repository: @gitaly_repo) GitalyClient.call(@storage, :repository_service, :repack_incremental, request) end + + def repository_size + request = Gitaly::RepositorySizeRequest.new(repository: @gitaly_repo) + GitalyClient.call(@storage, :repository_service, :repository_size, request).size + end end end end diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index c8ad3a7a5e0..c5c05bfe2fb 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -101,6 +101,7 @@ excluded_attributes: merge_requests: - :milestone_id - :ref_fetched + - :merge_jid award_emoji: - :awardable_id statuses: diff --git a/lib/gitlab/import_sources.rb b/lib/gitlab/import_sources.rb index 52276cbcd9a..5404dc11a87 100644 --- a/lib/gitlab/import_sources.rb +++ b/lib/gitlab/import_sources.rb @@ -8,7 +8,7 @@ module Gitlab ImportSource = Struct.new(:name, :title, :importer) ImportTable = [ - ImportSource.new('github', 'GitHub', Gitlab::GithubImport::Importer), + ImportSource.new('github', 'GitHub', Github::Import), ImportSource.new('bitbucket', 'Bitbucket', Gitlab::BitbucketImport::Importer), ImportSource.new('gitlab', 'GitLab.com', Gitlab::GitlabImport::Importer), ImportSource.new('google_code', 'Google Code', Gitlab::GoogleCodeImport::Importer), diff --git a/lib/gitlab/key_fingerprint.rb b/lib/gitlab/key_fingerprint.rb index b75ae512d92..d9a79f7c291 100644 --- a/lib/gitlab/key_fingerprint.rb +++ b/lib/gitlab/key_fingerprint.rb @@ -1,55 +1,48 @@ module Gitlab class KeyFingerprint - include Gitlab::Popen + attr_reader :key, :ssh_key - attr_accessor :key + # Unqualified MD5 fingerprint for compatibility + delegate :fingerprint, to: :ssh_key, allow_nil: true def initialize(key) @key = key - end - - def fingerprint - cmd_status = 0 - cmd_output = '' - - Tempfile.open('gitlab_key_file') do |file| - file.puts key - file.rewind - - cmd = [] - cmd.push('ssh-keygen') - cmd.push('-E', 'md5') if explicit_fingerprint_algorithm? - cmd.push('-lf', file.path) - - cmd_output, cmd_status = popen(cmd, '/tmp') - end - - return nil unless cmd_status.zero? - # 16 hex bytes separated by ':', optionally starting with "MD5:" - fingerprint_matches = cmd_output.match(/(MD5:)?(?<fingerprint>(\h{2}:){15}\h{2})/) - return nil unless fingerprint_matches - - fingerprint_matches[:fingerprint] + @ssh_key = + begin + Net::SSH::KeyFactory.load_data_public_key(key) + rescue Net::SSH::Exception, NotImplementedError + end end - private - - def explicit_fingerprint_algorithm? - # OpenSSH 6.8 introduces a new default output format for fingerprints. - # Check the version and decide which command to use. - - version_output, version_status = popen(%w(ssh -V)) - return false unless version_status.zero? + def valid? + ssh_key.present? + end - version_matches = version_output.match(/OpenSSH_(?<major>\d+)\.(?<minor>\d+)/) - return false unless version_matches + def type + return unless valid? - version_info = Gitlab::VersionInfo.new(version_matches[:major].to_i, version_matches[:minor].to_i) + parts = ssh_key.ssh_type.split('-') + parts.shift if parts[0] == 'ssh' - required_version_info = Gitlab::VersionInfo.new(6, 8) + parts[0].upcase + end - version_info >= required_version_info + def bits + return unless valid? + + case type + when 'RSA' + ssh_key.n.num_bits + when 'DSS', 'DSA' + ssh_key.p.num_bits + when 'ECDSA' + ssh_key.group.order.num_bits + when 'ED25519' + 256 + else + raise "Unsupported key type: #{type}" + end end end end diff --git a/lib/gitlab/metrics/base_sampler.rb b/lib/gitlab/metrics/base_sampler.rb index 219accfc029..716d20bb91a 100644 --- a/lib/gitlab/metrics/base_sampler.rb +++ b/lib/gitlab/metrics/base_sampler.rb @@ -1,20 +1,7 @@ require 'logger' module Gitlab module Metrics - class BaseSampler - def self.initialize_instance(*args) - raise "#{name} singleton instance already initialized" if @instance - @instance = new(*args) - at_exit(&@instance.method(:stop)) - @instance - end - - def self.instance - @instance - end - - attr_reader :running - + class BaseSampler < Daemon # interval - The sampling interval in seconds. def initialize(interval) interval_half = interval.to_f / 2 @@ -22,44 +9,7 @@ module Gitlab @interval = interval @interval_steps = (-interval_half..interval_half).step(0.1).to_a - @mutex = Mutex.new - end - - def enabled? - true - end - - def start - return unless enabled? - - @mutex.synchronize do - return if running - @running = true - - @thread = Thread.new do - sleep(sleep_interval) - - while running - safe_sample - - sleep(sleep_interval) - end - end - end - end - - def stop - @mutex.synchronize do - return unless running - - @running = false - - if @thread - @thread.wakeup if @thread.alive? - @thread.join - @thread = nil - end - end + super() end def safe_sample @@ -81,7 +31,7 @@ module Gitlab # potentially missing anything that happens in between samples). # 2. Don't sample data at the same interval two times in a row. def sleep_interval - while step = @interval_steps.sample + while (step = @interval_steps.sample) if step != @last_step @last_step = step @@ -89,6 +39,25 @@ module Gitlab end end end + + private + + attr_reader :running + + def start_working + @running = true + sleep(sleep_interval) + + while running + safe_sample + + sleep(sleep_interval) + end + end + + def stop_working + @running = false + end end end end diff --git a/lib/gitlab/metrics/sidekiq_metrics_exporter.rb b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb new file mode 100644 index 00000000000..5980a4ded2b --- /dev/null +++ b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb @@ -0,0 +1,39 @@ +require 'webrick' +require 'prometheus/client/rack/exporter' + +module Gitlab + module Metrics + class SidekiqMetricsExporter < Daemon + def enabled? + Gitlab::Metrics.metrics_folder_present? && settings.enabled + end + + def settings + Settings.monitoring.sidekiq_exporter + end + + private + + attr_reader :server + + def start_working + @server = ::WEBrick::HTTPServer.new(Port: settings.port, BindAddress: settings.address) + server.mount "/", Rack::Handler::WEBrick, rack_app + server.start + end + + def stop_working + server.shutdown + @server = nil + end + + def rack_app + Rack::Builder.app do + use Rack::Deflater + use ::Prometheus::Client::Rack::Exporter + run -> (env) { [404, {}, ['']] } + end + end + end + end +end diff --git a/lib/gitlab/project_template.rb b/lib/gitlab/project_template.rb new file mode 100644 index 00000000000..cf461adf697 --- /dev/null +++ b/lib/gitlab/project_template.rb @@ -0,0 +1,45 @@ +module Gitlab + class ProjectTemplate + attr_reader :title, :name + + def initialize(name, title) + @name, @title = name, title + end + + alias_method :logo, :name + + def file + archive_path.open + end + + def archive_path + Rails.root.join("vendor/project_templates/#{name}.tar.gz") + end + + def clone_url + "https://gitlab.com/gitlab-org/project-templates/#{name}.git" + end + + def ==(other) + name == other.name && title == other.title + end + + TEMPLATES_TABLE = [ + ProjectTemplate.new('rails', 'Ruby on Rails') + ].freeze + + class << self + def all + TEMPLATES_TABLE + end + + def find(name) + all.find { |template| template.name == name.to_s } + end + + def archive_directory + Rails.root.join("vendor_directory/project_templates") + end + end + end +end diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 4366ff336ef..0cb28732402 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -105,12 +105,24 @@ module Gitlab # fetch_remote("gitlab/gitlab-ci", "upstream") # # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387 - def fetch_remote(storage, name, remote, forced: false, no_tags: false) + def fetch_remote(storage, name, remote, ssh_auth: nil, forced: false, no_tags: false) args = [gitlab_shell_projects_path, 'fetch-remote', storage, "#{name}.git", remote, "#{Gitlab.config.gitlab_shell.git_timeout}"] args << '--force' if forced args << '--no-tags' if no_tags - gitlab_shell_fast_execute_raise_error(args) + vars = {} + + if ssh_auth&.ssh_import? + if ssh_auth.ssh_key_auth? && ssh_auth.ssh_private_key.present? + vars['GITLAB_SHELL_SSH_KEY'] = ssh_auth.ssh_private_key + end + + if ssh_auth.ssh_known_hosts.present? + vars['GITLAB_SHELL_KNOWN_HOSTS'] = ssh_auth.ssh_known_hosts + end + end + + gitlab_shell_fast_execute_raise_error(args, vars) end # Move repository @@ -293,15 +305,15 @@ module Gitlab false end - def gitlab_shell_fast_execute_raise_error(cmd) - output, status = gitlab_shell_fast_execute_helper(cmd) + def gitlab_shell_fast_execute_raise_error(cmd, vars = {}) + output, status = gitlab_shell_fast_execute_helper(cmd, vars) raise Error, output unless status.zero? true end - def gitlab_shell_fast_execute_helper(cmd) - vars = ENV.to_h.slice(*GITLAB_SHELL_ENV_VARS) + def gitlab_shell_fast_execute_helper(cmd, vars = {}) + vars.merge!(ENV.to_h.slice(*GITLAB_SHELL_ENV_VARS)) # Don't pass along the entire parent environment to prevent gitlab-shell # from wasting I/O by searching through GEM_PATH diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index 59c32bbe7a4..a7e30423c7a 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -4,6 +4,55 @@ namespace :gitlab do TEMPLATE_DATA.each { |template| update(template) } end + desc "GitLab | Update project templates" + task :update_project_templates do + if Rails.env.production? + puts "This rake task is not meant fo production instances".red + exit(1) + end + admin = User.find_by(admin: true) + + unless admin + puts "No admin user could be found".red + exit(1) + end + + Gitlab::ProjectTemplate.all.each do |template| + params = { + import_url: template.clone_url, + namespace_id: admin.namespace.id, + path: template.title, + skip_wiki: true + } + + puts "Creating project for #{template.name}" + project = Projects::CreateService.new(admin, params).execute + + loop do + if project.finished? + puts "Import finished for #{template.name}" + break + end + + if project.failed? + puts "Failed to import from #{project_params[:import_url]}".red + exit(1) + end + + puts "Waiting for the import to finish" + + sleep(5) + project.reload + end + + Projects::ImportExport::ExportService.new(project, admin).execute + FileUtils.cp(project.export_project_path, template.archive_path) + Projects::DestroyService.new(admin, project).execute + puts "Exported #{template.name}".green + end + puts "Done".green + end + def update(template) sub_dir = template.repo_url.match(/([A-Za-z-]+)\.git\z/)[1] dir = File.join(vendor_directory, sub_dir) diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 50b8e331469..96b8f59242c 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -7,7 +7,7 @@ class GithubImport end def initialize(token, gitlab_username, project_path, extras) - @options = { url: 'https://api.github.com', token: token, verbose: true } + @options = { token: token, verbose: true } @project_path = project_path @current_user = User.find_by_username(gitlab_username) @github_repo = extras.empty? ? nil : extras.first @@ -62,6 +62,7 @@ class GithubImport visibility_level: visibility_level, import_type: 'github', import_source: @repo['full_name'], + import_url: @repo['clone_url'].sub('://', "://#{@options[:token]}@"), skip_wiki: @repo['has_wiki'] ).execute end diff --git a/package.json b/package.json index 2355aad79cc..c5247a63e67 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "axios": "^0.16.2", "babel-core": "^6.22.1", "babel-eslint": "^7.2.1", - "babel-loader": "^6.2.10", + "babel-loader": "^7.1.1", "babel-plugin-transform-define": "^1.2.0", "babel-preset-latest": "^6.24.0", "babel-preset-stage-2": "^6.22.0", @@ -52,7 +52,6 @@ "react-dev-utils": "^0.5.2", "select2": "3.5.2-browserify", "sql.js": "^0.4.0", - "stats-webpack-plugin": "^0.4.3", "three": "^0.84.0", "three-orbit-controls": "^82.1.0", "three-stl-loader": "^1.0.4", @@ -64,14 +63,15 @@ "vue-loader": "^11.3.4", "vue-resource": "^1.3.4", "vue-template-compiler": "^2.2.6", - "webpack": "^2.6.1", - "webpack-bundle-analyzer": "^2.8.2" + "webpack": "^3.4.0", + "webpack-bundle-analyzer": "^2.8.2", + "webpack-stats-plugin": "^0.1.5" }, "devDependencies": { "babel-plugin-istanbul": "^4.0.0", "eslint": "^3.10.1", "eslint-config-airbnb-base": "^10.0.1", - "eslint-import-resolver-webpack": "^0.8.1", + "eslint-import-resolver-webpack": "^0.8.3", "eslint-plugin-filenames": "^1.1.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jasmine": "^2.1.0", @@ -85,8 +85,8 @@ "karma-jasmine": "^1.1.0", "karma-mocha-reporter": "^2.2.2", "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^2.0.2", + "karma-webpack": "^2.0.4", "nodemon": "^1.11.0", - "webpack-dev-server": "^2.4.2" + "webpack-dev-server": "^2.6.1" } } diff --git a/spec/factories/conversational_development_index_metrics.rb b/spec/factories/conversational_development_index_metrics.rb index a5412629195..3806c43ba15 100644 --- a/spec/factories/conversational_development_index_metrics.rb +++ b/spec/factories/conversational_development_index_metrics.rb @@ -2,32 +2,42 @@ FactoryGirl.define do factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do leader_issues 9.256 instance_issues 1.234 + percentage_issues 13.331 leader_notes 30.33333 instance_notes 28.123 + percentage_notes 92.713 leader_milestones 16.2456 instance_milestones 1.234 + percentage_milestones 7.595 leader_boards 5.2123 instance_boards 3.254 + percentage_boards 62.429 leader_merge_requests 1.2 instance_merge_requests 0.6 + percentage_merge_requests 50.0 leader_ci_pipelines 12.1234 instance_ci_pipelines 2.344 + percentage_ci_pipelines 19.334 leader_environments 3.3333 instance_environments 2.2222 + percentage_environments 66.672 leader_deployments 1.200 instance_deployments 0.771 + percentage_deployments 64.25 leader_projects_prometheus_active 0.111 instance_projects_prometheus_active 0.109 + percentage_projects_prometheus_active 98.198 leader_service_desk_issues 15.891 instance_service_desk_issues 13.345 + percentage_service_desk_issues 83.978 end end diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb index c51b81c1cff..ce458431c55 100644 --- a/spec/features/boards/boards_spec.rb +++ b/spec/features/boards/boards_spec.rb @@ -233,7 +233,7 @@ describe 'Issue Boards', js: true do wait_for_board_cards(4, 1) expect(find('.board:nth-child(3)')).to have_content(issue6.title) - expect(find('.board:nth-child(3)').all('.card').last).not_to have_content(development.title) + expect(find('.board:nth-child(3)').all('.card').last).to have_content(development.title) end it 'issue moves between lists' do @@ -244,7 +244,7 @@ describe 'Issue Boards', js: true do wait_for_board_cards(4, 1) expect(find('.board:nth-child(2)')).to have_content(issue7.title) - expect(find('.board:nth-child(2)').all('.card').first).not_to have_content(planning.title) + expect(find('.board:nth-child(2)').all('.card').first).to have_content(planning.title) end it 'issue moves from closed' do diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb index 373cd92793e..8d3d4ff8773 100644 --- a/spec/features/boards/sidebar_spec.rb +++ b/spec/features/boards/sidebar_spec.rb @@ -257,7 +257,7 @@ describe 'Issue Boards', js: true do end end - expect(card).to have_selector('.label', count: 2) + expect(card).to have_selector('.label', count: 3) expect(card).to have_content(bug.title) end @@ -283,7 +283,7 @@ describe 'Issue Boards', js: true do end end - expect(card).to have_selector('.label', count: 3) + expect(card).to have_selector('.label', count: 4) expect(card).to have_content(bug.title) expect(card).to have_content(regression.title) end @@ -308,7 +308,7 @@ describe 'Issue Boards', js: true do end end - expect(card).not_to have_selector('.label') + expect(card).to have_selector('.label', count: 1) expect(card).not_to have_content(stretch.title) end end diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index be6f78ee607..795335aa106 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -79,12 +79,21 @@ RSpec.describe 'Dashboard Issues' do end end - it 'shows the new issue page', :js do + it 'shows the new issue page', js: true do find('.new-project-item-select-button').trigger('click') + wait_for_requests - find('.select2-results li').click - expect(page).to have_current_path("/#{project.path_with_namespace}/issues/new") + project_path = "/#{project.path_with_namespace}" + project_json = { name: project.name_with_namespace, url: project_path }.to_json + + # similate selection, and prevent overlap by dropdown menu + execute_script("$('.project-item-select').val('#{project_json}').trigger('change');") + execute_script("$('#select2-drop-mask').remove();") + + find('.new-project-item-link').trigger('click') + + expect(page).to have_current_path("#{project_path}/issues/new") page.within('#content-body') do expect(page).to have_selector('.issue-form') diff --git a/spec/features/groups/empty_states_spec.rb b/spec/features/groups/empty_states_spec.rb index 7f28553c44e..243e8536168 100644 --- a/spec/features/groups/empty_states_spec.rb +++ b/spec/features/groups/empty_states_spec.rb @@ -38,7 +38,7 @@ feature 'Groups Merge Requests Empty States' do it 'should show a new merge request button' do within '.empty-state' do - expect(page).to have_content('New merge request') + expect(page).to have_content('create merge request') end end @@ -63,7 +63,7 @@ feature 'Groups Merge Requests Empty States' do it 'should not show a new merge request button' do within '.empty-state' do - expect(page).not_to have_link('New merge request') + expect(page).not_to have_link('create merge request') end end end diff --git a/spec/features/issues/create_branch_merge_request_spec.rb b/spec/features/issues/create_branch_merge_request_spec.rb index f59f687cf51..546dc7e8a49 100644 --- a/spec/features/issues/create_branch_merge_request_spec.rb +++ b/spec/features/issues/create_branch_merge_request_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Create Branch/Merge Request Dropdown on issue page', js: true do +feature 'Create Branch/Merge Request Dropdown on issue page', :feature, :js do let(:user) { create(:user) } let!(:project) { create(:project, :repository) } let(:issue) { create(:issue, project: project, title: 'Cherry-Coloured Funk') } @@ -14,10 +14,14 @@ feature 'Create Branch/Merge Request Dropdown on issue page', js: true do it 'allows creating a merge request from the issue page' do visit project_issue_path(project, issue) - select_dropdown_option('create-mr') - - expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"') - expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first)) + perform_enqueued_jobs do + select_dropdown_option('create-mr') + + expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"') + expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first)) + + wait_for_requests + end visit project_issue_path(project, issue) diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index 8e22441e0e8..af11b474842 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -130,8 +130,8 @@ feature 'Issue Sidebar' do it 'adds new label' do page.within('.block.labels') do fill_in 'new_label_name', with: 'wontfix' - page.find(".suggest-colors a", match: :first).click - click_button 'Create' + page.find('.suggest-colors a', match: :first).trigger('click') + page.find('button', text: 'Create').trigger('click') page.within('.dropdown-page-one') do expect(page).to have_content 'wontfix' @@ -142,8 +142,8 @@ feature 'Issue Sidebar' do it 'shows error message if label title is taken' do page.within('.block.labels') do fill_in 'new_label_name', with: label.title - page.find('.suggest-colors a', match: :first).click - click_button 'Create' + page.find('.suggest-colors a', match: :first).trigger('click') + page.find('button', text: 'Create').trigger('click') page.within('.dropdown-page-two') do expect(page).to have_content 'Title has already been taken' diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 489baa4291f..a5bb642221c 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -706,4 +706,30 @@ describe 'Issues' do expect(page).to have_text("updated title") end end + + describe 'confidential issue#show', js: true do + it 'shows confidential sibebar information as confidential and can be turned off' do + issue = create(:issue, :confidential, project: project) + + visit project_issue_path(project, issue) + + expect(page).to have_css('.confidential-issue-warning') + expect(page).to have_css('.is-confidential') + expect(page).not_to have_css('.is-not-confidential') + + find('.confidential-edit').click + expect(page).to have_css('.confidential-warning-message') + + within('.confidential-warning-message') do + find('.btn-close').click + end + + wait_for_requests + + visit project_issue_path(project, issue) + + expect(page).not_to have_css('.is-confidential') + expect(page).to have_css('.is-not-confidential') + end + end end diff --git a/spec/features/merge_requests/form_spec.rb b/spec/features/merge_requests/form_spec.rb index 6ffb05c5030..89410b0e90f 100644 --- a/spec/features/merge_requests/form_spec.rb +++ b/spec/features/merge_requests/form_spec.rb @@ -41,7 +41,7 @@ describe 'New/edit merge request', :js do expect(page).to have_content user2.name end - click_link 'Assign to me' + find('a', text: 'Assign to me').trigger('click') expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s) page.within '.js-assignee-search' do expect(page).to have_content user.name diff --git a/spec/features/merge_requests/widget_spec.rb b/spec/features/merge_requests/widget_spec.rb index 69e31c7481f..fd991293ee9 100644 --- a/spec/features/merge_requests/widget_spec.rb +++ b/spec/features/merge_requests/widget_spec.rb @@ -219,4 +219,17 @@ describe 'Merge request', :js do expect(page).to have_field('remove-source-branch-input', disabled: true) end end + + context 'ongoing merge process' do + it 'shows Merging state' do + allow_any_instance_of(MergeRequest).to receive(:merge_ongoing?).and_return(true) + + visit project_merge_request_path(project, merge_request) + + wait_for_requests + + expect(page).not_to have_button('Merge') + expect(page).to have_content('This merge request is in the process of being merged') + end + end end diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb index c0cfb9eafe2..24e7843db63 100644 --- a/spec/features/projects/import_export/import_file_spec.rb +++ b/spec/features/projects/import_export/import_file_spec.rb @@ -29,8 +29,9 @@ feature 'Import/Export - project import integration test', js: true do fill_in :project_path, with: 'test-project-path', visible: true click_link 'GitLab export' - expect(page).to have_content('GitLab project export') + expect(page).to have_content('Import an exported GitLab project') expect(URI.parse(current_url).query).to eq("namespace_id=#{namespace.id}&path=test-project-path") + expect(Gitlab::ImportExport).to receive(:import_upload_path).with(filename: /\A\h{32}_test-project-path\z/).and_call_original attach_file('file', file) @@ -60,17 +61,6 @@ feature 'Import/Export - project import integration test', js: true do expect(page).to have_content('Project could not be imported') end end - - scenario 'project with no name' do - create(:project, namespace: namespace) - - visit new_project_path - - select2(namespace.id, from: '#project_namespace_id') - - # Check for tooltip disabled import button - expect(find('.import_gitlab_project')['title']).to eq('Please enter a valid project name.') - end end context 'when limited to the default user namespace' do diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index dbcdac902d5..7e4d53332e5 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -1,6 +1,27 @@ require 'spec_helper' feature 'Project' do + describe 'creating from template' do + let(:user) { create(:user) } + let(:template) { Gitlab::ProjectTemplate.find(:rails) } + + before do + sign_in user + visit new_project_path + end + + it "allows creation from templates" do + page.choose(template.name) + fill_in("project_path", with: template.name) + + page.within '#content-body' do + click_button "Create project" + end + + expect(page).to have_content 'This project Loading..' + end + end + describe 'description' do let(:project) { create(:project, :repository) } let(:path) { project_path(project) } diff --git a/spec/fixtures/api/schemas/entities/merge_request.json b/spec/fixtures/api/schemas/entities/merge_request.json index 7ffa82fc4bd..2f12b671dec 100644 --- a/spec/fixtures/api/schemas/entities/merge_request.json +++ b/spec/fixtures/api/schemas/entities/merge_request.json @@ -19,7 +19,6 @@ "human_time_estimate": { "type": ["integer", "null"] }, "human_total_time_spent": { "type": ["integer", "null"] }, "in_progress_merge_commit_sha": { "type": ["string", "null"] }, - "locked_at": { "type": ["string", "null"] }, "merge_error": { "type": ["string", "null"] }, "merge_commit_sha": { "type": ["string", "null"] }, "merge_params": { "type": ["object", "null"] }, @@ -94,7 +93,8 @@ "commit_change_content_path": { "type": "string" }, "remove_wip_path": { "type": "string" }, "commits_count": { "type": "integer" }, - "remove_source_branch": { "type": ["boolean", "null"] } + "remove_source_branch": { "type": ["boolean", "null"] }, + "merge_ongoing": { "type": "boolean" } }, "additionalProperties": false } diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb index 58b43805705..4f46e40ce7a 100644 --- a/spec/fixtures/markdown.md.erb +++ b/spec/fixtures/markdown.md.erb @@ -227,8 +227,11 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Milestone in another project: <%= xmilestone.to_reference(project) %> - Ignored in code: `<%= simple_milestone.to_reference %>` - Ignored in links: [Link to <%= simple_milestone.to_reference %>](#milestone-link) -- Milestone by URL: <%= urls.project_milestone_url(milestone.project, milestone) %> +- Milestone by URL: <%= urls.milestone_url(milestone) %> - Link to milestone by URL: [Milestone](<%= milestone.to_reference %>) +- Group milestone by name: <%= Milestone.reference_prefix %><%= group_milestone.name %> +- Group milestone by name in quotes: <%= group_milestone.to_reference(format: :name) %> +- Group milestone by URL is ignore: <%= urls.milestone_url(group_milestone) %> ### Task Lists diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb index 537e457513f..a44b200c5da 100644 --- a/spec/helpers/gitlab_routing_helper_spec.rb +++ b/spec/helpers/gitlab_routing_helper_spec.rb @@ -63,44 +63,4 @@ describe GitlabRoutingHelper do it { expect(resend_invite_group_member_path(group_member)).to eq resend_invite_group_group_member_path(group_member.source, group_member) } end end - - describe '#milestone_path' do - context 'for a group milestone' do - let(:milestone) { build_stubbed(:milestone, group: group, iid: 1) } - - it 'links to the group milestone page' do - expect(milestone_path(milestone)) - .to eq(group_milestone_path(group, milestone)) - end - end - - context 'for a project milestone' do - let(:milestone) { build_stubbed(:milestone, project: project, iid: 1) } - - it 'links to the project milestone page' do - expect(milestone_path(milestone)) - .to eq(project_milestone_path(project, milestone)) - end - end - end - - describe '#milestone_url' do - context 'for a group milestone' do - let(:milestone) { build_stubbed(:milestone, group: group, iid: 1) } - - it 'links to the group milestone page' do - expect(milestone_url(milestone)) - .to eq(group_milestone_url(group, milestone)) - end - end - - context 'for a project milestone' do - let(:milestone) { build_stubbed(:milestone, project: project, iid: 1) } - - it 'links to the project milestone page' do - expect(milestone_url(milestone)) - .to eq(project_milestone_url(project, milestone)) - end - end - end end diff --git a/spec/helpers/milestones_routing_helper_spec.rb b/spec/helpers/milestones_routing_helper_spec.rb new file mode 100644 index 00000000000..dc13a43c2ab --- /dev/null +++ b/spec/helpers/milestones_routing_helper_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe MilestonesRoutingHelper do + let(:project) { build_stubbed(:project) } + let(:group) { build_stubbed(:group) } + + describe '#milestone_path' do + context 'for a group milestone' do + let(:milestone) { build_stubbed(:milestone, group: group, iid: 1) } + + it 'links to the group milestone page' do + expect(milestone_path(milestone)) + .to eq(group_milestone_path(group, milestone)) + end + end + + context 'for a project milestone' do + let(:milestone) { build_stubbed(:milestone, project: project, iid: 1) } + + it 'links to the project milestone page' do + expect(milestone_path(milestone)) + .to eq(project_milestone_path(project, milestone)) + end + end + end + + describe '#milestone_url' do + context 'for a group milestone' do + let(:milestone) { build_stubbed(:milestone, group: group, iid: 1) } + + it 'links to the group milestone page' do + expect(milestone_url(milestone)) + .to eq(group_milestone_url(group, milestone)) + end + end + + context 'for a project milestone' do + let(:milestone) { build_stubbed(:milestone, project: project, iid: 1) } + + it 'links to the project milestone page' do + expect(milestone_url(milestone)) + .to eq(project_milestone_url(project, milestone)) + end + end + end +end diff --git a/spec/javascripts/boards/issue_card_spec.js b/spec/javascripts/boards/issue_card_spec.js index bd9b4fbfdd3..69cfcbbce5a 100644 --- a/spec/javascripts/boards/issue_card_spec.js +++ b/spec/javascripts/boards/issue_card_spec.js @@ -238,12 +238,6 @@ describe('Issue card component', () => { }); describe('labels', () => { - it('does not render any', () => { - expect( - component.$el.querySelector('.label'), - ).toBeNull(); - }); - describe('exists', () => { beforeEach((done) => { component.issue.addLabel(label1); @@ -251,16 +245,21 @@ describe('Issue card component', () => { Vue.nextTick(() => done()); }); - it('does not render list label', () => { + it('renders list label', () => { expect( component.$el.querySelectorAll('.label').length, - ).toBe(1); + ).toBe(2); }); it('renders label', () => { + const nodes = []; + component.$el.querySelectorAll('.label').forEach((label) => { + nodes.push(label.title); + }); + expect( - component.$el.querySelector('.label').textContent, - ).toContain(label1.title); + nodes.includes(label1.description), + ).toBe(true); }); it('sets label description as title', () => { @@ -270,9 +269,14 @@ describe('Issue card component', () => { }); it('sets background color of button', () => { + const nodes = []; + component.$el.querySelectorAll('.label').forEach((label) => { + nodes.push(label.style.backgroundColor); + }); + expect( - component.$el.querySelector('.label').style.backgroundColor, - ).toContain(label1.color); + nodes.includes(label1.color), + ).toBe(true); }); }); }); diff --git a/spec/javascripts/build_spec.js b/spec/javascripts/build_spec.js index be90dbdd88a..35149611095 100644 --- a/spec/javascripts/build_spec.js +++ b/spec/javascripts/build_spec.js @@ -5,7 +5,6 @@ import '~/lib/utils/datetime_utility'; import '~/lib/utils/url_utility'; import '~/build'; import '~/breakpoints'; -import 'vendor/jquery.nicescroll'; describe('Build', () => { const BUILD_URL = `${gl.TEST_HOST}/frontend-fixtures/builds-project/-/jobs/1`; diff --git a/spec/javascripts/fixtures/project_select_combo_button.html.haml b/spec/javascripts/fixtures/project_select_combo_button.html.haml new file mode 100644 index 00000000000..54bc1a59279 --- /dev/null +++ b/spec/javascripts/fixtures/project_select_combo_button.html.haml @@ -0,0 +1,6 @@ +.project-item-select-holder + %input.project-item-select{ data: { group_id: '12345' , relative_path: 'issues/new' } } + %a.new-project-item-link{ data: { label: 'New issue' }, href: ''} + %i.fa.fa-spinner.spin + %a.new-project-item-select-button + %i.fa.fa-caret-down diff --git a/spec/javascripts/labels_issue_sidebar_spec.js b/spec/javascripts/labels_issue_sidebar_spec.js index c99f379b871..e47adc49224 100644 --- a/spec/javascripts/labels_issue_sidebar_spec.js +++ b/spec/javascripts/labels_issue_sidebar_spec.js @@ -4,7 +4,6 @@ import '~/gl_dropdown'; import 'select2'; -import 'vendor/jquery.nicescroll'; import '~/api'; import '~/create_label'; import '~/issuable_context'; diff --git a/spec/javascripts/project_select_combo_button_spec.js b/spec/javascripts/project_select_combo_button_spec.js new file mode 100644 index 00000000000..e10a5a3bef6 --- /dev/null +++ b/spec/javascripts/project_select_combo_button_spec.js @@ -0,0 +1,105 @@ +import ProjectSelectComboButton from '~/project_select_combo_button'; + +const fixturePath = 'static/project_select_combo_button.html.raw'; + +describe('Project Select Combo Button', function () { + preloadFixtures(fixturePath); + + beforeEach(function () { + this.defaults = { + label: 'Select project to create issue', + groupId: 12345, + projectMeta: { + name: 'My Cool Project', + url: 'http://mycoolproject.com', + }, + newProjectMeta: { + name: 'My Other Cool Project', + url: 'http://myothercoolproject.com', + }, + localStorageKey: 'group-12345-new-issue-recent-project', + relativePath: 'issues/new', + }; + + loadFixtures(fixturePath); + + this.newItemBtn = document.querySelector('.new-project-item-link'); + this.projectSelectInput = document.querySelector('.project-item-select'); + }); + + describe('on page load when localStorage is empty', function () { + beforeEach(function () { + this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); + }); + + it('newItemBtn is disabled', function () { + expect(this.newItemBtn.hasAttribute('disabled')).toBe(true); + expect(this.newItemBtn.classList.contains('disabled')).toBe(true); + }); + + it('newItemBtn href is null', function () { + expect(this.newItemBtn.getAttribute('href')).toBe(''); + }); + + it('newItemBtn text is the plain default label', function () { + expect(this.newItemBtn.textContent).toBe(this.defaults.label); + }); + }); + + describe('on page load when localStorage is filled', function () { + beforeEach(function () { + window.localStorage + .setItem(this.defaults.localStorageKey, JSON.stringify(this.defaults.projectMeta)); + this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); + }); + + it('newItemBtn is not disabled', function () { + expect(this.newItemBtn.hasAttribute('disabled')).toBe(false); + expect(this.newItemBtn.classList.contains('disabled')).toBe(false); + }); + + it('newItemBtn href is correctly set', function () { + expect(this.newItemBtn.getAttribute('href')).toBe(this.defaults.projectMeta.url); + }); + + it('newItemBtn text is the cached label', function () { + expect(this.newItemBtn.textContent) + .toBe(`New issue in ${this.defaults.projectMeta.name}`); + }); + + afterEach(function () { + window.localStorage.clear(); + }); + }); + + describe('after selecting a new project', function () { + beforeEach(function () { + this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); + + // mock the effect of selecting an item from the projects dropdown (select2) + $('.project-item-select') + .val(JSON.stringify(this.defaults.newProjectMeta)) + .trigger('change'); + }); + + it('newItemBtn is not disabled', function () { + expect(this.newItemBtn.hasAttribute('disabled')).toBe(false); + expect(this.newItemBtn.classList.contains('disabled')).toBe(false); + }); + + it('newItemBtn href is correctly set', function () { + expect(this.newItemBtn.getAttribute('href')) + .toBe('http://myothercoolproject.com/issues/new'); + }); + + it('newItemBtn text is the selected project label', function () { + expect(this.newItemBtn.textContent) + .toBe(`New issue in ${this.defaults.newProjectMeta.name}`); + }); + + afterEach(function () { + window.localStorage.clear(); + }); + }); +}); + diff --git a/spec/javascripts/projects/project_import_gitlab_project_spec.js b/spec/javascripts/projects/project_import_gitlab_project_spec.js new file mode 100644 index 00000000000..2f1aae109e3 --- /dev/null +++ b/spec/javascripts/projects/project_import_gitlab_project_spec.js @@ -0,0 +1,25 @@ +import projectImportGitlab from '~/projects/project_import_gitlab_project'; + +describe('Import Gitlab project', () => { + let projectName; + beforeEach(() => { + projectName = 'project'; + window.history.pushState({}, null, `?path=${projectName}`); + + setFixtures(` + <input class="js-path-name" /> + `); + + projectImportGitlab.bindEvents(); + }); + + afterEach(() => { + window.history.pushState({}, null, ''); + }); + + describe('path name', () => { + it('should fill in the project name derived from the previously filled project name', () => { + expect(document.querySelector('.js-path-name').value).toEqual(projectName); + }); + }); +}); diff --git a/spec/javascripts/sidebar/confidential_edit_buttons_spec.js b/spec/javascripts/sidebar/confidential_edit_buttons_spec.js new file mode 100644 index 00000000000..482be466aad --- /dev/null +++ b/spec/javascripts/sidebar/confidential_edit_buttons_spec.js @@ -0,0 +1,39 @@ +import Vue from 'vue'; +import editFormButtons from '~/sidebar/components/confidential/edit_form_buttons.vue'; + +describe('Edit Form Buttons', () => { + let vm1; + let vm2; + + beforeEach(() => { + const Component = Vue.extend(editFormButtons); + const toggleForm = () => { }; + const updateConfidentialAttribute = () => { }; + + vm1 = new Component({ + propsData: { + isConfidential: true, + toggleForm, + updateConfidentialAttribute, + }, + }).$mount(); + + vm2 = new Component({ + propsData: { + isConfidential: false, + toggleForm, + updateConfidentialAttribute, + }, + }).$mount(); + }); + + it('renders on or off text based on confidentiality', () => { + expect( + vm1.$el.innerHTML.includes('Turn Off'), + ).toBe(true); + + expect( + vm2.$el.innerHTML.includes('Turn On'), + ).toBe(true); + }); +}); diff --git a/spec/javascripts/sidebar/confidential_edit_form_buttons_spec.js b/spec/javascripts/sidebar/confidential_edit_form_buttons_spec.js new file mode 100644 index 00000000000..724f5126945 --- /dev/null +++ b/spec/javascripts/sidebar/confidential_edit_form_buttons_spec.js @@ -0,0 +1,39 @@ +import Vue from 'vue'; +import editForm from '~/sidebar/components/confidential/edit_form.vue'; + +describe('Edit Form Dropdown', () => { + let vm1; + let vm2; + + beforeEach(() => { + const Component = Vue.extend(editForm); + const toggleForm = () => { }; + const updateConfidentialAttribute = () => { }; + + vm1 = new Component({ + propsData: { + isConfidential: true, + toggleForm, + updateConfidentialAttribute, + }, + }).$mount(); + + vm2 = new Component({ + propsData: { + isConfidential: false, + toggleForm, + updateConfidentialAttribute, + }, + }).$mount(); + }); + + it('renders on the appropriate warning text', () => { + expect( + vm1.$el.innerHTML.includes('You are going to turn off the confidentiality.'), + ).toBe(true); + + expect( + vm2.$el.innerHTML.includes('You are going to turn on the confidentiality.'), + ).toBe(true); + }); +}); diff --git a/spec/javascripts/sidebar/confidential_issue_sidebar_spec.js b/spec/javascripts/sidebar/confidential_issue_sidebar_spec.js new file mode 100644 index 00000000000..90eac1ed1ab --- /dev/null +++ b/spec/javascripts/sidebar/confidential_issue_sidebar_spec.js @@ -0,0 +1,65 @@ +import Vue from 'vue'; +import confidentialIssueSidebar from '~/sidebar/components/confidential/confidential_issue_sidebar.vue'; + +describe('Confidential Issue Sidebar Block', () => { + let vm1; + let vm2; + + beforeEach(() => { + const Component = Vue.extend(confidentialIssueSidebar); + const service = { + update: () => new Promise((resolve, reject) => { + resolve(true); + reject('failed!'); + }), + }; + + vm1 = new Component({ + propsData: { + isConfidential: true, + isEditable: true, + service, + }, + }).$mount(); + + vm2 = new Component({ + propsData: { + isConfidential: false, + isEditable: false, + service, + }, + }).$mount(); + }); + + it('shows if confidential and/or editable', () => { + expect( + vm1.$el.innerHTML.includes('Edit'), + ).toBe(true); + + expect( + vm1.$el.innerHTML.includes('This issue is confidential'), + ).toBe(true); + + expect( + vm2.$el.innerHTML.includes('None'), + ).toBe(true); + }); + + it('displays the edit form when editable', (done) => { + expect(vm1.edit).toBe(false); + + vm1.$el.querySelector('.confidential-edit').click(); + + expect(vm1.edit).toBe(true); + + setTimeout(() => { + expect( + vm1.$el + .innerHTML + .includes('You are going to turn off the confidentiality.'), + ).toBe(true); + + done(); + }); + }); +}); diff --git a/spec/javascripts/vue_mr_widget/components/states/mr_widget_locked_spec.js b/spec/javascripts/vue_mr_widget/components/states/mr_widget_locked_spec.js index fb2ef606604..237035648cf 100644 --- a/spec/javascripts/vue_mr_widget/components/states/mr_widget_locked_spec.js +++ b/spec/javascripts/vue_mr_widget/components/states/mr_widget_locked_spec.js @@ -1,10 +1,10 @@ import Vue from 'vue'; -import lockedComponent from '~/vue_merge_request_widget/components/states/mr_widget_locked'; +import mergingComponent from '~/vue_merge_request_widget/components/states/mr_widget_merging'; -describe('MRWidgetLocked', () => { +describe('MRWidgetMerging', () => { describe('props', () => { it('should have props', () => { - const { mr } = lockedComponent.props; + const { mr } = mergingComponent.props; expect(mr.type instanceof Object).toBeTruthy(); expect(mr.required).toBeTruthy(); @@ -13,7 +13,7 @@ describe('MRWidgetLocked', () => { describe('template', () => { it('should have correct elements', () => { - const Component = Vue.extend(lockedComponent); + const Component = Vue.extend(mergingComponent); const mr = { targetBranchPath: '/branch-path', targetBranch: 'branch', @@ -24,7 +24,7 @@ describe('MRWidgetLocked', () => { }).$el; expect(el.classList.contains('mr-widget-body')).toBeTruthy(); - expect(el.innerText).toContain('it is locked'); + expect(el.innerText).toContain('This merge request is in the process of being merged'); expect(el.innerText).toContain('changes will be merged into'); expect(el.querySelector('.label-branch a').getAttribute('href')).toEqual(mr.targetBranchPath); expect(el.querySelector('.label-branch a').textContent).toContain(mr.targetBranch); diff --git a/spec/javascripts/vue_mr_widget/mock_data.js b/spec/javascripts/vue_mr_widget/mock_data.js index ad2f28b24f0..0795d0aaa82 100644 --- a/spec/javascripts/vue_mr_widget/mock_data.js +++ b/spec/javascripts/vue_mr_widget/mock_data.js @@ -20,7 +20,6 @@ export default { "human_time_estimate": null, "human_total_time_spent": null, "in_progress_merge_commit_sha": null, - "locked_at": null, "merge_commit_sha": "53027d060246c8f47e4a9310fb332aa52f221775", "merge_error": null, "merge_params": { diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js index 3a0c50b750f..669ee248bf1 100644 --- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js @@ -342,7 +342,7 @@ describe('mrWidgetOptions', () => { expect(comps['mr-widget-related-links']).toBeDefined(); expect(comps['mr-widget-merged']).toBeDefined(); expect(comps['mr-widget-closed']).toBeDefined(); - expect(comps['mr-widget-locked']).toBeDefined(); + expect(comps['mr-widget-merging']).toBeDefined(); expect(comps['mr-widget-failed-to-merge']).toBeDefined(); expect(comps['mr-widget-wip']).toBeDefined(); expect(comps['mr-widget-archived']).toBeDefined(); diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index 5db77566513..ebd6c79077e 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -3,57 +3,57 @@ require 'spec_helper' describe Banzai::Filter::MilestoneReferenceFilter do include FilterSpecHelper - let(:project) { create(:project, :public) } - let(:milestone) { create(:milestone, project: project) } - let(:reference) { milestone.to_reference } + let(:group) { create(:group, :public) } + let(:project) { create(:project, :public, group: group) } it 'requires project context' do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| - it "ignores valid references contained inside '#{elem}' element" do - exp = act = "<#{elem}>milestone #{milestone.to_reference}</#{elem}>" - expect(reference_filter(act).to_html).to eq exp + shared_examples 'reference parsing' do + %w(pre code a style).each do |elem| + it "ignores valid references contained inside '#{elem}' element" do + exp = act = "<#{elem}>milestone #{reference}</#{elem}>" + expect(reference_filter(act).to_html).to eq exp + end end - end - it 'includes default classes' do - doc = reference_filter("Milestone #{reference}") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-milestone has-tooltip' - end + it 'includes default classes' do + doc = reference_filter("Milestone #{reference}") - it 'includes a data-project attribute' do - doc = reference_filter("Milestone #{reference}") - link = doc.css('a').first + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-milestone has-tooltip' + end - expect(link).to have_attribute('data-project') - expect(link.attr('data-project')).to eq project.id.to_s - end + it 'includes a data-project attribute' do + doc = reference_filter("Milestone #{reference}") + link = doc.css('a').first - it 'includes a data-milestone attribute' do - doc = reference_filter("See #{reference}") - link = doc.css('a').first + expect(link).to have_attribute('data-project') + expect(link.attr('data-project')).to eq project.id.to_s + end - expect(link).to have_attribute('data-milestone') - expect(link.attr('data-milestone')).to eq milestone.id.to_s - end + it 'includes a data-milestone attribute' do + doc = reference_filter("See #{reference}") + link = doc.css('a').first + + expect(link).to have_attribute('data-milestone') + expect(link.attr('data-milestone')).to eq milestone.id.to_s + end - it 'supports an :only_path context' do - doc = reference_filter("Milestone #{reference}", only_path: true) - link = doc.css('a').first.attr('href') + it 'supports an :only_path context' do + doc = reference_filter("Milestone #{reference}", only_path: true) + link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) - expect(link).to eq urls - .project_milestone_path(project, milestone) + expect(link).not_to match %r(https?://) + expect(link).to eq urls.milestone_path(milestone) + end end - context 'Integer-based references' do + shared_examples 'Integer-based references' do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .project_milestone_url(project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone) end it 'links with adjacent text' do @@ -68,15 +68,17 @@ describe Banzai::Filter::MilestoneReferenceFilter do end end - context 'String-based single-word references' do - let(:milestone) { create(:milestone, name: 'gfm', project: project) } + shared_examples 'String-based single-word references' do let(:reference) { "#{Milestone.reference_prefix}#{milestone.name}" } + before do + milestone.update!(name: 'gfm') + end + it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .project_milestone_url(project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone) expect(doc.text).to eq 'See gfm' end @@ -92,15 +94,17 @@ describe Banzai::Filter::MilestoneReferenceFilter do end end - context 'String-based multi-word references in quotes' do - let(:milestone) { create(:milestone, name: 'gfm references', project: project) } + shared_examples 'String-based multi-word references in quotes' do let(:reference) { milestone.to_reference(format: :name) } + before do + milestone.update!(name: 'gfm references') + end + it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .project_milestone_url(project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone) expect(doc.text).to eq 'See gfm references' end @@ -116,23 +120,27 @@ describe Banzai::Filter::MilestoneReferenceFilter do end end - describe 'referencing a milestone in a link href' do - let(:reference) { %Q{<a href="#{milestone.to_reference}">Milestone</a>} } + shared_examples 'referencing a milestone in a link href' do + let(:unquoted_reference) { "#{Milestone.reference_prefix}#{milestone.name}" } + let(:link_reference) { %Q{<a href="#{unquoted_reference}">Milestone</a>} } + + before do + milestone.update!(name: 'gfm') + end it 'links to a valid reference' do - doc = reference_filter("See #{reference}") + doc = reference_filter("See #{link_reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .project_milestone_url(project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone) end it 'links with adjacent text' do - doc = reference_filter("Milestone (#{reference}.)") + doc = reference_filter("Milestone (#{link_reference}.)") expect(doc.to_html).to match(%r(\(<a.+>Milestone</a>\.\))) end it 'includes a data-project attribute' do - doc = reference_filter("Milestone #{reference}") + doc = reference_filter("Milestone #{link_reference}") link = doc.css('a').first expect(link).to have_attribute('data-project') @@ -140,7 +148,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do end it 'includes a data-milestone attribute' do - doc = reference_filter("See #{reference}") + doc = reference_filter("See #{link_reference}") link = doc.css('a').first expect(link).to have_attribute('data-milestone') @@ -148,7 +156,35 @@ describe Banzai::Filter::MilestoneReferenceFilter do end end - describe 'cross-project / cross-namespace complete reference' do + shared_examples 'linking to a milestone as the entire link' do + let(:unquoted_reference) { "#{Milestone.reference_prefix}#{milestone.name}" } + let(:link) { urls.milestone_url(milestone) } + let(:link_reference) { %Q{<a href="#{link}">#{link}</a>} } + + it 'replaces the link text with the milestone reference' do + doc = reference_filter("See #{link}") + + expect(doc.css('a').first.text).to eq(unquoted_reference) + end + + it 'includes a data-project attribute' do + doc = reference_filter("Milestone #{link_reference}") + link = doc.css('a').first + + expect(link).to have_attribute('data-project') + expect(link.attr('data-project')).to eq project.id.to_s + end + + it 'includes a data-milestone attribute' do + doc = reference_filter("See #{link_reference}") + link = doc.css('a').first + + expect(link).to have_attribute('data-milestone') + expect(link.attr('data-milestone')).to eq milestone.id.to_s + end + end + + shared_examples 'cross-project / cross-namespace complete reference' do let(:namespace) { create(:namespace) } let(:another_project) { create(:project, :public, namespace: namespace) } let(:milestone) { create(:milestone, project: another_project) } @@ -184,7 +220,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do end end - describe 'cross-project / same-namespace complete reference' do + shared_examples 'cross-project / same-namespace complete reference' do let(:namespace) { create(:namespace) } let(:project) { create(:project, :public, namespace: namespace) } let(:another_project) { create(:project, :public, namespace: namespace) } @@ -221,7 +257,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do end end - describe 'cross project shorthand reference' do + shared_examples 'cross project shorthand reference' do let(:namespace) { create(:namespace) } let(:project) { create(:project, :public, namespace: namespace) } let(:another_project) { create(:project, :public, namespace: namespace) } @@ -258,27 +294,53 @@ describe Banzai::Filter::MilestoneReferenceFilter do end end - describe 'cross project milestone references' do - let(:another_project) { create(:project, :public) } - let(:project_path) { another_project.full_path } - let(:milestone) { create(:milestone, project: another_project) } - let(:reference) { milestone.to_reference(project) } + context 'project milestones' do + let(:milestone) { create(:milestone, project: project) } + let(:reference) { milestone.to_reference } - let!(:result) { reference_filter("See #{reference}") } + include_examples 'reference parsing' - it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls - .project_milestone_url(another_project, milestone) + it_behaves_like 'Integer-based references' + it_behaves_like 'String-based single-word references' + it_behaves_like 'String-based multi-word references in quotes' + it_behaves_like 'referencing a milestone in a link href' + it_behaves_like 'cross-project / cross-namespace complete reference' + it_behaves_like 'cross-project / same-namespace complete reference' + it_behaves_like 'cross project shorthand reference' + end + + context 'group milestones' do + let(:milestone) { create(:milestone, group: group) } + let(:reference) { milestone.to_reference(format: :name) } + + include_examples 'reference parsing' + + it_behaves_like 'String-based single-word references' + it_behaves_like 'String-based multi-word references in quotes' + it_behaves_like 'referencing a milestone in a link href' + + it 'does not support references by IID' do + doc = reference_filter("See #{Milestone.reference_prefix}#{milestone.iid}") + + expect(doc.css('a')).to be_empty end - it 'contains cross project content' do - expect(result.css('a').first.text).to eq "#{milestone.name} in #{project_path}" + it 'does not support references by link' do + doc = reference_filter("See #{urls.milestone_url(milestone)}") + + expect(doc.css('a').first.text).to eq(urls.milestone_url(milestone)) end - it 'escapes the name attribute' do - allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="}) - doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text).to eq "#{milestone.name} in #{project_path}" + it 'does not support cross-project references' do + another_group = create(:group) + another_project = create(:project, :public, group: group) + project_reference = another_project.to_reference(project) + + milestone.update!(group: another_group) + + doc = reference_filter("See #{project_reference}#{reference}") + + expect(doc.css('a')).to be_empty end end end diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index d7d6a37f7cf..a66347ead76 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -54,7 +54,7 @@ describe Gitlab::BitbucketImport::Importer do create( :project, import_source: project_identifier, - import_data: ProjectImportData.new(credentials: data) + import_data_attributes: { credentials: data } ) end diff --git a/spec/lib/gitlab/daemon_spec.rb b/spec/lib/gitlab/daemon_spec.rb new file mode 100644 index 00000000000..c519984a267 --- /dev/null +++ b/spec/lib/gitlab/daemon_spec.rb @@ -0,0 +1,103 @@ +require 'spec_helper' + +describe Gitlab::Daemon do + subject { described_class.new } + + before do + allow(subject).to receive(:start_working) + allow(subject).to receive(:stop_working) + end + + describe '.instance' do + before do + allow(Kernel).to receive(:at_exit) + end + + after(:each) do + described_class.instance_variable_set(:@instance, nil) + end + + it 'provides instance of Daemon' do + expect(described_class.instance).to be_instance_of(described_class) + end + + it 'subsequent invocations provide the same instance' do + expect(described_class.instance).to eq(described_class.instance) + end + + it 'creates at_exit hook when instance is created' do + expect(described_class.instance).not_to be_nil + + expect(Kernel).to have_received(:at_exit) + end + end + + describe 'when Daemon is enabled' do + before do + allow(subject).to receive(:enabled?).and_return(true) + end + + describe 'when Daemon is stopped' do + describe '#start' do + it 'starts the Daemon' do + expect { subject.start.join }.to change { subject.thread? }.from(false).to(true) + + expect(subject).to have_received(:start_working) + end + end + + describe '#stop' do + it "doesn't shutdown stopped Daemon" do + expect { subject.stop }.not_to change { subject.thread? } + + expect(subject).not_to have_received(:start_working) + end + end + end + + describe 'when Daemon is running' do + before do + subject.start.join + end + + describe '#start' do + it "doesn't start running Daemon" do + expect { subject.start.join }.not_to change { subject.thread? } + + expect(subject).to have_received(:start_working).once + end + end + + describe '#stop' do + it 'shutdowns Daemon' do + expect { subject.stop }.to change { subject.thread? }.from(true).to(false) + + expect(subject).to have_received(:stop_working) + end + end + end + end + + describe 'when Daemon is disabled' do + before do + allow(subject).to receive(:enabled?).and_return(false) + end + + describe '#start' do + it "doesn't start working" do + expect(subject.start).to be_nil + expect { subject.start }.not_to change { subject.thread? } + + expect(subject).not_to have_received(:start_working) + end + end + + describe '#stop' do + it "doesn't stop working" do + expect { subject.stop }.not_to change { subject.thread? } + + expect(subject).not_to have_received(:stop_working) + end + end + end +end diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index 18320bb23b9..dfab0c2fe85 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -152,6 +152,77 @@ describe Gitlab::Git::Blob, seed_helper: true do end end + describe '.batch' do + let(:blob_references) do + [ + [SeedRepo::Commit::ID, "files/ruby/popen.rb"], + [SeedRepo::Commit::ID, 'six'] + ] + end + + subject { described_class.batch(repository, blob_references) } + + it { expect(subject.size).to eq(blob_references.size) } + + context 'first blob' do + let(:blob) { subject[0] } + + it { expect(blob.id).to eq(SeedRepo::RubyBlob::ID) } + it { expect(blob.name).to eq(SeedRepo::RubyBlob::NAME) } + it { expect(blob.path).to eq("files/ruby/popen.rb") } + it { expect(blob.commit_id).to eq(SeedRepo::Commit::ID) } + it { expect(blob.data[0..10]).to eq(SeedRepo::RubyBlob::CONTENT[0..10]) } + it { expect(blob.size).to eq(669) } + it { expect(blob.mode).to eq("100644") } + end + + context 'second blob' do + let(:blob) { subject[1] } + + it { expect(blob.id).to eq('409f37c4f05865e4fb208c771485f211a22c4c2d') } + it { expect(blob.data).to eq('') } + it 'does not mark the blob as binary' do + expect(blob).not_to be_binary + end + end + + context 'limiting' do + subject { described_class.batch(repository, blob_references, blob_size_limit: blob_size_limit) } + + context 'default' do + let(:blob_size_limit) { nil } + + it 'limits to MAX_DATA_DISPLAY_SIZE' do + stub_const('Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE', 100) + + expect(subject.first.data.size).to eq(100) + end + end + + context 'positive' do + let(:blob_size_limit) { 10 } + + it { expect(subject.first.data.size).to eq(10) } + end + + context 'zero' do + let(:blob_size_limit) { 0 } + + it { expect(subject.first.data).to eq('') } + end + + context 'negative' do + let(:blob_size_limit) { -1 } + + it 'ignores MAX_DATA_DISPLAY_SIZE' do + stub_const('Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE', 100) + + expect(subject.first.data.size).to eq(669) + end + end + end + end + describe 'encoding' do context 'file with russian text' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "encoding/russian.rb") } diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json index 469a014e4d2..4e631e13410 100644 --- a/spec/lib/gitlab/import_export/project.json +++ b/spec/lib/gitlab/import_export/project.json @@ -2534,7 +2534,6 @@ "iid": 9, "description": null, "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -2983,7 +2982,6 @@ "iid": 8, "description": null, "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -3267,7 +3265,6 @@ "iid": 7, "description": "Et commodi deserunt aspernatur vero rerum. Ut non dolorum alias in odit est libero. Voluptatibus eos in et vitae repudiandae facilis ex mollitia.", "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -3551,7 +3548,6 @@ "iid": 6, "description": "Dicta magnam non voluptates nam dignissimos nostrum deserunt. Dolorum et suscipit iure quae doloremque. Necessitatibus saepe aut labore sed.", "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -4241,7 +4237,6 @@ "iid": 5, "description": "Est eaque quasi qui qui. Similique voluptatem impedit iusto ratione reprehenderit. Itaque est illum ut nulla aut.", "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -4789,7 +4784,6 @@ "iid": 4, "description": "Nam magnam odit velit rerum. Sapiente dolore sunt saepe debitis. Culpa maiores ut ad dolores dolorem et.", "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -5288,7 +5282,6 @@ "iid": 3, "description": "Libero nesciunt mollitia quis odit eos vero quasi. Iure voluptatem ut sint pariatur voluptates ut aut. Laborum possimus unde illum ipsum eum.", "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -5548,7 +5541,6 @@ "iid": 2, "description": "Ut dolor quia aliquid dolore et nisi. Est minus suscipit enim quaerat sapiente consequatur rerum. Eveniet provident consequatur dolor accusantium reiciendis.", "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { @@ -6238,7 +6230,6 @@ "iid": 1, "description": "Eveniet nihil ratione veniam similique qui aut sapiente tempora. Sed praesentium iusto dignissimos possimus id repudiandae quo nihil. Qui doloremque autem et iure fugit.", "position": 0, - "locked_at": null, "updated_by_id": null, "merge_error": null, "merge_params": { diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 11f4c16ff96..4dce48f8079 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -145,7 +145,6 @@ MergeRequest: - iid - description - position -- locked_at - updated_by_id - merge_error - merge_params diff --git a/spec/lib/gitlab/import_sources_spec.rb b/spec/lib/gitlab/import_sources_spec.rb index b3b5e5e7e33..c5725f47453 100644 --- a/spec/lib/gitlab/import_sources_spec.rb +++ b/spec/lib/gitlab/import_sources_spec.rb @@ -56,7 +56,7 @@ describe Gitlab::ImportSources do describe '.importer' do import_sources = { - 'github' => Gitlab::GithubImport::Importer, + 'github' => Github::Import, 'bitbucket' => Gitlab::BitbucketImport::Importer, 'gitlab' => Gitlab::GitlabImport::Importer, 'google_code' => Gitlab::GoogleCodeImport::Importer, diff --git a/spec/lib/gitlab/key_fingerprint_spec.rb b/spec/lib/gitlab/key_fingerprint_spec.rb index d7bebaca675..f5fd5a96bc9 100644 --- a/spec/lib/gitlab/key_fingerprint_spec.rb +++ b/spec/lib/gitlab/key_fingerprint_spec.rb @@ -1,12 +1,82 @@ -require "spec_helper" +require 'spec_helper' -describe Gitlab::KeyFingerprint do - let(:key) { "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" } - let(:fingerprint) { "3f:a2:ee:de:b5:de:53:c3:aa:2f:9c:45:24:4c:47:7b" } +describe Gitlab::KeyFingerprint, lib: true do + KEYS = { + rsa: + 'example.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5z65PwQ1GE6foJgwk' \ + '9rmQi/glaXbUeVa5uvQpnZ3Z5+forcI7aTngh3aZ/H2UDP2L70TGy7kKNyp0J3a8/OdG' \ + 'Z08y5yi3JlbjFARO1NyoFEjw2H1SJxeJ43L6zmvTlu+hlK1jSAlidl7enS0ufTlzEEj4' \ + 'iJcuTPKdVzKRgZuTRVm9woWNVKqIrdRC0rJiTinERnfSAp/vNYERMuaoN4oJt8p/NEek' \ + 'rmFoDsQOsyDW5RAnCnjWUU+jFBKDpfkJQ1U2n6BjJewC9dl6ODK639l3yN4WOLZEk4tN' \ + 'UysfbGeF3rmMeflaD6O1Jplpv3YhwVGFNKa7fMq6k3Z0tszTJPYh', + ecdsa: + 'example.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAI' \ + 'bmlzdHAyNTYAAABBBKTJy43NZzJSfNxpv/e2E6Zy3qoHoTQbmOsU5FEfpWfWa1MdTeXQ' \ + 'YvKOi+qz/1AaNx6BK421jGu74JCDJtiZWT8=', + ed25519: + '@revoked example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjq' \ + 'uxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf', + dss: + 'example.com ssh-dss AAAAB3NzaC1kc3MAAACBAP1/U4EddRIpUt9KnC7s5Of2EbdS' \ + 'PO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f' \ + '6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iID' \ + 'GZ3RSAHHAAAAFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QAAAIEA9+GghdabPd7LvKtcNrhX' \ + 'uXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwW' \ + 'eotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6A' \ + 'e1UlZAFMO/7PSSoAAACBAJcQ4JODqhuGbXIEpqxetm7PWbdbCcr3y/GzIZ066pRovpL6' \ + 'qm3qCVIym4cyChxWwb8qlyCIi+YRUUWm1z/wiBYT2Vf3S4FXBnyymCkKEaV/EY7+jd4X' \ + '1bXI58OD2u+bLCB/sInM4fGB8CZUIWT9nJH0Ve9jJUge2ms348/QOJ1+' + }.freeze - describe "#fingerprint" do - it "generates the key's fingerprint" do - expect(described_class.new(key).fingerprint).to eq(fingerprint) + MD5_FINGERPRINTS = { + rsa: '06:b2:8a:92:df:0e:11:2c:ca:7b:8f:a4:ba:6e:4b:fd', + ecdsa: '45:ff:5b:98:9a:b6:8a:41:13:c1:30:8b:09:5e:7b:4e', + ed25519: '2e:65:6a:c8:cf:bf:b2:8b:9a:bd:6d:9f:11:5c:12:16', + dss: '57:98:86:02:5f:9c:f4:9b:ad:5a:1e:51:92:0e:fd:2b' + }.freeze + + BIT_COUNTS = { + rsa: 2048, + ecdsa: 256, + ed25519: 256, + dss: 1024 + }.freeze + + describe '#type' do + KEYS.each do |type, key| + it "calculates the type of #{type} keys" do + calculated_type = described_class.new(key).type + + expect(calculated_type).to eq(type.to_s.upcase) + end + end + end + + describe '#fingerprint' do + KEYS.each do |type, key| + it "calculates the MD5 fingerprint for #{type} keys" do + fp = described_class.new(key).fingerprint + + expect(fp).to eq(MD5_FINGERPRINTS[type]) + end + end + end + + describe '#bits' do + KEYS.each do |type, key| + it "calculates the number of bits in #{type} keys" do + bits = described_class.new(key).bits + + expect(bits).to eq(BIT_COUNTS[type]) + end + end + end + + describe '#key' do + it 'carries the unmodified key data' do + key = described_class.new(KEYS[:rsa]).key + + expect(key).to eq(KEYS[:rsa]) end end end diff --git a/spec/lib/gitlab/metrics/influx_sampler_spec.rb b/spec/lib/gitlab/metrics/influx_sampler_spec.rb index 0bc68d64276..999a9536d82 100644 --- a/spec/lib/gitlab/metrics/influx_sampler_spec.rb +++ b/spec/lib/gitlab/metrics/influx_sampler_spec.rb @@ -11,7 +11,7 @@ describe Gitlab::Metrics::InfluxSampler do it 'runs once and gathers a sample at a given interval' do expect(sampler).to receive(:sleep).with(a_kind_of(Numeric)).twice expect(sampler).to receive(:sample).once - expect(sampler).to receive(:running).and_return(false, true, false) + expect(sampler).to receive(:running).and_return(true, false) sampler.start.join end diff --git a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb new file mode 100644 index 00000000000..6721e02fb85 --- /dev/null +++ b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb @@ -0,0 +1,101 @@ +require 'spec_helper' + +describe Gitlab::Metrics::SidekiqMetricsExporter do + let(:exporter) { described_class.new } + let(:server) { double('server') } + + before do + allow(::WEBrick::HTTPServer).to receive(:new).and_return(server) + allow(server).to receive(:mount) + allow(server).to receive(:start) + allow(server).to receive(:shutdown) + end + + describe 'when exporter is enabled' do + before do + allow(Settings.monitoring.sidekiq_exporter).to receive(:enabled).and_return(true) + end + + describe 'when exporter is stopped' do + describe '#start' do + it 'starts the exporter' do + expect { exporter.start.join }.to change { exporter.thread? }.from(false).to(true) + + expect(server).to have_received(:start) + end + + describe 'with custom settings' do + let(:port) { 99999 } + let(:address) { 'sidekiq_exporter_address' } + + before do + allow(Settings.monitoring.sidekiq_exporter).to receive(:port).and_return(port) + allow(Settings.monitoring.sidekiq_exporter).to receive(:address).and_return(address) + end + + it 'starts server with port and address from settings' do + exporter.start.join + + expect(::WEBrick::HTTPServer).to have_received(:new).with( + Port: port, + BindAddress: address + ) + end + end + end + + describe '#stop' do + it "doesn't shutdown stopped server" do + expect { exporter.stop }.not_to change { exporter.thread? } + + expect(server).not_to have_received(:shutdown) + end + end + end + + describe 'when exporter is running' do + before do + exporter.start.join + end + + describe '#start' do + it "doesn't start running server" do + expect { exporter.start.join }.not_to change { exporter.thread? } + + expect(server).to have_received(:start).once + end + end + + describe '#stop' do + it 'shutdowns server' do + expect { exporter.stop }.to change { exporter.thread? }.from(true).to(false) + + expect(server).to have_received(:shutdown) + end + end + end + end + + describe 'when exporter is disabled' do + before do + allow(Settings.monitoring.sidekiq_exporter).to receive(:enabled).and_return(false) + end + + describe '#start' do + it "doesn't start" do + expect(exporter.start).to be_nil + expect { exporter.start }.not_to change { exporter.thread? } + + expect(server).not_to have_received(:start) + end + end + + describe '#stop' do + it "doesn't shutdown" do + expect { exporter.stop }.not_to change { exporter.thread? } + + expect(server).not_to have_received(:shutdown) + end + end + end +end diff --git a/spec/lib/gitlab/project_template_spec.rb b/spec/lib/gitlab/project_template_spec.rb new file mode 100644 index 00000000000..12e75cdd5d0 --- /dev/null +++ b/spec/lib/gitlab/project_template_spec.rb @@ -0,0 +1,63 @@ +require 'spec_helper' + +describe Gitlab::ProjectTemplate do + describe '.all' do + it 'returns a all templates' do + expected = [ + described_class.new('rails', 'Ruby on Rails') + ] + + expect(described_class.all).to be_an(Array) + expect(described_class.all).to eq(expected) + end + end + + describe '.find' do + subject { described_class.find(query) } + + context 'when there is a match' do + let(:query) { :rails } + + it { is_expected.to be_a(described_class) } + end + + context 'when there is no match' do + let(:query) { 'no-match' } + + it { is_expected.to be(nil) } + end + end + + describe 'instance methods' do + subject { described_class.new('phoenix', 'Phoenix Framework') } + + it { is_expected.to respond_to(:logo, :file, :archive_path) } + end + + describe 'validate all templates' do + set(:admin) { create(:admin) } + + described_class.all.each do |template| + it "#{template.name} has a valid archive" do + archive = template.archive_path + + expect(File.exist?(archive)).to be(true) + end + + context 'with valid parameters' do + it 'can be imported' do + params = { + template_name: template.name, + namespace_id: admin.namespace.id, + path: template.name + } + + project = Projects::CreateFromTemplateService.new(admin, params).execute + + expect(project).to be_valid + expect(project).to be_persisted + end + end + end + end +end diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb index b90d8dede0f..2345874cf10 100644 --- a/spec/lib/gitlab/shell_spec.rb +++ b/spec/lib/gitlab/shell_spec.rb @@ -174,20 +174,94 @@ describe Gitlab::Shell do end describe '#fetch_remote' do + def fetch_remote(ssh_auth = nil) + gitlab_shell.fetch_remote('current/storage', 'project/path', 'new/storage', ssh_auth: ssh_auth) + end + + def expect_popen(vars = {}) + popen_args = [ + projects_path, + 'fetch-remote', + 'current/storage', + 'project/path.git', + 'new/storage', + Gitlab.config.gitlab_shell.git_timeout.to_s + ] + + expect(Gitlab::Popen).to receive(:popen).with(popen_args, nil, popen_vars.merge(vars)) + end + + def build_ssh_auth(opts = {}) + defaults = { + ssh_import?: true, + ssh_key_auth?: false, + ssh_known_hosts: nil, + ssh_private_key: nil + } + + double(:ssh_auth, defaults.merge(opts)) + end + it 'returns true when the command succeeds' do - expect(Gitlab::Popen).to receive(:popen) - .with([projects_path, 'fetch-remote', 'current/storage', 'project/path.git', 'new/storage', '800'], - nil, popen_vars).and_return([nil, 0]) + expect_popen.and_return([nil, 0]) - expect(gitlab_shell.fetch_remote('current/storage', 'project/path', 'new/storage')).to be true + expect(fetch_remote).to be_truthy end it 'raises an exception when the command fails' do - expect(Gitlab::Popen).to receive(:popen) - .with([projects_path, 'fetch-remote', 'current/storage', 'project/path.git', 'new/storage', '800'], - nil, popen_vars).and_return(["error", 1]) + expect_popen.and_return(["error", 1]) + + expect { fetch_remote }.to raise_error(Gitlab::Shell::Error, "error") + end + + context 'SSH auth' do + it 'passes the SSH key if specified' do + expect_popen('GITLAB_SHELL_SSH_KEY' => 'foo').and_return([nil, 0]) + + ssh_auth = build_ssh_auth(ssh_key_auth?: true, ssh_private_key: 'foo') + + expect(fetch_remote(ssh_auth)).to be_truthy + end + + it 'does not pass an empty SSH key' do + expect_popen.and_return([nil, 0]) + + ssh_auth = build_ssh_auth(ssh_key_auth: true, ssh_private_key: '') + + expect(fetch_remote(ssh_auth)).to be_truthy + end + + it 'does not pass the key unless SSH key auth is to be used' do + expect_popen.and_return([nil, 0]) + + ssh_auth = build_ssh_auth(ssh_key_auth: false, ssh_private_key: 'foo') + + expect(fetch_remote(ssh_auth)).to be_truthy + end + + it 'passes the known_hosts data if specified' do + expect_popen('GITLAB_SHELL_KNOWN_HOSTS' => 'foo').and_return([nil, 0]) + + ssh_auth = build_ssh_auth(ssh_known_hosts: 'foo') + + expect(fetch_remote(ssh_auth)).to be_truthy + end + + it 'does not pass empty known_hosts data' do + expect_popen.and_return([nil, 0]) + + ssh_auth = build_ssh_auth(ssh_known_hosts: '') + + expect(fetch_remote(ssh_auth)).to be_truthy + end + + it 'does not pass known_hosts data unless SSH is to be used' do + expect_popen(popen_vars).and_return([nil, 0]) + + ssh_auth = build_ssh_auth(ssh_import?: false, ssh_known_hosts: 'foo') - expect { gitlab_shell.fetch_remote('current/storage', 'project/path', 'new/storage') }.to raise_error(Gitlab::Shell::Error, "error") + expect(fetch_remote(ssh_auth)).to be_truthy + end end end diff --git a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb new file mode 100644 index 00000000000..597d8eab51c --- /dev/null +++ b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb @@ -0,0 +1,41 @@ +# encoding: utf-8 + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20170803090603_calculate_conv_dev_index_percentages.rb') + +describe CalculateConvDevIndexPercentages, truncate: true do + let(:migration) { described_class.new } + let!(:conv_dev_index) do + create(:conversational_development_index_metric, + leader_notes: 0, + instance_milestones: 0, + percentage_issues: 0, + percentage_notes: 0, + percentage_milestones: 0, + percentage_boards: 0, + percentage_merge_requests: 0, + percentage_ci_pipelines: 0, + percentage_environments: 0, + percentage_deployments: 0, + percentage_projects_prometheus_active: 0, + percentage_service_desk_issues: 0) + end + + describe '#up' do + it 'calculates percentages correctly' do + migration.up + conv_dev_index.reload + + expect(conv_dev_index.percentage_issues).to be_within(0.1).of(13.3) + expect(conv_dev_index.percentage_notes).to be_zero # leader 0 + expect(conv_dev_index.percentage_milestones).to be_zero # instance 0 + expect(conv_dev_index.percentage_boards).to be_within(0.1).of(62.4) + expect(conv_dev_index.percentage_merge_requests).to eq(50.0) + expect(conv_dev_index.percentage_ci_pipelines).to be_within(0.1).of(19.3) + expect(conv_dev_index.percentage_environments).to be_within(0.1).of(66.7) + expect(conv_dev_index.percentage_deployments).to be_within(0.1).of(64.2) + expect(conv_dev_index.percentage_projects_prometheus_active).to be_within(0.1).of(98.2) + expect(conv_dev_index.percentage_service_desk_issues).to be_within(0.1).of(84.0) + end + end +end diff --git a/spec/models/conversational_development_index/metric_spec.rb b/spec/models/conversational_development_index/metric_spec.rb new file mode 100644 index 00000000000..b3193619503 --- /dev/null +++ b/spec/models/conversational_development_index/metric_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' + +describe ConversationalDevelopmentIndex::Metric do + let(:conv_dev_index) { create(:conversational_development_index_metric) } + + describe '#percentage_score' do + it 'returns stored percentage score' do + expect(conv_dev_index.percentage_score('issues')).to eq(13.331) + end + end +end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index fa22eee3dea..c055863d298 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -191,14 +191,10 @@ describe Issue do end it 'returns the merge request to close this issue' do - mr - expect(issue.closed_by_merge_requests(mr.author)).to eq([mr]) end it "returns an empty array when the merge request is closed already" do - closed_mr - expect(issue.closed_by_merge_requests(closed_mr.author)).to eq([]) end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 0daeb337168..3508391c721 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -83,15 +83,6 @@ describe Key, :mailer do expect(build(:key)).to be_valid end - it 'rejects an unfingerprintable key that contains a space' do - key = build(:key) - - # Not always the middle, but close enough - key.key = key.key[0..100] + ' ' + key.key[101..-1] - - expect(key).not_to be_valid - end - it 'accepts a key with newline charecters after stripping them' do key = build(:key) key.key = key.key.insert(100, "\n") @@ -102,7 +93,6 @@ describe Key, :mailer do it 'rejects the unfingerprintable key (not a key)' do expect(build(:key, key: 'ssh-rsa an-invalid-key==')).not_to be_valid end - end context 'callbacks' do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 3402c260f27..a1a3e70a7d2 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1369,6 +1369,32 @@ describe MergeRequest do end end + describe '#merge_ongoing?' do + it 'returns true when merge process is ongoing for merge_jid' do + merge_request = create(:merge_request, merge_jid: 'foo') + + allow(Gitlab::SidekiqStatus).to receive(:num_running).with(['foo']).and_return(1) + + expect(merge_request.merge_ongoing?).to be(true) + end + + it 'returns false when no merge process running for merge_jid' do + merge_request = build(:merge_request, merge_jid: 'foo') + + allow(Gitlab::SidekiqStatus).to receive(:num_running).with(['foo']).and_return(0) + + expect(merge_request.merge_ongoing?).to be(false) + end + + it 'returns false when merge_jid is nil' do + merge_request = build(:merge_request, merge_jid: nil) + + expect(Gitlab::SidekiqStatus).not_to receive(:num_running) + + expect(merge_request.merge_ongoing?).to be(false) + end + end + describe "#closed_without_fork?" do let(:project) { create(:project) } let(:fork_project) { create(:project, forked_from_project: project) } diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index b48aa9558d5..d3da0107d5c 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -230,16 +230,40 @@ describe Milestone do end describe '#to_reference' do - let(:project) { build(:project, name: 'sample-project') } - let(:milestone) { build(:milestone, iid: 1, project: project) } + let(:group) { build_stubbed(:group) } + let(:project) { build_stubbed(:project, name: 'sample-project') } + let(:another_project) { build_stubbed(:project, name: 'another-project', namespace: project.namespace) } + + context 'for a project milestone' do + let(:milestone) { build_stubbed(:milestone, iid: 1, project: project, name: 'milestone') } + + it 'returns a String reference to the object' do + expect(milestone.to_reference).to eq '%1' + end + + it 'returns a reference by name when the format is set to :name' do + expect(milestone.to_reference(format: :name)).to eq '%"milestone"' + end - it 'returns a String reference to the object' do - expect(milestone.to_reference).to eq "%1" + it 'supports a cross-project reference' do + expect(milestone.to_reference(another_project)).to eq 'sample-project%1' + end end - it 'supports a cross-project reference' do - another_project = build(:project, name: 'another-project', namespace: project.namespace) - expect(milestone.to_reference(another_project)).to eq "sample-project%1" + context 'for a group milestone' do + let(:milestone) { build_stubbed(:milestone, iid: 1, group: group, name: 'milestone') } + + it 'returns nil with the default format' do + expect(milestone.to_reference).to be_nil + end + + it 'returns a reference by name when the format is set to :name' do + expect(milestone.to_reference(format: :name)).to eq '%"milestone"' + end + + it 'does not supports cross-project references' do + expect(milestone.to_reference(another_project, format: :name)).to eq '%"milestone"' + end end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 4ddda5b638c..cfa77648338 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -234,19 +234,31 @@ describe Repository, models: true do end describe '#find_commits_by_message' do - it 'returns commits with messages containing a given string' do - commit_ids = repository.find_commits_by_message('submodule').map(&:id) + shared_examples 'finding commits by message' do + it 'returns commits with messages containing a given string' do + commit_ids = repository.find_commits_by_message('submodule').map(&:id) - expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') - expect(commit_ids).to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') - expect(commit_ids).to include('cfe32cf61b73a0d5e9f13e774abde7ff789b1660') - expect(commit_ids).not_to include('913c66a37b4a45b9769037c55c2d238bd0942d2e') + expect(commit_ids).to include( + '5937ac0a7beb003549fc5fd26fc247adbce4a52e', + '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9', + 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' + ) + expect(commit_ids).not_to include('913c66a37b4a45b9769037c55c2d238bd0942d2e') + end + + it 'is case insensitive' do + commit_ids = repository.find_commits_by_message('SUBMODULE').map(&:id) + + expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') + end end - it 'is case insensitive' do - commit_ids = repository.find_commits_by_message('SUBMODULE').map(&:id) + context 'when Gitaly commits_by_message feature is enabled' do + it_behaves_like 'finding commits by message' + end - expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') + context 'when Gitaly commits_by_message feature is disabled', skip_gitaly_mock: true do + it_behaves_like 'finding commits by message' end describe 'when storage is broken', broken_storage: true do diff --git a/spec/presenters/conversational_development_index/metric_presenter_spec.rb b/spec/presenters/conversational_development_index/metric_presenter_spec.rb index 1e015c71f5b..81eb05a9a6b 100644 --- a/spec/presenters/conversational_development_index/metric_presenter_spec.rb +++ b/spec/presenters/conversational_development_index/metric_presenter_spec.rb @@ -8,9 +8,9 @@ describe ConversationalDevelopmentIndex::MetricPresenter do it 'includes instance score, leader score and percentage score' do issues_card = subject.cards.first - expect(issues_card.instance_score).to eq 1.234 - expect(issues_card.leader_score).to eq 9.256 - expect(issues_card.percentage_score).to be_within(0.1).of(13.3) + expect(issues_card.instance_score).to eq(1.234) + expect(issues_card.leader_score).to eq(9.256) + expect(issues_card.percentage_score).to eq(13.331) end end diff --git a/spec/serializers/merge_request_entity_spec.rb b/spec/serializers/merge_request_entity_spec.rb index 18cd9e9c006..a2fd5b7daae 100644 --- a/spec/serializers/merge_request_entity_spec.rb +++ b/spec/serializers/merge_request_entity_spec.rb @@ -47,7 +47,7 @@ describe MergeRequestEntity do :cancel_merge_when_pipeline_succeeds_path, :create_issue_to_resolve_discussions_path, :source_branch_path, :target_branch_commits_path, - :target_branch_tree_path, :commits_count) + :target_branch_tree_path, :commits_count, :merge_ongoing) end it 'has email_patches_path' do diff --git a/spec/services/projects/autocomplete_service_spec.rb b/spec/services/projects/autocomplete_service_spec.rb index c1f098530bf..426593be428 100644 --- a/spec/services/projects/autocomplete_service_spec.rb +++ b/spec/services/projects/autocomplete_service_spec.rb @@ -88,4 +88,31 @@ describe Projects::AutocompleteService do end end end + + describe '#milestones' do + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:project) { create(:project, group: group) } + let!(:group_milestone) { create(:milestone, group: group) } + let!(:project_milestone) { create(:milestone, project: project) } + + let(:milestone_titles) { described_class.new(project, user).milestones.map(&:title) } + + it 'includes project and group milestones' do + expect(milestone_titles).to eq([group_milestone.title, project_milestone.title]) + end + + it 'does not include closed milestones' do + group_milestone.close + + expect(milestone_titles).to eq([project_milestone.title]) + end + + it 'does not include milestones from other projects in the group' do + other_project = create(:project, group: group) + project_milestone.update!(project: other_project) + + expect(milestone_titles).to eq([group_milestone.title]) + end + end end diff --git a/spec/services/projects/create_from_template_service_spec.rb b/spec/services/projects/create_from_template_service_spec.rb new file mode 100644 index 00000000000..9919ec254c6 --- /dev/null +++ b/spec/services/projects/create_from_template_service_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Projects::CreateFromTemplateService do + let(:user) { create(:user) } + let(:project_params) do + { + path: user.to_param, + template_name: 'rails' + } + end + + subject { described_class.new(user, project_params) } + + it 'calls the importer service' do + expect_any_instance_of(Projects::GitlabProjectsImportService).to receive(:execute) + + subject.execute + end + + it 'returns the project thats created' do + project = subject.execute + + expect(project).to be_saved + expect(project.scheduled?).to be(true) + end +end diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index c0ab1ea704d..034065aab00 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -38,8 +38,7 @@ describe Projects::ImportService do context 'with a Github repository' do it 'succeeds if repository import is successfully' do - expect_any_instance_of(Repository).to receive(:fetch_remote).and_return(true) - expect_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute).and_return(true) + expect_any_instance_of(Github::Import).to receive(:execute).and_return(true) result = subject.execute @@ -52,16 +51,7 @@ describe Projects::ImportService do result = subject.execute expect(result[:status]).to eq :error - expect(result[:message]).to eq "Error importing repository #{project.import_url} into #{project.full_path} - Failed to import the repository" - end - - it 'does not remove the GitHub remote' do - expect_any_instance_of(Repository).to receive(:fetch_remote).and_return(true) - expect_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute).and_return(true) - - subject.execute - - expect(project.repository.raw_repository.remote_names).to include('github') + expect(result[:message]).to eq "Error importing repository #{project.import_url} into #{project.path_with_namespace} - The remote data could not be imported." end end @@ -102,8 +92,7 @@ describe Projects::ImportService do end it 'succeeds if importer succeeds' do - allow_any_instance_of(Repository).to receive(:fetch_remote).and_return(true) - allow_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute).and_return(true) + allow_any_instance_of(Github::Import).to receive(:execute).and_return(true) result = subject.execute @@ -111,10 +100,7 @@ describe Projects::ImportService do end it 'flushes various caches' do - allow_any_instance_of(Repository).to receive(:fetch_remote) - .and_return(true) - - allow_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute) + allow_any_instance_of(Github::Import).to receive(:execute) .and_return(true) expect_any_instance_of(Repository).to receive(:expire_content_cache) @@ -123,8 +109,7 @@ describe Projects::ImportService do end it 'fails if importer fails' do - allow_any_instance_of(Repository).to receive(:fetch_remote).and_return(true) - allow_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute).and_return(false) + allow_any_instance_of(Github::Import).to receive(:execute).and_return(false) result = subject.execute @@ -133,8 +118,7 @@ describe Projects::ImportService do end it 'fails if importer raise an error' do - allow_any_instance_of(Gitlab::Shell).to receive(:fetch_remote).and_return(true) - allow_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute).and_raise(Projects::ImportService::Error.new('Github: failed to connect API')) + allow_any_instance_of(Github::Import).to receive(:execute).and_raise(Projects::ImportService::Error.new('Github: failed to connect API')) result = subject.execute @@ -143,9 +127,9 @@ describe Projects::ImportService do end it 'expires content cache after error' do - allow_any_instance_of(Project).to receive(:repository_exists?).and_return(false, true) + allow_any_instance_of(Project).to receive(:repository_exists?).and_return(false) - expect_any_instance_of(Gitlab::Shell).to receive(:fetch_remote).and_raise(Gitlab::Shell::Error.new('Failed to import the repository')) + expect_any_instance_of(Repository).to receive(:fetch_remote).and_raise(Gitlab::Shell::Error.new) expect_any_instance_of(Repository).to receive(:expire_content_cache) subject.execute diff --git a/spec/services/submit_usage_ping_service_spec.rb b/spec/services/submit_usage_ping_service_spec.rb index 817fa4262d5..c8a6fc1a99b 100644 --- a/spec/services/submit_usage_ping_service_spec.rb +++ b/spec/services/submit_usage_ping_service_spec.rb @@ -46,6 +46,8 @@ describe SubmitUsagePingService do .by(1) expect(ConversationalDevelopmentIndex::Metric.last.leader_issues).to eq 10.2 + expect(ConversationalDevelopmentIndex::Metric.last.instance_issues).to eq 3.2 + expect(ConversationalDevelopmentIndex::Metric.last.percentage_issues).to eq 31.37 end end @@ -60,6 +62,7 @@ describe SubmitUsagePingService do conv_index: { leader_issues: 10.2, instance_issues: 3.2, + percentage_issues: 31.37, leader_notes: 25.3, instance_notes: 23.2, @@ -86,7 +89,9 @@ describe SubmitUsagePingService do instance_projects_prometheus_active: 0.30, leader_service_desk_issues: 15.8, - instance_service_desk_issues: 15.1 + instance_service_desk_issues: 15.1, + + non_existing_column: 'value' } } end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index e3805160b04..8f1eb4863d9 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' describe SystemNoteService do include Gitlab::Routing - let(:project) { create(:project) } + let(:group) { create(:group) } + let(:project) { create(:project, group: group) } let(:author) { create(:user) } let(:noteable) { create(:issue, project: project) } let(:issue) { noteable } @@ -242,25 +243,51 @@ describe SystemNoteService do end describe '.change_milestone' do - subject { described_class.change_milestone(noteable, project, author, milestone) } + context 'for a project milestone' do + subject { described_class.change_milestone(noteable, project, author, milestone) } - let(:milestone) { create(:milestone, project: project) } + let(:milestone) { create(:milestone, project: project) } - it_behaves_like 'a system note' do - let(:action) { 'milestone' } - end + it_behaves_like 'a system note' do + let(:action) { 'milestone' } + end - context 'when milestone added' do - it 'sets the note text' do - expect(subject.note).to eq "changed milestone to #{milestone.to_reference}" + context 'when milestone added' do + it 'sets the note text' do + expect(subject.note).to eq "changed milestone to #{milestone.to_reference}" + end + end + + context 'when milestone removed' do + let(:milestone) { nil } + + it 'sets the note text' do + expect(subject.note).to eq 'removed milestone' + end end end - context 'when milestone removed' do - let(:milestone) { nil } + context 'for a group milestone' do + subject { described_class.change_milestone(noteable, project, author, milestone) } - it 'sets the note text' do - expect(subject.note).to eq 'removed milestone' + let(:milestone) { create(:milestone, group: group) } + + it_behaves_like 'a system note' do + let(:action) { 'milestone' } + end + + context 'when milestone added' do + it 'sets the note text to use the milestone name' do + expect(subject.note).to eq "changed milestone to #{milestone.to_reference(format: :name)}" + end + end + + context 'when milestone removed' do + let(:milestone) { nil } + + it 'sets the note text' do + expect(subject.note).to eq 'removed milestone' + end end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 06769b241ad..0ba6ed56314 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -134,13 +134,13 @@ RSpec.configure do |config| ActiveRecord::Migrator .migrate(migrations_paths, previous_migration.version) - ActiveRecord::Base.descendants.each(&:reset_column_information) + reset_column_in_migration_models end config.after(:example, :migration) do ActiveRecord::Migrator.migrate(migrations_paths) - ActiveRecord::Base.descendants.each(&:reset_column_information) + reset_column_in_migration_models end config.around(:each, :nested_groups) do |example| diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index c0a5491a430..30911e7fa86 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -41,7 +41,9 @@ module CycleAnalyticsHelpers target_branch: 'master' } - MergeRequests::CreateService.new(project, user, opts).execute + mr = MergeRequests::CreateService.new(project, user, opts).execute + NewMergeRequestWorker.new.perform(mr, user) + mr end def merge_merge_requests_closing_issue(issue) diff --git a/spec/support/issuable_shared_examples.rb b/spec/support/issuable_shared_examples.rb index 970fe10db2b..42f3b4db23c 100644 --- a/spec/support/issuable_shared_examples.rb +++ b/spec/support/issuable_shared_examples.rb @@ -21,15 +21,15 @@ shared_examples 'system notes for milestones' do create(:group_member, group: group, user: user) end - it 'does not create system note' do + it 'creates a system note' do expect do update_issuable(milestone: group_milestone) - end.not_to change { Note.system.count } + end.to change { Note.system.count }.by(1) end end context 'project milestones' do - it 'creates system note' do + it 'creates a system note' do expect do update_issuable(milestone: create(:milestone)) end.to change { Note.system.count }.by(1) diff --git a/spec/support/markdown_feature.rb b/spec/support/markdown_feature.rb index 21a054af4e1..c90359d7cfa 100644 --- a/spec/support/markdown_feature.rb +++ b/spec/support/markdown_feature.rb @@ -23,7 +23,7 @@ class MarkdownFeature # Direct references ---------------------------------------------------------- def project - @project ||= create(:project, :repository).tap do |project| + @project ||= create(:project, :repository, group: group).tap do |project| project.team << [user, :master] end end @@ -75,6 +75,10 @@ class MarkdownFeature @milestone ||= create(:milestone, name: 'next goal', project: project) end + def group_milestone + @group_milestone ||= create(:milestone, name: 'group-milestone', group: group) + end + # Cross-references ----------------------------------------------------------- def xproject diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb index 7afa57fb76b..d12b2757427 100644 --- a/spec/support/matchers/markdown_matchers.rb +++ b/spec/support/matchers/markdown_matchers.rb @@ -155,7 +155,7 @@ module MarkdownMatchers set_default_markdown_messages match do |actual| - expect(actual).to have_selector('a.gfm.gfm-milestone', count: 6) + expect(actual).to have_selector('a.gfm.gfm-milestone', count: 8) end end diff --git a/spec/support/migrations_helpers.rb b/spec/support/migrations_helpers.rb index 91fbb4eaf48..aabdad13047 100644 --- a/spec/support/migrations_helpers.rb +++ b/spec/support/migrations_helpers.rb @@ -15,6 +15,16 @@ module MigrationsHelpers ActiveRecord::Migrator.migrations(migrations_paths) end + def reset_column_in_migration_models + described_class.constants.sort.each do |name| + const = described_class.const_get(name) + + if const.is_a?(Class) && const < ActiveRecord::Base + const.reset_column_information + end + end + end + def previous_migration migrations.each_cons(2) do |previous, migration| break previous if migration.name == described_class.name diff --git a/spec/workers/merge_worker_spec.rb b/spec/workers/merge_worker_spec.rb index 303193bab9b..ee51000161a 100644 --- a/spec/workers/merge_worker_spec.rb +++ b/spec/workers/merge_worker_spec.rb @@ -27,4 +27,15 @@ describe MergeWorker do expect(source_project.repository.branch_names).not_to include('markdown') end end + + it 'persists merge_jid' do + merge_request = create(:merge_request, merge_jid: nil) + user = create(:user) + worker = described_class.new + + allow(worker).to receive(:jid) { '999' } + + expect { worker.perform(merge_request.id, user.id, {}) } + .to change { merge_request.reload.merge_jid }.from(nil).to('999') + end end diff --git a/spec/workers/new_issue_worker_spec.rb b/spec/workers/new_issue_worker_spec.rb new file mode 100644 index 00000000000..ed49ce57c0b --- /dev/null +++ b/spec/workers/new_issue_worker_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' + +describe NewIssueWorker do + describe '#perform' do + let(:worker) { described_class.new } + + context 'when an issue not found' do + it 'does not call Services' do + expect(EventCreateService).not_to receive(:new) + expect(NotificationService).not_to receive(:new) + + worker.perform(99, create(:user).id) + end + + it 'logs an error' do + expect(Rails.logger).to receive(:error).with('NewIssueWorker: couldn\'t find Issue with ID=99, skipping job') + + worker.perform(99, create(:user).id) + end + end + + context 'when a user not found' do + it 'does not call Services' do + expect(EventCreateService).not_to receive(:new) + expect(NotificationService).not_to receive(:new) + + worker.perform(create(:issue).id, 99) + end + + it 'logs an error' do + expect(Rails.logger).to receive(:error).with('NewIssueWorker: couldn\'t find User with ID=99, skipping job') + + worker.perform(create(:issue).id, 99) + end + end + + context 'when everything is ok' do + let(:project) { create(:project, :public) } + let(:mentioned) { create(:user) } + let(:user) { create(:user) } + let(:issue) { create(:issue, project: project, description: "issue for #{mentioned.to_reference}") } + + it 'creates a new event record' do + expect{ worker.perform(issue.id, user.id) }.to change { Event.count }.from(0).to(1) + end + + it 'creates a notification for the assignee' do + expect(Notify).to receive(:new_issue_email).with(mentioned.id, issue.id).and_return(double(deliver_later: true)) + + worker.perform(issue.id, user.id) + end + end + end +end diff --git a/spec/workers/new_merge_request_worker_spec.rb b/spec/workers/new_merge_request_worker_spec.rb new file mode 100644 index 00000000000..85af6184d39 --- /dev/null +++ b/spec/workers/new_merge_request_worker_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe NewMergeRequestWorker do + describe '#perform' do + let(:worker) { described_class.new } + + context 'when a merge request not found' do + it 'does not call Services' do + expect(EventCreateService).not_to receive(:new) + expect(NotificationService).not_to receive(:new) + + worker.perform(99, create(:user).id) + end + + it 'logs an error' do + expect(Rails.logger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find MergeRequest with ID=99, skipping job') + + worker.perform(99, create(:user).id) + end + end + + context 'when a user not found' do + it 'does not call Services' do + expect(EventCreateService).not_to receive(:new) + expect(NotificationService).not_to receive(:new) + + worker.perform(create(:merge_request).id, 99) + end + + it 'logs an error' do + expect(Rails.logger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find User with ID=99, skipping job') + + worker.perform(create(:merge_request).id, 99) + end + end + + context 'when everything is ok' do + let(:project) { create(:project, :public) } + let(:mentioned) { create(:user) } + let(:user) { create(:user) } + let(:merge_request) do + create(:merge_request, source_project: project, description: "mr for #{mentioned.to_reference}") + end + + it 'creates a new event record' do + expect{ worker.perform(merge_request.id, user.id) }.to change { Event.count }.from(0).to(1) + end + + it 'creates a notification for the assignee' do + expect(Notify).to receive(:new_merge_request_email).with(mentioned.id, merge_request.id).and_return(double(deliver_later: true)) + + worker.perform(merge_request.id, user.id) + end + end + end +end diff --git a/spec/workers/stuck_merge_jobs_worker_spec.rb b/spec/workers/stuck_merge_jobs_worker_spec.rb new file mode 100644 index 00000000000..a5ad78393c9 --- /dev/null +++ b/spec/workers/stuck_merge_jobs_worker_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' + +describe StuckMergeJobsWorker do + describe 'perform' do + let(:worker) { described_class.new } + + context 'merge job identified as completed' do + it 'updates merge request to merged when locked but has merge_commit_sha' do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w(123 456)) + mr_with_sha = create(:merge_request, :locked, merge_jid: '123', state: :locked, merge_commit_sha: 'foo-bar-baz') + mr_without_sha = create(:merge_request, :locked, merge_jid: '123', state: :locked, merge_commit_sha: nil) + + worker.perform + + expect(mr_with_sha.reload).to be_merged + expect(mr_without_sha.reload).to be_opened + end + + it 'updates merge request to opened when locked but has not been merged' do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w(123)) + merge_request = create(:merge_request, :locked, merge_jid: '123', state: :locked) + + worker.perform + + expect(merge_request.reload).to be_opened + end + + it 'logs updated stuck merge job ids' do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w(123 456)) + + create(:merge_request, :locked, merge_jid: '123') + create(:merge_request, :locked, merge_jid: '456') + + expect(Rails).to receive_message_chain(:logger, :info).with('Updated state of locked merge jobs. JIDs: 123, 456') + + worker.perform + end + end + + context 'merge job not identified as completed' do + it 'does not change merge request state when job is not completed yet' do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([]) + + merge_request = create(:merge_request, :locked, merge_jid: '123') + + expect { worker.perform }.not_to change { merge_request.reload.state }.from('locked') + end + end + end +end diff --git a/vendor/assets/javascripts/jquery.nicescroll.js b/vendor/assets/javascripts/jquery.nicescroll.js deleted file mode 100644 index 7653f25df4b..00000000000 --- a/vendor/assets/javascripts/jquery.nicescroll.js +++ /dev/null @@ -1,3634 +0,0 @@ -/* jquery.nicescroll --- version 3.6.0 --- copyright 2014-11-21 InuYaksa*2014 --- licensed under the MIT --- --- http://nicescroll.areaaperta.com/ --- https://github.com/inuyaksa/jquery.nicescroll --- -*/ - -(function(factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as anonymous module. - define(['jquery'], factory); - } else { - // Browser globals. - factory(jQuery); - } -}(function(jQuery) { - "use strict"; - - // globals - var domfocus = false; - var mousefocus = false; - var tabindexcounter = 0; - var ascrailcounter = 2000; - var globalmaxzindex = 0; - - var $ = jQuery; // sandbox - - // http://stackoverflow.com/questions/2161159/get-script-path - function getScriptPath() { - var scripts = document.getElementsByTagName('script'); - var path = scripts[scripts.length - 1].src.split('?')[0]; - return (path.split('/').length > 0) ? path.split('/').slice(0, -1).join('/') + '/' : ''; - } - - var vendors = ['webkit','ms','moz','o']; - - var setAnimationFrame = window.requestAnimationFrame || false; - var clearAnimationFrame = window.cancelAnimationFrame || false; - - if (!setAnimationFrame) { // legacy detection - for (var vx in vendors) { - var v = vendors[vx]; - if (!setAnimationFrame) setAnimationFrame = window[v + 'RequestAnimationFrame']; - if (!clearAnimationFrame) clearAnimationFrame = window[v + 'CancelAnimationFrame'] || window[v + 'CancelRequestAnimationFrame']; - } - } - - var ClsMutationObserver = window.MutationObserver || window.WebKitMutationObserver || false; - - var _globaloptions = { - zindex: "auto", - cursoropacitymin: 0, - cursoropacitymax: 1, - cursorcolor: "#424242", - cursorwidth: "5px", - cursorborder: "1px solid #fff", - cursorborderradius: "5px", - scrollspeed: 60, - mousescrollstep: 8 * 3, - touchbehavior: false, - hwacceleration: true, - usetransition: true, - boxzoom: false, - dblclickzoom: true, - gesturezoom: true, - grabcursorenabled: true, - autohidemode: true, - background: "", - iframeautoresize: true, - cursorminheight: 32, - preservenativescrolling: true, - railoffset: false, - railhoffset: false, - bouncescroll: true, - spacebarenabled: true, - railpadding: { - top: 0, - right: 0, - left: 0, - bottom: 0 - }, - disableoutline: true, - horizrailenabled: true, - railalign: "right", - railvalign: "bottom", - enabletranslate3d: true, - enablemousewheel: true, - enablekeyboard: true, - smoothscroll: true, - sensitiverail: true, - enablemouselockapi: true, - // cursormaxheight:false, - cursorfixedheight: false, - directionlockdeadzone: 6, - hidecursordelay: 400, - nativeparentscrolling: true, - enablescrollonselection: true, - overflowx: true, - overflowy: true, - cursordragspeed: 0.3, - rtlmode: "auto", - cursordragontouch: false, - oneaxismousemode: "auto", - scriptpath: getScriptPath(), - preventmultitouchscrolling: true - }; - - var browserdetected = false; - - var getBrowserDetection = function() { - - if (browserdetected) return browserdetected; - - var _el = document.createElement('DIV'), - _style = _el.style, - _agent = navigator.userAgent, - _platform = navigator.platform, - d = {}; - - d.haspointerlock = "pointerLockElement" in document || "webkitPointerLockElement" in document || "mozPointerLockElement" in document; - - d.isopera = ("opera" in window); // 12- - d.isopera12 = (d.isopera && ("getUserMedia" in navigator)); - d.isoperamini = (Object.prototype.toString.call(window.operamini) === "[object OperaMini]"); - - d.isie = (("all" in document) && ("attachEvent" in _el) && !d.isopera); //IE10- - d.isieold = (d.isie && !("msInterpolationMode" in _style)); // IE6 and older - d.isie7 = d.isie && !d.isieold && (!("documentMode" in document) || (document.documentMode == 7)); - d.isie8 = d.isie && ("documentMode" in document) && (document.documentMode == 8); - d.isie9 = d.isie && ("performance" in window) && (document.documentMode >= 9); - d.isie10 = d.isie && ("performance" in window) && (document.documentMode == 10); - d.isie11 = ("msRequestFullscreen" in _el) && (document.documentMode >= 11); // IE11+ - - d.isie9mobile = /iemobile.9/i.test(_agent); //wp 7.1 mango - if (d.isie9mobile) d.isie9 = false; - d.isie7mobile = (!d.isie9mobile && d.isie7) && /iemobile/i.test(_agent); //wp 7.0 - - d.ismozilla = ("MozAppearance" in _style); - - d.iswebkit = ("WebkitAppearance" in _style); - - d.ischrome = ("chrome" in window); - d.ischrome22 = (d.ischrome && d.haspointerlock); - d.ischrome26 = (d.ischrome && ("transition" in _style)); // issue with transform detection (maintain prefix) - - d.cantouch = ("ontouchstart" in document.documentElement) || ("ontouchstart" in window); // detection for Chrome Touch Emulation - d.hasmstouch = (window.MSPointerEvent || false); // IE10 pointer events - d.hasw3ctouch = (window.PointerEvent || false); //IE11 pointer events, following W3C Pointer Events spec - - d.ismac = /^mac$/i.test(_platform); - - d.isios = (d.cantouch && /iphone|ipad|ipod/i.test(_platform)); - d.isios4 = ((d.isios) && !("seal" in Object)); - d.isios7 = ((d.isios)&&("webkitHidden" in document)); //iOS 7+ - - d.isandroid = (/android/i.test(_agent)); - - d.haseventlistener = ("addEventListener" in _el); - - d.trstyle = false; - d.hastransform = false; - d.hastranslate3d = false; - d.transitionstyle = false; - d.hastransition = false; - d.transitionend = false; - - var a; - var check = ['transform', 'msTransform', 'webkitTransform', 'MozTransform', 'OTransform']; - for (a = 0; a < check.length; a++) { - if (typeof _style[check[a]] != "undefined") { - d.trstyle = check[a]; - break; - } - } - d.hastransform = (!!d.trstyle); - if (d.hastransform) { - _style[d.trstyle] = "translate3d(1px,2px,3px)"; - d.hastranslate3d = /translate3d/.test(_style[d.trstyle]); - } - - d.transitionstyle = false; - d.prefixstyle = ''; - d.transitionend = false; - check = ['transition', 'webkitTransition', 'msTransition', 'MozTransition', 'OTransition', 'OTransition', 'KhtmlTransition']; - var prefix = ['', '-webkit-', '-ms-', '-moz-', '-o-', '-o', '-khtml-']; - var evs = ['transitionend', 'webkitTransitionEnd', 'msTransitionEnd', 'transitionend', 'otransitionend', 'oTransitionEnd', 'KhtmlTransitionEnd']; - for (a = 0; a < check.length; a++) { - if (check[a] in _style) { - d.transitionstyle = check[a]; - d.prefixstyle = prefix[a]; - d.transitionend = evs[a]; - break; - } - } - if (d.ischrome26) { // always use prefix - d.prefixstyle = prefix[1]; - } - - d.hastransition = (d.transitionstyle); - - function detectCursorGrab() { - var lst = ['-webkit-grab', '-moz-grab', 'grab']; - if ((d.ischrome && !d.ischrome22) || d.isie) lst = []; // force setting for IE returns false positive and chrome cursor bug - for (var a = 0; a < lst.length; a++) { - var p = lst[a]; - _style.cursor = p; - if (_style.cursor == p) return p; - } - return 'url(//mail.google.com/mail/images/2/openhand.cur),n-resize'; // thank you google for custom cursor! - } - d.cursorgrabvalue = detectCursorGrab(); - - d.hasmousecapture = ("setCapture" in _el); - - d.hasMutationObserver = (ClsMutationObserver !== false); - - _el = null; //memory released - - browserdetected = d; - - return d; - }; - - var NiceScrollClass = function(myopt, me) { - - var self = this; - - this.version = '3.6.0'; - this.name = 'nicescroll'; - - this.me = me; - - this.opt = { - doc: $("body"), - win: false - }; - - $.extend(this.opt, _globaloptions); // clone opts - - // Options for internal use - this.opt.snapbackspeed = 80; - - if (myopt || false) { - for (var a in self.opt) { - if (typeof myopt[a] != "undefined") self.opt[a] = myopt[a]; - } - } - - this.doc = self.opt.doc; - this.iddoc = (this.doc && this.doc[0]) ? this.doc[0].id || '' : ''; - this.ispage = /^BODY|HTML/.test((self.opt.win) ? self.opt.win[0].nodeName : this.doc[0].nodeName); - this.haswrapper = (self.opt.win !== false); - this.win = self.opt.win || (this.ispage ? $(window) : this.doc); - this.docscroll = (this.ispage && !this.haswrapper) ? $(window) : this.win; - this.body = $("body"); - this.viewport = false; - - this.isfixed = false; - - this.iframe = false; - this.isiframe = ((this.doc[0].nodeName == 'IFRAME') && (this.win[0].nodeName == 'IFRAME')); - - this.istextarea = (this.win[0].nodeName == 'TEXTAREA'); - - this.forcescreen = false; //force to use screen position on events - - this.canshowonmouseevent = (self.opt.autohidemode != "scroll"); - - // Events jump table - this.onmousedown = false; - this.onmouseup = false; - this.onmousemove = false; - this.onmousewheel = false; - this.onkeypress = false; - this.ongesturezoom = false; - this.onclick = false; - - // Nicescroll custom events - this.onscrollstart = false; - this.onscrollend = false; - this.onscrollcancel = false; - - this.onzoomin = false; - this.onzoomout = false; - - // Let's start! - this.view = false; - this.page = false; - - this.scroll = { - x: 0, - y: 0 - }; - this.scrollratio = { - x: 0, - y: 0 - }; - this.cursorheight = 20; - this.scrollvaluemax = 0; - - this.isrtlmode = (this.opt.rtlmode == "auto") ? ((this.win[0] == window ? this.body : this.win).css("direction") == "rtl") : (this.opt.rtlmode === true); - // this.checkrtlmode = false; - - this.scrollrunning = false; - - this.scrollmom = false; - - this.observer = false; // observer div changes - this.observerremover = false; // observer on parent for remove detection - this.observerbody = false; // observer on body for position change - - do { - this.id = "ascrail" + (ascrailcounter++); - } while (document.getElementById(this.id)); - - this.rail = false; - this.cursor = false; - this.cursorfreezed = false; - this.selectiondrag = false; - - this.zoom = false; - this.zoomactive = false; - - this.hasfocus = false; - this.hasmousefocus = false; - - this.visibility = true; - this.railslocked = false; // locked by resize - this.locked = false; // prevent lost of locked status sets by user - this.hidden = false; // rails always hidden - this.cursoractive = true; // user can interact with cursors - - this.wheelprevented = false; //prevent mousewheel event - - this.overflowx = self.opt.overflowx; - this.overflowy = self.opt.overflowy; - - this.nativescrollingarea = false; - this.checkarea = 0; - - this.events = []; // event list for unbind - - this.saved = {}; // style saved - - this.delaylist = {}; - this.synclist = {}; - - this.lastdeltax = 0; - this.lastdeltay = 0; - - this.detected = getBrowserDetection(); - - var cap = $.extend({}, this.detected); - - this.canhwscroll = (cap.hastransform && self.opt.hwacceleration); - this.ishwscroll = (this.canhwscroll && self.haswrapper); - - this.hasreversehr = (this.isrtlmode&&!cap.iswebkit); //RTL mode with reverse horizontal axis - - this.istouchcapable = false; // desktop devices with touch screen support - - //## Check WebKit-based desktop with touch support - //## + Firefox 18 nightly build (desktop) false positive (or desktop with touch support) - if (cap.cantouch && !cap.isios && !cap.isandroid && (cap.iswebkit || cap.ismozilla)) { - this.istouchcapable = true; - cap.cantouch = false; // parse normal desktop events - } - - //## disable MouseLock API on user request - if (!self.opt.enablemouselockapi) { - cap.hasmousecapture = false; - cap.haspointerlock = false; - } - -/* deprecated - this.delayed = function(name, fn, tm, lazy) { - }; -*/ - - this.debounced = function(name, fn, tm) { - var dd = self.delaylist[name]; - self.delaylist[name] = fn; - if (!dd) { - setTimeout(function() { - var fn = self.delaylist[name]; - self.delaylist[name] = false; - fn.call(self); - }, tm); - } - }; - - var _onsync = false; - - this.synched = function(name, fn) { - - function requestSync() { - if (_onsync) return; - setAnimationFrame(function() { - _onsync = false; - for (var nn in self.synclist) { - var fn = self.synclist[nn]; - if (fn) fn.call(self); - self.synclist[nn] = false; - } - }); - _onsync = true; - } - - self.synclist[name] = fn; - requestSync(); - return name; - }; - - this.unsynched = function(name) { - if (self.synclist[name]) self.synclist[name] = false; - }; - - this.css = function(el, pars) { // save & set - for (var n in pars) { - self.saved.css.push([el, n, el.css(n)]); - el.css(n, pars[n]); - } - }; - - this.scrollTop = function(val) { - return (typeof val == "undefined") ? self.getScrollTop() : self.setScrollTop(val); - }; - - this.scrollLeft = function(val) { - return (typeof val == "undefined") ? self.getScrollLeft() : self.setScrollLeft(val); - }; - - // derived by by Dan Pupius www.pupius.net - var BezierClass = function(st, ed, spd, p1, p2, p3, p4) { - - this.st = st; - this.ed = ed; - this.spd = spd; - - this.p1 = p1 || 0; - this.p2 = p2 || 1; - this.p3 = p3 || 0; - this.p4 = p4 || 1; - - this.ts = (new Date()).getTime(); - this.df = this.ed - this.st; - }; - BezierClass.prototype = { - B2: function(t) { - return 3 * t * t * (1 - t); - }, - B3: function(t) { - return 3 * t * (1 - t) * (1 - t); - }, - B4: function(t) { - return (1 - t) * (1 - t) * (1 - t); - }, - getNow: function() { - var nw = (new Date()).getTime(); - var pc = 1 - ((nw - this.ts) / this.spd); - var bz = this.B2(pc) + this.B3(pc) + this.B4(pc); - return (pc < 0) ? this.ed : this.st + Math.round(this.df * bz); - }, - update: function(ed, spd) { - this.st = this.getNow(); - this.ed = ed; - this.spd = spd; - this.ts = (new Date()).getTime(); - this.df = this.ed - this.st; - return this; - } - }; - - //derived from http://stackoverflow.com/questions/11236090/ - function getMatrixValues() { - var tr = self.doc.css(cap.trstyle); - if (tr && (tr.substr(0, 6) == "matrix")) { - return tr.replace(/^.*\((.*)\)$/g, "$1").replace(/px/g, '').split(/, +/); - } - return false; - } - - if (this.ishwscroll) { - // hw accelerated scroll - this.doc.translate = { - x: 0, - y: 0, - tx: "0px", - ty: "0px" - }; - - //this one can help to enable hw accel on ios6 http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/ - if (cap.hastranslate3d && cap.isios) this.doc.css("-webkit-backface-visibility", "hidden"); // prevent flickering http://stackoverflow.com/questions/3461441/ - - this.getScrollTop = function(last) { - if (!last) { - var mtx = getMatrixValues(); - if (mtx) return (mtx.length == 16) ? -mtx[13] : -mtx[5]; //matrix3d 16 on IE10 - if (self.timerscroll && self.timerscroll.bz) return self.timerscroll.bz.getNow(); - } - return self.doc.translate.y; - }; - - this.getScrollLeft = function(last) { - if (!last) { - var mtx = getMatrixValues(); - if (mtx) return (mtx.length == 16) ? -mtx[12] : -mtx[4]; //matrix3d 16 on IE10 - if (self.timerscroll && self.timerscroll.bh) return self.timerscroll.bh.getNow(); - } - return self.doc.translate.x; - }; - - this.notifyScrollEvent = function(el) { - var e = document.createEvent("UIEvents"); - e.initUIEvent("scroll", false, true, window, 1); - e.niceevent = true; - el.dispatchEvent(e); - }; - - var cxscrollleft = (this.isrtlmode) ? 1 : -1; - - if (cap.hastranslate3d && self.opt.enabletranslate3d) { - this.setScrollTop = function(val, silent) { - self.doc.translate.y = val; - self.doc.translate.ty = (val * -1) + "px"; - self.doc.css(cap.trstyle, "translate3d(" + self.doc.translate.tx + "," + self.doc.translate.ty + ",0px)"); - if (!silent) self.notifyScrollEvent(self.win[0]); - }; - this.setScrollLeft = function(val, silent) { - self.doc.translate.x = val; - self.doc.translate.tx = (val * cxscrollleft) + "px"; - self.doc.css(cap.trstyle, "translate3d(" + self.doc.translate.tx + "," + self.doc.translate.ty + ",0px)"); - if (!silent) self.notifyScrollEvent(self.win[0]); - }; - } else { - this.setScrollTop = function(val, silent) { - self.doc.translate.y = val; - self.doc.translate.ty = (val * -1) + "px"; - self.doc.css(cap.trstyle, "translate(" + self.doc.translate.tx + "," + self.doc.translate.ty + ")"); - if (!silent) self.notifyScrollEvent(self.win[0]); - }; - this.setScrollLeft = function(val, silent) { - self.doc.translate.x = val; - self.doc.translate.tx = (val * cxscrollleft) + "px"; - self.doc.css(cap.trstyle, "translate(" + self.doc.translate.tx + "," + self.doc.translate.ty + ")"); - if (!silent) self.notifyScrollEvent(self.win[0]); - }; - } - } else { - // native scroll - this.getScrollTop = function() { - return self.docscroll.scrollTop(); - }; - this.setScrollTop = function(val) { - return self.docscroll.scrollTop(val); - }; - this.getScrollLeft = function() { - if (self.detected.ismozilla && self.isrtlmode) - return Math.abs(self.docscroll.scrollLeft()); - return self.docscroll.scrollLeft(); - }; - this.setScrollLeft = function(val) { - return self.docscroll.scrollLeft((self.detected.ismozilla && self.isrtlmode) ? -val : val); - }; - } - - this.getTarget = function(e) { - if (!e) return false; - if (e.target) return e.target; - if (e.srcElement) return e.srcElement; - return false; - }; - - this.hasParent = function(e, id) { - if (!e) return false; - var el = e.target || e.srcElement || e || false; - while (el && el.id != id) { - el = el.parentNode || false; - } - return (el !== false); - }; - - function getZIndex() { - var dom = self.win; - if ("zIndex" in dom) return dom.zIndex(); // use jQuery UI method when available - while (dom.length > 0) { - if (dom[0].nodeType == 9) return false; - var zi = dom.css('zIndex'); - if (!isNaN(zi) && zi != 0) return parseInt(zi); - dom = dom.parent(); - } - return false; - } - - //inspired by http://forum.jquery.com/topic/width-includes-border-width-when-set-to-thin-medium-thick-in-ie - var _convertBorderWidth = { - "thin": 1, - "medium": 3, - "thick": 5 - }; - - function getWidthToPixel(dom, prop, chkheight) { - var wd = dom.css(prop); - var px = parseFloat(wd); - if (isNaN(px)) { - px = _convertBorderWidth[wd] || 0; - var brd = (px == 3) ? ((chkheight) ? (self.win.outerHeight() - self.win.innerHeight()) : (self.win.outerWidth() - self.win.innerWidth())) : 1; //DON'T TRUST CSS - if (self.isie8 && px) px += 1; - return (brd) ? px : 0; - } - return px; - } - - this.getDocumentScrollOffset = function() { - return {top:window.pageYOffset||document.documentElement.scrollTop, - left:window.pageXOffset||document.documentElement.scrollLeft}; - } - - this.getOffset = function() { - if (self.isfixed) { - var ofs = self.win.offset(); // fix Chrome auto issue (when right/bottom props only) - var scrl = self.getDocumentScrollOffset(); - ofs.top-=scrl.top; - ofs.left-=scrl.left; - return ofs; - } - var ww = self.win.offset(); - if (!self.viewport) return ww; - var vp = self.viewport.offset(); - return { - top: ww.top - vp.top,// + self.viewport.scrollTop(), - left: ww.left - vp.left // + self.viewport.scrollLeft() - }; - }; - - this.updateScrollBar = function(len) { - if (self.ishwscroll) { - self.rail.css({ //** - height: self.win.innerHeight() - (self.opt.railpadding.top + self.opt.railpadding.bottom) - }); - if (self.railh) self.railh.css({ //** - width: self.win.innerWidth() - (self.opt.railpadding.left + self.opt.railpadding.right) - }); - - } else { - var wpos = self.getOffset(); - var pos = { - top: wpos.top, - left: wpos.left - (self.opt.railpadding.left + self.opt.railpadding.right) - }; - pos.top += getWidthToPixel(self.win, 'border-top-width', true); - pos.left += (self.rail.align) ? self.win.outerWidth() - getWidthToPixel(self.win, 'border-right-width') - self.rail.width : getWidthToPixel(self.win, 'border-left-width'); - - var off = self.opt.railoffset; - if (off) { - if (off.top) pos.top += off.top; - if (self.rail.align && off.left) pos.left += off.left; - } - - if (!self.railslocked) self.rail.css({ - top: pos.top, - left: pos.left, - height: ((len) ? len.h : self.win.innerHeight()) - (self.opt.railpadding.top + self.opt.railpadding.bottom) - }); - - if (self.zoom) { - self.zoom.css({ - top: pos.top + 1, - left: (self.rail.align == 1) ? pos.left - 20 : pos.left + self.rail.width + 4 - }); - } - - if (self.railh && !self.railslocked) { - var pos = { - top: wpos.top, - left: wpos.left - }; - var off = self.opt.railhoffset; - if (!!off) { - if (!!off.top) pos.top += off.top; - if (!!off.left) pos.left += off.left; - } - var y = (self.railh.align) ? pos.top + getWidthToPixel(self.win, 'border-top-width', true) + self.win.innerHeight() - self.railh.height : pos.top + getWidthToPixel(self.win, 'border-top-width', true); - var x = pos.left + getWidthToPixel(self.win, 'border-left-width'); - self.railh.css({ - top: y - (self.opt.railpadding.top + self.opt.railpadding.bottom), - left: x, - width: self.railh.width - }); - } - - - } - }; - - this.doRailClick = function(e, dbl, hr) { - var fn, pg, cur, pos; - - if (self.railslocked) return; - self.cancelEvent(e); - - if (dbl) { - fn = (hr) ? self.doScrollLeft : self.doScrollTop; - cur = (hr) ? ((e.pageX - self.railh.offset().left - (self.cursorwidth / 2)) * self.scrollratio.x) : ((e.pageY - self.rail.offset().top - (self.cursorheight / 2)) * self.scrollratio.y); - fn(cur); - } else { - fn = (hr) ? self.doScrollLeftBy : self.doScrollBy; - cur = (hr) ? self.scroll.x : self.scroll.y; - pos = (hr) ? e.pageX - self.railh.offset().left : e.pageY - self.rail.offset().top; - pg = (hr) ? self.view.w : self.view.h; - fn((cur >= pos) ? pg: -pg);// (cur >= pos) ? fn(pg): fn(-pg); - } - - }; - - self.hasanimationframe = (setAnimationFrame); - self.hascancelanimationframe = (clearAnimationFrame); - - if (!self.hasanimationframe) { - setAnimationFrame = function(fn) { - return setTimeout(fn, 15 - Math.floor((+new Date()) / 1000) % 16); - }; // 1000/60)}; - clearAnimationFrame = clearInterval; - } else if (!self.hascancelanimationframe) clearAnimationFrame = function() { - self.cancelAnimationFrame = true; - }; - - this.init = function() { - - self.saved.css = []; - - if (cap.isie7mobile) return true; // SORRY, DO NOT WORK! - if (cap.isoperamini) return true; // SORRY, DO NOT WORK! - - if (cap.hasmstouch) self.css((self.ispage) ? $("html") : self.win, { - '-ms-touch-action': 'none' - }); - - self.zindex = "auto"; - if (!self.ispage && self.opt.zindex == "auto") { - self.zindex = getZIndex() || "auto"; - } else { - self.zindex = self.opt.zindex; - } - - if (!self.ispage && self.zindex != "auto") { - if (self.zindex > globalmaxzindex) globalmaxzindex = self.zindex; - } - - if (self.isie && self.zindex == 0 && self.opt.zindex == "auto") { // fix IE auto == 0 - self.zindex = "auto"; - } - - if (!self.ispage || (!cap.cantouch && !cap.isieold && !cap.isie9mobile)) { - - var cont = self.docscroll; - if (self.ispage) cont = (self.haswrapper) ? self.win : self.doc; - - if (!cap.isie9mobile) self.css(cont, { - 'overflow-y': 'hidden' - }); - - if (self.ispage && cap.isie7) { - if (self.doc[0].nodeName == 'BODY') self.css($("html"), { - 'overflow-y': 'hidden' - }); //IE7 double scrollbar issue - else if (self.doc[0].nodeName == 'HTML') self.css($("body"), { - 'overflow-y': 'hidden' - }); //IE7 double scrollbar issue - } - - if (cap.isios && !self.ispage && !self.haswrapper) self.css($("body"), { - "-webkit-overflow-scrolling": "touch" - }); //force hw acceleration - - var cursor = $(document.createElement('div')); - cursor.css({ - position: "relative", - top: 0, - "float": "right", - width: self.opt.cursorwidth, - height: "0px", - 'background-color': self.opt.cursorcolor, - border: self.opt.cursorborder, - 'background-clip': 'padding-box', - '-webkit-border-radius': self.opt.cursorborderradius, - '-moz-border-radius': self.opt.cursorborderradius, - 'border-radius': self.opt.cursorborderradius - }); - - cursor.hborder = parseFloat(cursor.outerHeight() - cursor.innerHeight()); - - cursor.addClass('nicescroll-cursors'); - - self.cursor = cursor; - - var rail = $(document.createElement('div')); - rail.attr('id', self.id); - rail.addClass('nicescroll-rails nicescroll-rails-vr'); - - var v, a, kp = ["left","right","top","bottom"]; //** - for (var n in kp) { - a = kp[n]; - v = self.opt.railpadding[a]; - (v) ? rail.css("padding-"+a,v+"px") : self.opt.railpadding[a] = 0; - } - - rail.append(cursor); - - rail.width = Math.max(parseFloat(self.opt.cursorwidth), cursor.outerWidth()); - rail.css({ - width: rail.width + "px", - 'zIndex': self.zindex, - "background": self.opt.background, - cursor: "default" - }); - - rail.visibility = true; - rail.scrollable = true; - - rail.align = (self.opt.railalign == "left") ? 0 : 1; - - self.rail = rail; - - self.rail.drag = false; - - var zoom = false; - if (self.opt.boxzoom && !self.ispage && !cap.isieold) { - zoom = document.createElement('div'); - - self.bind(zoom, "click", self.doZoom); - self.bind(zoom, "mouseenter", function() { - self.zoom.css('opacity', self.opt.cursoropacitymax); - }); - self.bind(zoom, "mouseleave", function() { - self.zoom.css('opacity', self.opt.cursoropacitymin); - }); - - self.zoom = $(zoom); - self.zoom.css({ - "cursor": "pointer", - 'z-index': self.zindex, - 'backgroundImage': 'url(' + self.opt.scriptpath + 'zoomico.png)', - 'height': 18, - 'width': 18, - 'backgroundPosition': '0px 0px' - }); - if (self.opt.dblclickzoom) self.bind(self.win, "dblclick", self.doZoom); - if (cap.cantouch && self.opt.gesturezoom) { - self.ongesturezoom = function(e) { - if (e.scale > 1.5) self.doZoomIn(e); - if (e.scale < 0.8) self.doZoomOut(e); - return self.cancelEvent(e); - }; - self.bind(self.win, "gestureend", self.ongesturezoom); - } - } - - // init HORIZ - - self.railh = false; - var railh; - - if (self.opt.horizrailenabled) { - - self.css(cont, { - 'overflow-x': 'hidden' - }); - - var cursor = $(document.createElement('div')); - cursor.css({ - position: "absolute", - top: 0, - height: self.opt.cursorwidth, - width: "0px", - 'background-color': self.opt.cursorcolor, - border: self.opt.cursorborder, - 'background-clip': 'padding-box', - '-webkit-border-radius': self.opt.cursorborderradius, - '-moz-border-radius': self.opt.cursorborderradius, - 'border-radius': self.opt.cursorborderradius - }); - - if (cap.isieold) cursor.css({'overflow':'hidden'}); //IE6 horiz scrollbar issue - - cursor.wborder = parseFloat(cursor.outerWidth() - cursor.innerWidth()); - - cursor.addClass('nicescroll-cursors'); - - self.cursorh = cursor; - - railh = $(document.createElement('div')); - railh.attr('id', self.id + '-hr'); - railh.addClass('nicescroll-rails nicescroll-rails-hr'); - railh.height = Math.max(parseFloat(self.opt.cursorwidth), cursor.outerHeight()); - railh.css({ - height: railh.height + "px", - 'zIndex': self.zindex, - "background": self.opt.background - }); - - railh.append(cursor); - - railh.visibility = true; - railh.scrollable = true; - - railh.align = (self.opt.railvalign == "top") ? 0 : 1; - - self.railh = railh; - - self.railh.drag = false; - - } - - // - - if (self.ispage) { - rail.css({ - position: "fixed", - top: "0px", - height: "100%" - }); - (rail.align) ? rail.css({ - right: "0px" - }): rail.css({ - left: "0px" - }); - self.body.append(rail); - if (self.railh) { - railh.css({ - position: "fixed", - left: "0px", - width: "100%" - }); - (railh.align) ? railh.css({ - bottom: "0px" - }): railh.css({ - top: "0px" - }); - self.body.append(railh); - } - } else { - if (self.ishwscroll) { - if (self.win.css('position') == 'static') self.css(self.win, { - 'position': 'relative' - }); - var bd = (self.win[0].nodeName == 'HTML') ? self.body : self.win; - $(bd).scrollTop(0).scrollLeft(0); // fix rail position if content already scrolled - if (self.zoom) { - self.zoom.css({ - position: "absolute", - top: 1, - right: 0, - "margin-right": rail.width + 4 - }); - bd.append(self.zoom); - } - rail.css({ - position: "absolute", - top: 0 - }); - (rail.align) ? rail.css({ - right: 0 - }): rail.css({ - left: 0 - }); - bd.append(rail); - if (railh) { - railh.css({ - position: "absolute", - left: 0, - bottom: 0 - }); - (railh.align) ? railh.css({ - bottom: 0 - }): railh.css({ - top: 0 - }); - bd.append(railh); - } - } else { - self.isfixed = (self.win.css("position") == "fixed"); - var rlpos = (self.isfixed) ? "fixed" : "absolute"; - - if (!self.isfixed) self.viewport = self.getViewport(self.win[0]); - if (self.viewport) { - self.body = self.viewport; - if ((/fixed|absolute/.test(self.viewport.css("position"))) == false) self.css(self.viewport, { - "position": "relative" - }); - } - - rail.css({ - position: rlpos - }); - if (self.zoom) self.zoom.css({ - position: rlpos - }); - self.updateScrollBar(); - self.body.append(rail); - if (self.zoom) self.body.append(self.zoom); - if (self.railh) { - railh.css({ - position: rlpos - }); - self.body.append(railh); - } - } - - if (cap.isios) self.css(self.win, { - '-webkit-tap-highlight-color': 'rgba(0,0,0,0)', - '-webkit-touch-callout': 'none' - }); // prevent grey layer on click - - if (cap.isie && self.opt.disableoutline) self.win.attr("hideFocus", "true"); // IE, prevent dotted rectangle on focused div - if (cap.iswebkit && self.opt.disableoutline) self.win.css({"outline": "none"}); // Webkit outline - //if (cap.isopera&&self.opt.disableoutline) self.win.css({"outline":"0"}); // Opera 12- to test [TODO] - - } - - if (self.opt.autohidemode === false) { - self.autohidedom = false; - self.rail.css({ - opacity: self.opt.cursoropacitymax - }); - if (self.railh) self.railh.css({ - opacity: self.opt.cursoropacitymax - }); - } else if ((self.opt.autohidemode === true) || (self.opt.autohidemode === "leave")) { - self.autohidedom = $().add(self.rail); - if (cap.isie8) self.autohidedom = self.autohidedom.add(self.cursor); - if (self.railh) self.autohidedom = self.autohidedom.add(self.railh); - if (self.railh && cap.isie8) self.autohidedom = self.autohidedom.add(self.cursorh); - } else if (self.opt.autohidemode == "scroll") { - self.autohidedom = $().add(self.rail); - if (self.railh) self.autohidedom = self.autohidedom.add(self.railh); - } else if (self.opt.autohidemode == "cursor") { - self.autohidedom = $().add(self.cursor); - if (self.railh) self.autohidedom = self.autohidedom.add(self.cursorh); - } else if (self.opt.autohidemode == "hidden") { - self.autohidedom = false; - self.hide(); - self.railslocked = false; - } - - if (cap.isie9mobile) { - - self.scrollmom = new ScrollMomentumClass2D(self); - - self.onmangotouch = function() { - var py = self.getScrollTop(); - var px = self.getScrollLeft(); - - if ((py == self.scrollmom.lastscrolly) && (px == self.scrollmom.lastscrollx)) return true; - - var dfy = py - self.mangotouch.sy; - var dfx = px - self.mangotouch.sx; - var df = Math.round(Math.sqrt(Math.pow(dfx, 2) + Math.pow(dfy, 2))); - if (df == 0) return; - - var dry = (dfy < 0) ? -1 : 1; - var drx = (dfx < 0) ? -1 : 1; - - var tm = +new Date(); - if (self.mangotouch.lazy) clearTimeout(self.mangotouch.lazy); - - if (((tm - self.mangotouch.tm) > 80) || (self.mangotouch.dry != dry) || (self.mangotouch.drx != drx)) { - self.scrollmom.stop(); - self.scrollmom.reset(px, py); - self.mangotouch.sy = py; - self.mangotouch.ly = py; - self.mangotouch.sx = px; - self.mangotouch.lx = px; - self.mangotouch.dry = dry; - self.mangotouch.drx = drx; - self.mangotouch.tm = tm; - } else { - - self.scrollmom.stop(); - self.scrollmom.update(self.mangotouch.sx - dfx, self.mangotouch.sy - dfy); - self.mangotouch.tm = tm; - - var ds = Math.max(Math.abs(self.mangotouch.ly - py), Math.abs(self.mangotouch.lx - px)); - self.mangotouch.ly = py; - self.mangotouch.lx = px; - - if (ds > 2) { - self.mangotouch.lazy = setTimeout(function() { - self.mangotouch.lazy = false; - self.mangotouch.dry = 0; - self.mangotouch.drx = 0; - self.mangotouch.tm = 0; - self.scrollmom.doMomentum(30); - }, 100); - } - } - }; - - var top = self.getScrollTop(); - var lef = self.getScrollLeft(); - self.mangotouch = { - sy: top, - ly: top, - dry: 0, - sx: lef, - lx: lef, - drx: 0, - lazy: false, - tm: 0 - }; - - self.bind(self.docscroll, "scroll", self.onmangotouch); - - } else { - - if (cap.cantouch || self.istouchcapable || self.opt.touchbehavior || cap.hasmstouch) { - - self.scrollmom = new ScrollMomentumClass2D(self); - - self.ontouchstart = function(e) { - if (e.pointerType && e.pointerType != 2 && e.pointerType != "touch") return false; - - self.hasmoving = false; - - if (!self.railslocked) { - - var tg; - if (cap.hasmstouch) { - tg = (e.target) ? e.target : false; - while (tg) { - var nc = $(tg).getNiceScroll(); - if ((nc.length > 0) && (nc[0].me == self.me)) break; - if (nc.length > 0) return false; - if ((tg.nodeName == 'DIV') && (tg.id == self.id)) break; - tg = (tg.parentNode) ? tg.parentNode : false; - } - } - - self.cancelScroll(); - - tg = self.getTarget(e); - - if (tg) { - var skp = (/INPUT/i.test(tg.nodeName)) && (/range/i.test(tg.type)); - if (skp) return self.stopPropagation(e); - } - - if (!("clientX" in e) && ("changedTouches" in e)) { - e.clientX = e.changedTouches[0].clientX; - e.clientY = e.changedTouches[0].clientY; - } - - if (self.forcescreen) { - var le = e; - e = { - "original": (e.original) ? e.original : e - }; - e.clientX = le.screenX; - e.clientY = le.screenY; - } - - self.rail.drag = { - x: e.clientX, - y: e.clientY, - sx: self.scroll.x, - sy: self.scroll.y, - st: self.getScrollTop(), - sl: self.getScrollLeft(), - pt: 2, - dl: false - }; - - if (self.ispage || !self.opt.directionlockdeadzone) { - self.rail.drag.dl = "f"; - } else { - - var view = { - w: $(window).width(), - h: $(window).height() - }; - - var page = { - w: Math.max(document.body.scrollWidth, document.documentElement.scrollWidth), - h: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) - }; - - var maxh = Math.max(0, page.h - view.h); - var maxw = Math.max(0, page.w - view.w); - - if (!self.rail.scrollable && self.railh.scrollable) self.rail.drag.ck = (maxh > 0) ? "v" : false; - else if (self.rail.scrollable && !self.railh.scrollable) self.rail.drag.ck = (maxw > 0) ? "h" : false; - else self.rail.drag.ck = false; - if (!self.rail.drag.ck) self.rail.drag.dl = "f"; - } - - if (self.opt.touchbehavior && self.isiframe && cap.isie) { - var wp = self.win.position(); - self.rail.drag.x += wp.left; - self.rail.drag.y += wp.top; - } - - self.hasmoving = false; - self.lastmouseup = false; - self.scrollmom.reset(e.clientX, e.clientY); - - if (!cap.cantouch && !this.istouchcapable && !e.pointerType) { - - var ip = (tg) ? /INPUT|SELECT|TEXTAREA/i.test(tg.nodeName) : false; - if (!ip) { - if (!self.ispage && cap.hasmousecapture) tg.setCapture(); - if (self.opt.touchbehavior) { - if (tg.onclick && !(tg._onclick || false)) { // intercept DOM0 onclick event - tg._onclick = tg.onclick; - tg.onclick = function(e) { - if (self.hasmoving) return false; - tg._onclick.call(this, e); - }; - } - return self.cancelEvent(e); - } - return self.stopPropagation(e); - } - - if (/SUBMIT|CANCEL|BUTTON/i.test($(tg).attr('type'))) { - pc = { - "tg": tg, - "click": false - }; - self.preventclick = pc; - } - - } - } - - }; - - self.ontouchend = function(e) { - if (!self.rail.drag) return true; - if (self.rail.drag.pt == 2) { - if (e.pointerType && e.pointerType != 2 && e.pointerType != "touch") return false; - self.scrollmom.doMomentum(); - self.rail.drag = false; - if (self.hasmoving) { - self.lastmouseup = true; - self.hideCursor(); - if (cap.hasmousecapture) document.releaseCapture(); - if (!cap.cantouch) return self.cancelEvent(e); - } - } - else if (self.rail.drag.pt == 1) { - return self.onmouseup(e); - } - - }; - - var moveneedoffset = (self.opt.touchbehavior && self.isiframe && !cap.hasmousecapture); - - self.ontouchmove = function(e, byiframe) { - - if (!self.rail.drag) return false; - - if (e.targetTouches && self.opt.preventmultitouchscrolling) { - if (e.targetTouches.length > 1) return false; // multitouch - } - - if (e.pointerType && e.pointerType != 2 && e.pointerType != "touch") return false; - - if (self.rail.drag.pt == 2) { - if (cap.cantouch && (cap.isios) && (typeof e.original == "undefined")) return true; // prevent ios "ghost" events by clickable elements - - self.hasmoving = true; - - if (self.preventclick && !self.preventclick.click) { - self.preventclick.click = self.preventclick.tg.onclick || false; - self.preventclick.tg.onclick = self.onpreventclick; - } - - var ev = $.extend({ - "original": e - }, e); - e = ev; - - if (("changedTouches" in e)) { - e.clientX = e.changedTouches[0].clientX; - e.clientY = e.changedTouches[0].clientY; - } - - if (self.forcescreen) { - var le = e; - e = { - "original": (e.original) ? e.original : e - }; - e.clientX = le.screenX; - e.clientY = le.screenY; - } - - var ofy,ofx; - ofx = ofy = 0; - - if (moveneedoffset && !byiframe) { - var wp = self.win.position(); - ofx = -wp.left; - ofy = -wp.top; - } - - var fy = e.clientY + ofy; - var my = (fy - self.rail.drag.y); - var fx = e.clientX + ofx; - var mx = (fx - self.rail.drag.x); - - var ny = self.rail.drag.st - my; - - if (self.ishwscroll && self.opt.bouncescroll) { - if (ny < 0) { - ny = Math.round(ny / 2); - // fy = 0; - } else if (ny > self.page.maxh) { - ny = self.page.maxh + Math.round((ny - self.page.maxh) / 2); - // fy = 0; - } - } else { - if (ny < 0) { - ny = 0; - fy = 0; - } - if (ny > self.page.maxh) { - ny = self.page.maxh; - fy = 0; - } - } - - var nx; - if (self.railh && self.railh.scrollable) { - nx = (self.isrtlmode) ? mx - self.rail.drag.sl : self.rail.drag.sl - mx; - - if (self.ishwscroll && self.opt.bouncescroll) { - if (nx < 0) { - nx = Math.round(nx / 2); - // fx = 0; - } else if (nx > self.page.maxw) { - nx = self.page.maxw + Math.round((nx - self.page.maxw) / 2); - // fx = 0; - } - } else { - if (nx < 0) { - nx = 0; - fx = 0; - } - if (nx > self.page.maxw) { - nx = self.page.maxw; - fx = 0; - } - } - - } - - var grabbed = false; - if (self.rail.drag.dl) { - grabbed = true; - if (self.rail.drag.dl == "v") nx = self.rail.drag.sl; - else if (self.rail.drag.dl == "h") ny = self.rail.drag.st; - } else { - var ay = Math.abs(my); - var ax = Math.abs(mx); - var dz = self.opt.directionlockdeadzone; - if (self.rail.drag.ck == "v") { - if (ay > dz && (ax <= (ay * 0.3))) { - self.rail.drag = false; - return true; - } else if (ax > dz) { - self.rail.drag.dl = "f"; - $("body").scrollTop($("body").scrollTop()); // stop iOS native scrolling (when active javascript has blocked) - } - } else if (self.rail.drag.ck == "h") { - if (ax > dz && (ay <= (ax * 0.3))) { - self.rail.drag = false; - return true; - } else if (ay > dz) { - self.rail.drag.dl = "f"; - $("body").scrollLeft($("body").scrollLeft()); // stop iOS native scrolling (when active javascript has blocked) - } - } - } - - self.synched("touchmove", function() { - if (self.rail.drag && (self.rail.drag.pt == 2)) { - if (self.prepareTransition) self.prepareTransition(0); - if (self.rail.scrollable) self.setScrollTop(ny); - self.scrollmom.update(fx, fy); - if (self.railh && self.railh.scrollable) { - self.setScrollLeft(nx); - self.showCursor(ny, nx); - } else { - self.showCursor(ny); - } - if (cap.isie10) document.selection.clear(); - } - }); - - if (cap.ischrome && self.istouchcapable) grabbed = false; //chrome touch emulation doesn't like! - if (grabbed) return self.cancelEvent(e); - } - else if (self.rail.drag.pt == 1) { // drag on cursor - return self.onmousemove(e); - } - - }; - - } - - self.onmousedown = function(e, hronly) { - if (self.rail.drag && self.rail.drag.pt != 1) return; - if (self.railslocked) return self.cancelEvent(e); - self.cancelScroll(); - self.rail.drag = { - x: e.clientX, - y: e.clientY, - sx: self.scroll.x, - sy: self.scroll.y, - pt: 1, - hr: (!!hronly) - }; - var tg = self.getTarget(e); - if (!self.ispage && cap.hasmousecapture) tg.setCapture(); - if (self.isiframe && !cap.hasmousecapture) { - self.saved.csspointerevents = self.doc.css("pointer-events"); - self.css(self.doc, { - "pointer-events": "none" - }); - } - self.hasmoving = false; - return self.cancelEvent(e); - }; - - self.onmouseup = function(e) { - if (self.rail.drag) { - if (self.rail.drag.pt != 1) return true; - if (cap.hasmousecapture) document.releaseCapture(); - if (self.isiframe && !cap.hasmousecapture) self.doc.css("pointer-events", self.saved.csspointerevents); - self.rail.drag = false; - //if (!self.rail.active) self.hideCursor(); - if (self.hasmoving) self.triggerScrollEnd(); // TODO - check &&!self.scrollrunning - return self.cancelEvent(e); - } - }; - - self.onmousemove = function(e) { - if (self.rail.drag) { - if (self.rail.drag.pt != 1) return; - - if (cap.ischrome && e.which == 0) return self.onmouseup(e); - - self.cursorfreezed = true; - self.hasmoving = true; - - if (self.rail.drag.hr) { - self.scroll.x = self.rail.drag.sx + (e.clientX - self.rail.drag.x); - if (self.scroll.x < 0) self.scroll.x = 0; - var mw = self.scrollvaluemaxw; - if (self.scroll.x > mw) self.scroll.x = mw; - } else { - self.scroll.y = self.rail.drag.sy + (e.clientY - self.rail.drag.y); - if (self.scroll.y < 0) self.scroll.y = 0; - var my = self.scrollvaluemax; - if (self.scroll.y > my) self.scroll.y = my; - } - - self.synched('mousemove', function() { - if (self.rail.drag && (self.rail.drag.pt == 1)) { - self.showCursor(); - if (self.rail.drag.hr) { - if (self.hasreversehr) { - self.doScrollLeft(self.scrollvaluemaxw-Math.round(self.scroll.x * self.scrollratio.x), self.opt.cursordragspeed); - } else { - self.doScrollLeft(Math.round(self.scroll.x * self.scrollratio.x), self.opt.cursordragspeed); - } - } - else self.doScrollTop(Math.round(self.scroll.y * self.scrollratio.y), self.opt.cursordragspeed); - } - }); - - return self.cancelEvent(e); - } - /* - else { - self.checkarea = true; - } -*/ - }; - - if (cap.cantouch || self.opt.touchbehavior) { - - self.onpreventclick = function(e) { - if (self.preventclick) { - self.preventclick.tg.onclick = self.preventclick.click; - self.preventclick = false; - return self.cancelEvent(e); - } - } - - self.bind(self.win, "mousedown", self.ontouchstart); // control content dragging - - self.onclick = (cap.isios) ? false : function(e) { - if (self.lastmouseup) { - self.lastmouseup = false; - return self.cancelEvent(e); - } else { - return true; - } - }; - - if (self.opt.grabcursorenabled && cap.cursorgrabvalue) { - self.css((self.ispage) ? self.doc : self.win, { - 'cursor': cap.cursorgrabvalue - }); - self.css(self.rail, { - 'cursor': cap.cursorgrabvalue - }); - } - - } else { - - var checkSelectionScroll = function(e) { - if (!self.selectiondrag) return; - - if (e) { - var ww = self.win.outerHeight(); - var df = (e.pageY - self.selectiondrag.top); - if (df > 0 && df < ww) df = 0; - if (df >= ww) df -= ww; - self.selectiondrag.df = df; - } - if (self.selectiondrag.df == 0) return; - - var rt = -Math.floor(self.selectiondrag.df / 6) * 2; - self.doScrollBy(rt); - - self.debounced("doselectionscroll", function() { - checkSelectionScroll() - }, 50); - }; - - if ("getSelection" in document) { // A grade - Major browsers - self.hasTextSelected = function() { - return (document.getSelection().rangeCount > 0); - }; - } else if ("selection" in document) { //IE9- - self.hasTextSelected = function() { - return (document.selection.type != "None"); - }; - } else { - self.hasTextSelected = function() { // no support - return false; - }; - } - - self.onselectionstart = function(e) { -/* More testing - severe chrome issues - if (!self.haswrapper&&(e.which&&e.which==2)) { // fool browser to manage middle button scrolling - self.win.css({'overflow':'auto'}); - setTimeout(function(){ - self.win.css({'overflow':''}); - },10); - return true; - } -*/ - if (self.ispage) return; - self.selectiondrag = self.win.offset(); - }; - - self.onselectionend = function(e) { - self.selectiondrag = false; - }; - self.onselectiondrag = function(e) { - if (!self.selectiondrag) return; - if (self.hasTextSelected()) self.debounced("selectionscroll", function() { - checkSelectionScroll(e) - }, 250); - }; - - - } - - if (cap.hasw3ctouch) { //IE11+ - self.css(self.rail, { - 'touch-action': 'none' - }); - self.css(self.cursor, { - 'touch-action': 'none' - }); - self.bind(self.win, "pointerdown", self.ontouchstart); - self.bind(document, "pointerup", self.ontouchend); - self.bind(document, "pointermove", self.ontouchmove); - } else if (cap.hasmstouch) { //IE10 - self.css(self.rail, { - '-ms-touch-action': 'none' - }); - self.css(self.cursor, { - '-ms-touch-action': 'none' - }); - self.bind(self.win, "MSPointerDown", self.ontouchstart); - self.bind(document, "MSPointerUp", self.ontouchend); - self.bind(document, "MSPointerMove", self.ontouchmove); - self.bind(self.cursor, "MSGestureHold", function(e) { - e.preventDefault() - }); - self.bind(self.cursor, "contextmenu", function(e) { - e.preventDefault() - }); - } else if (this.istouchcapable) { //desktop with screen touch enabled - self.bind(self.win, "touchstart", self.ontouchstart); - self.bind(document, "touchend", self.ontouchend); - self.bind(document, "touchcancel", self.ontouchend); - self.bind(document, "touchmove", self.ontouchmove); - } - - - if (self.opt.cursordragontouch || (!cap.cantouch && !self.opt.touchbehavior)) { - - self.rail.css({ - "cursor": "default" - }); - self.railh && self.railh.css({ - "cursor": "default" - }); - - self.jqbind(self.rail, "mouseenter", function() { - if (!self.ispage && !self.win.is(":visible")) return false; - if (self.canshowonmouseevent) self.showCursor(); - self.rail.active = true; - }); - self.jqbind(self.rail, "mouseleave", function() { - self.rail.active = false; - if (!self.rail.drag) self.hideCursor(); - }); - - if (self.opt.sensitiverail) { - self.bind(self.rail, "click", function(e) { - self.doRailClick(e, false, false) - }); - self.bind(self.rail, "dblclick", function(e) { - self.doRailClick(e, true, false) - }); - self.bind(self.cursor, "click", function(e) { - self.cancelEvent(e) - }); - self.bind(self.cursor, "dblclick", function(e) { - self.cancelEvent(e) - }); - } - - if (self.railh) { - self.jqbind(self.railh, "mouseenter", function() { - if (!self.ispage && !self.win.is(":visible")) return false; - if (self.canshowonmouseevent) self.showCursor(); - self.rail.active = true; - }); - self.jqbind(self.railh, "mouseleave", function() { - self.rail.active = false; - if (!self.rail.drag) self.hideCursor(); - }); - - if (self.opt.sensitiverail) { - self.bind(self.railh, "click", function(e) { - self.doRailClick(e, false, true) - }); - self.bind(self.railh, "dblclick", function(e) { - self.doRailClick(e, true, true) - }); - self.bind(self.cursorh, "click", function(e) { - self.cancelEvent(e) - }); - self.bind(self.cursorh, "dblclick", function(e) { - self.cancelEvent(e) - }); - } - - } - - } - - if (!cap.cantouch && !self.opt.touchbehavior) { - - self.bind((cap.hasmousecapture) ? self.win : document, "mouseup", self.onmouseup); - self.bind(document, "mousemove", self.onmousemove); - if (self.onclick) self.bind(document, "click", self.onclick); - - self.bind(self.cursor, "mousedown", self.onmousedown); - self.bind(self.cursor, "mouseup", self.onmouseup); - - if (self.railh) { - self.bind(self.cursorh, "mousedown", function(e) { - self.onmousedown(e, true) - }); - self.bind(self.cursorh, "mouseup", self.onmouseup); - } - - if (!self.ispage && self.opt.enablescrollonselection) { - self.bind(self.win[0], "mousedown", self.onselectionstart); - self.bind(document, "mouseup", self.onselectionend); - self.bind(self.cursor, "mouseup", self.onselectionend); - if (self.cursorh) self.bind(self.cursorh, "mouseup", self.onselectionend); - self.bind(document, "mousemove", self.onselectiondrag); - } - - if (self.zoom) { - self.jqbind(self.zoom, "mouseenter", function() { - if (self.canshowonmouseevent) self.showCursor(); - self.rail.active = true; - }); - self.jqbind(self.zoom, "mouseleave", function() { - self.rail.active = false; - if (!self.rail.drag) self.hideCursor(); - }); - } - - } else { - - self.bind((cap.hasmousecapture) ? self.win : document, "mouseup", self.ontouchend); - self.bind(document, "mousemove", self.ontouchmove); - if (self.onclick) self.bind(document, "click", self.onclick); - - if (self.opt.cursordragontouch) { - self.bind(self.cursor, "mousedown", self.onmousedown); - self.bind(self.cursor, "mouseup", self.onmouseup); - //self.bind(self.cursor, "mousemove", self.onmousemove); - self.cursorh && self.bind(self.cursorh, "mousedown", function(e) { - self.onmousedown(e, true) - }); - //self.cursorh && self.bind(self.cursorh, "mousemove", self.onmousemove); - self.cursorh && self.bind(self.cursorh, "mouseup", self.onmouseup); - } - - } - - if (self.opt.enablemousewheel) { - if (!self.isiframe) self.bind((cap.isie && self.ispage) ? document : self.win /*self.docscroll*/ , "mousewheel", self.onmousewheel); - self.bind(self.rail, "mousewheel", self.onmousewheel); - if (self.railh) self.bind(self.railh, "mousewheel", self.onmousewheelhr); - } - - if (!self.ispage && !cap.cantouch && !(/HTML|^BODY/.test(self.win[0].nodeName))) { - if (!self.win.attr("tabindex")) self.win.attr({ - "tabindex": tabindexcounter++ - }); - - self.jqbind(self.win, "focus", function(e) { - domfocus = (self.getTarget(e)).id || true; - self.hasfocus = true; - if (self.canshowonmouseevent) self.noticeCursor(); - }); - self.jqbind(self.win, "blur", function(e) { - domfocus = false; - self.hasfocus = false; - }); - - self.jqbind(self.win, "mouseenter", function(e) { - mousefocus = (self.getTarget(e)).id || true; - self.hasmousefocus = true; - if (self.canshowonmouseevent) self.noticeCursor(); - }); - self.jqbind(self.win, "mouseleave", function() { - mousefocus = false; - self.hasmousefocus = false; - if (!self.rail.drag) self.hideCursor(); - }); - - } - - } // !ie9mobile - - //Thanks to http://www.quirksmode.org !! - self.onkeypress = function(e) { - if (self.railslocked && self.page.maxh == 0) return true; - - e = (e) ? e : window.e; - var tg = self.getTarget(e); - if (tg && /INPUT|TEXTAREA|SELECT|OPTION/.test(tg.nodeName)) { - var tp = tg.getAttribute('type') || tg.type || false; - if ((!tp) || !(/submit|button|cancel/i.tp)) return true; - } - - if ($(tg).attr('contenteditable')) return true; - - if (self.hasfocus || (self.hasmousefocus && !domfocus) || (self.ispage && !domfocus && !mousefocus)) { - var key = e.keyCode; - - if (self.railslocked && key != 27) return self.cancelEvent(e); - - var ctrl = e.ctrlKey || false; - var shift = e.shiftKey || false; - - var ret = false; - switch (key) { - case 38: - case 63233: //safari - self.doScrollBy(24 * 3); - ret = true; - break; - case 40: - case 63235: //safari - self.doScrollBy(-24 * 3); - ret = true; - break; - case 37: - case 63232: //safari - if (self.railh) { - (ctrl) ? self.doScrollLeft(0): self.doScrollLeftBy(24 * 3); - ret = true; - } - break; - case 39: - case 63234: //safari - if (self.railh) { - (ctrl) ? self.doScrollLeft(self.page.maxw): self.doScrollLeftBy(-24 * 3); - ret = true; - } - break; - case 33: - case 63276: // safari - self.doScrollBy(self.view.h); - ret = true; - break; - case 34: - case 63277: // safari - self.doScrollBy(-self.view.h); - ret = true; - break; - case 36: - case 63273: // safari - (self.railh && ctrl) ? self.doScrollPos(0, 0): self.doScrollTo(0); - ret = true; - break; - case 35: - case 63275: // safari - (self.railh && ctrl) ? self.doScrollPos(self.page.maxw, self.page.maxh): self.doScrollTo(self.page.maxh); - ret = true; - break; - case 32: - if (self.opt.spacebarenabled) { - (shift) ? self.doScrollBy(self.view.h): self.doScrollBy(-self.view.h); - ret = true; - } - break; - case 27: // ESC - if (self.zoomactive) { - self.doZoom(); - ret = true; - } - break; - } - if (ret) return self.cancelEvent(e); - } - }; - - if (self.opt.enablekeyboard) self.bind(document, (cap.isopera && !cap.isopera12) ? "keypress" : "keydown", self.onkeypress); - - self.bind(document, "keydown", function(e) { - var ctrl = e.ctrlKey || false; - if (ctrl) self.wheelprevented = true; - }); - self.bind(document, "keyup", function(e) { - var ctrl = e.ctrlKey || false; - if (!ctrl) self.wheelprevented = false; - }); - self.bind(window,"blur",function(e){ - self.wheelprevented = false; - }); - - self.bind(window, 'resize', self.lazyResize); - self.bind(window, 'orientationchange', self.lazyResize); - - self.bind(window, "load", self.lazyResize); - - if (cap.ischrome && !self.ispage && !self.haswrapper) { //chrome void scrollbar bug - it persists in version 26 - var tmp = self.win.attr("style"); - var ww = parseFloat(self.win.css("width")) + 1; - self.win.css('width', ww); - self.synched("chromefix", function() { - self.win.attr("style", tmp) - }); - } - - - // Trying a cross-browser implementation - good luck! - - self.onAttributeChange = function(e) { - self.lazyResize(self.isieold ? 250 : 30); - }; - - if (ClsMutationObserver !== false) { - self.observerbody = new ClsMutationObserver(function(mutations) { - mutations.forEach(function(mut){ - if (mut.type=="attributes") { - return ($("body").hasClass("modal-open")) ? self.hide() : self.show(); // Support for Bootstrap modal - } - }); - if (document.body.scrollHeight!=self.page.maxh) return self.lazyResize(30); - }); - self.observerbody.observe(document.body, { - childList: true, - subtree: true, - characterData: false, - attributes: true, - attributeFilter: ['class'] - }); - } - - if (!self.ispage && !self.haswrapper) { - // redesigned MutationObserver for Chrome18+/Firefox14+/iOS6+ with support for: remove div, add/remove content - if (ClsMutationObserver !== false) { - self.observer = new ClsMutationObserver(function(mutations) { - mutations.forEach(self.onAttributeChange); - }); - self.observer.observe(self.win[0], { - childList: true, - characterData: false, - attributes: true, - subtree: false - }); - self.observerremover = new ClsMutationObserver(function(mutations) { - mutations.forEach(function(mo) { - if (mo.removedNodes.length > 0) { - for (var dd in mo.removedNodes) { - if (!!self && (mo.removedNodes[dd] == self.win[0])) return self.remove(); - } - } - }); - }); - self.observerremover.observe(self.win[0].parentNode, { - childList: true, - characterData: false, - attributes: false, - subtree: false - }); - } else { - self.bind(self.win, (cap.isie && !cap.isie9) ? "propertychange" : "DOMAttrModified", self.onAttributeChange); - if (cap.isie9) self.win[0].attachEvent("onpropertychange", self.onAttributeChange); //IE9 DOMAttrModified bug - self.bind(self.win, "DOMNodeRemoved", function(e) { - if (e.target == self.win[0]) self.remove(); - }); - } - } - - // - - if (!self.ispage && self.opt.boxzoom) self.bind(window, "resize", self.resizeZoom); - if (self.istextarea) self.bind(self.win, "mouseup", self.lazyResize); - - // self.checkrtlmode = true; - self.lazyResize(30); - - } - - if (this.doc[0].nodeName == 'IFRAME') { - var oniframeload = function() { - self.iframexd = false; - var doc; - try { - doc = 'contentDocument' in this ? this.contentDocument : this.contentWindow.document; - var a = doc.domain; - } catch (e) { - self.iframexd = true; - doc = false - } - - if (self.iframexd) { - if ("console" in window) console.log('NiceScroll error: policy restriced iframe'); - return true; //cross-domain - I can't manage this - } - - self.forcescreen = true; - - if (self.isiframe) { - self.iframe = { - "doc": $(doc), - "html": self.doc.contents().find('html')[0], - "body": self.doc.contents().find('body')[0] - }; - self.getContentSize = function() { - return { - w: Math.max(self.iframe.html.scrollWidth, self.iframe.body.scrollWidth), - h: Math.max(self.iframe.html.scrollHeight, self.iframe.body.scrollHeight) - }; - }; - self.docscroll = $(self.iframe.body); //$(this.contentWindow); - } - - if (!cap.isios && self.opt.iframeautoresize && !self.isiframe) { - self.win.scrollTop(0); // reset position - self.doc.height(""); //reset height to fix browser bug - var hh = Math.max(doc.getElementsByTagName('html')[0].scrollHeight, doc.body.scrollHeight); - self.doc.height(hh); - } - self.lazyResize(30); - - if (cap.isie7) self.css($(self.iframe.html), { - 'overflow-y': 'hidden' - }); - self.css($(self.iframe.body), { - 'overflow-y': 'hidden' - }); - - if (cap.isios && self.haswrapper) { - self.css($(doc.body), { - '-webkit-transform': 'translate3d(0,0,0)' - }); // avoid iFrame content clipping - thanks to http://blog.derraab.com/2012/04/02/avoid-iframe-content-clipping-with-css-transform-on-ios/ - } - - if ('contentWindow' in this) { - self.bind(this.contentWindow, "scroll", self.onscroll); //IE8 & minor - } else { - self.bind(doc, "scroll", self.onscroll); - } - - if (self.opt.enablemousewheel) { - self.bind(doc, "mousewheel", self.onmousewheel); - } - - if (self.opt.enablekeyboard) self.bind(doc, (cap.isopera) ? "keypress" : "keydown", self.onkeypress); - - if (cap.cantouch || self.opt.touchbehavior) { - self.bind(doc, "mousedown", self.ontouchstart); - self.bind(doc, "mousemove", function(e) { - return self.ontouchmove(e, true) - }); - if (self.opt.grabcursorenabled && cap.cursorgrabvalue) self.css($(doc.body), { - 'cursor': cap.cursorgrabvalue - }); - } - - self.bind(doc, "mouseup", self.ontouchend); - - if (self.zoom) { - if (self.opt.dblclickzoom) self.bind(doc, 'dblclick', self.doZoom); - if (self.ongesturezoom) self.bind(doc, "gestureend", self.ongesturezoom); - } - }; - - if (this.doc[0].readyState && this.doc[0].readyState == "complete") { - setTimeout(function() { - oniframeload.call(self.doc[0], false) - }, 500); - } - self.bind(this.doc, "load", oniframeload); - - } - - }; - - this.showCursor = function(py, px) { - if (self.cursortimeout) { - clearTimeout(self.cursortimeout); - self.cursortimeout = 0; - } - if (!self.rail) return; - if (self.autohidedom) { - self.autohidedom.stop().css({ - opacity: self.opt.cursoropacitymax - }); - self.cursoractive = true; - } - - if (!self.rail.drag || self.rail.drag.pt != 1) { - if ((typeof py != "undefined") && (py !== false)) { - self.scroll.y = Math.round(py * 1 / self.scrollratio.y); - } - if (typeof px != "undefined") { - self.scroll.x = Math.round(px * 1 / self.scrollratio.x); - } - } - - self.cursor.css({ - height: self.cursorheight, - top: self.scroll.y - }); - if (self.cursorh) { - var lx = (self.hasreversehr) ? self.scrollvaluemaxw-self.scroll.x : self.scroll.x; - (!self.rail.align && self.rail.visibility) ? self.cursorh.css({ - width: self.cursorwidth, - left: lx + self.rail.width - }): self.cursorh.css({ - width: self.cursorwidth, - left: lx - }); - self.cursoractive = true; - } - - if (self.zoom) self.zoom.stop().css({ - opacity: self.opt.cursoropacitymax - }); - }; - - this.hideCursor = function(tm) { - if (self.cursortimeout) return; - if (!self.rail) return; - if (!self.autohidedom) return; - if (self.hasmousefocus && self.opt.autohidemode == "leave") return; - self.cursortimeout = setTimeout(function() { - if (!self.rail.active || !self.showonmouseevent) { - self.autohidedom.stop().animate({ - opacity: self.opt.cursoropacitymin - }); - if (self.zoom) self.zoom.stop().animate({ - opacity: self.opt.cursoropacitymin - }); - self.cursoractive = false; - } - self.cursortimeout = 0; - }, tm || self.opt.hidecursordelay); - }; - - this.noticeCursor = function(tm, py, px) { - self.showCursor(py, px); - if (!self.rail.active) self.hideCursor(tm); - }; - - this.getContentSize = - (self.ispage) ? - function() { - return { - w: Math.max(document.body.scrollWidth, document.documentElement.scrollWidth), - h: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) - } - } : (self.haswrapper) ? - function() { - return { - w: self.doc.outerWidth() + parseInt(self.win.css('paddingLeft')) + parseInt(self.win.css('paddingRight')), - h: self.doc.outerHeight() + parseInt(self.win.css('paddingTop')) + parseInt(self.win.css('paddingBottom')) - } - } : function() { - return { - w: self.docscroll[0].scrollWidth, - h: self.docscroll[0].scrollHeight - } - }; - - this.onResize = function(e, page) { - - if (!self || !self.win) return false; - - if (!self.haswrapper && !self.ispage) { - if (self.win.css('display') == 'none') { - if (self.visibility) self.hideRail().hideRailHr(); - return false; - } else { - if (!self.hidden && !self.visibility) self.showRail().showRailHr(); - } - } - - var premaxh = self.page.maxh; - var premaxw = self.page.maxw; - - var preview = { - h: self.view.h, - w: self.view.w - }; - - self.view = { - w: (self.ispage) ? self.win.width() : parseInt(self.win[0].clientWidth), - h: (self.ispage) ? self.win.height() : parseInt(self.win[0].clientHeight) - }; - - self.page = (page) ? page : self.getContentSize(); - - self.page.maxh = Math.max(0, self.page.h - self.view.h); - self.page.maxw = Math.max(0, self.page.w - self.view.w); - - if ((self.page.maxh == premaxh) && (self.page.maxw == premaxw) && (self.view.w == preview.w) && (self.view.h == preview.h)) { - // test position - if (!self.ispage) { - var pos = self.win.offset(); - if (self.lastposition) { - var lst = self.lastposition; - if ((lst.top == pos.top) && (lst.left == pos.left)) return self; //nothing to do - } - self.lastposition = pos; - } else { - return self; //nothing to do - } - } - - if (self.page.maxh == 0) { - self.hideRail(); - self.scrollvaluemax = 0; - self.scroll.y = 0; - self.scrollratio.y = 0; - self.cursorheight = 0; - self.setScrollTop(0); - self.rail.scrollable = false; - } else { - self.page.maxh -= (self.opt.railpadding.top + self.opt.railpadding.bottom); //** - self.rail.scrollable = true; - } - - if (self.page.maxw == 0) { - self.hideRailHr(); - self.scrollvaluemaxw = 0; - self.scroll.x = 0; - self.scrollratio.x = 0; - self.cursorwidth = 0; - self.setScrollLeft(0); - self.railh.scrollable = false; - } else { - self.page.maxw -= (self.opt.railpadding.left + self.opt.railpadding.right); //** - self.railh.scrollable = true; - } - - self.railslocked = (self.locked) || ((self.page.maxh == 0) && (self.page.maxw == 0)); - if (self.railslocked) { - if (!self.ispage) self.updateScrollBar(self.view); - return false; - } - - if (!self.hidden && !self.visibility) { - self.showRail().showRailHr(); - } - else if (!self.hidden && !self.railh.visibility) self.showRailHr(); - - if (self.istextarea && self.win.css('resize') && self.win.css('resize') != 'none') self.view.h -= 20; - - self.cursorheight = Math.min(self.view.h, Math.round(self.view.h * (self.view.h / self.page.h))); - self.cursorheight = (self.opt.cursorfixedheight) ? self.opt.cursorfixedheight : Math.max(self.opt.cursorminheight, self.cursorheight); - - self.cursorwidth = Math.min(self.view.w, Math.round(self.view.w * (self.view.w / self.page.w))); - self.cursorwidth = (self.opt.cursorfixedheight) ? self.opt.cursorfixedheight : Math.max(self.opt.cursorminheight, self.cursorwidth); - - self.scrollvaluemax = self.view.h - self.cursorheight - self.cursor.hborder - (self.opt.railpadding.top + self.opt.railpadding.bottom); //** - - if (self.railh) { - self.railh.width = (self.page.maxh > 0) ? (self.view.w - self.rail.width) : self.view.w; - self.scrollvaluemaxw = self.railh.width - self.cursorwidth - self.cursorh.wborder - (self.opt.railpadding.left + self.opt.railpadding.right); //** - } - - /* - if (self.checkrtlmode&&self.railh) { - self.checkrtlmode = false; - if (self.opt.rtlmode&&self.scroll.x==0) self.setScrollLeft(self.page.maxw); - } -*/ - - if (!self.ispage) self.updateScrollBar(self.view); - - self.scrollratio = { - x: (self.page.maxw / self.scrollvaluemaxw), - y: (self.page.maxh / self.scrollvaluemax) - }; - - var sy = self.getScrollTop(); - if (sy > self.page.maxh) { - self.doScrollTop(self.page.maxh); - } else { - self.scroll.y = Math.round(self.getScrollTop() * (1 / self.scrollratio.y)); - self.scroll.x = Math.round(self.getScrollLeft() * (1 / self.scrollratio.x)); - if (self.cursoractive) self.noticeCursor(); - } - - if (self.scroll.y && (self.getScrollTop() == 0)) self.doScrollTo(Math.floor(self.scroll.y * self.scrollratio.y)); - - return self; - }; - - this.resize = self.onResize; - - this.lazyResize = function(tm) { // event debounce - tm = (isNaN(tm)) ? 30 : tm; - self.debounced('resize', self.resize, tm); - return self; - }; - - // modified by MDN https://developer.mozilla.org/en-US/docs/DOM/Mozilla_event_reference/wheel - function _modernWheelEvent(dom, name, fn, bubble) { - self._bind(dom, name, function(e) { - var e = (e) ? e : window.event; - var event = { - original: e, - target: e.target || e.srcElement, - type: "wheel", - deltaMode: e.type == "MozMousePixelScroll" ? 0 : 1, - deltaX: 0, - deltaZ: 0, - preventDefault: function() { - e.preventDefault ? e.preventDefault() : e.returnValue = false; - return false; - }, - stopImmediatePropagation: function() { - (e.stopImmediatePropagation) ? e.stopImmediatePropagation(): e.cancelBubble = true; - } - }; - - if (name == "mousewheel") { - event.deltaY = -1 / 40 * e.wheelDelta; - e.wheelDeltaX && (event.deltaX = -1 / 40 * e.wheelDeltaX); - } else { - event.deltaY = e.detail; - } - - return fn.call(dom, event); - }, bubble); - }; - - - - this.jqbind = function(dom, name, fn) { // use jquery bind for non-native events (mouseenter/mouseleave) - self.events.push({ - e: dom, - n: name, - f: fn, - q: true - }); - $(dom).bind(name, fn); - }; - - this.bind = function(dom, name, fn, bubble) { // touch-oriented & fixing jquery bind - var el = ("jquery" in dom) ? dom[0] : dom; - - if (name == 'mousewheel') { - if (window.addEventListener||'onwheel' in document) { // modern brosers & IE9 detection fix - self._bind(el, "wheel", fn, bubble || false); - } else { - var wname = (typeof document.onmousewheel != "undefined") ? "mousewheel" : "DOMMouseScroll"; // older IE/Firefox - _modernWheelEvent(el, wname, fn, bubble || false); - if (wname == "DOMMouseScroll") _modernWheelEvent(el, "MozMousePixelScroll", fn, bubble || false); // Firefox legacy - } - } else if (el.addEventListener) { - if (cap.cantouch && /mouseup|mousedown|mousemove/.test(name)) { // touch device support - var tt = (name == 'mousedown') ? 'touchstart' : (name == 'mouseup') ? 'touchend' : 'touchmove'; - self._bind(el, tt, function(e) { - if (e.touches) { - if (e.touches.length < 2) { - var ev = (e.touches.length) ? e.touches[0] : e; - ev.original = e; - fn.call(this, ev); - } - } else if (e.changedTouches) { - var ev = e.changedTouches[0]; - ev.original = e; - fn.call(this, ev); - } //blackberry - }, bubble || false); - } - self._bind(el, name, fn, bubble || false); - if (cap.cantouch && name == "mouseup") self._bind(el, "touchcancel", fn, bubble || false); - } else { - self._bind(el, name, function(e) { - e = e || window.event || false; - if (e) { - if (e.srcElement) e.target = e.srcElement; - } - if (!("pageY" in e)) { - e.pageX = e.clientX + document.documentElement.scrollLeft; - e.pageY = e.clientY + document.documentElement.scrollTop; - } - return ((fn.call(el, e) === false) || bubble === false) ? self.cancelEvent(e) : true; - }); - } - }; - - if (cap.haseventlistener) { // W3C standard model - this._bind = function(el, name, fn, bubble) { // primitive bind - self.events.push({ - e: el, - n: name, - f: fn, - b: bubble, - q: false - }); - el.addEventListener(name, fn, bubble || false); - }; - this.cancelEvent = function(e) { - if (!e) return false; - var e = (e.original) ? e.original : e; - e.preventDefault(); - e.stopPropagation(); - if (e.preventManipulation) e.preventManipulation(); //IE10 - return false; - }; - this.stopPropagation = function(e) { - if (!e) return false; - var e = (e.original) ? e.original : e; - e.stopPropagation(); - return false; - }; - this._unbind = function(el, name, fn, bub) { // primitive unbind - el.removeEventListener(name, fn, bub); - }; - } else { // old IE model - this._bind = function(el, name, fn, bubble) { // primitive bind - self.events.push({ - e: el, - n: name, - f: fn, - b: bubble, - q: false - }); - if (el.attachEvent) { - el.attachEvent("on" + name, fn); - } else { - el["on" + name] = fn; - } - }; - // Thanks to http://www.switchonthecode.com !! - this.cancelEvent = function(e) { - var e = window.event || false; - if (!e) return false; - e.cancelBubble = true; - e.cancel = true; - e.returnValue = false; - return false; - }; - this.stopPropagation = function(e) { - var e = window.event || false; - if (!e) return false; - e.cancelBubble = true; - return false; - }; - this._unbind = function(el, name, fn, bub) { // primitive unbind IE old - if (el.detachEvent) { - el.detachEvent('on' + name, fn); - } else { - el['on' + name] = false; - } - }; - } - - this.unbindAll = function() { - for (var a = 0; a < self.events.length; a++) { - var r = self.events[a]; - (r.q) ? r.e.unbind(r.n, r.f): self._unbind(r.e, r.n, r.f, r.b); - } - }; - - this.showRail = function() { - if ((self.page.maxh != 0) && (self.ispage || self.win.css('display') != 'none')) { - self.visibility = true; - self.rail.visibility = true; - self.rail.css('display', 'block'); - } - return self; - }; - - this.showRailHr = function() { - if (!self.railh) return self; - if ((self.page.maxw != 0) && (self.ispage || self.win.css('display') != 'none')) { - self.railh.visibility = true; - self.railh.css('display', 'block'); - } - return self; - }; - - this.hideRail = function() { - self.visibility = false; - self.rail.visibility = false; - self.rail.css('display', 'none'); - return self; - }; - - this.hideRailHr = function() { - if (!self.railh) return self; - self.railh.visibility = false; - self.railh.css('display', 'none'); - return self; - }; - - this.show = function() { - self.hidden = false; - self.railslocked = false; - return self.showRail().showRailHr(); - }; - - this.hide = function() { - self.hidden = true; - self.railslocked = true; - return self.hideRail().hideRailHr(); - }; - - this.toggle = function() { - return (self.hidden) ? self.show() : self.hide(); - }; - - this.remove = function() { - self.stop(); - if (self.cursortimeout) clearTimeout(self.cursortimeout); - self.doZoomOut(); - self.unbindAll(); - - if (cap.isie9) self.win[0].detachEvent("onpropertychange", self.onAttributeChange); //IE9 DOMAttrModified bug - - if (self.observer !== false) self.observer.disconnect(); - if (self.observerremover !== false) self.observerremover.disconnect(); - if (self.observerbody !== false) self.observerbody.disconnect(); - - self.events = null; - - if (self.cursor) { - self.cursor.remove(); - } - if (self.cursorh) { - self.cursorh.remove(); - } - if (self.rail) { - self.rail.remove(); - } - if (self.railh) { - self.railh.remove(); - } - if (self.zoom) { - self.zoom.remove(); - } - for (var a = 0; a < self.saved.css.length; a++) { - var d = self.saved.css[a]; - d[0].css(d[1], (typeof d[2] == "undefined") ? '' : d[2]); - } - self.saved = false; - self.me.data('__nicescroll', ''); //erase all traces - - // memory leak fixed by GianlucaGuarini - thanks a lot! - // remove the current nicescroll from the $.nicescroll array & normalize array - var lst = $.nicescroll; - lst.each(function(i) { - if (!this) return; - if (this.id === self.id) { - delete lst[i]; - for (var b = ++i; b < lst.length; b++, i++) lst[i] = lst[b]; - lst.length--; - if (lst.length) delete lst[lst.length]; - } - }); - - for (var i in self) { - self[i] = null; - delete self[i]; - } - - self = null; - - }; - - this.scrollstart = function(fn) { - this.onscrollstart = fn; - return self; - }; - this.scrollend = function(fn) { - this.onscrollend = fn; - return self; - }; - this.scrollcancel = function(fn) { - this.onscrollcancel = fn; - return self; - }; - - this.zoomin = function(fn) { - this.onzoomin = fn; - return self; - }; - this.zoomout = function(fn) { - this.onzoomout = fn; - return self; - }; - - this.isScrollable = function(e) { - var dom = (e.target) ? e.target : e; - if (dom.nodeName == 'OPTION') return true; - while (dom && (dom.nodeType == 1) && !(/^BODY|HTML/.test(dom.nodeName))) { - var dd = $(dom); - var ov = dd.css('overflowY') || dd.css('overflowX') || dd.css('overflow') || ''; - if (/scroll|auto/.test(ov)) return (dom.clientHeight != dom.scrollHeight); - dom = (dom.parentNode) ? dom.parentNode : false; - } - return false; - }; - - this.getViewport = function(me) { - var dom = (me && me.parentNode) ? me.parentNode : false; - while (dom && (dom.nodeType == 1) && !(/^BODY|HTML/.test(dom.nodeName))) { - var dd = $(dom); - if (/fixed|absolute/.test(dd.css("position"))) return dd; - var ov = dd.css('overflowY') || dd.css('overflowX') || dd.css('overflow') || ''; - if ((/scroll|auto/.test(ov)) && (dom.clientHeight != dom.scrollHeight)) return dd; - if (dd.getNiceScroll().length > 0) return dd; - dom = (dom.parentNode) ? dom.parentNode : false; - } - return false; //(dom) ? $(dom) : false; - }; - - this.triggerScrollEnd = function() { - if (!self.onscrollend) return; - - var px = self.getScrollLeft(); - var py = self.getScrollTop(); - - var info = { - "type": "scrollend", - "current": { - "x": px, - "y": py - }, - "end": { - "x": px, - "y": py - } - }; - self.onscrollend.call(self, info); - } - - function execScrollWheel(e, hr, chkscroll) { - var px, py; - - if (e.deltaMode == 0) { // PIXEL - px = -Math.floor(e.deltaX * (self.opt.mousescrollstep / (18 * 3))); - py = -Math.floor(e.deltaY * (self.opt.mousescrollstep / (18 * 3))); - } else if (e.deltaMode == 1) { // LINE - px = -Math.floor(e.deltaX * self.opt.mousescrollstep); - py = -Math.floor(e.deltaY * self.opt.mousescrollstep); - } - - if (hr && self.opt.oneaxismousemode && (px == 0) && py) { // classic vertical-only mousewheel + browser with x/y support - px = py; - py = 0; - - if (chkscroll) { - var hrend = (px < 0) ? (self.getScrollLeft() >= self.page.maxw) : (self.getScrollLeft() <= 0); - if (hrend) { // preserve vertical scrolling - py = px; - px = 0; - } - } - - } - - if (px) { - if (self.scrollmom) { - self.scrollmom.stop() - } - self.lastdeltax += px; - self.debounced("mousewheelx", function() { - var dt = self.lastdeltax; - self.lastdeltax = 0; - if (!self.rail.drag) { - self.doScrollLeftBy(dt) - } - }, 15); - } - if (py) { - if (self.opt.nativeparentscrolling && chkscroll && !self.ispage && !self.zoomactive) { - if (py < 0) { - if (self.getScrollTop() >= self.page.maxh) return true; - } else { - if (self.getScrollTop() <= 0) return true; - } - } - if (self.scrollmom) { - self.scrollmom.stop() - } - self.lastdeltay += py; - self.debounced("mousewheely", function() { - var dt = self.lastdeltay; - self.lastdeltay = 0; - if (!self.rail.drag) { - self.doScrollBy(dt) - } - }, 15); - } - - e.stopImmediatePropagation(); - return e.preventDefault(); - }; - - this.onmousewheel = function(e) { - if (self.wheelprevented) return; - if (self.railslocked) { - self.debounced("checkunlock", self.resize, 250); - return true; - } - if (self.rail.drag) return self.cancelEvent(e); - - if (self.opt.oneaxismousemode == "auto" && e.deltaX != 0) self.opt.oneaxismousemode = false; // check two-axis mouse support (not very elegant) - - if (self.opt.oneaxismousemode && e.deltaX == 0) { - if (!self.rail.scrollable) { - if (self.railh && self.railh.scrollable) { - return self.onmousewheelhr(e); - } else { - return true; - } - } - } - - var nw = +(new Date()); - var chk = false; - if (self.opt.preservenativescrolling && ((self.checkarea + 600) < nw)) { - self.nativescrollingarea = self.isScrollable(e); - chk = true; - } - self.checkarea = nw; - if (self.nativescrollingarea) return true; // this isn't my business - var ret = execScrollWheel(e, false, chk); - if (ret) self.checkarea = 0; - return ret; - }; - - this.onmousewheelhr = function(e) { - if (self.wheelprevented) return; - if (self.railslocked || !self.railh.scrollable) return true; - if (self.rail.drag) return self.cancelEvent(e); - - var nw = +(new Date()); - var chk = false; - if (self.opt.preservenativescrolling && ((self.checkarea + 600) < nw)) { - self.nativescrollingarea = self.isScrollable(e); - chk = true; - } - self.checkarea = nw; - if (self.nativescrollingarea) return true; // this isn't my business - if (self.railslocked) return self.cancelEvent(e); - - return execScrollWheel(e, true, chk); - }; - - this.stop = function() { - self.cancelScroll(); - if (self.scrollmon) self.scrollmon.stop(); - self.cursorfreezed = false; - self.scroll.y = Math.round(self.getScrollTop() * (1 / self.scrollratio.y)); - self.noticeCursor(); - return self; - }; - - this.getTransitionSpeed = function(dif) { - var sp = Math.round(self.opt.scrollspeed * 10); - var ex = Math.min(sp, Math.round((dif / 20) * self.opt.scrollspeed)); - return (ex > 20) ? ex : 0; - }; - - if (!self.opt.smoothscroll) { - this.doScrollLeft = function(x, spd) { //direct - var y = self.getScrollTop(); - self.doScrollPos(x, y, spd); - }; - this.doScrollTop = function(y, spd) { //direct - var x = self.getScrollLeft(); - self.doScrollPos(x, y, spd); - }; - this.doScrollPos = function(x, y, spd) { //direct - var nx = (x > self.page.maxw) ? self.page.maxw : x; - if (nx < 0) nx = 0; - var ny = (y > self.page.maxh) ? self.page.maxh : y; - if (ny < 0) ny = 0; - self.synched('scroll', function() { - self.setScrollTop(ny); - self.setScrollLeft(nx); - }); - }; - this.cancelScroll = function() {}; // direct - } else if (self.ishwscroll && cap.hastransition && self.opt.usetransition && !!self.opt.smoothscroll) { - this.prepareTransition = function(dif, istime) { - var ex = (istime) ? ((dif > 20) ? dif : 0) : self.getTransitionSpeed(dif); - var trans = (ex) ? cap.prefixstyle + 'transform ' + ex + 'ms ease-out' : ''; - if (!self.lasttransitionstyle || self.lasttransitionstyle != trans) { - self.lasttransitionstyle = trans; - self.doc.css(cap.transitionstyle, trans); - } - return ex; - }; - - this.doScrollLeft = function(x, spd) { //trans - var y = (self.scrollrunning) ? self.newscrolly : self.getScrollTop(); - self.doScrollPos(x, y, spd); - }; - - this.doScrollTop = function(y, spd) { //trans - var x = (self.scrollrunning) ? self.newscrollx : self.getScrollLeft(); - self.doScrollPos(x, y, spd); - }; - - this.doScrollPos = function(x, y, spd) { //trans - - var py = self.getScrollTop(); - var px = self.getScrollLeft(); - - if (((self.newscrolly - py) * (y - py) < 0) || ((self.newscrollx - px) * (x - px) < 0)) self.cancelScroll(); //inverted movement detection - - if (self.opt.bouncescroll == false) { - if (y < 0) y = 0; - else if (y > self.page.maxh) y = self.page.maxh; - if (x < 0) x = 0; - else if (x > self.page.maxw) x = self.page.maxw; - } - - if (self.scrollrunning && x == self.newscrollx && y == self.newscrolly) return false; - - self.newscrolly = y; - self.newscrollx = x; - - self.newscrollspeed = spd || false; - - if (self.timer) return false; - - self.timer = setTimeout(function() { - - var top = self.getScrollTop(); - var lft = self.getScrollLeft(); - - var dst = {}; - dst.x = x - lft; - dst.y = y - top; - dst.px = lft; - dst.py = top; - - var dd = Math.round(Math.sqrt(Math.pow(dst.x, 2) + Math.pow(dst.y, 2))); - var ms = (self.newscrollspeed && self.newscrollspeed > 1) ? self.newscrollspeed : self.getTransitionSpeed(dd); - if (self.newscrollspeed && self.newscrollspeed <= 1) ms *= self.newscrollspeed; - - self.prepareTransition(ms, true); - - if (self.timerscroll && self.timerscroll.tm) clearInterval(self.timerscroll.tm); - - if (ms > 0) { - - if (!self.scrollrunning && self.onscrollstart) { - var info = { - "type": "scrollstart", - "current": { - "x": lft, - "y": top - }, - "request": { - "x": x, - "y": y - }, - "end": { - "x": self.newscrollx, - "y": self.newscrolly - }, - "speed": ms - }; - self.onscrollstart.call(self, info); - } - - if (cap.transitionend) { - if (!self.scrollendtrapped) { - self.scrollendtrapped = true; - self.bind(self.doc, cap.transitionend, self.onScrollTransitionEnd, false); //I have got to do something usefull!! - } - } else { - if (self.scrollendtrapped) clearTimeout(self.scrollendtrapped); - self.scrollendtrapped = setTimeout(self.onScrollTransitionEnd, ms); // simulate transitionend event - } - - var py = top; - var px = lft; - self.timerscroll = { - bz: new BezierClass(py, self.newscrolly, ms, 0, 0, 0.58, 1), - bh: new BezierClass(px, self.newscrollx, ms, 0, 0, 0.58, 1) - }; - if (!self.cursorfreezed) self.timerscroll.tm = setInterval(function() { - self.showCursor(self.getScrollTop(), self.getScrollLeft()) - }, 60); - - } - - self.synched("doScroll-set", function() { - self.timer = 0; - if (self.scrollendtrapped) self.scrollrunning = true; - self.setScrollTop(self.newscrolly); - self.setScrollLeft(self.newscrollx); - if (!self.scrollendtrapped) self.onScrollTransitionEnd(); - }); - - - }, 50); - - }; - - this.cancelScroll = function() { - if (!self.scrollendtrapped) return true; - var py = self.getScrollTop(); - var px = self.getScrollLeft(); - self.scrollrunning = false; - if (!cap.transitionend) clearTimeout(cap.transitionend); - self.scrollendtrapped = false; - self._unbind(self.doc[0], cap.transitionend, self.onScrollTransitionEnd); - self.prepareTransition(0); - self.setScrollTop(py); // fire event onscroll - if (self.railh) self.setScrollLeft(px); - if (self.timerscroll && self.timerscroll.tm) clearInterval(self.timerscroll.tm); - self.timerscroll = false; - - self.cursorfreezed = false; - - self.showCursor(py, px); - return self; - }; - this.onScrollTransitionEnd = function() { - if (self.scrollendtrapped) self._unbind(self.doc[0], cap.transitionend, self.onScrollTransitionEnd); - self.scrollendtrapped = false; - self.prepareTransition(0); - if (self.timerscroll && self.timerscroll.tm) clearInterval(self.timerscroll.tm); - self.timerscroll = false; - var py = self.getScrollTop(); - var px = self.getScrollLeft(); - self.setScrollTop(py); // fire event onscroll - if (self.railh) self.setScrollLeft(px); // fire event onscroll left - - self.noticeCursor(false, py, px); - - self.cursorfreezed = false; - - if (py < 0) py = 0 - else if (py > self.page.maxh) py = self.page.maxh; - if (px < 0) px = 0 - else if (px > self.page.maxw) px = self.page.maxw; - if ((py != self.newscrolly) || (px != self.newscrollx)) return self.doScrollPos(px, py, self.opt.snapbackspeed); - - if (self.onscrollend && self.scrollrunning) { - self.triggerScrollEnd(); - } - self.scrollrunning = false; - - }; - - } else { - - this.doScrollLeft = function(x, spd) { //no-trans - var y = (self.scrollrunning) ? self.newscrolly : self.getScrollTop(); - self.doScrollPos(x, y, spd); - }; - - this.doScrollTop = function(y, spd) { //no-trans - var x = (self.scrollrunning) ? self.newscrollx : self.getScrollLeft(); - self.doScrollPos(x, y, spd); - }; - - this.doScrollPos = function(x, y, spd) { //no-trans - var y = ((typeof y == "undefined") || (y === false)) ? self.getScrollTop(true) : y; - - if ((self.timer) && (self.newscrolly == y) && (self.newscrollx == x)) return true; - - if (self.timer) clearAnimationFrame(self.timer); - self.timer = 0; - - var py = self.getScrollTop(); - var px = self.getScrollLeft(); - - if (((self.newscrolly - py) * (y - py) < 0) || ((self.newscrollx - px) * (x - px) < 0)) self.cancelScroll(); //inverted movement detection - - self.newscrolly = y; - self.newscrollx = x; - - if (!self.bouncescroll || !self.rail.visibility) { - if (self.newscrolly < 0) { - self.newscrolly = 0; - } else if (self.newscrolly > self.page.maxh) { - self.newscrolly = self.page.maxh; - } - } - if (!self.bouncescroll || !self.railh.visibility) { - if (self.newscrollx < 0) { - self.newscrollx = 0; - } else if (self.newscrollx > self.page.maxw) { - self.newscrollx = self.page.maxw; - } - } - - self.dst = {}; - self.dst.x = x - px; - self.dst.y = y - py; - self.dst.px = px; - self.dst.py = py; - - var dst = Math.round(Math.sqrt(Math.pow(self.dst.x, 2) + Math.pow(self.dst.y, 2))); - - self.dst.ax = self.dst.x / dst; - self.dst.ay = self.dst.y / dst; - - var pa = 0; - var pe = dst; - - if (self.dst.x == 0) { - pa = py; - pe = y; - self.dst.ay = 1; - self.dst.py = 0; - } else if (self.dst.y == 0) { - pa = px; - pe = x; - self.dst.ax = 1; - self.dst.px = 0; - } - - var ms = self.getTransitionSpeed(dst); - if (spd && spd <= 1) ms *= spd; - if (ms > 0) { - self.bzscroll = (self.bzscroll) ? self.bzscroll.update(pe, ms) : new BezierClass(pa, pe, ms, 0, 1, 0, 1); - } else { - self.bzscroll = false; - } - - if (self.timer) return; - - if ((py == self.page.maxh && y >= self.page.maxh) || (px == self.page.maxw && x >= self.page.maxw)) self.checkContentSize(); - - var sync = 1; - - function scrolling() { - if (self.cancelAnimationFrame) return true; - - self.scrollrunning = true; - - sync = 1 - sync; - if (sync) return (self.timer = setAnimationFrame(scrolling) || 1); - - var done = 0; - var sx, sy; - - var sc = sy = self.getScrollTop(); - if (self.dst.ay) { - sc = (self.bzscroll) ? self.dst.py + (self.bzscroll.getNow() * self.dst.ay) : self.newscrolly; - var dr = sc - sy; - if ((dr < 0 && sc < self.newscrolly) || (dr > 0 && sc > self.newscrolly)) sc = self.newscrolly; - self.setScrollTop(sc); - if (sc == self.newscrolly) done = 1; - } else { - done = 1; - } - - var scx = sx = self.getScrollLeft(); - if (self.dst.ax) { - scx = (self.bzscroll) ? self.dst.px + (self.bzscroll.getNow() * self.dst.ax) : self.newscrollx; - var dr = scx - sx; - if ((dr < 0 && scx < self.newscrollx) || (dr > 0 && scx > self.newscrollx)) scx = self.newscrollx; - self.setScrollLeft(scx); - if (scx == self.newscrollx) done += 1; - } else { - done += 1; - } - - if (done == 2) { - self.timer = 0; - self.cursorfreezed = false; - self.bzscroll = false; - self.scrollrunning = false; - if (sc < 0) sc = 0; - else if (sc > self.page.maxh) sc = self.page.maxh; - if (scx < 0) scx = 0; - else if (scx > self.page.maxw) scx = self.page.maxw; - if ((scx != self.newscrollx) || (sc != self.newscrolly)) self.doScrollPos(scx, sc); - else { - if (self.onscrollend) { - self.triggerScrollEnd(); - } - } - } else { - self.timer = setAnimationFrame(scrolling) || 1; - } - }; - self.cancelAnimationFrame = false; - self.timer = 1; - - if (self.onscrollstart && !self.scrollrunning) { - var info = { - "type": "scrollstart", - "current": { - "x": px, - "y": py - }, - "request": { - "x": x, - "y": y - }, - "end": { - "x": self.newscrollx, - "y": self.newscrolly - }, - "speed": ms - }; - self.onscrollstart.call(self, info); - } - - scrolling(); - - if ((py == self.page.maxh && y >= py) || (px == self.page.maxw && x >= px)) self.checkContentSize(); - - self.noticeCursor(); - }; - - this.cancelScroll = function() { - if (self.timer) clearAnimationFrame(self.timer); - self.timer = 0; - self.bzscroll = false; - self.scrollrunning = false; - return self; - }; - - } - - this.doScrollBy = function(stp, relative) { - var ny = 0; - if (relative) { - ny = Math.floor((self.scroll.y - stp) * self.scrollratio.y) - } else { - var sy = (self.timer) ? self.newscrolly : self.getScrollTop(true); - ny = sy - stp; - } - if (self.bouncescroll) { - var haf = Math.round(self.view.h / 2); - if (ny < -haf) ny = -haf - else if (ny > (self.page.maxh + haf)) ny = (self.page.maxh + haf); - } - self.cursorfreezed = false; - - var py = self.getScrollTop(true); - if (ny < 0 && py <= 0) return self.noticeCursor(); - else if (ny > self.page.maxh && py >= self.page.maxh) { - self.checkContentSize(); - return self.noticeCursor(); - } - - self.doScrollTop(ny); - }; - - this.doScrollLeftBy = function(stp, relative) { - var nx = 0; - if (relative) { - nx = Math.floor((self.scroll.x - stp) * self.scrollratio.x) - } else { - var sx = (self.timer) ? self.newscrollx : self.getScrollLeft(true); - nx = sx - stp; - } - if (self.bouncescroll) { - var haf = Math.round(self.view.w / 2); - if (nx < -haf) nx = -haf; - else if (nx > (self.page.maxw + haf)) nx = (self.page.maxw + haf); - } - self.cursorfreezed = false; - - var px = self.getScrollLeft(true); - if (nx < 0 && px <= 0) return self.noticeCursor(); - else if (nx > self.page.maxw && px >= self.page.maxw) return self.noticeCursor(); - - self.doScrollLeft(nx); - }; - - this.doScrollTo = function(pos, relative) { - var ny = (relative) ? Math.round(pos * self.scrollratio.y) : pos; - if (ny < 0) ny = 0; - else if (ny > self.page.maxh) ny = self.page.maxh; - self.cursorfreezed = false; - self.doScrollTop(pos); - }; - - this.checkContentSize = function() { - var pg = self.getContentSize(); - if ((pg.h != self.page.h) || (pg.w != self.page.w)) self.resize(false, pg); - }; - - self.onscroll = function(e) { - if (self.rail.drag) return; - if (!self.cursorfreezed) { - self.synched('scroll', function() { - self.scroll.y = Math.round(self.getScrollTop() * (1 / self.scrollratio.y)); - if (self.railh) self.scroll.x = Math.round(self.getScrollLeft() * (1 / self.scrollratio.x)); - self.noticeCursor(); - }); - } - }; - self.bind(self.docscroll, "scroll", self.onscroll); - - this.doZoomIn = function(e) { - if (self.zoomactive) return; - self.zoomactive = true; - - self.zoomrestore = { - style: {} - }; - var lst = ['position', 'top', 'left', 'zIndex', 'backgroundColor', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight']; - var win = self.win[0].style; - for (var a in lst) { - var pp = lst[a]; - self.zoomrestore.style[pp] = (typeof win[pp] != "undefined") ? win[pp] : ''; - } - - self.zoomrestore.style.width = self.win.css('width'); - self.zoomrestore.style.height = self.win.css('height'); - - self.zoomrestore.padding = { - w: self.win.outerWidth() - self.win.width(), - h: self.win.outerHeight() - self.win.height() - }; - - if (cap.isios4) { - self.zoomrestore.scrollTop = $(window).scrollTop(); - $(window).scrollTop(0); - } - - self.win.css({ - "position": (cap.isios4) ? "absolute" : "fixed", - "top": 0, - "left": 0, - "z-index": globalmaxzindex + 100, - "margin": "0px" - }); - var bkg = self.win.css("backgroundColor"); - if (bkg == "" || /transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(bkg)) self.win.css("backgroundColor", "#fff"); - self.rail.css({ - "z-index": globalmaxzindex + 101 - }); - self.zoom.css({ - "z-index": globalmaxzindex + 102 - }); - self.zoom.css('backgroundPosition', '0px -18px'); - self.resizeZoom(); - - if (self.onzoomin) self.onzoomin.call(self); - - return self.cancelEvent(e); - }; - - this.doZoomOut = function(e) { - if (!self.zoomactive) return; - self.zoomactive = false; - - self.win.css("margin", ""); - self.win.css(self.zoomrestore.style); - - if (cap.isios4) { - $(window).scrollTop(self.zoomrestore.scrollTop); - } - - self.rail.css({ - "z-index": self.zindex - }); - self.zoom.css({ - "z-index": self.zindex - }); - self.zoomrestore = false; - self.zoom.css('backgroundPosition', '0px 0px'); - self.onResize(); - - if (self.onzoomout) self.onzoomout.call(self); - - return self.cancelEvent(e); - }; - - this.doZoom = function(e) { - return (self.zoomactive) ? self.doZoomOut(e) : self.doZoomIn(e); - }; - - this.resizeZoom = function() { - if (!self.zoomactive) return; - - var py = self.getScrollTop(); //preserve scrolling position - self.win.css({ - width: $(window).width() - self.zoomrestore.padding.w + "px", - height: $(window).height() - self.zoomrestore.padding.h + "px" - }); - self.onResize(); - - self.setScrollTop(Math.min(self.page.maxh, py)); - }; - - this.init(); - - $.nicescroll.push(this); - - }; - - // Inspired by the work of Kin Blas - // http://webpro.host.adobe.com/people/jblas/momentum/includes/jquery.momentum.0.7.js - - - var ScrollMomentumClass2D = function(nc) { - var self = this; - this.nc = nc; - - this.lastx = 0; - this.lasty = 0; - this.speedx = 0; - this.speedy = 0; - this.lasttime = 0; - this.steptime = 0; - this.snapx = false; - this.snapy = false; - this.demulx = 0; - this.demuly = 0; - - this.lastscrollx = -1; - this.lastscrolly = -1; - - this.chkx = 0; - this.chky = 0; - - this.timer = 0; - - this.time = function() { - return +new Date(); //beautifull hack - }; - - this.reset = function(px, py) { - self.stop(); - var now = self.time(); - self.steptime = 0; - self.lasttime = now; - self.speedx = 0; - self.speedy = 0; - self.lastx = px; - self.lasty = py; - self.lastscrollx = -1; - self.lastscrolly = -1; - }; - - this.update = function(px, py) { - var now = self.time(); - self.steptime = now - self.lasttime; - self.lasttime = now; - var dy = py - self.lasty; - var dx = px - self.lastx; - var sy = self.nc.getScrollTop(); - var sx = self.nc.getScrollLeft(); - var newy = sy + dy; - var newx = sx + dx; - self.snapx = (newx < 0) || (newx > self.nc.page.maxw); - self.snapy = (newy < 0) || (newy > self.nc.page.maxh); - self.speedx = dx; - self.speedy = dy; - self.lastx = px; - self.lasty = py; - }; - - this.stop = function() { - self.nc.unsynched("domomentum2d"); - if (self.timer) clearTimeout(self.timer); - self.timer = 0; - self.lastscrollx = -1; - self.lastscrolly = -1; - }; - - this.doSnapy = function(nx, ny) { - var snap = false; - - if (ny < 0) { - ny = 0; - snap = true; - } else if (ny > self.nc.page.maxh) { - ny = self.nc.page.maxh; - snap = true; - } - - if (nx < 0) { - nx = 0; - snap = true; - } else if (nx > self.nc.page.maxw) { - nx = self.nc.page.maxw; - snap = true; - } - - (snap) ? self.nc.doScrollPos(nx, ny, self.nc.opt.snapbackspeed): self.nc.triggerScrollEnd(); - }; - - this.doMomentum = function(gp) { - var t = self.time(); - var l = (gp) ? t + gp : self.lasttime; - - var sl = self.nc.getScrollLeft(); - var st = self.nc.getScrollTop(); - - var pageh = self.nc.page.maxh; - var pagew = self.nc.page.maxw; - - self.speedx = (pagew > 0) ? Math.min(60, self.speedx) : 0; - self.speedy = (pageh > 0) ? Math.min(60, self.speedy) : 0; - - var chk = l && (t - l) <= 60; - - if ((st < 0) || (st > pageh) || (sl < 0) || (sl > pagew)) chk = false; - - var sy = (self.speedy && chk) ? self.speedy : false; - var sx = (self.speedx && chk) ? self.speedx : false; - - if (sy || sx) { - var tm = Math.max(16, self.steptime); //timeout granularity - - if (tm > 50) { // do smooth - var xm = tm / 50; - self.speedx *= xm; - self.speedy *= xm; - tm = 50; - } - - self.demulxy = 0; - - self.lastscrollx = self.nc.getScrollLeft(); - self.chkx = self.lastscrollx; - self.lastscrolly = self.nc.getScrollTop(); - self.chky = self.lastscrolly; - - var nx = self.lastscrollx; - var ny = self.lastscrolly; - - var onscroll = function() { - var df = ((self.time() - t) > 600) ? 0.04 : 0.02; - - if (self.speedx) { - nx = Math.floor(self.lastscrollx - (self.speedx * (1 - self.demulxy))); - self.lastscrollx = nx; - if ((nx < 0) || (nx > pagew)) df = 0.10; - } - - if (self.speedy) { - ny = Math.floor(self.lastscrolly - (self.speedy * (1 - self.demulxy))); - self.lastscrolly = ny; - if ((ny < 0) || (ny > pageh)) df = 0.10; - } - - self.demulxy = Math.min(1, self.demulxy + df); - - self.nc.synched("domomentum2d", function() { - - if (self.speedx) { - var scx = self.nc.getScrollLeft(); - if (scx != self.chkx) self.stop(); - self.chkx = nx; - self.nc.setScrollLeft(nx); - } - - if (self.speedy) { - var scy = self.nc.getScrollTop(); - if (scy != self.chky) self.stop(); - self.chky = ny; - self.nc.setScrollTop(ny); - } - - if (!self.timer) { - self.nc.hideCursor(); - self.doSnapy(nx, ny); - } - - }); - - if (self.demulxy < 1) { - self.timer = setTimeout(onscroll, tm); - } else { - self.stop(); - self.nc.hideCursor(); - self.doSnapy(nx, ny); - } - }; - - onscroll(); - - } else { - self.doSnapy(self.nc.getScrollLeft(), self.nc.getScrollTop()); - } - - } - - }; - - - // override jQuery scrollTop - - var _scrollTop = jQuery.fn.scrollTop; // preserve original function - - jQuery.cssHooks["pageYOffset"] = { - get: function(elem, computed, extra) { - var nice = $.data(elem, '__nicescroll') || false; - return (nice && nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(elem); - }, - set: function(elem, value) { - var nice = $.data(elem, '__nicescroll') || false; - (nice && nice.ishwscroll) ? nice.setScrollTop(parseInt(value)): _scrollTop.call(elem, value); - return this; - } - }; - - /* - $.fx.step["scrollTop"] = function(fx){ - $.cssHooks["scrollTop"].set( fx.elem, fx.now + fx.unit ); - }; -*/ - - jQuery.fn.scrollTop = function(value) { - if (typeof value == "undefined") { - var nice = (this[0]) ? $.data(this[0], '__nicescroll') || false : false; - return (nice && nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(this); - } else { - return this.each(function() { - var nice = $.data(this, '__nicescroll') || false; - (nice && nice.ishwscroll) ? nice.setScrollTop(parseInt(value)): _scrollTop.call($(this), value); - }); - } - }; - - // override jQuery scrollLeft - - var _scrollLeft = jQuery.fn.scrollLeft; // preserve original function - - $.cssHooks.pageXOffset = { - get: function(elem, computed, extra) { - var nice = $.data(elem, '__nicescroll') || false; - return (nice && nice.ishwscroll) ? nice.getScrollLeft() : _scrollLeft.call(elem); - }, - set: function(elem, value) { - var nice = $.data(elem, '__nicescroll') || false; - (nice && nice.ishwscroll) ? nice.setScrollLeft(parseInt(value)): _scrollLeft.call(elem, value); - return this; - } - }; - - /* - $.fx.step["scrollLeft"] = function(fx){ - $.cssHooks["scrollLeft"].set( fx.elem, fx.now + fx.unit ); - }; -*/ - - jQuery.fn.scrollLeft = function(value) { - if (typeof value == "undefined") { - var nice = (this[0]) ? $.data(this[0], '__nicescroll') || false : false; - return (nice && nice.ishwscroll) ? nice.getScrollLeft() : _scrollLeft.call(this); - } else { - return this.each(function() { - var nice = $.data(this, '__nicescroll') || false; - (nice && nice.ishwscroll) ? nice.setScrollLeft(parseInt(value)): _scrollLeft.call($(this), value); - }); - } - }; - - var NiceScrollArray = function(doms) { - var self = this; - this.length = 0; - this.name = "nicescrollarray"; - - this.each = function(fn) { - for (var a = 0, i = 0; a < self.length; a++) fn.call(self[a], i++); - return self; - }; - - this.push = function(nice) { - self[self.length] = nice; - self.length++; - }; - - this.eq = function(idx) { - return self[idx]; - }; - - if (doms) { - for (var a = 0; a < doms.length; a++) { - var nice = $.data(doms[a], '__nicescroll') || false; - if (nice) { - this[this.length] = nice; - this.length++; - } - }; - } - - return this; - }; - - function mplex(el, lst, fn) { - for (var a = 0; a < lst.length; a++) fn(el, lst[a]); - }; - mplex( - NiceScrollArray.prototype, ['show', 'hide', 'toggle', 'onResize', 'resize', 'remove', 'stop', 'doScrollPos'], - function(e, n) { - e[n] = function() { - var args = arguments; - return this.each(function() { - this[n].apply(this, args); - }); - }; - } - ); - - jQuery.fn.getNiceScroll = function(index) { - if (typeof index == "undefined") { - return new NiceScrollArray(this); - } else { - var nice = this[index] && $.data(this[index], '__nicescroll') || false; - return nice; - } - }; - - jQuery.extend(jQuery.expr[':'], { - nicescroll: function(a) { - return ($.data(a, '__nicescroll')) ? true : false; - } - }); - - $.fn.niceScroll = function(wrapper, opt) { - if (typeof opt == "undefined") { - if ((typeof wrapper == "object") && !("jquery" in wrapper)) { - opt = wrapper; - wrapper = false; - } - } - opt = $.extend({},opt); // cloning - var ret = new NiceScrollArray(); - if (typeof opt == "undefined") opt = {}; - - if (wrapper || false) { - opt.doc = $(wrapper); - opt.win = $(this); - } - var docundef = !("doc" in opt); - if (!docundef && !("win" in opt)) opt.win = $(this); - - this.each(function() { - var nice = $(this).data('__nicescroll') || false; - if (!nice) { - opt.doc = (docundef) ? $(this) : opt.doc; - nice = new NiceScrollClass(opt, $(this)); - $(this).data('__nicescroll', nice); - } - ret.push(nice); - }); - return (ret.length == 1) ? ret[0] : ret; - }; - - window.NiceScroll = { - getjQuery: function() { - return jQuery - } - }; - - if (!$.nicescroll) { - $.nicescroll = new NiceScrollArray(); - $.nicescroll.options = _globaloptions; - } - -}));
\ No newline at end of file diff --git a/vendor/project_templates/rails.tar.gz b/vendor/project_templates/rails.tar.gz Binary files differnew file mode 100644 index 00000000000..b54cae3143a --- /dev/null +++ b/vendor/project_templates/rails.tar.gz diff --git a/yarn.lock b/yarn.lock index dcddda47cd9..c9e1b630a9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -41,10 +41,14 @@ after@0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" -ajv-keywords@^1.0.0, ajv-keywords@^1.1.1: +ajv-keywords@^1.0.0: version "1.5.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" +ajv-keywords@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" + ajv@^4.7.0: version "4.11.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.2.tgz#f166c3c11cbc6cb9dcc102a5bcfe5b72c95287e6" @@ -52,6 +56,15 @@ ajv@^4.7.0: co "^4.6.0" json-stable-stringify "^1.0.1" +ajv@^5.1.5: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.0.tgz#c1735024c5da2ef75cc190713073d44f098bf486" + dependencies: + co "^4.6.0" + fast-deep-equal "^0.1.0" + json-schema-traverse "^0.3.0" + json-stable-stringify "^1.0.1" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -128,6 +141,10 @@ arr-flatten@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + array-find@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-find/-/array-find-1.0.0.tgz#6c8e286d11ed768327f8e62ecee87353ca3e78b8" @@ -136,6 +153,10 @@ array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" +array-flatten@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-2.1.1.tgz#426bb9da84090c1838d812c8150af20a8331e296" + array-slice@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5" @@ -412,14 +433,13 @@ babel-helpers@^6.23.0: babel-runtime "^6.22.0" babel-template "^6.23.0" -babel-loader@^6.2.10: - version "6.2.10" - resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-6.2.10.tgz#adefc2b242320cd5d15e65b31cea0e8b1b02d4b0" +babel-loader@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.1.tgz#b87134c8b12e3e4c2a94e0546085bc680a2b8488" dependencies: - find-cache-dir "^0.1.1" - loader-utils "^0.2.11" + find-cache-dir "^1.0.0" + loader-utils "^1.0.2" mkdirp "^0.5.1" - object-assign "^4.0.1" babel-messages@^6.23.0: version "6.23.0" @@ -832,11 +852,7 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23 lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.11.0: - version "6.15.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" - -babylon@^6.13.0, babylon@^6.15.0, babylon@^6.16.1: +babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0, babylon@^6.16.1: version "6.16.1" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" @@ -921,6 +937,17 @@ body-parser@^1.16.1: raw-body "~2.2.0" type-is "~1.6.15" +bonjour@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/bonjour/-/bonjour-3.5.0.tgz#8e890a183d8ee9a2393b3844c691a42bcf7bc9f5" + dependencies: + array-flatten "^2.1.0" + deep-equal "^1.0.1" + dns-equal "^1.0.0" + dns-txt "^2.0.2" + multicast-dns "^6.0.1" + multicast-dns-service-types "^1.1.0" + boom@2.x.x: version "2.10.1" resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" @@ -1014,6 +1041,10 @@ browserslist@^1.3.6, browserslist@^1.5.2, browserslist@^1.7.6: caniuse-db "^1.0.30000639" electron-to-chromium "^1.2.7" +buffer-indexof@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.0.tgz#f54f647c4f4e25228baa656a2e57e43d5f270982" + buffer-shims@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" @@ -1060,14 +1091,29 @@ callsites@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + caniuse-api@^1.5.2: version "1.6.1" resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-1.6.1.tgz#b534e7c734c4f81ec5fbe8aca2ad24354b962c6c" @@ -1117,6 +1163,21 @@ chokidar@^1.4.1, chokidar@^1.4.3, chokidar@^1.6.0: optionalDependencies: fsevents "^1.0.0" +chokidar@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + cipher-base@^1.0.0, cipher-base@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.3.tgz#eeabf194419ce900da3018c207d212f2a6df0a07" @@ -1439,6 +1500,14 @@ cropper@^2.3.0: dependencies: jquery ">= 1.9.1" +cross-spawn@^5.0.1: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + dependencies: + lru-cache "^4.0.1" + shebang-command "^1.2.0" + which "^1.2.9" + cryptiles@2.x.x: version "2.0.5" resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" @@ -1545,6 +1614,12 @@ csso@~2.3.1: clap "^1.0.9" source-map "^0.5.3" +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + custom-event@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" @@ -1597,11 +1672,11 @@ debug@2.6.7: dependencies: ms "2.0.0" -debug@^2.1.0, debug@^2.1.1, debug@^2.2.0, debug@^2.4.5: - version "2.6.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" +debug@^2.1.0, debug@^2.1.1, debug@^2.2.0, debug@^2.4.5, debug@^2.6.6, debug@^2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: - ms "0.7.2" + ms "2.0.0" decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" @@ -1617,6 +1692,10 @@ decompress-response@^3.2.0: dependencies: mimic-response "^1.0.0" +deep-equal@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" + deep-extend@~0.4.0: version "0.4.1" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" @@ -1653,6 +1732,17 @@ del@^2.0.2: pinkie-promise "^2.0.0" rimraf "^2.2.8" +del@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/del/-/del-3.0.0.tgz#53ecf699ffcbcb39637691ab13baf160819766e5" + dependencies: + globby "^6.1.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + p-map "^1.1.1" + pify "^3.0.0" + rimraf "^2.2.8" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -1698,6 +1788,23 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +dns-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" + +dns-packet@^1.0.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-1.1.1.tgz#2369d45038af045f3898e6fa56862aed3f40296c" + dependencies: + ip "^1.1.0" + safe-buffer "^5.0.1" + +dns-txt@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/dns-txt/-/dns-txt-2.0.2.tgz#b91d806f5d27188e4ab3e7d107d881a1cc4642b6" + dependencies: + buffer-indexof "^1.0.0" + doctrine@1.5.0, doctrine@^1.2.2: version "1.5.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" @@ -1864,14 +1971,14 @@ engine.io@1.8.3: engine.io-parser "1.3.2" ws "1.1.2" -enhanced-resolve@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.1.0.tgz#9f4b626f577245edcf4b2ad83d86e17f4f421dec" +enhanced-resolve@^3.4.0: + version "3.4.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz#0421e339fd71419b3da13d129b3979040230476e" dependencies: graceful-fs "^4.1.2" memory-fs "^0.4.0" object-assign "^4.0.1" - tapable "^0.2.5" + tapable "^0.2.7" enhanced-resolve@~0.9.0: version "0.9.1" @@ -1997,12 +2104,12 @@ eslint-import-resolver-node@^0.2.0: object-assign "^4.0.1" resolve "^1.1.6" -eslint-import-resolver-webpack@^0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.8.1.tgz#c7f8b4d5bd3c5b489457e5728c5db1c4ffbac9aa" +eslint-import-resolver-webpack@^0.8.3: + version "0.8.3" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.8.3.tgz#ad61e28df378a474459d953f246fd43f92675385" dependencies: array-find "^1.0.0" - debug "^2.2.0" + debug "^2.6.8" enhanced-resolve "~0.9.0" find-root "^0.1.1" has "^1.0.1" @@ -2181,6 +2288,18 @@ evp_bytestokey@^1.0.0: dependencies: create-hash "^1.1.1" +execa@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" + dependencies: + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + exit-hook@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" @@ -2266,6 +2385,10 @@ extsprintf@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" +fast-deep-equal@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-0.1.0.tgz#5c6f4599aba6b333ee3342e2ed978672f1001f8d" + fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" @@ -2353,13 +2476,13 @@ finalhandler@1.0.3, finalhandler@~1.0.3: statuses "~1.3.1" unpipe "~1.0.0" -find-cache-dir@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-0.1.1.tgz#c8defae57c8a52a8a784f9e31c57c742e993a0b9" +find-cache-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f" dependencies: commondir "^1.0.1" - mkdirp "^0.5.1" - pkg-dir "^1.0.0" + make-dir "^1.0.0" + pkg-dir "^2.0.0" find-root@^0.1.1: version "0.1.2" @@ -2372,7 +2495,7 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" -find-up@^2.1.0: +find-up@^2.0.0, find-up@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" dependencies: @@ -2507,6 +2630,10 @@ get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -2576,6 +2703,16 @@ globby@^5.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" +globby@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" + dependencies: + array-union "^1.0.1" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + good-listener@^1.2.0: version "1.2.2" resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50" @@ -2673,6 +2810,10 @@ has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" +has-flag@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" + has-symbol-support-x@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.3.0.tgz#588bd6927eaa0e296afae24160659167fc2be4f8" @@ -2843,6 +2984,12 @@ imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + indexes-of@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607" @@ -2892,6 +3039,12 @@ inquirer@^0.12.0: strip-ansi "^3.0.0" through "^2.3.6" +internal-ip@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-1.2.0.tgz#ae9fbf93b984878785d50a8de1b356956058cf5c" + dependencies: + meow "^3.3.0" + interpret@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" @@ -2906,6 +3059,10 @@ invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" +ip@^1.1.0: + version "1.1.5" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" + ipaddr.js@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.3.0.tgz#1e03a52fdad83a8bbb2b25cbf4998b4cffcd3dec" @@ -3070,7 +3227,7 @@ is-retry-allowed@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" -is-stream@^1.0.0: +is-stream@^1.0.0, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -3293,6 +3450,10 @@ json-loader@^0.5.4: version "0.5.4" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de" +json-schema-traverse@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.0.tgz#0016c0b1ca1efe46d44d37541bcdfc19dcfae0db" + json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" @@ -3380,9 +3541,9 @@ karma-sourcemap-loader@^0.3.7: dependencies: graceful-fs "^4.1.2" -karma-webpack@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/karma-webpack/-/karma-webpack-2.0.2.tgz#bd38350af5645c9644090770939ebe7ce726f864" +karma-webpack@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/karma-webpack/-/karma-webpack-2.0.4.tgz#3e2d4f48ba94a878e1c66bb8e1ae6128987a175b" dependencies: async "~0.9.0" loader-utils "^0.2.5" @@ -3473,11 +3634,20 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" +load-json-file@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + strip-bom "^3.0.0" + loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" -loader-utils@^0.2.11, loader-utils@^0.2.15, loader-utils@^0.2.16, loader-utils@^0.2.5: +loader-utils@^0.2.15, loader-utils@^0.2.5: version "0.2.16" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d" dependencies: @@ -3653,6 +3823,10 @@ log4js@^0.6.31: readable-stream "~1.0.2" semver "~4.3.3" +loglevel@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.4.1.tgz#95b383f91a3c2756fd4ab093667e4309161f2bcd" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -3663,6 +3837,13 @@ loose-envify@^1.0.0: dependencies: js-tokens "^3.0.0" +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + lowercase-keys@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" @@ -3688,6 +3869,16 @@ macaddress@^0.2.8: version "0.2.8" resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12" +make-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.0.0.tgz#97a011751e91dd87cfadef58832ebb04936de978" + dependencies: + pify "^2.3.0" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + map-stream@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" @@ -3704,6 +3895,12 @@ media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" +mem@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" + dependencies: + mimic-fn "^1.0.0" + memory-fs@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" @@ -3715,6 +3912,21 @@ memory-fs@^0.4.0, memory-fs@~0.4.1: errno "^0.1.3" readable-stream "^2.0.1" +meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3748,30 +3960,24 @@ miller-rabin@^4.0.0: bn.js "^4.0.0" brorand "^1.0.1" -"mime-db@>= 1.24.0 < 2", mime-db@~1.26.0: - version "1.26.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.26.0.tgz#eaffcd0e4fc6935cf8134da246e2e6c35305adff" - -mime-db@~1.27.0: +"mime-db@>= 1.24.0 < 2", mime-db@~1.27.0: version "1.27.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" -mime-types@^2.1.12, mime-types@~2.1.15, mime-types@~2.1.7: +mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.15, mime-types@~2.1.7: version "2.1.15" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" dependencies: mime-db "~1.27.0" -mime-types@~2.1.11: - version "2.1.14" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee" - dependencies: - mime-db "~1.26.0" - mime@1.3.4, mime@1.3.x, mime@^1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" +mimic-fn@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" + mimic-response@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.0.tgz#df3d3652a73fded6b9b0b24146e6fd052353458e" @@ -3790,7 +3996,7 @@ minimist@0.0.8, minimist@~0.0.1: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@^1.2.0: +minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -3824,6 +4030,17 @@ ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" +multicast-dns-service-types@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz#899f11d9686e5e05cb91b35d5f0e63b773cfc901" + +multicast-dns@^6.0.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-6.1.1.tgz#6e7de86a570872ab17058adea7160bbeca814dde" + dependencies: + dns-packet "^1.0.1" + thunky "^0.1.0" + mute-stream@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" @@ -3856,6 +4073,10 @@ node-dir@^0.1.10: dependencies: minimatch "^3.0.2" +node-forge@0.6.33: + version "0.6.33" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.6.33.tgz#463811879f573d45155ad6a9f43dc296e8e85ebc" + node-libs-browser@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-1.1.1.tgz#2a38243abedd7dffcd07a97c9aca5668975a6fea" @@ -3962,7 +4183,7 @@ nopt@~1.0.10: dependencies: abbrev "1" -normalize-package-data@^2.3.2: +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: version "2.3.5" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.5.tgz#8d924f142960e1777e7ffe170543631cc7cb02df" dependencies: @@ -3988,6 +4209,12 @@ normalize-url@^1.4.0: query-string "^4.1.0" sort-keys "^1.0.0" +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + dependencies: + path-key "^2.0.0" + npmlog@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" @@ -4119,6 +4346,14 @@ os-locale@^1.4.0: dependencies: lcid "^1.0.0" +os-locale@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" + dependencies: + execa "^0.7.0" + lcid "^1.0.0" + mem "^1.1.0" + os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -4148,6 +4383,10 @@ p-locate@^2.0.0: dependencies: p-limit "^1.1.0" +p-map@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-1.1.1.tgz#05f5e4ae97a068371bc2a5cc86bfbdbc19c4ae7a" + p-timeout@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.0.tgz#9820f99434c5817868b4f34809ee5291660d5b6c" @@ -4238,6 +4477,10 @@ path-is-inside@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" +path-key@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + path-parse@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" @@ -4254,6 +4497,12 @@ path-type@^1.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" +path-type@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" + dependencies: + pify "^2.0.0" + pause-stream@0.0.11: version "0.0.11" resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" @@ -4266,10 +4515,14 @@ pbkdf2@^3.0.3: dependencies: create-hmac "^1.1.2" -pify@^2.0.0: +pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + pikaday@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/pikaday/-/pikaday-1.5.1.tgz#0a48549bc1a14ea1d08c44074d761bc2f2bfcfd3" @@ -4292,6 +4545,12 @@ pkg-dir@^1.0.0: dependencies: find-up "^1.0.0" +pkg-dir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" + dependencies: + find-up "^2.1.0" + pkg-up@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-1.0.0.tgz#3e08fb461525c4421624a33b9f7e6d0af5b05a26" @@ -4683,6 +4942,10 @@ querystringify@0.0.x: version "0.0.4" resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-0.0.4.tgz#0cf7f84f9463ff0ae51c4c4b142d95be37724d9c" +querystringify@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb" + randomatic@^1.1.3: version "1.1.6" resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" @@ -4760,6 +5023,13 @@ read-pkg-up@^1.0.1: find-up "^1.0.0" read-pkg "^1.0.0" +read-pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" + dependencies: + find-up "^2.0.0" + read-pkg "^2.0.0" + read-pkg@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" @@ -4768,6 +5038,14 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +read-pkg@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" + dependencies: + load-json-file "^2.0.0" + normalize-package-data "^2.3.2" + path-type "^2.0.0" + readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.1.0, readable-stream@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e" @@ -4841,6 +5119,13 @@ recursive-readdir@2.1.1: dependencies: minimatch "3.0.3" +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + reduce-css-calc@^1.2.6: version "1.3.0" resolved "https://registry.yarnpkg.com/reduce-css-calc/-/reduce-css-calc-1.3.0.tgz#747c914e049614a4c9cfbba629871ad1d2927716" @@ -5053,6 +5338,12 @@ select@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d" +selfsigned@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.9.1.tgz#cdda4492d70d486570f87c65546023558e1dfa5a" + dependencies: + node-forge "0.6.33" + semver-diff@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" @@ -5132,6 +5423,16 @@ sha.js@^2.3.6: dependencies: inherits "^2.0.1" +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + shelljs@^0.7.5: version "0.7.6" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.6.tgz#379cccfb56b91c8601e4793356eb5382924de9ad" @@ -5221,16 +5522,16 @@ sockjs-client@1.0.1: json3 "^3.3.2" url-parse "^1.0.1" -sockjs-client@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.1.2.tgz#f0212a8550e4c9468c8cceaeefd2e3493c033ad5" +sockjs-client@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.1.4.tgz#5babe386b775e4cf14e7520911452654016c8b12" dependencies: - debug "^2.2.0" + debug "^2.6.6" eventsource "0.1.6" faye-websocket "~0.11.0" inherits "^2.0.1" json3 "^3.3.2" - url-parse "^1.1.1" + url-parse "^1.1.8" sockjs@0.3.18: version "0.3.18" @@ -5249,9 +5550,9 @@ source-list-map@^0.1.7, source-list-map@~0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.8.tgz#c550b2ab5427f6b3f21f5afead88c4f5587b2106" -source-list-map@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-1.1.1.tgz#1a33ac210ca144d1e561f906ebccab5669ff4cb4" +source-list-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" source-map-support@^0.4.2: version "0.4.11" @@ -5344,10 +5645,6 @@ sshpk@^1.7.0: jsbn "~0.1.0" tweetnacl "~0.14.0" -stats-webpack-plugin@^0.4.3: - version "0.4.3" - resolved "https://registry.yarnpkg.com/stats-webpack-plugin/-/stats-webpack-plugin-0.4.3.tgz#b2f618202f28dd04ab47d7ecf54ab846137b7aea" - "statuses@>= 1.3.1 < 2", statuses@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" @@ -5428,6 +5725,16 @@ strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + strip-json-comments@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" @@ -5450,6 +5757,12 @@ supports-color@^3.1.0, supports-color@^3.1.1, supports-color@^3.1.2, supports-co dependencies: has-flag "^1.0.0" +supports-color@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.1.tgz#65a4bb2631e90e02420dba5554c375a4754bb836" + dependencies: + has-flag "^2.0.0" + svgo@^0.7.0: version "0.7.2" resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5" @@ -5477,9 +5790,9 @@ tapable@^0.1.8: version "0.1.10" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.1.10.tgz#29c35707c2b70e50d07482b5d202e8ed446dafd4" -tapable@^0.2.5, tapable@~0.2.5: - version "0.2.6" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.6.tgz#206be8e188860b514425375e6f1ae89bfb01fd8d" +tapable@^0.2.7: + version "0.2.7" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.7.tgz#e46c0daacbb2b8a98b9b0cea0f4052105817ed5c" tar-pack@~3.3.0: version "3.3.0" @@ -5532,6 +5845,10 @@ through@2, through@^2.3.6, through@~2.3, through@~2.3.1: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" +thunky@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/thunky/-/thunky-0.1.0.tgz#bf30146824e2b6e67b0f2d7a4ac8beb26908684e" + timeago.js@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/timeago.js/-/timeago.js-2.0.5.tgz#730c74fbdb0b0917a553675a4460e3a7f80db86c" @@ -5594,6 +5911,10 @@ traverse@0.6.6: version "0.6.6" resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" @@ -5631,9 +5952,9 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -uglify-js@^2.6, uglify-js@^2.8.27: - version "2.8.27" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.27.tgz#47787f912b0f242e5b984343be8e35e95f694c9c" +uglify-js@^2.6, uglify-js@^2.8.29: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" dependencies: source-map "~0.5.1" yargs "~3.10.0" @@ -5644,6 +5965,14 @@ uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" +uglifyjs-webpack-plugin@^0.4.6: + version "0.4.6" + resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz#b951f4abb6bd617e66f63eb891498e391763e309" + dependencies: + source-map "^0.5.6" + uglify-js "^2.8.29" + webpack-sources "^1.0.1" + uid-number@~0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" @@ -5718,13 +6047,20 @@ url-parse@1.0.x: querystringify "0.0.x" requires-port "1.0.x" -url-parse@^1.0.1, url-parse@^1.1.1: +url-parse@^1.0.1: version "1.1.7" resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.7.tgz#025cff999653a459ab34232147d89514cc87d74a" dependencies: querystringify "0.0.x" requires-port "1.0.x" +url-parse@^1.1.8: + version "1.1.9" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.9.tgz#c67f1d775d51f0a18911dd7b3ffad27bb9e5bd19" + dependencies: + querystringify "~1.0.0" + requires-port "1.0.x" + url-to-options@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" @@ -5855,12 +6191,12 @@ vue@^2.2.6: version "2.2.6" resolved "https://registry.yarnpkg.com/vue/-/vue-2.2.6.tgz#451714b394dd6d4eae7b773c40c2034a59621aed" -watchpack@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.3.1.tgz#7d8693907b28ce6013e7f3610aa2a1acf07dad87" +watchpack@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.4.0.tgz#4a1472bcbb952bd0a9bb4036801f954dfb39faac" dependencies: async "^2.1.2" - chokidar "^1.4.3" + chokidar "^1.7.0" graceful-fs "^4.1.2" wbuf@^1.1.0, wbuf@^1.4.0: @@ -5885,35 +6221,40 @@ webpack-bundle-analyzer@^2.8.2: opener "^1.4.3" ws "^2.3.1" -webpack-dev-middleware@^1.0.11, webpack-dev-middleware@^1.9.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.10.0.tgz#7d5be2651e692fddfafd8aaed177c16ff51f0eb8" +webpack-dev-middleware@^1.0.11, webpack-dev-middleware@^1.11.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.11.0.tgz#09691d0973a30ad1f82ac73a12e2087f0a4754f9" dependencies: memory-fs "~0.4.1" mime "^1.3.4" path-is-absolute "^1.0.0" range-parser "^1.0.3" -webpack-dev-server@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.4.2.tgz#cf595d6b40878452b6d2ad7229056b686f8a16be" +webpack-dev-server@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.6.1.tgz#0b292a9da96daf80a65988f69f87b4166e5defe7" dependencies: ansi-html "0.0.7" + bonjour "^3.5.0" chokidar "^1.6.0" compression "^1.5.2" connect-history-api-fallback "^1.3.0" + del "^3.0.0" express "^4.13.3" html-entities "^1.2.0" http-proxy-middleware "~0.17.4" + internal-ip "^1.2.0" + loglevel "^1.4.1" opn "4.0.2" portfinder "^1.0.9" + selfsigned "^1.9.1" serve-index "^1.7.2" sockjs "0.3.18" - sockjs-client "1.1.2" + sockjs-client "1.1.4" spdy "^3.4.1" strip-ansi "^3.0.0" supports-color "^3.1.1" - webpack-dev-middleware "^1.9.0" + webpack-dev-middleware "^1.11.0" yargs "^6.0.0" webpack-sources@^0.1.0: @@ -5923,38 +6264,43 @@ webpack-sources@^0.1.0: source-list-map "~0.1.7" source-map "~0.5.3" -webpack-sources@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb" +webpack-sources@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" dependencies: - source-list-map "^1.1.1" + source-list-map "^2.0.0" source-map "~0.5.3" -webpack@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-2.6.1.tgz#2e0457f0abb1ac5df3ab106c69c672f236785f07" +webpack-stats-plugin@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/webpack-stats-plugin/-/webpack-stats-plugin-0.1.5.tgz#29e5f12ebfd53158d31d656a113ac1f7b86179d9" + +webpack@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.4.0.tgz#e9465b660ad79dd2d33874d968b31746ea9a8e63" dependencies: acorn "^5.0.0" acorn-dynamic-import "^2.0.0" - ajv "^4.7.0" - ajv-keywords "^1.1.1" + ajv "^5.1.5" + ajv-keywords "^2.0.0" async "^2.1.2" - enhanced-resolve "^3.0.0" + enhanced-resolve "^3.4.0" + escope "^3.6.0" interpret "^1.0.0" json-loader "^0.5.4" json5 "^0.5.1" loader-runner "^2.3.0" - loader-utils "^0.2.16" + loader-utils "^1.1.0" memory-fs "~0.4.1" mkdirp "~0.5.0" node-libs-browser "^2.0.0" source-map "^0.5.3" - supports-color "^3.1.0" - tapable "~0.2.5" - uglify-js "^2.8.27" - watchpack "^1.3.1" - webpack-sources "^0.2.3" - yargs "^6.0.0" + supports-color "^4.2.1" + tapable "^0.2.7" + uglifyjs-webpack-plugin "^0.4.6" + watchpack "^1.4.0" + webpack-sources "^1.0.1" + yargs "^8.0.2" websocket-driver@>=0.3.6, websocket-driver@>=0.5.1: version "0.6.5" @@ -5974,7 +6320,11 @@ which-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" -which@^1.1.1, which@^1.2.1: +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + +which@^1.1.1, which@^1.2.1, which@^1.2.9: version "1.2.12" resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" dependencies: @@ -6073,6 +6423,12 @@ yargs-parser@^4.2.0: dependencies: camelcase "^3.0.0" +yargs-parser@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-7.0.0.tgz#8d0ac42f16ea55debd332caf4c4038b3e3f5dfd9" + dependencies: + camelcase "^4.1.0" + yargs@^6.0.0: version "6.6.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208" @@ -6091,6 +6447,24 @@ yargs@^6.0.0: y18n "^3.2.1" yargs-parser "^4.2.0" +yargs@^8.0.2: + version "8.0.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360" + dependencies: + camelcase "^4.1.0" + cliui "^3.2.0" + decamelize "^1.1.1" + get-caller-file "^1.0.1" + os-locale "^2.0.0" + read-pkg-up "^2.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1" + yargs-parser "^7.0.0" + yargs@~3.10.0: version "3.10.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" |