feat(reports): hide metrics in frontend reports UI
Add useHiddenMetrics composable to filter hidden metrics from report keys. Update WootReports.vue to use the composable so hidden metrics are not fetched or displayed in the reports UI.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { computed } from 'vue';
|
||||
import { useStore } from 'dashboard/composables/store';
|
||||
|
||||
// Bidirectional alias mapping for consistency
|
||||
const METRIC_ALIASES = {
|
||||
avg_reply_time: 'reply_time',
|
||||
};
|
||||
|
||||
export function useHiddenMetrics() {
|
||||
const store = useStore();
|
||||
|
||||
const hiddenMetrics = computed(() => {
|
||||
return (
|
||||
store.getters.getCurrentAccount?.settings?.report_hidden_metrics || []
|
||||
);
|
||||
});
|
||||
|
||||
const isMetricHidden = metricKey => {
|
||||
const normalized = METRIC_ALIASES[metricKey] || metricKey;
|
||||
return hiddenMetrics.value.includes(normalized);
|
||||
};
|
||||
|
||||
const filterVisibleReportKeys = reportKeys => {
|
||||
// Filter out hidden metrics from reportKeys object
|
||||
return Object.fromEntries(
|
||||
Object.entries(reportKeys).filter(([, value]) => !isMetricHidden(value))
|
||||
);
|
||||
};
|
||||
|
||||
return { hiddenMetrics, isMetricHidden, filterVisibleReportKeys };
|
||||
}
|
||||
+8
-1
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import V4Button from 'dashboard/components-next/button/Button.vue';
|
||||
import { useAlert, useTrack } from 'dashboard/composables';
|
||||
import { useHiddenMetrics } from 'dashboard/composables/useHiddenMetrics';
|
||||
import ReportFilters from './ReportFilters.vue';
|
||||
import ReportContainer from '../ReportContainer.vue';
|
||||
import { GROUP_BY_FILTER } from '../constants';
|
||||
@@ -63,6 +64,10 @@ export default {
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
const { filterVisibleReportKeys } = useHiddenMetrics();
|
||||
return { filterVisibleReportKeys };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
from: 0,
|
||||
@@ -82,7 +87,7 @@ export default {
|
||||
return this.type === 'agent';
|
||||
},
|
||||
reportKeys() {
|
||||
return {
|
||||
const allKeys = {
|
||||
CONVERSATIONS: 'conversations_count',
|
||||
...(!this.isAgentType && {
|
||||
INCOMING_MESSAGES: 'incoming_messages_count',
|
||||
@@ -93,6 +98,8 @@ export default {
|
||||
RESOLUTION_COUNT: 'resolutions_count',
|
||||
REPLY_TIME: 'reply_time',
|
||||
};
|
||||
// Filter out hidden metrics
|
||||
return this.filterVisibleReportKeys(allKeys);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
|
||||
Reference in New Issue
Block a user