Skip to content

Commit

Permalink
feat: node 18 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Monika-Khviasko committed Nov 8, 2024
1 parent 2b47ba1 commit 41c291d
Show file tree
Hide file tree
Showing 45 changed files with 156 additions and 569 deletions.
13 changes: 2 additions & 11 deletions client/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ const webAuthOptions = {
const webAuth = new auth0.WebAuth(webAuthOptions); // eslint-disable-line no-undef

export function login(returnUrl, locale) {
console.log("login function running");

sessionStorage.setItem('delegated-admin:returnTo', returnUrl || '/users');

console.log('delegated-admin:returnTo', returnUrl || '/users')

console.log({ webAuthOptions })

webAuth.authorize({
ui_locales: locale
});
Expand Down Expand Up @@ -146,8 +140,6 @@ const processTokens = (dispatch, apiToken, returnTo) => {
}
});


console.log(`dispatching LOGIN_SUCCESS with token: ${apiToken}, decodedToken: ${decodedToken}, user: ${decodedToken}, returnTo: ${returnTo}`);
dispatch({
type: constants.LOGIN_SUCCESS,
payload: {
Expand All @@ -170,7 +162,6 @@ const processTokens = (dispatch, apiToken, returnTo) => {
export function loadCredentials() {
return (dispatch) => {
if (window.location.hash) {
console.log(`dispatching LOGIN_PENDING`);
dispatch({
type: constants.LOGIN_PENDING
});
Expand Down Expand Up @@ -238,7 +229,7 @@ export function getAppSettings(onSuccess) {

export function toggleStyleSettings() {
return (dispatch, getState) => {
let settings = getState().settings.get('record');
let settings = getState().settings.get('record').toJS();
settings = settings.settings || settings || {};
const useAlt = localStorage.getItem('delegated-admin:use-alt-css') === 'true';
const path = useAlt ? settings.css : settings.altcss;
Expand All @@ -255,7 +246,7 @@ export function toggleStyleSettings() {

export function getStyleSettings() {
return (dispatch, getState) => {
let settings = getState().settings.get('record');
let settings = getState().settings.get('record').toJS();
settings = settings.settings || settings || {};
const useAlt = localStorage.getItem('delegated-admin:use-alt-css') === 'true';
const path = !useAlt ? settings.css : settings.altcss;
Expand Down
54 changes: 27 additions & 27 deletions client/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const addRequiredTextParam = (url, languageDictionary) => {
*/
export function fetchUsers(search, reset = false, page = 0, filterBy, sort, onSuccess) {
return (dispatch, getState) => {
const { sortProperty, sortOrder, searchValue, selectedFilter } = getState().users;
const { sortProperty, sortOrder, searchValue, selectedFilter } = getState().users.toJS();
const meta = { page, sortProperty, sortOrder, searchValue, onSuccess };
meta.selectedFilter = reset ? '' : filterBy || selectedFilter;
meta.searchValue = reset ? '' : search || searchValue;
Expand Down Expand Up @@ -75,7 +75,7 @@ export function createUser(user, languageDictionary) {
*/
export function requestCreateUser(memberships) {
return (dispatch, getState) => {
const connections = getState().connections.get('records');
const connections = getState().connections.get('records').toJS();

const connection = connections.length === 0
? null
Expand Down Expand Up @@ -238,27 +238,27 @@ export function cancelBlockUser() {
/*
* Update the user details.
*/
// export function updateUser(userId, data, onSuccess, languageDictionary) {
// return (dispatch) => {
// dispatch({
// type: constants.UPDATE_USER,
// meta: {
// userId,
// onSuccess: () => {
// if (onSuccess) {
// onSuccess();
// }
// dispatch(fetchUserDetail(userId));
// }
// },
// payload: {
// promise: axios.put(addRequiredTextParam(`/api/users/${userId}`, languageDictionary), data, {
// responseType: 'json'
// })
// }
// });
// };
// }
export function updateUser(userId, data, onSuccess, languageDictionary) {
return (dispatch) => {
dispatch({
type: constants.UPDATE_USER,
meta: {
userId,
onSuccess: () => {
if (onSuccess) {
onSuccess();
}
dispatch(fetchUserDetail(userId));
}
},
payload: {
promise: axios.put(addRequiredTextParam(`/api/users/${userId}`, languageDictionary), data, {
responseType: 'json'
})
}
});
};
}
/*
* Block a user.
*/
Expand Down Expand Up @@ -384,7 +384,7 @@ export function cancelDeleteUser() {
*/
export function deleteUser() {
return (dispatch, getState) => {
const { user: {user_id} } = getState().userDelete;
const { user: {user_id} } = getState().userDelete.toJS();
dispatch({
type: constants.DELETE_USER,
payload: {
Expand Down Expand Up @@ -425,7 +425,7 @@ export function cancelPasswordReset() {
*/
export function resetPassword(application) {
return (dispatch, getState) => {
const { user: { user_id }, connection } = getState().passwordReset;
const { user: { user_id }, connection } = getState().passwordReset.toJS();
const clientId = application.client ? (application.client.value || application.client) : null;
dispatch({
type: constants.PASSWORD_RESET,
Expand Down Expand Up @@ -467,7 +467,7 @@ export function cancelPasswordChange() {
*/
export function changePassword(formData, languageDictionary) {
return (dispatch, getState) => {
const { user: { user_id }, connection } = getState().passwordChange;
const { user: { user_id }, connection } = getState().passwordChange.toJS();
dispatch({
type: constants.PASSWORD_CHANGE,
payload: {
Expand Down Expand Up @@ -510,7 +510,7 @@ export function cancelUsernameChange() {
*/
export function changeUsername(userId, data, languageDictionary) {
return (dispatch, getState) => {
const user = getState().user.get('record');
const user = getState().user.get('record').toJS();
user.username = data.username;
dispatch({
type: constants.USERNAME_CHANGE,
Expand Down
21 changes: 9 additions & 12 deletions client/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,22 @@ export default class Header extends Component {
getName(iss, user) {
let thisMenuName = this.props.getDictValue('menuName');

// user.get was erroring so commented out. User seems to be a decoded jwt
// I don't know what it was previously - to have getter fns, or why it's changed

// thisMenuName = thisMenuName || (user && user.get('name'));
// thisMenuName = thisMenuName || (user && user.get('nickname'));
// thisMenuName = thisMenuName || (user && user.get('email'));
thisMenuName = thisMenuName || (user && user.get('name'));
thisMenuName = thisMenuName || (user && user.get('nickname'));
thisMenuName = thisMenuName || (user && user.get('email'));
thisMenuName = thisMenuName || iss;

return thisMenuName.length >= 21 ? thisMenuName.substr(0,18)+'...' : thisMenuName;
}

getPicture(iss, user) {
// if (user && user.get('picture')) {
// return user.get('picture');
// }
if (user && user.get('picture')) {
return user.get('picture');
}

// if (user && user.get('nickname')) {
// return `https://cdn.auth0.com/avatars/${user.get('nickname').slice(0, 2).toLowerCase()}.png`;
// }
if (user && user.get('nickname')) {
return `https://cdn.auth0.com/avatars/${user.get('nickname').slice(0, 2).toLowerCase()}.png`;
}

return `https://cdn.auth0.com/avatars/${iss.slice(0, 2).toLowerCase()}.png`;
}
Expand Down
2 changes: 1 addition & 1 deletion client/components/Logs/LogDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class LogDialog extends Component {

const languageDictionary = this.props.languageDictionary || {};

const log = this.props.log;
const log = this.props.log.toJS();

const logType = _.get(languageDictionary, `logTypes.${log.shortType}.event`, log.type);

Expand Down
2 changes: 1 addition & 1 deletion client/components/Logs/LogsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class LogsTable extends Component {
return <div>{languageDictionary.noLogsMessage || 'No logs found'}</div>;
}

const logs = this.props.logs;
const logs = this.props.logs.toJS();
return (
<LoadingPanel show={loading} animationStyle={{ paddingTop: '5px', paddingBottom: '5px' }}>
<Error title={languageDictionary.errorTitle} message={getErrorMessage(languageDictionary, error, settings.errorTranslator)} />
Expand Down
8 changes: 4 additions & 4 deletions client/components/Users/UserActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export default class UserActions extends Component {

if (props.user) {
this.state = {
user: props.user,
user: props.user.toJS(),
loading: props.loading
};

if (props.databaseConnections) {
this.state.databaseConnections = props.databaseConnections;
this.state.databaseConnections = props.databaseConnections.toJS();
}
} else {
this.state = {
Expand All @@ -49,7 +49,7 @@ export default class UserActions extends Component {

componentWillReceiveProps(nextProps) {
if (nextProps.user) {
const { record, loading } = nextProps.user;
const { record, loading } = nextProps.user.toJS();
this.setState({
user: record,
loading
Expand All @@ -58,7 +58,7 @@ export default class UserActions extends Component {

if (nextProps.databaseConnections) {
this.setState({
databaseConnections: nextProps.databaseConnections
databaseConnections: nextProps.databaseConnections.toJS()
});
}

Expand Down
2 changes: 1 addition & 1 deletion client/components/Users/UserDevices.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class UserDevices extends Component {
return <div>{languageDictionary.noDevicesMessage || 'This user does not have any registered devices.'}</div>;
}

const devices = this.props.devices;
const devices = this.props.devices.toJS();

return (
<LoadingPanel show={loading} animationStyle={{ paddingTop: '5px', paddingBottom: '5px' }}>
Expand Down
2 changes: 1 addition & 1 deletion client/components/Users/UserHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class UserHeader extends Component {
return <div></div>;
}

const user = this.props.user;
const user = this.props.user.toJS();
const userFields = this.props.userFields || [];
const languageDictionary = this.props.languageDictionary || {};

Expand Down
2 changes: 1 addition & 1 deletion client/components/Users/UserInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class UserInfo extends Component {
.value();

/* Prepare the user object */
const userObject = user;
const userObject = user.toJS();
if (!userObject || Object.keys(userObject).length === 0) {
return (
<LoadingPanel show={loading} animationStyle={{ paddingTop: '5px', paddingBottom: '5px' }}>
Expand Down
2 changes: 1 addition & 1 deletion client/components/Users/UserLogs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class UserLogs extends Component {
}

const languageDictionary = this.props.languageDictionary || {};
const logs = this.props.logs;
const logs = this.props.logs.toJS();
return (
<LoadingPanel show={loading} animationStyle={{ paddingTop: '5px', paddingBottom: '5px' }}>
<Error title={languageDictionary.errorTitle} message={getErrorMessage(languageDictionary, error, settings.errorTranslator)} />
Expand Down
2 changes: 1 addition & 1 deletion client/components/Users/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class UserProfile extends Component {
return (
<LoadingPanel show={loading} animationStyle={{ paddingTop: '5px', paddingBottom: '5px' }}>
<Error title={this.props.languageDictionary.errorTitle} message={getErrorMessage(this.props.languageDictionary, error, settings.errorTranslator)} >
<Json jsonObject={user} />
<Json jsonObject={user.toJS()} />
</Error>
</LoadingPanel>
);
Expand Down
1 change: 1 addition & 0 deletions client/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const CREATE_USER_REJECTED = 'CREATE_USER_REJECTED';
export const CREATE_USER_FULFILLED = 'CREATE_USER_FULFILLED';

// Edit user.
export const UPDATE_USER = 'UPDATE_USER';
export const REQUEST_FIELDS_CHANGE = 'REQUEST_FIELDS_CHANGE';
export const CANCEL_FIELDS_CHANGE = 'CANCEL_FIELDS_CHANGE';
export const FIELDS_CHANGE = 'FIELDS_CHANGE';
Expand Down
4 changes: 2 additions & 2 deletions client/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class App extends Component {

render() {
const { settingsLoading } = this.props;
const languageDictionary = this.props.languageDictionary ? this.props.languageDictionary : {};
const settings = this.props.settings.get('settings') && this.props.settings.get('settings');
const languageDictionary = this.props.languageDictionary ? this.props.languageDictionary.toJS() : {};
const settings = this.props.settings.get('settings') && this.props.settings.get('settings').toJS();
const renderCssToggle = !!(settings && settings.css && settings.altcss);

if (settingsLoading) {
Expand Down
8 changes: 4 additions & 4 deletions client/containers/Configuration/Configuration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import getErrorMessage from '../../utils/getErrorMessage';
export default connectContainer(class extends Component {
static stateToProps = (state) => ({
scripts: state.scripts,
settings: (state.settings.get('record') && state.settings.get('record').settings) || {},
languageDictionary: state.languageDictionary && state.languageDictionary.get('record')
settings: (state.settings.get('record') && state.settings.get('record').toJS().settings) || {},
languageDictionary: state.languageDictionary && state.languageDictionary.get('record').toJS()
});

static actionsToProps = {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default connectContainer(class extends Component {
componentWillReceiveProps(nextProps) {
if (nextProps.scripts) {
const code = this.state.code;
const scripts = nextProps.scripts;
const scripts = nextProps.scripts.toJS();
Object.keys(scripts).forEach(scriptName => {
if (!code[scriptName]) {
code[scriptName] = scripts[scriptName].script;
Expand Down Expand Up @@ -84,7 +84,7 @@ export default connectContainer(class extends Component {

render() {
const code = this.state.code;
const scripts = this.props.scripts;
const scripts = this.props.scripts.toJS();
const { languageDictionary, settings } = this.props;
const originalTitle = (settings.dict && settings.dict.title) || window.config.TITLE || 'User Management';
document.title = `${languageDictionary.configurationMenuItemText || 'Configuration'} - ${originalTitle}`;
Expand Down
17 changes: 2 additions & 15 deletions client/containers/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,8 @@ class LoginContainer extends Component {

componentWillMount() {
if (this.props.auth.isAuthenticated) {
console.log(`
isAuthenticated: ${this.props.auth.isAuthenticated},
pushing to ${this.props.auth.returnTo || '/users'}
`);

this.props.push(this.props.auth.returnTo || '/users');
} else if (!this.props.auth.isAuthenticating && !this.props.auth.error) {

console.log(`
isAuthenticated: ${this.props.auth.isAuthenticated},
isAuthenticating: ${this.props.auth.isAuthenticating},
error: ${this.props.auth.error},
pushing to login
`);

// reset the local storage for locale
this.props.login(this.props.location.query.returnUrl, window.config.LOCALE || 'en');
}
Expand Down Expand Up @@ -77,8 +64,8 @@ class LoginContainer extends Component {

function mapStateToProps(state) {
return {
auth: state.auth,
languageDictionary: state.languageDictionary.get('record')
auth: state.auth.toJS(),
languageDictionary: state.languageDictionary.get('record').toJS()
};
}

Expand Down
4 changes: 2 additions & 2 deletions client/containers/Logs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ function mapStateToProps(state) {
error: state.log.get('error'),
loading: state.log.get('loading')
},
settings: (state.settings.get('record') && state.settings.get('record').settings) || {},
languageDictionary: state.languageDictionary.get('record')
settings: (state.settings.get('record') && state.settings.get('record').toJS().settings) || {},
languageDictionary: state.languageDictionary.get('record').toJS()
};
}

Expand Down
Loading

0 comments on commit 41c291d

Please sign in to comment.