Skip to content

Commit e68f974

Browse files
authored
fix: No Export dropdown if audit log disabled (M2-10978) (#2237)
🔗 [Jira Ticket M2-10978](https://mindlogger.atlassian.net/browse/M2-10978) Changes include: - Display export modal immediately instead of opening dropdown with a single **Responses** option.
1 parent c20f8f9 commit e68f974

2 files changed

Lines changed: 20 additions & 25 deletions

File tree

src/modules/Dashboard/components/HeaderOptions/HeaderOptions.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ describe('HeaderOptions show or hide depending on feature flag', () => {
135135

136136
test('header for enableAuditLogs off', () => {
137137
fireEvent.click(screen.getByTestId('header-option-export-button'));
138-
expect(screen.queryByTestId('header-option-response-data-button')).toBeInTheDocument();
139-
expect(screen.queryByTestId('header-option-audit-logs-button')).not.toBeInTheDocument();
138+
139+
expect(screen.queryByTestId('header-option-export-menu')).not.toBeInTheDocument();
140+
expect(screen.getByTestId('response-data-export-settings')).toBeInTheDocument();
141+
expect(spyMixpanelTrack).toHaveBeenCalledWith({ action: MixpanelEventType.ExportDataClick });
140142
});
141143
});

src/modules/Dashboard/components/HeaderOptions/HeaderOptions.tsx

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ export const HeaderOptions = () => {
3333
const exportButtonRef = useRef<HTMLButtonElement>(null);
3434

3535
const handleOpenExportMenu = () => {
36-
const fullAccess = checkIfFullAccess(roles);
36+
const canExportAuditLogs = checkIfFullAccess(roles) && featureFlags.enableAuditLogs;
3737

38-
if (fullAccess) {
38+
if (canExportAuditLogs) {
3939
setShowExportMenu(true);
4040
} else {
4141
setIsResponseDataExportOpen(true);
@@ -67,27 +67,20 @@ export const HeaderOptions = () => {
6767
const canAccessData = checkIfCanAccessData(roles);
6868
const canEdit = checkIfCanEdit(roles);
6969

70-
const getExportActions = () => {
71-
const actions = [
72-
{
73-
icon: <Svg id="response-data" />,
74-
action: handleOpenResponseData,
75-
title: t('dataExport.responseData.menuCaption'),
76-
'data-testid': 'header-option-response-data-button',
77-
},
78-
];
79-
80-
if (featureFlags.enableAuditLogs) {
81-
actions.push({
82-
icon: <Svg id="audit-logs" />,
83-
action: handleOpenAuditLogs,
84-
title: t('dataExport.auditLogs.menuCaption'),
85-
'data-testid': 'header-option-audit-logs-button',
86-
});
87-
}
88-
89-
return actions;
90-
};
70+
const getExportActions = () => [
71+
{
72+
icon: <Svg id="response-data" />,
73+
action: handleOpenResponseData,
74+
title: t('dataExport.responseData.menuCaption'),
75+
'data-testid': 'header-option-response-data-button',
76+
},
77+
{
78+
icon: <Svg id="audit-logs" />,
79+
action: handleOpenAuditLogs,
80+
title: t('dataExport.auditLogs.menuCaption'),
81+
'data-testid': 'header-option-audit-logs-button',
82+
},
83+
];
9184

9285
return canEdit || canAccessData ? (
9386
<StyledFlexTopCenter sx={{ gap: 1, ml: 'auto' }}>

0 commit comments

Comments
 (0)