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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-12 09:09:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-12 09:09:53 +0300
commit90156f527b43a15e794c3351ecfc59aff42c440a (patch)
treea59318246adf4297b3911f442b6a789fd38d35a6 /app/assets/javascripts
parent737684a392db1178770ad5b1d20b64386aadcac5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue21
-rw-r--r--app/assets/javascripts/monitoring/components/alert_widget.vue8
-rw-r--r--app/assets/javascripts/monitoring/components/alert_widget_form.vue32
-rw-r--r--app/assets/javascripts/monitoring/services/alerts_service.js25
-rw-r--r--app/assets/javascripts/monitoring/validators.js13
5 files changed, 67 insertions, 32 deletions
diff --git a/app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue b/app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue
index 7b703c5ede1..5002a8fe85d 100644
--- a/app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue
+++ b/app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue
@@ -1,5 +1,5 @@
<script>
-import { GlTable, GlDeprecatedButton, GlModalDirective, GlIcon } from '@gitlab/ui';
+import { GlTable, GlButton, GlModalDirective, GlIcon } from '@gitlab/ui';
import { s__, __ } from '~/locale';
import { mapState, mapActions } from 'vuex';
import { ADD_CI_VARIABLE_MODAL_ID } from '../constants';
@@ -51,7 +51,7 @@ export default {
],
components: {
GlTable,
- GlDeprecatedButton,
+ GlButton,
GlIcon,
CiVariablePopover,
},
@@ -147,14 +147,14 @@ export default {
</div>
</template>
<template #cell(actions)="{ item }">
- <gl-deprecated-button
+ <gl-button
ref="edit-ci-variable"
v-gl-modal-directive="$options.modalId"
+ icon="pencil"
+ :aria-label="__('Edit')"
data-qa-selector="edit_ci_variable_button"
@click="editVariable(item)"
- >
- <gl-icon :size="$options.iconSize" name="pencil" />
- </gl-deprecated-button>
+ />
</template>
<template #empty>
<p ref="empty-variables" class="text-center empty-variables text-plain">
@@ -166,20 +166,21 @@ export default {
class="ci-variable-actions d-flex justify-content-end"
:class="{ 'justify-content-center': !tableIsNotEmpty }"
>
- <gl-deprecated-button
+ <gl-button
v-if="tableIsNotEmpty"
ref="secret-value-reveal-button"
data-qa-selector="reveal_ci_variable_value_button"
class="gl-mr-3"
@click="toggleValues(!valuesHidden)"
- >{{ valuesButtonText }}</gl-deprecated-button
+ >{{ valuesButtonText }}</gl-button
>
- <gl-deprecated-button
+ <gl-button
ref="add-ci-variable"
v-gl-modal-directive="$options.modalId"
data-qa-selector="add_ci_variable_button"
variant="success"
- >{{ __('Add Variable') }}</gl-deprecated-button
+ category="primary"
+ >{{ __('Add Variable') }}</gl-button
>
</div>
</div>
diff --git a/app/assets/javascripts/monitoring/components/alert_widget.vue b/app/assets/javascripts/monitoring/components/alert_widget.vue
index 5562981fe1c..3476b180699 100644
--- a/app/assets/javascripts/monitoring/components/alert_widget.vue
+++ b/app/assets/javascripts/monitoring/components/alert_widget.vue
@@ -174,8 +174,8 @@ export default {
handleSetApiAction(apiAction) {
this.apiAction = apiAction;
},
- handleCreate({ operator, threshold, prometheus_metric_id }) {
- const newAlert = { operator, threshold, prometheus_metric_id };
+ handleCreate({ operator, threshold, prometheus_metric_id, runbookUrl }) {
+ const newAlert = { operator, threshold, prometheus_metric_id, runbookUrl };
this.isLoading = true;
this.service
.createAlert(newAlert)
@@ -189,8 +189,8 @@ export default {
this.isLoading = false;
});
},
- handleUpdate({ alert, operator, threshold }) {
- const updatedAlert = { operator, threshold };
+ handleUpdate({ alert, operator, threshold, runbookUrl }) {
+ const updatedAlert = { operator, threshold, runbookUrl };
this.isLoading = true;
this.service
.updateAlert(alert, updatedAlert)
diff --git a/app/assets/javascripts/monitoring/components/alert_widget_form.vue b/app/assets/javascripts/monitoring/components/alert_widget_form.vue
index 60558c0ba14..ef9dfce4aa9 100644
--- a/app/assets/javascripts/monitoring/components/alert_widget_form.vue
+++ b/app/assets/javascripts/monitoring/components/alert_widget_form.vue
@@ -88,6 +88,7 @@ export default {
operator: null,
threshold: null,
prometheusMetricId: null,
+ runbookUrl: null,
selectedAlert: {},
alertQuery: '',
};
@@ -116,7 +117,8 @@ export default {
this.operator &&
this.threshold === Number(this.threshold) &&
(this.operator !== this.selectedAlert.operator ||
- this.threshold !== this.selectedAlert.threshold)
+ this.threshold !== this.selectedAlert.threshold ||
+ this.runbookUrl !== this.selectedAlert.runbookUrl)
);
},
submitAction() {
@@ -153,13 +155,17 @@ export default {
const existingAlert = this.alertsToManage[existingAlertPath];
if (existingAlert) {
+ const { operator, threshold, runbookUrl } = existingAlert;
+
this.selectedAlert = existingAlert;
- this.operator = existingAlert.operator;
- this.threshold = existingAlert.threshold;
+ this.operator = operator;
+ this.threshold = threshold;
+ this.runbookUrl = runbookUrl;
} else {
this.selectedAlert = {};
this.operator = this.operators.greaterThan;
this.threshold = null;
+ this.runbookUrl = null;
}
this.prometheusMetricId = queryId;
@@ -168,13 +174,13 @@ export default {
this.resetAlertData();
this.$emit('cancel');
},
- handleSubmit(e) {
- e.preventDefault();
+ handleSubmit() {
this.$emit(this.submitAction, {
alert: this.selectedAlert.alert_path,
operator: this.operator,
threshold: this.threshold,
prometheus_metric_id: this.prometheusMetricId,
+ runbookUrl: this.runbookUrl,
});
},
handleShown() {
@@ -189,6 +195,7 @@ export default {
this.threshold = null;
this.prometheusMetricId = null;
this.selectedAlert = {};
+ this.runbookUrl = null;
},
getAlertFormActionTrackingOption() {
const label = `${this.submitAction}_alert`;
@@ -217,7 +224,7 @@ export default {
:modal-id="modalId"
:ok-variant="submitAction === 'delete' ? 'danger' : 'success'"
:ok-disabled="formDisabled"
- @ok="handleSubmit"
+ @ok.prevent="handleSubmit"
@hidden="handleHidden"
@shown="handleShown"
>
@@ -259,7 +266,7 @@ export default {
</gl-deprecated-dropdown-item>
</gl-deprecated-dropdown>
</gl-form-group>
- <gl-button-group class="mb-2" :label="s__('PrometheusAlerts|Operator')">
+ <gl-button-group class="mb-3" :label="s__('PrometheusAlerts|Operator')">
<gl-deprecated-button
:class="{ active: operator === operators.greaterThan }"
:disabled="formDisabled"
@@ -296,11 +303,16 @@ export default {
</gl-form-group>
<gl-form-group
v-if="glFeatures.alertRunbooks"
- :label="s__('PrometheusAlerts|Runbook')"
+ :label="s__('PrometheusAlerts|Runbook URL (optional)')"
label-for="alert-runbook"
- data-testid="alertRunbookField"
>
- <gl-form-input id="alert-runbook" :disabled="formDisabled" type="text" />
+ <gl-form-input
+ id="alert-runbook"
+ v-model="runbookUrl"
+ :disabled="formDisabled"
+ data-testid="alertRunbookField"
+ type="text"
+ />
</gl-form-group>
</div>
<template #modal-ok>
diff --git a/app/assets/javascripts/monitoring/services/alerts_service.js b/app/assets/javascripts/monitoring/services/alerts_service.js
index 4b7337972fe..a67675f1a3d 100644
--- a/app/assets/javascripts/monitoring/services/alerts_service.js
+++ b/app/assets/javascripts/monitoring/services/alerts_service.js
@@ -1,28 +1,39 @@
import axios from '~/lib/utils/axios_utils';
+const mapAlert = ({ runbook_url, ...alert }) => {
+ return { runbookUrl: runbook_url, ...alert };
+};
+
export default class AlertsService {
constructor({ alertsEndpoint }) {
this.alertsEndpoint = alertsEndpoint;
}
getAlerts() {
- return axios.get(this.alertsEndpoint).then(resp => resp.data);
+ return axios.get(this.alertsEndpoint).then(resp => mapAlert(resp.data));
}
- createAlert({ prometheus_metric_id, operator, threshold }) {
+ createAlert({ prometheus_metric_id, operator, threshold, runbookUrl }) {
return axios
- .post(this.alertsEndpoint, { prometheus_metric_id, operator, threshold })
- .then(resp => resp.data);
+ .post(this.alertsEndpoint, {
+ prometheus_metric_id,
+ operator,
+ threshold,
+ runbook_url: runbookUrl,
+ })
+ .then(resp => mapAlert(resp.data));
}
// eslint-disable-next-line class-methods-use-this
readAlert(alertPath) {
- return axios.get(alertPath).then(resp => resp.data);
+ return axios.get(alertPath).then(resp => mapAlert(resp.data));
}
// eslint-disable-next-line class-methods-use-this
- updateAlert(alertPath, { operator, threshold }) {
- return axios.put(alertPath, { operator, threshold }).then(resp => resp.data);
+ updateAlert(alertPath, { operator, threshold, runbookUrl }) {
+ return axios
+ .put(alertPath, { operator, threshold, runbook_url: runbookUrl })
+ .then(resp => mapAlert(resp.data));
}
// eslint-disable-next-line class-methods-use-this
diff --git a/app/assets/javascripts/monitoring/validators.js b/app/assets/javascripts/monitoring/validators.js
index cd426f1a221..c6b323f6360 100644
--- a/app/assets/javascripts/monitoring/validators.js
+++ b/app/assets/javascripts/monitoring/validators.js
@@ -1,3 +1,12 @@
+import { isSafeURL } from '~/lib/utils/url_utility';
+
+const isRunbookUrlValid = runbookUrl => {
+ if (!runbookUrl) {
+ return true;
+ }
+ return isSafeURL(runbookUrl);
+};
+
// Prop validator for alert information, expecting an object like the example below.
//
// {
@@ -8,6 +17,7 @@
// query: "rate(http_requests_total[5m])[30m:1m]",
// threshold: 0.002,
// title: "Core Usage (Total)",
+// runbookUrl: "https://www.gitlab.com/my-project/-/wikis/runbook"
// }
// }
export function alertsValidator(value) {
@@ -19,7 +29,8 @@ export function alertsValidator(value) {
alert.metricId &&
typeof alert.metricId === 'string' &&
alert.operator &&
- typeof alert.threshold === 'number'
+ typeof alert.threshold === 'number' &&
+ isRunbookUrlValid(alert.runbookUrl)
);
});
}