diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /app/assets/javascripts/vue_shared/components/alert_details_table.vue | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/alert_details_table.vue')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/alert_details_table.vue | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/app/assets/javascripts/vue_shared/components/alert_details_table.vue b/app/assets/javascripts/vue_shared/components/alert_details_table.vue index c94e784c01e..34f6d384f7b 100644 --- a/app/assets/javascripts/vue_shared/components/alert_details_table.vue +++ b/app/assets/javascripts/vue_shared/components/alert_details_table.vue @@ -1,20 +1,38 @@ <script> import { GlLoadingIcon, GlTable } from '@gitlab/ui'; +import { reduce } from 'lodash'; import { s__ } from '~/locale'; import { capitalizeFirstCharacter, convertToSentenceCase, splitCamelCase, } from '~/lib/utils/text_utility'; +import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; const thClass = 'gl-bg-transparent! gl-border-1! gl-border-b-solid! gl-border-gray-200!'; const tdClass = 'gl-border-gray-100! gl-p-5!'; +const allowedFields = [ + 'iid', + 'title', + 'severity', + 'status', + 'startedAt', + 'eventCount', + 'monitoringTool', + 'service', + 'description', + 'endedAt', + 'details', + 'hosts', +]; + export default { components: { GlLoadingIcon, GlTable, }, + mixins: [glFeatureFlagsMixin()], props: { alert: { type: Object, @@ -42,14 +60,37 @@ export default { }, ], computed: { + flaggedAllowedFields() { + return this.shouldDisplayEnvironment ? [...allowedFields, 'environment'] : allowedFields; + }, items() { if (!this.alert) { return []; } - return Object.entries(this.alert).map(([fieldName, value]) => ({ - fieldName, - value, - })); + return reduce( + this.alert, + (allowedItems, fieldValue, fieldName) => { + if (this.isAllowed(fieldName)) { + let value; + if (fieldName === 'environment') { + value = fieldValue?.name; + } else { + value = fieldValue; + } + return [...allowedItems, { fieldName, value }]; + } + return allowedItems; + }, + [], + ); + }, + shouldDisplayEnvironment() { + return this.glFeatures.exposeEnvironmentPathInAlertDetails; + }, + }, + methods: { + isAllowed(fieldName) { + return this.flaggedAllowedFields.includes(fieldName); }, }, }; |