Commit 366f0c11 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza

Unnecessary API calls

parent 1e270aec
Pipeline #7444 passed with stages
in 9 minutes and 43 seconds
......@@ -5,6 +5,7 @@ import { clearCookies, saveCookies } from 'utilities';
import { ROLE_CLIENT } from 'constants/userRoles';
import { log } from 'utilities/debug';
import { configureBackendApi } from 'utilities/requestUtils';
import {receiveUserProfile} from './userProfile';
export function checkAccessTokens(dispatch) {
const cookieToken: string = typeof window !== 'undefined' && cookies.get('access_token');
......@@ -123,6 +124,7 @@ export const logoutRequest = () => (dispatch, getState) => {
return LoginService.logout(token)
.then(() => {
clearCookies();
dispatch(receiveUserProfile(null));
return dispatch(logout());
});
};
......@@ -7,7 +7,7 @@ import { RECEIVE_USER_PROFILE } from 'constants/userProfile';
import User from 'model/user/User';
import { IReducerAction } from 'model/common.model';
const receiveUserProfile = (user: User): IReducerAction => ({
export const receiveUserProfile = (user: User): IReducerAction => ({
type: RECEIVE_USER_PROFILE, payload: user,
});
......
......@@ -161,7 +161,7 @@ const mapStateToProps = (state, ownProps) => ({
sort: parse(ownProps.location.search).s, // page sorts
dir: parse(ownProps.location.search).d, // page sort directions
filter: state.filterCode.filters && parse(ownProps.location.search).filter && state.filterCode.filters[parse(ownProps.location.search).filter] || null,
filterCode: parse(ownProps.location.search).filter,
filterCode: parse(ownProps.location.search).filter || '',
}),
paged: state.datasets.public.paged,
});
......
......@@ -33,7 +33,9 @@ interface IDatasetProps extends React.ClassAttributes<any> {
class BasicInfoStep extends React.Component<IDatasetProps, any> {
protected static needs = [];
protected static needs = [
() => loadMyPartners(),
];
public componentWillMount() {
const {myPartners, loadMyPartners} = this.props;
......@@ -68,6 +70,7 @@ class BasicInfoStep extends React.Component<IDatasetProps, any> {
const mapStateToProps = (state, ownProps) => ({
dataset: state.datasets.dashboard.dataset,
myPartners: state.partner.dashboard.myPartners,
stillLoading: ownProps.stillLoading,
location: ownProps.location,
onDelete: ownProps.onDelete,
......
......@@ -168,7 +168,7 @@ const mapStateToProps = (state, ownProps) => ({
sort: parse(ownProps.location.search).s, // page sorts
dir: parse(ownProps.location.search).d, // page sort directions
filter: state.filterCode.filters && parse(ownProps.location.search).filter && state.filterCode.filters[parse(ownProps.location.search).filter] || null,
filterCode: parse(ownProps.location.search).filter,
filterCode: parse(ownProps.location.search).filter || '',
}),
paged: state.descriptorList.public.paged,
loading: state.descriptorList.loading,
......
......@@ -45,9 +45,9 @@ class DescriptorListPage extends React.Component<IDescriptorListPageProps, any>
];
public componentWillMount() {
const {uuid, loading, loadDescriptorList} = this.props;
const {uuid, loadDescriptorList, descriptorList} = this.props;
if (uuid && (! loading || loading.uuid !== uuid)) {
if (uuid && (! descriptorList || descriptorList.uuid !== uuid)) {
loadDescriptorList(uuid);
}
}
......
......@@ -13,8 +13,6 @@ import BottomSection from 'ui/common/stepper/BottomSection';
import DescriptorList from 'model/catalog/DescriptorList';
import renderRoutes from 'ui/renderRoutes';
import {loadMyPartners} from 'partners/actions/dashboard';
import Partner from 'model/genesys/Partner';
import steps from './steps';
import PageLayout from 'ui/layout/PageLayout';
......@@ -30,8 +28,6 @@ interface IDescriptorListProps extends React.ClassAttributes<any> {
navigateTo: (path: string) => void;
setPageTitle: (title: string) => void;
loadMyPartners: any;
myPartners: Partner[];
publishDescriptorList: (descriptorList: DescriptorList, showDescriptorList: boolean) => void;
deleteDescriptorList: (descriptorList: DescriptorList) => Promise<DescriptorList>;
}
......@@ -52,11 +48,7 @@ class DescriptorListStepper extends React.Component<IDescriptorListProps, any> {
}
public componentWillMount() {
const {uuid, descriptorList, loadDescriptorList, myPartners, loadMyPartners} = this.props;
if (!myPartners) {
loadMyPartners();
}
const {uuid, descriptorList, loadDescriptorList} = this.props;
if (uuid && ! descriptorList) {
loadDescriptorList(uuid);
......@@ -128,7 +120,6 @@ const mapStateToProps = (state, ownProps) => ({
const mapDispatchToProps = (dispatch) => bindActionCreators({
loadDescriptorList,
deleteDescriptorList,
loadMyPartners,
publishDescriptorList,
setPageTitle,
navigateTo,
......
......@@ -164,7 +164,7 @@ const mapStateToProps = (state, ownProps) => ({
sort: parse(ownProps.location.search).s, // page sorts
dir: parse(ownProps.location.search).d, // page sort directions
filter: state.filterCode.filters && parse(ownProps.location.search).filter && state.filterCode.filters[parse(ownProps.location.search).filter] || null,
filterCode: parse(ownProps.location.search).filter,
filterCode: parse(ownProps.location.search).filter || '',
}),
paged: state.partner.public.paged,
loading: state.partner.public.loading,
......
......@@ -21,13 +21,19 @@ interface IProfilePageProps extends React.ClassAttributes<any> {
class ProfilePage extends React.Component<IProfilePageProps, any> {
protected static needs = [
() => loadUserProfile(),
];
constructor(props) {
super(props);
}
public componentWillMount() {
const { loadUserProfile } = this.props;
loadUserProfile();
const { loadUserProfile, userProfile } = this.props;
if (! userProfile) {
loadUserProfile();
}
}
private onChangePassword = (values) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment