Skip to content

Commit

Permalink
Merge branch 'formatted-message-refactor' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaG committed Dec 14, 2020
2 parents b563fd3 + 74fc9dc commit c7fad14
Show file tree
Hide file tree
Showing 41 changed files with 315 additions and 134 deletions.
25 changes: 16 additions & 9 deletions packages/vulcan-admin/lib/components/AdminHome.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
import React from 'react';
import { Components, withCurrentUser, AdminColumns } from 'meteor/vulcan:core';
import { FormattedMessage } from 'meteor/vulcan:i18n';
import Users from 'meteor/vulcan:users';

import '../modules/columns.js';

const AdminHome = ({ currentUser }) =>
const AdminHome = ({ currentUser }) => (
<div className="admin-home page">
<Components.ShowIf check={Users.isAdmin} document={currentUser} failureComponent={<p className="admin-home-message"><FormattedMessage id="app.noPermission" /></p>}>
<Components.Datatable
collection={Users}
columns={AdminColumns}
<Components.ShowIf
check={Users.isAdmin}
document={currentUser}
failureComponent={
<p className="admin-home-message">
<Components.FormattedMessage id="app.noPermission" />
</p>
}>
<Components.Datatable
collection={Users}
columns={AdminColumns}
options={{
fragmentName: 'UsersAdmin',
terms: {view: 'usersAdmin'},
limit: 20
terms: { view: 'usersAdmin' },
limit: 20,
}}
title="Users"
showEdit={true}
showPaper={true}
/>
</Components.ShowIf>
</div>;
</div>
);

export default withCurrentUser(AdminHome);
6 changes: 3 additions & 3 deletions packages/vulcan-core/lib/modules/components/AccessControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCurrentUser } from '../containers/currentUser';
import Users from 'meteor/vulcan:users';
import { useHistory } from 'react-router-dom';
import withMessages from '../containers/withMessages';
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
import { intlShape } from 'meteor/vulcan:i18n';

