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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/ci/ci_environments_dropdown/ci_environments_dropdown.vue (renamed from app/assets/javascripts/ci/ci_variable_list/components/ci_environments_dropdown.vue)37
-rw-r--r--app/assets/javascripts/ci/ci_environments_dropdown/constants.js14
-rw-r--r--app/assets/javascripts/ci/ci_environments_dropdown/graphql/queries/group_environments.query.graphql (renamed from app/assets/javascripts/ci/ci_variable_list/graphql/queries/group_environments.query.graphql)0
-rw-r--r--app/assets/javascripts/ci/ci_environments_dropdown/graphql/queries/project_environments.query.graphql (renamed from app/assets/javascripts/ci/ci_variable_list/graphql/queries/project_environments.query.graphql)0
-rw-r--r--app/assets/javascripts/ci/ci_environments_dropdown/utils.js (renamed from app/assets/javascripts/ci/ci_variable_list/utils.js)13
-rw-r--r--app/assets/javascripts/ci/ci_variable_list/components/ci_group_variables.vue2
-rw-r--r--app/assets/javascripts/ci/ci_variable_list/components/ci_project_variables.vue2
-rw-r--r--app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue5
-rw-r--r--app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue6
-rw-r--r--app/assets/javascripts/ci/ci_variable_list/components/ci_variable_table.vue2
-rw-r--r--app/assets/javascripts/ci/ci_variable_list/constants.js9
-rw-r--r--app/assets/javascripts/ci/common/private/ci_environments_dropdown.js9
-rw-r--r--app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue26
-rw-r--r--app/services/draft_notes/destroy_service.rb8
-rw-r--r--app/services/merge_requests/approval_service.rb1
-rw-r--r--app/services/merge_requests/remove_approval_service.rb1
16 files changed, 87 insertions, 48 deletions
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_environments_dropdown.vue b/app/assets/javascripts/ci/ci_environments_dropdown/ci_environments_dropdown.vue
index 77af643cbb3..2d2e3e280c0 100644
--- a/app/assets/javascripts/ci/ci_variable_list/components/ci_environments_dropdown.vue
+++ b/app/assets/javascripts/ci/ci_environments_dropdown/ci_environments_dropdown.vue
@@ -3,8 +3,12 @@ import { debounce, uniq } from 'lodash';
import { GlDropdownDivider, GlDropdownItem, GlCollapsibleListbox, GlSprintf } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { __, s__, sprintf } from '~/locale';
-import { convertEnvironmentScope } from '../utils';
-import { ENVIRONMENT_QUERY_LIMIT } from '../constants';
+import { convertEnvironmentScope } from './utils';
+import {
+ ALL_ENVIRONMENTS_OPTION,
+ ENVIRONMENT_QUERY_LIMIT,
+ NO_ENVIRONMENT_OPTION,
+} from './constants';
export default {
name: 'CiEnvironmentsDropdown',
@@ -16,10 +20,20 @@ export default {
},
mixins: [glFeatureFlagsMixin()],
props: {
+ isEnvironmentRequired: {
+ type: Boolean,
+ required: false,
+ default: true,
+ },
areEnvironmentsLoading: {
type: Boolean,
required: true,
},
+ canCreateWildcard: {
+ type: Boolean,
+ required: false,
+ default: true,
+ },
environments: {
type: Array,
required: true,
@@ -51,22 +65,31 @@ export default {
searchedEnvironments() {
let filtered = this.environments;
- // If there is no search term, make sure to include *
- if (!this.searchTerm) {
- filtered = uniq([...filtered, '*']);
- }
-
// add custom env scope if it matches the search term
if (this.customEnvScope && this.customEnvScope.startsWith(this.searchTerm)) {
filtered = uniq([...filtered, this.customEnvScope]);
}
+ // If there is no search term, make sure to include *
+ if (!this.searchTerm) {
+ filtered = uniq([...filtered, ALL_ENVIRONMENTS_OPTION.type]);
+
+ // lastly, add Not Applicable (None) as the first option if isEnvironmentRequired is true
+ if (!this.isEnvironmentRequired) {
+ filtered = [NO_ENVIRONMENT_OPTION.type, ...filtered];
+ }
+ }
+
return filtered.sort().map((environment) => ({
value: environment,
text: environment,
}));
},
shouldRenderCreateButton() {
+ if (!this.canCreateWildcard) {
+ return false;
+ }
+
return (
this.searchTerm && ![...this.environments, this.customEnvScope].includes(this.searchTerm)
);
diff --git a/app/assets/javascripts/ci/ci_environments_dropdown/constants.js b/app/assets/javascripts/ci/ci_environments_dropdown/constants.js
new file mode 100644
index 00000000000..98e543a75d0
--- /dev/null
+++ b/app/assets/javascripts/ci/ci_environments_dropdown/constants.js
@@ -0,0 +1,14 @@
+import { __ } from '~/locale';
+
+export const ENVIRONMENT_QUERY_LIMIT = 30;
+
+export const ALL_ENVIRONMENTS_OPTION = {
+ type: '*',
+ text: __('All (default)'),
+};
+
+export const NO_ENVIRONMENT_OPTION = {
+ // TODO: This is a placeholder value. It will be replaced with the actual value used once it's implemented on the backend
+ type: 'Not applicable',
+ text: __('Not applicable'),
+};
diff --git a/app/assets/javascripts/ci/ci_variable_list/graphql/queries/group_environments.query.graphql b/app/assets/javascripts/ci/ci_environments_dropdown/graphql/queries/group_environments.query.graphql
index 5768d370474..5768d370474 100644
--- a/app/assets/javascripts/ci/ci_variable_list/graphql/queries/group_environments.query.graphql
+++ b/app/assets/javascripts/ci/ci_environments_dropdown/graphql/queries/group_environments.query.graphql
diff --git a/app/assets/javascripts/ci/ci_variable_list/graphql/queries/project_environments.query.graphql b/app/assets/javascripts/ci/ci_environments_dropdown/graphql/queries/project_environments.query.graphql
index 26d1b6a3aaa..26d1b6a3aaa 100644
--- a/app/assets/javascripts/ci/ci_variable_list/graphql/queries/project_environments.query.graphql
+++ b/app/assets/javascripts/ci/ci_environments_dropdown/graphql/queries/project_environments.query.graphql
diff --git a/app/assets/javascripts/ci/ci_variable_list/utils.js b/app/assets/javascripts/ci/ci_environments_dropdown/utils.js
index a7e020206ea..093b04dab0c 100644
--- a/app/assets/javascripts/ci/ci_variable_list/utils.js
+++ b/app/assets/javascripts/ci/ci_environments_dropdown/utils.js
@@ -1,4 +1,4 @@
-import { allEnvironments } from './constants';
+import { ALL_ENVIRONMENTS_OPTION, NO_ENVIRONMENT_OPTION } from './constants';
/**
* This function job is to convert the * wildcard to text when applicable
@@ -10,11 +10,14 @@ import { allEnvironments } from './constants';
*/
export const convertEnvironmentScope = (environmentScope = '') => {
- if (environmentScope === allEnvironments.type || !environmentScope) {
- return allEnvironments.text;
+ switch (environmentScope) {
+ case ALL_ENVIRONMENTS_OPTION.type || '':
+ return ALL_ENVIRONMENTS_OPTION.text;
+ case NO_ENVIRONMENT_OPTION.type:
+ return NO_ENVIRONMENT_OPTION.text;
+ default:
+ return environmentScope;
}
-
- return environmentScope;
};
/**
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_group_variables.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_group_variables.vue
index 842d88e1267..b118d54d2b0 100644
--- a/app/assets/javascripts/ci/ci_variable_list/components/ci_group_variables.vue
+++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_group_variables.vue
@@ -2,8 +2,8 @@
import { TYPENAME_GROUP } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
+import { getGroupEnvironments } from '~/ci/common/private/ci_environments_dropdown';
import { ADD_MUTATION_ACTION, DELETE_MUTATION_ACTION, UPDATE_MUTATION_ACTION } from '../constants';
-import getGroupEnvironments from '../graphql/queries/group_environments.query.graphql';
import getGroupVariables from '../graphql/queries/group_variables.query.graphql';
import addGroupVariable from '../graphql/mutations/group_add_variable.mutation.graphql';
import deleteGroupVariable from '../graphql/mutations/group_delete_variable.mutation.graphql';
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_project_variables.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_project_variables.vue
index 43938e9b88f..822a2b01f24 100644
--- a/app/assets/javascripts/ci/ci_variable_list/components/ci_project_variables.vue
+++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_project_variables.vue
@@ -2,8 +2,8 @@
import { TYPENAME_PROJECT } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
+import { getProjectEnvironments } from '~/ci/common/private/ci_environments_dropdown';
import { ADD_MUTATION_ACTION, DELETE_MUTATION_ACTION, UPDATE_MUTATION_ACTION } from '../constants';
-import getProjectEnvironments from '../graphql/queries/project_environments.query.graphql';
import getProjectVariables from '../graphql/queries/project_variables.query.graphql';
import addProjectVariable from '../graphql/mutations/project_add_variable.mutation.graphql';
import deleteProjectVariable from '../graphql/mutations/project_delete_variable.mutation.graphql';
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue
index 2ad6c7c6578..1a4c5f3b502 100644
--- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue
+++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue
@@ -20,8 +20,8 @@ import { DRAWER_Z_INDEX } from '~/lib/utils/constants';
import { getContentWrapperHeight } from '~/lib/utils/dom_utils';
import { helpPagePath } from '~/helpers/help_page_helper';
import Tracking from '~/tracking';
+import CiEnvironmentsDropdown from '~/ci/common/private/ci_environments_dropdown';
import {
- allEnvironments,
defaultVariableState,
DRAWER_EVENT_LABEL,
EDIT_VARIABLE_ACTION,
@@ -34,7 +34,6 @@ import {
variableOptions,
WHITESPACE_REG_EX,
} from '../constants';
-import CiEnvironmentsDropdown from './ci_environments_dropdown.vue';
import { awsTokenList } from './ci_variable_autocomplete_tokens';
const trackingMixin = Tracking.mixin({ label: DRAWER_EVENT_LABEL });
@@ -43,7 +42,7 @@ const KEY_REGEX = /^\w+$/;
export const i18n = {
addVariable: s__('CiVariables|Add variable'),
cancel: __('Cancel'),
- defaultScope: allEnvironments.text,
+ defaultScope: __('All (default)'),
deleteVariable: s__('CiVariables|Delete variable'),
editVariable: s__('CiVariables|Edit variable'),
environments: __('Environments'),
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue
index 011a424b6c2..609b8523612 100644
--- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue
+++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue
@@ -3,11 +3,13 @@ import { createAlert } from '~/alert';
import { __ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { reportToSentry } from '~/ci/utils';
-import { mapEnvironmentNames } from '../utils';
+import {
+ ENVIRONMENT_QUERY_LIMIT,
+ mapEnvironmentNames,
+} from '~/ci/common/private/ci_environments_dropdown';
import {
ADD_MUTATION_ACTION,
DELETE_MUTATION_ACTION,
- ENVIRONMENT_QUERY_LIMIT,
SORT_DIRECTIONS,
UPDATE_MUTATION_ACTION,
mapMutationActionToToast,
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_table.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_table.vue
index 86287d586ec..901bd39930a 100644
--- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_table.vue
+++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_table.vue
@@ -15,13 +15,13 @@ import {
} from '@gitlab/ui';
import { __, s__, sprintf } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
+import { convertEnvironmentScope } from '~/ci/common/private/ci_environments_dropdown';
import {
DEFAULT_EXCEEDS_VARIABLE_LIMIT_TEXT,
EXCEEDS_VARIABLE_LIMIT_TEXT,
MAXIMUM_VARIABLE_LIMIT_REACHED,
variableTypes,
} from '../constants';
-import { convertEnvironmentScope } from '../utils';
export default {
defaultFields: [
diff --git a/app/assets/javascripts/ci/ci_variable_list/constants.js b/app/assets/javascripts/ci/ci_variable_list/constants.js
index 4ec7333f465..c4f92fed829 100644
--- a/app/assets/javascripts/ci/ci_variable_list/constants.js
+++ b/app/assets/javascripts/ci/ci_variable_list/constants.js
@@ -1,7 +1,5 @@
import { __, s__, sprintf } from '~/locale';
-export const ENVIRONMENT_QUERY_LIMIT = 30;
-
export const MASKED_VALUE_MIN_LENGTH = 8;
export const WHITESPACE_REG_EX = /\s/;
@@ -15,18 +13,13 @@ export const variableTypes = {
fileType: 'FILE',
};
-export const allEnvironments = {
- type: '*',
- text: __('All (default)'),
-};
-
export const variableOptions = [
{ value: variableTypes.envType, text: __('Variable (default)') },
{ value: variableTypes.fileType, text: __('File') },
];
export const defaultVariableState = {
- environmentScope: allEnvironments.type,
+ environmentScope: '*',
key: '',
masked: false,
protected: false,
diff --git a/app/assets/javascripts/ci/common/private/ci_environments_dropdown.js b/app/assets/javascripts/ci/common/private/ci_environments_dropdown.js
new file mode 100644
index 00000000000..f8958f9600c
--- /dev/null
+++ b/app/assets/javascripts/ci/common/private/ci_environments_dropdown.js
@@ -0,0 +1,9 @@
+import CiEnvironmentsDropdown from '~/ci/ci_environments_dropdown/ci_environments_dropdown.vue';
+
+export default CiEnvironmentsDropdown;
+
+export { getGroupEnvironments } from '~/ci/ci_environments_dropdown/graphql/queries/group_environments.query.graphql';
+export { getProjectEnvironments } from '~/ci/ci_environments_dropdown/graphql/queries/project_environments.query.graphql';
+
+export { ENVIRONMENT_QUERY_LIMIT } from '~/ci/ci_environments_dropdown/constants';
+export * from '~/ci/ci_environments_dropdown/utils';
diff --git a/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue b/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue
index 6ff7d58fd9e..89ab184d808 100644
--- a/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue
+++ b/app/assets/javascripts/packages_and_registries/settings/group/components/group_settings_app.vue
@@ -1,6 +1,6 @@
<script>
import { GlAlert } from '@gitlab/ui';
-import { n__ } from '~/locale';
+import { __ } from '~/locale';
import PackagesSettings from '~/packages_and_registries/settings/group/components/packages_settings.vue';
import PackagesForwardingSettings from '~/packages_and_registries/settings/group/components/packages_forwarding_settings.vue';
import DependencyProxySettings from '~/packages_and_registries/settings/group/components/dependency_proxy_settings.vue';
@@ -50,21 +50,13 @@ export default {
dismissAlert() {
this.alertMessage = null;
},
- handleSuccess(amount = 1) {
- const successMessage = n__(
- 'Setting saved successfully',
- 'Settings saved successfully',
- amount,
- );
+ handleSuccess() {
+ const successMessage = __('Settings saved successfully.');
this.$toast.show(successMessage);
this.dismissAlert();
},
- handleError(amount = 1) {
- const errorMessage = n__(
- 'An error occurred while saving the setting',
- 'An error occurred while saving the settings',
- amount,
- );
+ handleError() {
+ const errorMessage = __('An error occurred while saving the settings.');
this.alertMessage = errorMessage;
},
},
@@ -81,14 +73,14 @@ export default {
class="settings-section-no-bottom"
:package-settings="packageSettings"
:is-loading="isLoading"
- @success="handleSuccess(2)"
- @error="handleError(2)"
+ @success="handleSuccess"
+ @error="handleError"
/>
<packages-forwarding-settings
:forward-settings="packageSettings"
- @success="handleSuccess(2)"
- @error="handleError(2)"
+ @success="handleSuccess"
+ @error="handleError"
/>
<dependency-proxy-settings
diff --git a/app/services/draft_notes/destroy_service.rb b/app/services/draft_notes/destroy_service.rb
index ddca0debb03..6c7b0dfdbd7 100644
--- a/app/services/draft_notes/destroy_service.rb
+++ b/app/services/draft_notes/destroy_service.rb
@@ -15,9 +15,11 @@ module DraftNotes
private
def clear_highlight_diffs_cache(drafts)
- if drafts.any? { |draft| draft.diff_file&.unfolded? }
- merge_request.diffs.clear_cache
- end
+ merge_request.diffs.clear_cache if unfolded_drafts?(drafts)
+ end
+
+ def unfolded_drafts?(drafts)
+ drafts.any? { |draft| draft.diff_file&.unfolded? }
end
end
end
diff --git a/app/services/merge_requests/approval_service.rb b/app/services/merge_requests/approval_service.rb
index f9857cdad39..8458eaeaf57 100644
--- a/app/services/merge_requests/approval_service.rb
+++ b/app/services/merge_requests/approval_service.rb
@@ -4,6 +4,7 @@ module MergeRequests
class ApprovalService < MergeRequests::BaseService
def execute(merge_request)
return unless eligible_for_approval?(merge_request)
+ return if merge_request.merged?
approval = merge_request.approvals.new(
user: current_user,
diff --git a/app/services/merge_requests/remove_approval_service.rb b/app/services/merge_requests/remove_approval_service.rb
index c0bb257eda6..b8f512bdb2c 100644
--- a/app/services/merge_requests/remove_approval_service.rb
+++ b/app/services/merge_requests/remove_approval_service.rb
@@ -5,6 +5,7 @@ module MergeRequests
# rubocop: disable CodeReuse/ActiveRecord
def execute(merge_request)
return unless merge_request.approved_by?(current_user)
+ return if merge_request.merged?
# paranoid protection against running wrong deletes
return unless merge_request.id && current_user.id