mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-19 18:08:14 +00:00
* review comment * i18n fix * review comments * review comments * Fix import order in report_problem.test.tsx Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> * Add distinctUntilChanged to observeIsFreeEdition and fix skip-screen condition - Added distinctUntilChanged() to observeIsFreeEdition to match sibling helpers - Removed attachLogsEnabled from skip-screen condition as it controls file picker for post composition, not report email - Removed unused attachLogsEnabled prop and observable from settings report_problem component - Updated tests to reflect the removed condition Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> * Remove unused Screens import from report_problem test Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor Agent <agent@cursor.com> Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> Co-authored-by: Cursor <cursoragent@cursor.com>
88 lines
3.0 KiB
TypeScript
88 lines
3.0 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {useCallback} from 'react';
|
|
import {defineMessages, useIntl} from 'react-intl';
|
|
|
|
import SettingItem from '@components/settings/item';
|
|
import {Screens} from '@constants';
|
|
import {DEFAULT_REPORT_A_PROBLEM_EMAIL} from '@constants/report_a_problem';
|
|
import {navigateToSettingsScreen} from '@screens/navigation';
|
|
import {emailLogs, getDefaultReportAProblemLink} from '@utils/share_logs';
|
|
import {tryOpenURL} from '@utils/url';
|
|
|
|
import type {ReportAProblemMetadata} from '@typings/screens/report_a_problem';
|
|
|
|
type ReportProblemProps = {
|
|
allowDownloadLogs?: boolean;
|
|
isFreeEdition?: boolean;
|
|
reportAProblemMail?: string;
|
|
reportAProblemType?: string;
|
|
siteName?: string;
|
|
metadata: ReportAProblemMetadata;
|
|
}
|
|
|
|
const messages = defineMessages({
|
|
downloadLogs: {id: 'report_problem.download_logs.title', defaultMessage: 'Download app logs'},
|
|
reportProblem: {id: 'report_problem.title', defaultMessage: 'Report a problem'},
|
|
});
|
|
|
|
const ReportProblem = ({
|
|
allowDownloadLogs,
|
|
isFreeEdition,
|
|
reportAProblemMail,
|
|
reportAProblemType,
|
|
siteName,
|
|
metadata,
|
|
}: ReportProblemProps) => {
|
|
const intl = useIntl();
|
|
const onlyAllowLogs = allowDownloadLogs && reportAProblemType === 'hidden';
|
|
const skipReportAProblemScreen =
|
|
(reportAProblemType === 'email' && !allowDownloadLogs) ||
|
|
(reportAProblemType === 'default' && isFreeEdition === true) ||
|
|
(reportAProblemType === 'default' && isFreeEdition === false && !allowDownloadLogs);
|
|
|
|
const onPress = useCallback(() => {
|
|
if (skipReportAProblemScreen) {
|
|
if (reportAProblemType === 'default' && isFreeEdition) {
|
|
tryOpenURL(getDefaultReportAProblemLink(false));
|
|
} else {
|
|
const mail = reportAProblemType === 'default' ? DEFAULT_REPORT_A_PROBLEM_EMAIL : reportAProblemMail;
|
|
emailLogs(metadata, siteName, mail, !allowDownloadLogs);
|
|
}
|
|
return;
|
|
}
|
|
const message = onlyAllowLogs ? messages.downloadLogs : messages.reportProblem;
|
|
const title = intl.formatMessage(message);
|
|
navigateToSettingsScreen(Screens.REPORT_PROBLEM, {title});
|
|
}, [allowDownloadLogs, intl, isFreeEdition, metadata, onlyAllowLogs, reportAProblemMail, reportAProblemType, siteName, skipReportAProblemScreen]);
|
|
|
|
if (onlyAllowLogs) {
|
|
return (
|
|
<SettingItem
|
|
onPress={onPress}
|
|
optionName='download_logs'
|
|
separator={false}
|
|
testID='settings.download_logs.option'
|
|
type='link'
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (reportAProblemType === 'hidden') {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<SettingItem
|
|
onPress={onPress}
|
|
optionName='report_problem'
|
|
separator={false}
|
|
testID='settings.report_problem.option'
|
|
type='link'
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default ReportProblem;
|