const AccessControl = ({ currentRoute, children, flash }, { intl }) => {
const { loading, currentUser } = useCurrentUser();
Expand Down Expand Up @@ -56,15 +56,15 @@ const FailureComponent = props => {

const DefaultLogInFailureComponent = () => (
<Components.Alert className="access-control-failure" variant="danger">
<FormattedMessage id="app.please_sign_up_log_in" defaultMessage="Please log in first." />
<Components.FormattedMessage id="app.please_sign_up_log_in" defaultMessage="Please log in first." />
</Components.Alert>
);

registerComponent({ name: 'DefaultLogInFailureComponent', component: DefaultLogInFailureComponent });

const DefaultPermissionFailureComponent = () => (
<Components.Alert className="access-control-failure" variant="danger">
<FormattedMessage id="app.no_access_permissions" defaultMessage="Sorry, you are not allowed to access this page." />
<Components.FormattedMessage id="app.no_access_permissions" defaultMessage="Sorry, you are not allowed to access this page." />
</Components.Alert>
);

Expand Down
4 changes: 2 additions & 2 deletions packages/vulcan-core/lib/modules/components/Card/Card.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { registerComponent, Components, formatLabel } from 'meteor/vulcan:lib';
import { intlShape, FormattedMessage } from 'meteor/vulcan:i18n';
import { intlShape } from 'meteor/vulcan:i18n';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
Expand Down Expand Up @@ -49,7 +49,7 @@ const CardEdit = (props, context) => (
label={context.intl.formatMessage({ id: 'cards.edit' })}
component={
<Components.Button variant="info">
<FormattedMessage id="cards.edit" />
<Components.FormattedMessage id="cards.edit" />
</Components.Button>
}>
<CardEditForm {...props} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { registerComponent } from 'meteor/vulcan:lib';
import { Components, registerComponent } from 'meteor/vulcan:lib';
import React, { memo } from 'react';
import { FormattedMessage } from 'meteor/vulcan:i18n';
import PropTypes from 'prop-types';
import _sortBy from 'lodash/sortBy';

Expand Down Expand Up @@ -91,12 +90,12 @@ const DatatableContents = props => {
))}
{showEdit ? (
<th>
<FormattedMessage id="datatable.edit" defaultMessage="Edit" />
<Components.FormattedMessage id="datatable.edit" defaultMessage="Edit" />
</th>
) : null}
{showDelete ? (
<th>
<FormattedMessage id="datatable.delete" defaultMessage="Delete" />
<Components.FormattedMessage id="datatable.delete" defaultMessage="Delete" />
</th>
) : null}
</Components.DatatableContentsHeadLayout>
Expand Down Expand Up @@ -195,7 +194,7 @@ const DatatableEmpty = () => (
<tr>
<td colSpan="99">
<div style={{ textAlign: 'center', padding: 10 }}>
<FormattedMessage id="datatable.empty" defaultMessage="No items to display." />
<Components.FormattedMessage id="datatable.empty" defaultMessage="No items to display." />
</div>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Components, registerComponent, Utils } from 'meteor/vulcan:lib';
import React, { useState } from 'react';
import gql from 'graphql-tag';
import { useQuery } from '@apollo/client';
import { FormattedMessage } from 'meteor/vulcan:i18n';
import moment from 'moment';

const getCount = columnFilters => {
Expand Down Expand Up @@ -46,7 +45,7 @@ const DatatableFilter = props => {
return (
<span className="datatable-filter">
<Components.ModalTrigger
title={<FormattedMessage id="datatable.filter_column" values={{ label }} defaultMessage={`Filter “${label}”`} />}
title={<Components.FormattedMessage id="datatable.filter_column" values={{ label }} defaultMessage={`Filter “${label}”`} />}
size="small"
trigger={<Filter count={getCount(columnFilters)} />}>
{query ? <Components.DatatableFilterContentsWithData {...props} /> : <Components.DatatableFilterContents {...props} />}
Expand Down Expand Up @@ -117,7 +116,7 @@ const DatatableFilterContents = props => {
default:
contents = (
<p>
<FormattedMessage id="datatable.specify_option" defaultMessage="Please specify an options property on your schema field." />
<Components.FormattedMessage id="datatable.specify_option" defaultMessage="Please specify an options property on your schema field." />
</p>
);
}
Expand All @@ -133,15 +132,15 @@ const DatatableFilterContents = props => {
onClick={() => {
setFilters(undefined);
}}>
<FormattedMessage id="datatable.clear_all" defaultMessage="Clear All" />
<Components.FormattedMessage id="datatable.clear_all" defaultMessage="Clear All" />
</Components.Button>
<Components.Button
type="submit"
className="datatable_filter_submit"
onClick={() => {
submitFilters({ name, filters });
}}>
<FormattedMessage id="datatable.submit" defaultMessage="Submit" />
<Components.FormattedMessage id="datatable.submit" defaultMessage="Submit" />
</Components.Button>
</form>
);
Expand Down Expand Up @@ -215,7 +214,7 @@ const DatatableFilterDates = ({ filters, setFilters }) => (
<Components.FormComponentDate
path="_gte"
itemProperties={{
label: <FormattedMessage id="datatable.after" defaultMessage="After" />,
label: <Components.FormattedMessage id="datatable.after" defaultMessage="After" />,
layout: 'horizontal',
}}
inputProperties={{}}
Expand All @@ -233,7 +232,7 @@ const DatatableFilterDates = ({ filters, setFilters }) => (
<Components.FormComponentDate
path="_lte"
itemProperties={{
label: <FormattedMessage id="datatable.before" defaultMessage="Before" />,
label: <Components.FormattedMessage id="datatable.before" defaultMessage="Before" />,
layout: 'horizontal',
}}
inputProperties={{}}
Expand Down Expand Up @@ -265,7 +264,7 @@ const DatatableFilterNumbers = ({ filters, setFilters }) => (
<Components.FormComponentNumber
path="_gte"
itemProperties={{
label: <FormattedMessage id="datatable.greater_than" defaultMessage="Greater than" />,
label: <Components.FormattedMessage id="datatable.greater_than" defaultMessage="Greater than" />,
layout: 'horizontal',
}}
inputProperties={{
Expand All @@ -285,7 +284,7 @@ const DatatableFilterNumbers = ({ filters, setFilters }) => (
<Components.FormComponentNumber
path="_lte"
itemProperties={{
label: <FormattedMessage id="datatable.lower_than" defaultMessage="Lower than" />,
label: <Components.FormattedMessage id="datatable.lower_than" defaultMessage="Lower than" />,
layout: 'horizontal',
}}
inputProperties={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { registerComponent, Components } from 'meteor/vulcan:lib';
import React, { memo } from 'react';
import { FormattedMessage } from 'meteor/vulcan:i18n';
import PropTypes from 'prop-types';

/*
Expand All @@ -15,7 +14,7 @@ const DatatableSubmitSelected = ({ selectedItems, onSubmitSelected }) => (
e.preventDefault();
onSubmitSelected(selectedItems);
}}>
<FormattedMessage id="datatable.submit" />
<Components.FormattedMessage id="datatable.submit" />
</Components.Button>
);

Expand Down
5 changes: 2 additions & 3 deletions packages/vulcan-core/lib/modules/components/DeleteButton.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Components, registerComponent } from 'meteor/vulcan:lib';
import React from 'react';
import { FormattedMessage } from 'meteor/vulcan:i18n';
import { useDelete2 } from '../containers/delete2';

const DeleteButton = (props) => {
const { label, collection, collectionName, fragment, fragmentName, documentId, mutationOptions, ...rest } = props;
const { label, collection, collectionName, fragment, fragmentName, documentId, mutationOptions, currentUser, ...rest } = props;
const [deleteFunction, { loading }] = useDelete2({
collection,
collectionName,
Expand All @@ -19,7 +18,7 @@ const DeleteButton = (props) => {
onClick={() => {
deleteFunction({ input: { id: documentId } });
}}
label={label || <FormattedMessage id="datatable.delete" defaultMessage="Delete" />}
label={label || <Components.FormattedMessage id="datatable.delete" defaultMessage="Delete" />}
{...rest}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/vulcan-core/lib/modules/components/EditButton.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Components, registerComponent } from 'meteor/vulcan:lib';
import React from 'react';
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
import { intlShape } from 'meteor/vulcan:i18n';

const EditButton = ({ style = 'primary', variant, label, size, showId, modalProps, formProps, component, ...props }, { intl }) => (
<Components.ModalTrigger
Expand All @@ -10,7 +10,7 @@ const EditButton = ({ style = 'primary', variant, label, size, showId, modalProp
component
) : (
<Components.Button size={size} variant={variant || style}>
{label || <FormattedMessage id="datatable.edit" defaultMessage="Edit" />}
{label || <Components.FormattedMessage id="datatable.edit" defaultMessage="Edit" />}
</Components.Button>
)
}
Expand Down
5 changes: 2 additions & 3 deletions packages/vulcan-core/lib/modules/components/Error404.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { registerComponent } from 'meteor/vulcan:lib';
import { Components, registerComponent } from 'meteor/vulcan:lib';
import React from 'react';
import { FormattedMessage } from 'meteor/vulcan:i18n';

const Error404 = () => {
return (
<div className="error404">
<h3>
<FormattedMessage id="app.404" defaultMessage="Sorry, we couldn't find what you were looking for." />
<Components.FormattedMessage id="app.404" defaultMessage="Sorry, we couldn't find what you were looking for." />
</h3>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/vulcan-core/lib/modules/components/NewButton.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Components, registerComponent } from 'meteor/vulcan:lib';
import React from 'react';
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
import { intlShape } from 'meteor/vulcan:i18n';

const NewButton = ({ collection, size, label, style = 'primary', formProps, ...props }, { intl }) => (
<Components.ModalTrigger
label={label || intl.formatMessage({ id: 'datatable.new' })}
title={label || intl.formatMessage({ id: 'datatable.new' })}
component={
<Components.Button variant={style} size={size}>
{label || <FormattedMessage id="datatable.new" />}
{label || <Components.FormattedMessage id="datatable.new" />}
</Components.Button>
}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { registerComponent } from 'meteor/vulcan:lib';
import { Components, registerComponent } from 'meteor/vulcan:lib';
import React from 'react';
import { FormattedMessage } from 'meteor/vulcan:i18n';
import withComponents from '../../containers/withComponents';
import { useMulti2 } from '../../containers/multi2';

Expand Down Expand Up @@ -101,7 +100,7 @@ registerComponent('PaginatedListItem', PaginatedListItem);

const PaginatedListNoResults = () => (
<p className="list-noresults">
<FormattedMessage id="paginatedlist.no_results" />
<Components.FormattedMessage id="paginatedlist.no_results" />
</p>
);

Expand All @@ -118,7 +117,7 @@ const PaginatedListLoadMore = ({ Components, loadMore, count, totalCount }) => (
e.preventDefault();
loadMore();
}}>
<FormattedMessage id="paginatedlist.load_more" defaultMessage="Load More" />
<Components.FormattedMessage id="paginatedlist.load_more" defaultMessage="Load More" />
&nbsp;{' '}
<span className="list-loadedcount">
({count}/{totalCount})
Expand Down
1 change: 1 addition & 0 deletions packages/vulcan-core/lib/modules/containers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './localeData';
1 change: 1 addition & 0 deletions packages/vulcan-core/lib/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import './callbacks';
export * from 'meteor/vulcan:lib';

export * from './containers';
export * from './components.js';

export { default as App } from './components/App.jsx';
Expand Down
4 changes: 2 additions & 2 deletions packages/vulcan-debug/lib/components/ErrorCatcherContents.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Components, replaceComponent } from 'meteor/vulcan:lib';

const ErrorCatcherContents = ({ error }) => (
const ErrorCatcherContents = ({ error, message }) => (
<div className="error-catcher">
<Components.Flash message={{ id: 'errors.generic_report', properties: { errorMessage: error.message } }} />
<Components.Flash message={{ id: 'errors.generic_report', message, properties: { error } }} />
<div className="error-catcher-help">
<p>Here are some suggestions to help you fix this issue:</p>
<ol>
Expand Down
6 changes: 3 additions & 3 deletions packages/vulcan-email/lib/server/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const send = (to, subject, html, text, throwErrors, cc, bcc, replyTo, hea

const shouldSendEmail = process.env.NODE_ENV === 'production' || getSetting('enableDevelopmentEmails', false);

console.log(`//////// sending email${shouldSendEmail ? '' : ' (simulation)'}…`); // eslint-disable-line
console.log(`✉️ sending email${shouldSendEmail ? '' : ' (simulation)'}…`); // eslint-disable-line
console.log('from: ' + _from); // eslint-disable-line
console.log('to: ' + to); // eslint-disable-line
console.log('subject: ' + subject); // eslint-disable-line
Expand Down Expand Up @@ -219,8 +219,8 @@ export const buildAndSend = async ({
from,
}) => {
try {
const email = await VulcanEmail.build({ to, emailName, variables, locale });
return VulcanEmail.send({ to: email.to, cc, bcc, replyTo, subject: email.subject, html: email.html, headers, attachments, from });
const email = await build({ to, emailName, variables, locale });
return send({ to: email.to, cc, bcc, replyTo, subject: email.subject, html: email.html, headers, attachments, from });
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
Expand Down
8 changes: 4 additions & 4 deletions packages/vulcan-embed/lib/components/EmbedURL.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Components, registerComponent, Utils, getSetting } from 'meteor/vulcan:
import { withMutation } from 'meteor/vulcan:core';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
import { intlShape } from 'meteor/vulcan:i18n';

class EmbedURL extends Component {
constructor(props) {
Expand Down Expand Up @@ -133,10 +133,10 @@ class EmbedURL extends Component {
</div>
<div className="embedly-thumbnail-actions">
<a className="thumbnail-edit" onClick={this.editThumbnail}>
<Components.Icon name="edit" /> <FormattedMessage id="posts.enter_thumbnail_url" />
<Components.Icon name="edit" /> <Components.FormattedMessage id="posts.enter_thumbnail_url" />
</a>
<a className="thumbnail-clear" onClick={this.clearThumbnail}>
<Components.Icon name="delete" /> <FormattedMessage id="posts.clear_thumbnail" />
<Components.Icon name="delete" /> <Components.FormattedMessage id="posts.clear_thumbnail" />
</a>
</div>
</div>
Expand All @@ -151,7 +151,7 @@ class EmbedURL extends Component {
onClick={this.editThumbnail}
className="embedly-thumbnail-placeholder">
<Components.Icon name="image" />
<FormattedMessage id="posts.enter_thumbnail_url" />
<Components.FormattedMessage id="posts.enter_thumbnail_url" />
</div>

<div className="embedly-url-field-loading" style={this.getLoadingStyle()}>
Expand Down
Loading

0 comments on commit c7fad14

Please sign in to comment.