Merge branch 'fix-nest-ternary-expressions' into 'main'
Refactored nest ternary expressions See merge request soapbox-pub/soapbox!3179
This commit is contained in:
commit
01f00a018c
|
@ -133,7 +133,7 @@
|
|||
"no-irregular-whitespace": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-mixed-spaces-and-tabs": "error",
|
||||
"no-nested-ternary": "warn",
|
||||
"no-nested-ternary": "error",
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
|
|
|
@ -241,7 +241,8 @@ const saveSettings = (opts?: SettingOpts) =>
|
|||
const getLocale = (state: RootState, fallback = 'en') => {
|
||||
const localeWithVariant = (getSettings(state).get('locale') as string).replace('_', '-');
|
||||
const locale = localeWithVariant.split('-')[0];
|
||||
return Object.keys(messages).includes(localeWithVariant) ? localeWithVariant : Object.keys(messages).includes(locale) ? locale : fallback;
|
||||
const fallbackLocale = Object.keys(messages).includes(locale) ? locale : fallback;
|
||||
return Object.keys(messages).includes(localeWithVariant) ? localeWithVariant : fallbackLocale;
|
||||
};
|
||||
|
||||
type SettingsAction =
|
||||
|
|
|
@ -51,7 +51,9 @@ const Domain: React.FC<IDomain> = ({ domain }) => {
|
|||
}));
|
||||
};
|
||||
|
||||
const domainState = domain.last_checked_at ? (domain.resolves ? 'active' : 'error') : 'pending';
|
||||
const resolveState = domain.resolves ? 'active' : 'error';
|
||||
const domainState = domain.last_checked_at ? resolveState : 'pending';
|
||||
|
||||
const domainStateLabel = {
|
||||
active: <FormattedMessage id='admin.domains.resolve.success_label' defaultMessage='Resolves correctly' />,
|
||||
error: <FormattedMessage id='admin.domains.resolve.fail_label' defaultMessage='Not resolving' />,
|
||||
|
|
|
@ -141,13 +141,19 @@ const RegistrationForm: React.FC<IRegistrationForm> = ({ inviteToken }) => {
|
|||
/></p>}
|
||||
</>);
|
||||
|
||||
const confirmationHeading = needsConfirmation
|
||||
? intl.formatMessage(messages.needsConfirmationHeader)
|
||||
: undefined;
|
||||
|
||||
const approvalHeading = needsApproval
|
||||
? intl.formatMessage(messages.needsApprovalHeader)
|
||||
: undefined;
|
||||
|
||||
const heading = confirmationHeading || approvalHeading;
|
||||
|
||||
dispatch(openModal('CONFIRM', {
|
||||
icon: require('@tabler/icons/outline/check.svg'),
|
||||
heading: needsConfirmation
|
||||
? intl.formatMessage(messages.needsConfirmationHeader)
|
||||
: needsApproval
|
||||
? intl.formatMessage(messages.needsApprovalHeader)
|
||||
: undefined,
|
||||
heading: heading,
|
||||
message,
|
||||
confirm: intl.formatMessage(messages.close),
|
||||
}));
|
||||
|
|
|
@ -88,12 +88,14 @@ const Backups = () => {
|
|||
</Card>
|
||||
);
|
||||
|
||||
const body = showLoading ? <Spinner /> : backups.isEmpty() ? emptyMessage : (
|
||||
const backupsContent = backups.isEmpty() ? emptyMessage : (
|
||||
<div className='mb-4 grid grid-cols-1 gap-4 sm:grid-cols-2'>
|
||||
{backups.map((backup) => <Backup key={backup.id} backup={backup} />)}
|
||||
</div>
|
||||
);
|
||||
|
||||
const body = showLoading ? <Spinner /> : backupsContent;
|
||||
|
||||
return (
|
||||
<Column label={intl.formatMessage(messages.heading)}>
|
||||
{body}
|
||||
|
|
|
@ -70,7 +70,17 @@ const Filters = () => {
|
|||
emptyMessage={emptyMessage}
|
||||
itemClassName='pb-4 last:pb-0'
|
||||
>
|
||||
{filters.map((filter) => (
|
||||
{filters.map((filter) => {
|
||||
|
||||
const truthMessageFilter = filter.filter_action === 'hide' ?
|
||||
<FormattedMessage id='filters.filters_list_hide_completely' defaultMessage='Hide content' /> :
|
||||
<FormattedMessage id='filters.filters_list_warn' defaultMessage='Display warning' />;
|
||||
|
||||
const falseMessageFilter = (filter.filter_action === 'hide' ?
|
||||
<FormattedMessage id='filters.filters_list_drop' defaultMessage='Drop' /> :
|
||||
<FormattedMessage id='filters.filters_list_hide' defaultMessage='Hide' />);
|
||||
|
||||
return (
|
||||
<div key={filter.id} className='rounded-lg bg-gray-100 p-4 dark:bg-primary-800'>
|
||||
<Stack space={2}>
|
||||
<Stack className='grow' space={1}>
|
||||
|
@ -86,13 +96,7 @@ const Filters = () => {
|
|||
</Text>
|
||||
<HStack space={4} wrap>
|
||||
<Text weight='medium'>
|
||||
{filtersV2 ? (
|
||||
filter.filter_action === 'hide' ?
|
||||
<FormattedMessage id='filters.filters_list_hide_completely' defaultMessage='Hide content' /> :
|
||||
<FormattedMessage id='filters.filters_list_warn' defaultMessage='Display warning' />
|
||||
) : (filter.filter_action === 'hide' ?
|
||||
<FormattedMessage id='filters.filters_list_drop' defaultMessage='Drop' /> :
|
||||
<FormattedMessage id='filters.filters_list_hide' defaultMessage='Hide' />)}
|
||||
{filtersV2 ? truthMessageFilter : falseMessageFilter}
|
||||
</Text>
|
||||
{filter.expires_at && (
|
||||
<Text weight='medium'>
|
||||
|
@ -113,7 +117,9 @@ const Filters = () => {
|
|||
</HStack>
|
||||
</Stack>
|
||||
</div>
|
||||
))}
|
||||
);
|
||||
},
|
||||
)}
|
||||
</ScrollableList>
|
||||
</Column>
|
||||
);
|
||||
|
|
|
@ -22,6 +22,8 @@ const CaptchaModal: React.FC<ICaptchaModal> = ({ onClose }) => {
|
|||
xPosition,
|
||||
} = useCaptcha();
|
||||
|
||||
const messageButton = tryAgain ? <FormattedMessage id='nostr_signup.captcha_try_again_button' defaultMessage='Try again' /> : <FormattedMessage id='nostr_signup.captcha_check_button' defaultMessage='Check' />;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={<FormattedMessage id='nostr_signup.captcha_title' defaultMessage='Human Verification' />} width='sm'
|
||||
|
@ -46,10 +48,7 @@ const CaptchaModal: React.FC<ICaptchaModal> = ({ onClose }) => {
|
|||
>
|
||||
{isSubmitting ? (
|
||||
<FormattedMessage id='nostr_signup.captcha_check_button.checking' defaultMessage='Checking…' />
|
||||
) : (tryAgain ?
|
||||
<FormattedMessage id='nostr_signup.captcha_try_again_button' defaultMessage='Try again' /> :
|
||||
<FormattedMessage id='nostr_signup.captcha_check_button' defaultMessage='Check' />
|
||||
)}
|
||||
) : messageButton}
|
||||
</Button>
|
||||
<Button onClick={loadCaptcha}>
|
||||
<FormattedMessage id='nostr_signup.captcha_reset_button' defaultMessage='Reset puzzle' />
|
||||
|
|
|
@ -33,12 +33,18 @@ export const AdminAccountRecord = ImmutableRecord({
|
|||
|
||||
const normalizePleromaAccount = (account: ImmutableMap<string, any>) => {
|
||||
if (!account.get('account')) {
|
||||
|
||||
const isAdmin = account.getIn(['roles', 'admin']);
|
||||
const isModerator = account.getIn(['roles', 'moderator']) ? 'moderator' : null;
|
||||
|
||||
const accountRole = isAdmin ? 'admin' : isModerator;
|
||||
|
||||
return account.withMutations(account => {
|
||||
account.set('approved', account.get('is_approved'));
|
||||
account.set('confirmed', account.get('is_confirmed'));
|
||||
account.set('disabled', !account.get('is_active'));
|
||||
account.set('invite_request', account.get('registration_reason'));
|
||||
account.set('role', account.getIn(['roles', 'admin']) ? 'admin' : (account.getIn(['roles', 'moderator']) ? 'moderator' : null));
|
||||
account.set('role', accountRole);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue