mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
Renamed sidebar actions as they make more sense
This commit is contained in:
parent
73d4707420
commit
c949359d6f
4 changed files with 17 additions and 17 deletions
|
@ -12,8 +12,8 @@ import { AsideMenuProps } from './AsideMenu';
|
||||||
import './MenuLayout.scss';
|
import './MenuLayout.scss';
|
||||||
|
|
||||||
interface MenuLayoutProps {
|
interface MenuLayoutProps {
|
||||||
sidebarRendered: Function;
|
sidebarPresent: Function;
|
||||||
sidebarNotRendered: Function;
|
sidebarNotPresent: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuLayout = (
|
const MenuLayout = (
|
||||||
|
@ -29,16 +29,16 @@ const MenuLayout = (
|
||||||
Overview: FC,
|
Overview: FC,
|
||||||
EditShortUrl: FC,
|
EditShortUrl: FC,
|
||||||
ManageDomains: FC,
|
ManageDomains: FC,
|
||||||
) => withSelectedServer<MenuLayoutProps>(({ selectedServer, sidebarNotRendered, sidebarRendered }) => {
|
) => withSelectedServer<MenuLayoutProps>(({ selectedServer, sidebarNotPresent, sidebarPresent }) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [ sidebarVisible, toggleSidebar, showSidebar, hideSidebar ] = useToggle();
|
const [ sidebarVisible, toggleSidebar, showSidebar, hideSidebar ] = useToggle();
|
||||||
const showContent = isReachableServer(selectedServer);
|
const showContent = isReachableServer(selectedServer);
|
||||||
|
|
||||||
useEffect(() => hideSidebar(), [ location ]);
|
useEffect(() => hideSidebar(), [ location ]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
showContent && sidebarRendered();
|
showContent && sidebarPresent();
|
||||||
|
|
||||||
return () => sidebarNotRendered();
|
return () => sidebarNotPresent();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!showContent) {
|
if (!showContent) {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { Action } from 'redux';
|
||||||
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
|
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
|
||||||
|
|
||||||
/* eslint-disable padding-line-between-statements */
|
/* eslint-disable padding-line-between-statements */
|
||||||
export const SIDEBAR_RENDERED = 'shlink/common/SIDEBAR_RENDERED';
|
export const SIDEBAR_PRESENT = 'shlink/common/SIDEBAR_PRESENT';
|
||||||
export const SIDEBAR_NOT_RENDERED = 'shlink/common/SIDEBAR_NOT_RENDERED';
|
export const SIDEBAR_NOT_PRESENT = 'shlink/common/SIDEBAR_NOT_PRESENT';
|
||||||
/* eslint-enable padding-line-between-statements */
|
/* eslint-enable padding-line-between-statements */
|
||||||
|
|
||||||
export interface Sidebar {
|
export interface Sidebar {
|
||||||
|
@ -18,10 +18,10 @@ const initialState: Sidebar = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildReducer<Sidebar, SidebarRenderedAction & SidebarNotRenderedAction>({
|
export default buildReducer<Sidebar, SidebarRenderedAction & SidebarNotRenderedAction>({
|
||||||
[SIDEBAR_RENDERED]: () => ({ hasSidebar: true }),
|
[SIDEBAR_PRESENT]: () => ({ hasSidebar: true }),
|
||||||
[SIDEBAR_NOT_RENDERED]: () => ({ hasSidebar: false }),
|
[SIDEBAR_NOT_PRESENT]: () => ({ hasSidebar: false }),
|
||||||
}, initialState);
|
}, initialState);
|
||||||
|
|
||||||
export const sidebarRendered = buildActionCreator(SIDEBAR_RENDERED);
|
export const sidebarPresent = buildActionCreator(SIDEBAR_PRESENT);
|
||||||
|
|
||||||
export const sidebarNotRendered = buildActionCreator(SIDEBAR_NOT_RENDERED);
|
export const sidebarNotPresent = buildActionCreator(SIDEBAR_NOT_PRESENT);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import ErrorHandler from '../ErrorHandler';
|
||||||
import ShlinkVersionsContainer from '../ShlinkVersionsContainer';
|
import ShlinkVersionsContainer from '../ShlinkVersionsContainer';
|
||||||
import { ConnectDecorator } from '../../container/types';
|
import { ConnectDecorator } from '../../container/types';
|
||||||
import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer';
|
import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer';
|
||||||
import { sidebarNotRendered, sidebarRendered } from '../reducers/sidebar';
|
import { sidebarNotPresent, sidebarPresent } from '../reducers/sidebar';
|
||||||
import { ImageDownloader } from './ImageDownloader';
|
import { ImageDownloader } from './ImageDownloader';
|
||||||
|
|
||||||
const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
|
@ -45,7 +45,7 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
'EditShortUrl',
|
'EditShortUrl',
|
||||||
'ManageDomains',
|
'ManageDomains',
|
||||||
);
|
);
|
||||||
bottle.decorator('MenuLayout', connect([ 'selectedServer' ], [ 'selectServer', 'sidebarRendered', 'sidebarNotRendered' ]));
|
bottle.decorator('MenuLayout', connect([ 'selectedServer' ], [ 'selectServer', 'sidebarPresent', 'sidebarNotPresent' ]));
|
||||||
|
|
||||||
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
|
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window', 'console');
|
bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window', 'console');
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
bottle.serviceFactory('sidebarRendered', () => sidebarRendered);
|
bottle.serviceFactory('sidebarPresent', () => sidebarPresent);
|
||||||
bottle.serviceFactory('sidebarNotRendered', () => sidebarNotRendered);
|
bottle.serviceFactory('sidebarNotPresent', () => sidebarNotPresent);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default provideServices;
|
export default provideServices;
|
||||||
|
|
|
@ -22,8 +22,8 @@ describe('<MenuLayout />', () => {
|
||||||
|
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<MenuLayout
|
<MenuLayout
|
||||||
sidebarNotRendered={jest.fn()}
|
sidebarNotPresent={jest.fn()}
|
||||||
sidebarRendered={jest.fn}
|
sidebarPresent={jest.fn}
|
||||||
selectServer={jest.fn()}
|
selectServer={jest.fn()}
|
||||||
selectedServer={selectedServer}
|
selectedServer={selectedServer}
|
||||||
/>,
|
/>,
|
||||||
|
|
Loading…
Reference in a new issue