-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1137 from shlinkio/develop
Release 4.1.1
- Loading branch information
Showing
8 changed files
with
914 additions
and
1,058 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
import { clsx } from 'clsx'; | ||
import { useMemo } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import type { SelectedServer } from '../servers/data'; | ||
import { isReachableServer } from '../servers/data'; | ||
import { ShlinkVersions } from './ShlinkVersions'; | ||
import './ShlinkVersionsContainer.scss'; | ||
|
||
export type ShlinkVersionsContainerProps = { | ||
selectedServer: SelectedServer; | ||
}; | ||
|
||
const SHLINK_CONTAINER_PATH_PATTERN = /^\/server\/[a-zA-Z0-9-]*\/(?!edit)/; | ||
|
||
export const ShlinkVersionsContainer = ({ selectedServer }: ShlinkVersionsContainerProps) => { | ||
const { pathname } = useLocation(); | ||
const withPadding = useMemo(() => SHLINK_CONTAINER_PATH_PATTERN.test(pathname), [pathname]); | ||
|
||
const classes = clsx('text-center', { | ||
'shlink-versions-container--with-sidebar': withPadding, | ||
}); | ||
|
||
return ( | ||
<div className={classes}> | ||
<ShlinkVersions selectedServer={selectedServer} /> | ||
</div> | ||
); | ||
}; | ||
export const ShlinkVersionsContainer = ({ selectedServer }: ShlinkVersionsContainerProps) => ( | ||
<div | ||
className={clsx('text-center', { | ||
'shlink-versions-container--with-sidebar': isReachableServer(selectedServer), | ||
})} | ||
> | ||
<ShlinkVersions selectedServer={selectedServer} /> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
import { render } from '@testing-library/react'; | ||
import { fromPartial } from '@total-typescript/shoehorn'; | ||
import { createMemoryHistory } from 'history'; | ||
import { Router } from 'react-router-dom'; | ||
import { ShlinkVersionsContainer } from '../../src/common/ShlinkVersionsContainer'; | ||
import type { ReachableServer, SelectedServer } from '../../src/servers/data'; | ||
import { checkAccessibility } from '../__helpers__/accessibility'; | ||
|
||
describe('<ShlinkVersionsContainer />', () => { | ||
const setUp = (activeRoute: string = '') => { | ||
const history = createMemoryHistory(); | ||
history.push(activeRoute); | ||
const setUp = (selectedServer: SelectedServer = null) => render( | ||
<ShlinkVersionsContainer selectedServer={selectedServer} />, | ||
); | ||
|
||
return render( | ||
<Router location={history.location} navigator={history}> | ||
<ShlinkVersionsContainer selectedServer={fromPartial({})} /> | ||
</Router>, | ||
); | ||
}; | ||
|
||
it('passes a11y checks', () => checkAccessibility(setUp())); | ||
it.each([ | ||
[null], | ||
[fromPartial<SelectedServer>({})], | ||
[fromPartial<ReachableServer>({ version: '1.0.0', printableVersion: 'v1.0.0' })], | ||
])('passes a11y checks', (selectedServer) => checkAccessibility(setUp(selectedServer))); | ||
|
||
it.each([ | ||
['/something', 'text-center'], | ||
['/server/foo/edit', 'text-center'], | ||
['/server/foo/bar', 'text-center shlink-versions-container--with-sidebar'], | ||
])('renders proper col classes based on sidebar status', (sidebar, expectedClasses) => { | ||
const { container } = setUp(sidebar); | ||
[null, 'text-center'], | ||
[fromPartial<SelectedServer>({}), 'text-center'], | ||
[fromPartial<ReachableServer>({ version: '1.0.0' }), 'text-center shlink-versions-container--with-sidebar'], | ||
])('renders proper col classes based on sidebar status', (selectedServer, expectedClasses) => { | ||
const { container } = setUp(selectedServer); | ||
expect(container.firstChild).toHaveAttribute('class', `${expectedClasses}`); | ||
}); | ||
}); |