mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added saga for boris load stats
This commit is contained in:
parent
f8b2b3707b
commit
29c3b8a26f
8 changed files with 83 additions and 7 deletions
|
@ -14,15 +14,18 @@ import { NodeCommentForm } from '~/components/node/NodeCommentForm';
|
||||||
import * as NODE_ACTIONS from '~/redux/node/actions';
|
import * as NODE_ACTIONS from '~/redux/node/actions';
|
||||||
import * as AUTH_ACTIONS from '~/redux/auth/actions';
|
import * as AUTH_ACTIONS from '~/redux/auth/actions';
|
||||||
import * as MODAL_ACTIONS from '~/redux/modal/actions';
|
import * as MODAL_ACTIONS from '~/redux/modal/actions';
|
||||||
|
import * as BORIS_ACTIONS from '~/redux/boris/actions';
|
||||||
import isBefore from 'date-fns/isBefore';
|
import isBefore from 'date-fns/isBefore';
|
||||||
import { Card } from '~/components/containers/Card';
|
import { Card } from '~/components/containers/Card';
|
||||||
import { Footer } from '~/components/main/Footer';
|
import { Footer } from '~/components/main/Footer';
|
||||||
import { Filler } from '~/components/containers/Filler';
|
|
||||||
import { Sticky } from '~/components/containers/Sticky';
|
import { Sticky } from '~/components/containers/Sticky';
|
||||||
|
import { Placeholder } from '~/components/placeholders/Placeholder';
|
||||||
|
import { selectBorisStats } from '~/redux/boris/selectors';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
node: selectNode(state),
|
node: selectNode(state),
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
|
stats: selectBorisStats(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
|
@ -32,6 +35,7 @@ const mapDispatchToProps = {
|
||||||
nodeLoadMoreComments: NODE_ACTIONS.nodeLoadMoreComments,
|
nodeLoadMoreComments: NODE_ACTIONS.nodeLoadMoreComments,
|
||||||
authSetUser: AUTH_ACTIONS.authSetUser,
|
authSetUser: AUTH_ACTIONS.authSetUser,
|
||||||
modalShowPhotoswipe: MODAL_ACTIONS.modalShowPhotoswipe,
|
modalShowPhotoswipe: MODAL_ACTIONS.modalShowPhotoswipe,
|
||||||
|
borisLoadStats: BORIS_ACTIONS.borisLoadStats,
|
||||||
};
|
};
|
||||||
|
|
||||||
type IProps = ReturnType<typeof mapStateToProps> &
|
type IProps = ReturnType<typeof mapStateToProps> &
|
||||||
|
@ -50,6 +54,8 @@ const BorisLayoutUnconnected: FC<IProps> = ({
|
||||||
nodeLoadMoreComments,
|
nodeLoadMoreComments,
|
||||||
modalShowPhotoswipe,
|
modalShowPhotoswipe,
|
||||||
authSetUser,
|
authSetUser,
|
||||||
|
borisLoadStats,
|
||||||
|
stats,
|
||||||
}) => {
|
}) => {
|
||||||
const title = getRandomPhrase('BORIS_TITLE');
|
const title = getRandomPhrase('BORIS_TITLE');
|
||||||
|
|
||||||
|
@ -67,6 +73,10 @@ const BorisLayoutUnconnected: FC<IProps> = ({
|
||||||
nodeLoadNode(id, 'DESC');
|
nodeLoadNode(id, 'DESC');
|
||||||
}, [nodeLoadNode, id]);
|
}, [nodeLoadNode, id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
borisLoadStats();
|
||||||
|
}, [borisLoadStats]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<div className={styles.cover} />
|
<div className={styles.cover} />
|
||||||
|
@ -111,7 +121,30 @@ const BorisLayoutUnconnected: FC<IProps> = ({
|
||||||
<p>Здесь мы сидим и слушаем всё, что вас беспокоит.</p>
|
<p>Здесь мы сидим и слушаем всё, что вас беспокоит.</p>
|
||||||
<p>А потом чиним долгими дождливыми вечерами.</p>
|
<p>А потом чиним долгими дождливыми вечерами.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/*
|
||||||
|
<div className={styles.stats__title}>Контент</div>
|
||||||
|
|
||||||
|
<Placeholder width="35%" />
|
||||||
|
<Placeholder width="40%" />
|
||||||
|
<Placeholder width="35%" />
|
||||||
|
<Placeholder width="20%" />
|
||||||
|
|
||||||
|
<div className={styles.stats__title}>Хранилище</div>
|
||||||
|
|
||||||
|
<Placeholder width="35%" />
|
||||||
|
<Placeholder width="35%" />
|
||||||
|
<Placeholder width="40%" />
|
||||||
|
*/}
|
||||||
|
|
||||||
<div className={styles.stats__title}>Изменения</div>
|
<div className={styles.stats__title}>Изменения</div>
|
||||||
|
|
||||||
|
<Placeholder width="50%" />
|
||||||
|
<Placeholder width="100%" />
|
||||||
|
<Placeholder width="50%" />
|
||||||
|
<Placeholder width="70%" />
|
||||||
|
<Placeholder width="60%" />
|
||||||
|
<Placeholder width="100%" />
|
||||||
</Group>
|
</Group>
|
||||||
</Sticky>
|
</Sticky>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 4;
|
flex: 3;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
border-radius: $radius 0 0 $radius;
|
border-radius: $radius;
|
||||||
// flex: 0 1 $limited_width;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background: $node_bg;
|
background: $node_bg;
|
||||||
box-shadow: inset transparentize(mix($wisegreen, white, 60%), 0.6) 0 1px;
|
box-shadow: inset transparentize(mix($wisegreen, white, 60%), 0.6) 0 1px;
|
||||||
|
@ -117,6 +116,7 @@
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
padding-top: 10px;
|
||||||
|
|
||||||
&__container {
|
&__container {
|
||||||
background: darken($content_bg, 4%);
|
background: darken($content_bg, 4%);
|
||||||
|
@ -132,7 +132,6 @@
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
margin-top: 16px !important;
|
margin-top: 16px !important;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__about {
|
&__about {
|
||||||
|
|
11
src/redux/boris/actions.ts
Normal file
11
src/redux/boris/actions.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { IBorisState } from './reducer';
|
||||||
|
import { BORIS_ACTIONS } from './constants';
|
||||||
|
|
||||||
|
export const borisSet = (state: Partial<IBorisState>) => ({
|
||||||
|
type: BORIS_ACTIONS.SET_BORIS,
|
||||||
|
state,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const borisLoadStats = () => ({
|
||||||
|
type: BORIS_ACTIONS.LOAD_STATS,
|
||||||
|
});
|
6
src/redux/boris/constants.ts
Normal file
6
src/redux/boris/constants.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
const prefix = `BORIS.`;
|
||||||
|
|
||||||
|
export const BORIS_ACTIONS = {
|
||||||
|
SET_BORIS: `${prefix}SET_BORIS`,
|
||||||
|
LOAD_STATS: `${prefix}LOAD_STATS`,
|
||||||
|
};
|
|
@ -1 +1,11 @@
|
||||||
export const BORIS_HANDLERS = {};
|
import { IBorisState } from './reducer';
|
||||||
|
import { BORIS_ACTIONS } from './constants';
|
||||||
|
|
||||||
|
const borisSet = (current: IBorisState, { state }: ReturnType<typeof borisSet>) => ({
|
||||||
|
...current,
|
||||||
|
...state,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const BORIS_HANDLERS = {
|
||||||
|
[BORIS_ACTIONS.SET_BORIS]: borisSet,
|
||||||
|
};
|
||||||
|
|
|
@ -11,12 +11,14 @@ export type IBorisState = Readonly<{
|
||||||
stats: {
|
stats: {
|
||||||
git: IStatGitRow[];
|
git: IStatGitRow[];
|
||||||
};
|
};
|
||||||
|
is_loading: boolean;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
const BORIS_INITIAL_STATE: IBorisState = {
|
const BORIS_INITIAL_STATE: IBorisState = {
|
||||||
stats: {
|
stats: {
|
||||||
git: [],
|
git: [],
|
||||||
},
|
},
|
||||||
|
is_loading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createReducer(BORIS_INITIAL_STATE, BORIS_HANDLERS);
|
export default createReducer(BORIS_INITIAL_STATE, BORIS_HANDLERS);
|
||||||
|
|
|
@ -1 +1,12 @@
|
||||||
export default function* borisSaga() {}
|
import { takeLatest, put } from 'redux-saga/effects';
|
||||||
|
import { BORIS_ACTIONS } from './constants';
|
||||||
|
import { borisSet } from './actions';
|
||||||
|
|
||||||
|
function* loadStats() {
|
||||||
|
yield put(borisSet({ is_loading: true }));
|
||||||
|
yield put(borisSet({ is_loading: false }));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function* borisSaga() {
|
||||||
|
yield takeLatest(BORIS_ACTIONS.LOAD_STATS, loadStats);
|
||||||
|
}
|
||||||
|
|
4
src/redux/boris/selectors.ts
Normal file
4
src/redux/boris/selectors.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import { IState } from '../store';
|
||||||
|
|
||||||
|
export const selectBoris = (state: IState) => state.boris;
|
||||||
|
export const selectBorisStats = (state: IState) => state.boris.stats;
|
Loading…
Add table
Add a link
Reference in a new issue