mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SignIn: Update redirect on reroute (#18360)
* Connect SignIn with redux and get url * Update test snapshot
This commit is contained in:
parent
09e7938499
commit
b62ab25c41
@ -1,10 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import SignIn from './SignIn';
|
import { SignIn } from './SignIn';
|
||||||
|
|
||||||
describe('Render', () => {
|
describe('Render', () => {
|
||||||
it('should render component', () => {
|
it('should render component', () => {
|
||||||
const wrapper = shallow(<SignIn />);
|
const wrapper = shallow(<SignIn url="/" />);
|
||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
import { connectWithStore } from 'app/core/utils/connectWithReduxStore';
|
||||||
|
import { StoreState } from 'app/types';
|
||||||
|
|
||||||
const SignIn: FC<any> = () => {
|
export const SignIn: FC<any> = ({ url }) => {
|
||||||
const loginUrl = `login?redirect=${encodeURIComponent(window.location.pathname)}`;
|
const loginUrl = `login?redirect=${encodeURIComponent(url)}`;
|
||||||
return (
|
return (
|
||||||
<div className="sidemenu-item">
|
<div className="sidemenu-item">
|
||||||
<a href={loginUrl} className="sidemenu-link" target="_self">
|
<a href={loginUrl} className="sidemenu-link" target="_self">
|
||||||
@ -20,4 +22,8 @@ const SignIn: FC<any> = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SignIn;
|
const mapStateToProps = (state: StoreState) => ({
|
||||||
|
url: state.location.url,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connectWithStore(SignIn, mapStateToProps);
|
||||||
|
@ -4,7 +4,7 @@ exports[`Render should render component 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="sidemenu__bottom"
|
className="sidemenu__bottom"
|
||||||
>
|
>
|
||||||
<SignIn />
|
<Component />
|
||||||
<BottomNavLinks
|
<BottomNavLinks
|
||||||
key="undefined-0"
|
key="undefined-0"
|
||||||
link={
|
link={
|
||||||
|
Loading…
Reference in New Issue
Block a user