Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions commitlint.config.js → commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module.exports = {
import type { UserConfig } from '@commitlint/types';
import { RuleConfigSeverity } from '@commitlint/types';

const Configuration: UserConfig = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [RuleConfigSeverity.Error, 'always', 200],
'type-enum': [
2,
RuleConfigSeverity.Error,
'always',
[
'feat', // New feature
Expand All @@ -19,4 +23,7 @@ module.exports = {
],
],
},
// ...
};

export default Configuration;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { checkIfBulkApiJobIsDone, convertDateToLocale, useBrowserNotifications,
import {
decodeHtmlEntity,
getErrorMessage,
getErrorMessageAndStackObj,
getSuccessOrFailureChar,
pluralizeFromNumber,
splitArrayToMaxSize,
Expand Down Expand Up @@ -286,7 +285,6 @@ export const LoadRecordsBulkApiResults = ({
body: `❌ ${getErrorMessage(ex)}`,
tag: 'load-records',
});
rollbar.error('Error preparing bulk api data', getErrorMessageAndStackObj(ex));
return;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
83 changes: 20 additions & 63 deletions libs/ui/src/lib/data-table/data-table-formatters.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { logger } from '@jetstream/shared/client-logger';
import { DATE_FORMATS } from '@jetstream/shared/constants';
import { logErrorToRollbar } from '@jetstream/shared/ui-utils';
import { Maybe } from '@jetstream/types';
import { formatDate } from 'date-fns/format';
import { parse as parseDate } from 'date-fns/parse';
Expand All @@ -16,26 +16,19 @@ export const dataTableDateFormatter = (dateOrDateTime: Maybe<Date | string>): st
try {
if (!dateOrDateTime) {
return null;
} else if (isDate(dateOrDateTime)) {
}
if (isDate(dateOrDateTime)) {
return formatDate(dateOrDateTime as Date, DATE_FORMATS.YYYY_MM_DD_HH_mm_ss_a);
} else if (dateOrDateTime.length === 28) {
}
if (dateOrDateTime.length === 28) {
return formatDate(parseISO(dateOrDateTime), DATE_FORMATS.YYYY_MM_DD_HH_mm_ss_a);
} else if (dateOrDateTime.length === 10) {
}
if (dateOrDateTime.length === 10) {
return formatDate(startOfDay(parseISO(dateOrDateTime)), DATE_FORMATS.yyyy_MM_dd);
} else {
return dateOrDateTime;
}
return dateOrDateTime;
} catch (ex) {
logErrorToRollbar(
ex.message,
{
stack: ex.stack,
place: 'dataTableDateFormatter',
type: 'Error formatting date',
inputValue: dateOrDateTime,
},
'warn',
);
logger.warn('error formatting date', dateOrDateTime, ex);
return String(dateOrDateTime || '');
}
};
Expand All @@ -45,43 +38,25 @@ export const dataTableTimeFormatter = (value: Maybe<string>): string | null => {
const time = value;
if (!time) {
return null;
} else if (time.length === 13) {
}
if (time.length === 13) {
return formatDate(parseDate(time, DATE_FORMATS.HH_mm_ss_ssss_z, new Date()), DATE_FORMATS.HH_MM_SS_a);
} else {
return time;
}
return time;
} catch (ex) {
logErrorToRollbar(
ex.message,
{
stack: ex.stack,
place: 'dataTableDateFormatter',
type: 'Error formatting time',
inputValue: value,
},
'warn',
);
logger.warn('error formatting time', value, ex);
return String(value || '');
}
};

export const dataTableFileSizeFormatter = (sizeInBytes: Maybe<string | number>): string | null => {
if (isNil(sizeInBytes)) {
return null;
}
try {
return fileSizeFormatter(sizeInBytes as any);
if (isNil(sizeInBytes)) {
return null;
}
return fileSizeFormatter(sizeInBytes);
} catch (ex) {
logErrorToRollbar(
ex.message,
{
stack: ex.stack,
place: 'dataTableDateFormatter',
type: 'error formatting file size',
inputValue: sizeInBytes,
},
'warn',
);
logger.warn('error formatting file size', sizeInBytes, ex);
return String(sizeInBytes || '');
}
};
Expand All @@ -98,16 +73,7 @@ export const dataTableAddressValueFormatter = (value: any): string | null => {
const remainingParts = [address.city, address.state, address.postalCode, address.country].filter((part) => !!part).join(', ');
return [street, remainingParts].join('\n');
} catch (ex) {
logErrorToRollbar(
ex.message,
{
stack: ex.stack,
place: 'dataTableDateFormatter',
type: 'error formatting address',
inputValue: value,
},
'warn',
);
logger.warn('error formatting address', value, ex);
return String(value || '');
}
};
Expand All @@ -120,16 +86,7 @@ export const dataTableLocationFormatter = (value: Maybe<SalesforceLocationField>
const location: SalesforceLocationField = value as SalesforceLocationField;
return `Latitude: ${location.latitude}°, Longitude: ${location.longitude}°`;
} catch (ex) {
logErrorToRollbar(
ex.message,
{
stack: ex.stack,
place: 'dataTableDateFormatter',
type: 'error formatting location',
inputValue: value,
},
'warn',
);
logger.warn('error formatting location', value, ex);
return String(value || '');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,17 @@ const TooltipContent = ({
LIMIT 1`;
const results = await queryWithCache<CustomField>(org, query, true);
if (isMounted.current) {
if (!results.data.queryResults.records[0]) {
setContent({ label: `Oops. There was a problem getting the Roll-Up Summary content.`, items: [] });
return;
}
const { summarizedField, summaryOperation, summaryFilterItems } = results.data.queryResults.records[0].Metadata;
setContent({
label: `${summaryOperation.toUpperCase()}${summarizedField ? `(${summarizedField})` : ''}`,
items: summaryFilterItems.map(({ field, operation, value }) => `${field} ${operation} ${value}`),
});
}
} catch (ex) {
rollbar.error('Error getting tooltip content', {
query,
message: ex.message,
stack: ex.stack,
});
} catch {
if (isMounted.current) {
setContent({ label: `Oops. There was a problem getting the Roll-Up Summary content.`, items: [] });
}
Expand Down
Loading