mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-05 18:38:54 +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>
90 lines
3.4 KiB
TypeScript
90 lines
3.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import TurboLogger from '@mattermost/react-native-turbo-log';
|
|
import {defineMessages} from 'react-intl';
|
|
import {Alert} from 'react-native';
|
|
import Share from 'react-native-share';
|
|
|
|
import {pathWithPrefix} from '@utils/file';
|
|
|
|
import type {ReportAProblemMetadata} from '@typings/screens/report_a_problem';
|
|
|
|
const buildEmailBody = (metadata: ReportAProblemMetadata) => [
|
|
'Please share a description of the problem with reproduction steps:',
|
|
'',
|
|
'',
|
|
'You may also attach the mobile logs and any relevant screen captures.',
|
|
'',
|
|
'App metadata',
|
|
metadataToString(metadata),
|
|
].join('\n');
|
|
|
|
export const shareLogs = async (metadata: ReportAProblemMetadata, siteName: string | undefined, reportAProblemMail: string | undefined, excludeLogs: boolean = false) => {
|
|
try {
|
|
const logPaths = await TurboLogger.getLogPaths();
|
|
const attachments = excludeLogs ? [] : logPaths.map((path) => pathWithPrefix('file://', path));
|
|
await Share.open({
|
|
subject: `Problem with ${siteName || 'Mattermost'} mobile app`,
|
|
email: reportAProblemMail,
|
|
failOnCancel: false,
|
|
urls: attachments.length ? attachments : undefined,
|
|
message: buildEmailBody(metadata),
|
|
});
|
|
} catch (e: unknown) {
|
|
Alert.alert('Error', `${e}`);
|
|
}
|
|
};
|
|
|
|
export const emailLogs = async (metadata: ReportAProblemMetadata, siteName: string | undefined, reportAProblemMail: string | undefined, excludeLogs: boolean = false) => {
|
|
try {
|
|
const logPaths = await TurboLogger.getLogPaths();
|
|
const attachments = excludeLogs ? [] : logPaths.map((path) => pathWithPrefix('file://', path));
|
|
await Share.shareSingle({
|
|
social: Share.Social.EMAIL as any, // The type is not correct in the library
|
|
subject: `Problem with ${siteName || 'Mattermost'} mobile app`,
|
|
email: reportAProblemMail,
|
|
urls: attachments.length ? attachments : undefined,
|
|
message: buildEmailBody(metadata),
|
|
});
|
|
} catch (e: unknown) {
|
|
Alert.alert('Error', `${e}`);
|
|
}
|
|
};
|
|
|
|
export const getDefaultReportAProblemLink = (isLicensed: boolean) => {
|
|
return isLicensed ? 'https://mattermost.com/pl/report_a_problem_licensed' : 'https://mattermost.com/pl/report_a_problem_unlicensed';
|
|
};
|
|
|
|
export function metadataToString(metadata: ReportAProblemMetadata): string {
|
|
return Object.entries(metadata).
|
|
map(([key, value]) => `${reportAProblemMessages[key as keyof ReportAProblemMetadata].defaultMessage}: ${value}`).
|
|
join('\n');
|
|
}
|
|
|
|
export const reportAProblemMessages = defineMessages({
|
|
currentUserId: {
|
|
id: 'report_a_problem.metadata.currentUserId',
|
|
defaultMessage: 'Current User ID',
|
|
},
|
|
currentTeamId: {
|
|
id: 'report_a_problem.metadata.currentTeamId',
|
|
defaultMessage: 'Current Team ID',
|
|
},
|
|
serverVersion: {
|
|
id: 'report_a_problem.metadata.serverVersion',
|
|
defaultMessage: 'Server Version',
|
|
},
|
|
appVersion: {
|
|
id: 'report_a_problem.metadata.appVersion',
|
|
defaultMessage: 'App Version',
|
|
},
|
|
appPlatform: {
|
|
id: 'report_a_problem.metadata.appPlatform',
|
|
defaultMessage: 'App Platform',
|
|
},
|
|
deviceModel: {
|
|
id: 'report_a_problem.metadata.deviceModel',
|
|
defaultMessage: 'Device Model',
|
|
},
|
|
});
|