summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/alert_details_table.vue
diff options
context:
space:
mode:
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.vue49
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);
},
},
};