import DeferredSpinner from '../../../components/common/DeferredSpinner';
import handleRequiredAuthentication from '../../../app/utils/handleRequiredAuthentication';
import { getCurrentUser } from '../../../store/rootReducer';
+import { addGlobalErrorMessage } from '../../../store/globalMessages/duck';
import { skipOnboarding as skipOnboardingAction } from '../../../store/users/actions';
import { CurrentUser, IdentityProvider, isLoggedIn, LoggedInUser } from '../../../app/types';
import { skipOnboarding, getIdentityProviders } from '../../../api/users';
}
interface DispatchProps {
+ addGlobalErrorMessage: (message: string) => void;
skipOnboardingAction: () => void;
}
constructor(props: Props) {
super(props);
this.state = { loading: true };
+ const query = parseQuery(props.location.query);
+ if (query.error) {
+ this.props.addGlobalErrorMessage(query.error);
+ }
if (!this.canAutoCreate(props)) {
this.updateQuery({ manual: true });
}
};
};
-const mapDispatchToProps: DispatchProps = { skipOnboardingAction };
+const mapDispatchToProps: DispatchProps = { addGlobalErrorMessage, skipOnboardingAction };
export default connect<StateProps, DispatchProps, OwnProps>(mapStateToProps, mapDispatchToProps)(
CreateProjectPage
expect(wrapper.find('AutoProjectCreate').exists()).toBeTruthy();
});
+it('should display an error message on load', () => {
+ const addGlobalErrorMessage = jest.fn();
+ getWrapper({
+ addGlobalErrorMessage,
+ location: { pathname: 'foo', query: { error: 'Foo error' } }
+ });
+ expect(addGlobalErrorMessage).toHaveBeenCalledWith('Foo error');
+});
+
function getWrapper(props = {}) {
return shallow(
<CreateProjectPage
+ addGlobalErrorMessage={jest.fn()}
currentUser={user}
location={{ pathname: 'foo', query: { manual: 'false' } } as Location}
router={{ push: jest.fn(), replace: jest.fn() }}
cleanQuery,
RawQuery,
parseAsBoolean,
- serializeOptionalBoolean
+ serializeOptionalBoolean,
+ parseAsOptionalString
} from '../../../helpers/query';
export interface Query {
+ error?: string;
manual: boolean;
}
export const parseQuery = memoize((urlQuery: RawQuery): Query => {
return {
+ error: parseAsOptionalString(urlQuery['error']),
manual: parseAsBoolean(urlQuery['manual'], false)
};
});