@@ -85,7 +105,7 @@ class CommentStream extends Component {
SettingsConfigure Stream
- {loggedIn && }
+ {loggedIn && }
{/* Add to the restricted param a boolean if the user is suspended*/}
}>
@@ -109,7 +129,7 @@ class CommentStream extends Component {
:
Comments are closed for this thread.
}
- {!loggedIn && }
+ {!loggedIn && }
{
rootItem.comments && rootItem.comments.map((commentId) => {
const comment = comments[commentId];
@@ -267,7 +287,7 @@ const mapDispatchToProps = (dispatch) => ({
getStream: (rootId) => dispatch(getStream(rootId)),
addNotification: (type, text) => dispatch(addNotification(type, text)),
clearNotification: () => dispatch(clearNotification()),
- showSignInDialog: () => dispatch(showSignInDialog()),
+ showSignInDialog: (offset) => dispatch(showSignInDialog(offset)),
postAction: (item, action, user, itemType) => dispatch(postAction(item, action, user, itemType)),
deleteAction: (item, action, user, itemType) => dispatch(deleteAction(item, action, user, itemType)),
appendItemArray: (item, property, value, addToFront, itemType) => dispatch(appendItemArray(item, property, value, addToFront, itemType)),
diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css
index 59efc3dc8..766ad763a 100644
--- a/client/coral-embed-stream/style/default.css
+++ b/client/coral-embed-stream/style/default.css
@@ -8,7 +8,7 @@ body {
}
.expandForSignin {
- min-height: 550px;
+ min-height: 600px;
}
button {
@@ -113,7 +113,6 @@ hr {
/* Comment styles */
.comment {
- position: relative;
margin-bottom: 10px;
position: relative;
}
diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js
index 13a9c72bc..7ad5e4c34 100644
--- a/client/coral-framework/actions/auth.js
+++ b/client/coral-framework/actions/auth.js
@@ -6,7 +6,7 @@ import coralApi, {base} from '../helpers/response';
import {addItem} from './items';
// Dialog Actions
-export const showSignInDialog = () => ({type: actions.SHOW_SIGNIN_DIALOG});
+export const showSignInDialog = (offset = 0) => ({type: actions.SHOW_SIGNIN_DIALOG, offset});
export const hideSignInDialog = () => ({type: actions.HIDE_SIGNIN_DIALOG});
export const changeView = view => dispatch =>
diff --git a/client/coral-framework/modules/i18n/i18n.js b/client/coral-framework/modules/i18n/i18n.js
index afe8606d1..1d81e885c 100644
--- a/client/coral-framework/modules/i18n/i18n.js
+++ b/client/coral-framework/modules/i18n/i18n.js
@@ -1,5 +1,7 @@
import timeago from 'timeago.js';
import esTA from '../../../../node_modules/timeago.js/locales/es';
+import has from 'lodash/has';
+import get from 'lodash/get';
/**
* Default locales, this should be overriden by config file
@@ -46,21 +48,18 @@ class i18n {
* it takes a string with the translation key and returns
* the translation value or the key itself if not found
* it works with nested translations (my.page.title)
+ *
+ * any extra parameters are optional and replace a variable marked by {0}, {1}, etc in the translation.
*/
- this.t = (key) => {
- const arr = key.split('.');
- let translation = this.translations;
- try {
- for (let i = 0; i < arr.length; i++) {translation = translation[arr[i]];}
- } catch (error) {
- console.warn(`${key} language key not set`);
- return key;
- }
-
- const val = String(translation);
- if (val) {
- return val;
+ this.t = (key, ...replacements) => {
+ if (has(this.translations, key)) {
+ let translation = get(this.translations, key);
+ // replace any {n} with the arguments passed to this method
+ replacements.forEach((str, i) => {
+ translation = translation.replace(new RegExp(`\\{${i}\\}`, 'g'), str);
+ });
+ return translation;
} else {
console.warn(`${key} language key not set`);
return key;
diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js
index a4803fa96..cf5b25921 100644
--- a/client/coral-framework/reducers/auth.js
+++ b/client/coral-framework/reducers/auth.js
@@ -22,7 +22,8 @@ export default function auth (state = initialState, action) {
switch (action.type) {
case actions.SHOW_SIGNIN_DIALOG :
return state
- .set('showSignInDialog', true);
+ .set('showSignInDialog', true)
+ .set('signInOffset', action.offset);
case actions.HIDE_SIGNIN_DIALOG :
return state.merge(Map({
isLoading: false,
diff --git a/client/coral-plugin-flags/FlagButton.js b/client/coral-plugin-flags/FlagButton.js
index f0ab1b22f..dd5979888 100644
--- a/client/coral-plugin-flags/FlagButton.js
+++ b/client/coral-plugin-flags/FlagButton.js
@@ -8,7 +8,8 @@ const FlagButton = ({flag, id, postAction, deleteAction, addItem, showSignInDial
const flagged = flag && flag.current_user;
const onFlagClick = () => {
if (!currentUser) {
- showSignInDialog();
+ const offset = document.getElementById(`c_${id}`).getBoundingClientRect().top - 75;
+ showSignInDialog(offset);
return;
}
if (!flagged) {
diff --git a/client/coral-plugin-likes/LikeButton.js b/client/coral-plugin-likes/LikeButton.js
index b3d31fbf4..0672da071 100644
--- a/client/coral-plugin-likes/LikeButton.js
+++ b/client/coral-plugin-likes/LikeButton.js
@@ -8,7 +8,8 @@ const LikeButton = ({like, id, postAction, deleteAction, addItem, showSignInDial
const liked = like && like.current_user;
const onLikeClick = () => {
if (!currentUser) {
- showSignInDialog();
+ const offset = document.getElementById(`c_${id}`).getBoundingClientRect().top - 75;
+ showSignInDialog(offset);
return;
}
if (!liked) {
diff --git a/client/coral-sign-in/components/SignDialog.js b/client/coral-sign-in/components/SignDialog.js
index 242b7443a..68d96b910 100644
--- a/client/coral-sign-in/components/SignDialog.js
+++ b/client/coral-sign-in/components/SignDialog.js
@@ -6,8 +6,14 @@ import SignInContent from './SignInContent';
import SingUpContent from './SignUpContent';
import ForgotContent from './ForgotContent';
-const SignDialog = ({open, view, handleClose, ...props}) => (
-