mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-12-15 13:39:40 -06:00
Added short URL title to visits header
This commit is contained in:
parent
df87ad5867
commit
87a32b412f
@ -61,7 +61,8 @@ body,
|
|||||||
.dropdown-divider,
|
.dropdown-divider,
|
||||||
.dropdown-menu,
|
.dropdown-menu,
|
||||||
.list-group-item,
|
.list-group-item,
|
||||||
.modal-content {
|
.modal-content,
|
||||||
|
hr {
|
||||||
border-color: var(--border-color);
|
border-color: var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ $mediumGrey: #dee2e6;
|
|||||||
$textPlaceholder: #6c757d;
|
$textPlaceholder: #6c757d;
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
$headerHeight: 57px;
|
$headerHeight: 56px;
|
||||||
$asideMenuWidth: 260px;
|
$asideMenuWidth: 260px;
|
||||||
$footer-height: 2.3rem;
|
$footer-height: 2.3rem;
|
||||||
$footer-margin: .8rem;
|
$footer-margin: .8rem;
|
||||||
|
|||||||
@ -17,6 +17,7 @@ const ShortUrlVisitsHeader = ({ shortUrlDetail, shortUrlVisits, goBack }: ShortU
|
|||||||
const { visits } = shortUrlVisits;
|
const { visits } = shortUrlVisits;
|
||||||
const shortLink = shortUrl?.shortUrl ?? '';
|
const shortLink = shortUrl?.shortUrl ?? '';
|
||||||
const longLink = shortUrl?.longUrl ?? '';
|
const longLink = shortUrl?.longUrl ?? '';
|
||||||
|
const title = shortUrl?.title;
|
||||||
|
|
||||||
const renderDate = () => !shortUrl ? <small>Loading...</small> : (
|
const renderDate = () => !shortUrl ? <small>Loading...</small> : (
|
||||||
<span>
|
<span>
|
||||||
@ -39,9 +40,9 @@ const ShortUrlVisitsHeader = ({ shortUrlDetail, shortUrlVisits, goBack }: ShortU
|
|||||||
<hr />
|
<hr />
|
||||||
<div>Created: {renderDate()}</div>
|
<div>Created: {renderDate()}</div>
|
||||||
<div>
|
<div>
|
||||||
Long URL:{' '}
|
{`${title ? 'Title' : 'Long URL'}: `}
|
||||||
{loading && <small>Loading...</small>}
|
{loading && <small>Loading...</small>}
|
||||||
{!loading && <ExternalLink href={longLink} />}
|
{!loading && <ExternalLink href={longLink}>{title ?? longLink}</ExternalLink>}
|
||||||
</div>
|
</div>
|
||||||
</VisitsHeader>
|
</VisitsHeader>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -8,35 +8,48 @@ import { ShortUrlVisits } from '../../src/visits/reducers/shortUrlVisits';
|
|||||||
|
|
||||||
describe('<ShortUrlVisitsHeader />', () => {
|
describe('<ShortUrlVisitsHeader />', () => {
|
||||||
let wrapper: ShallowWrapper;
|
let wrapper: ShallowWrapper;
|
||||||
const shortUrlDetail = Mock.of<ShortUrlDetail>({
|
const dateCreated = '2018-01-01T10:00:00+01:00';
|
||||||
shortUrl: {
|
const longUrl = 'https://foo.bar/bar/foo';
|
||||||
shortUrl: 'https://doma.in/abc123',
|
|
||||||
longUrl: 'https://foo.bar/bar/foo',
|
|
||||||
dateCreated: '2018-01-01T10:00:00+01:00',
|
|
||||||
},
|
|
||||||
loading: false,
|
|
||||||
});
|
|
||||||
const shortUrlVisits = Mock.of<ShortUrlVisits>({
|
const shortUrlVisits = Mock.of<ShortUrlVisits>({
|
||||||
visits: [{}, {}, {}],
|
visits: [{}, {}, {}],
|
||||||
});
|
});
|
||||||
const goBack = jest.fn();
|
const goBack = jest.fn();
|
||||||
|
const createWrapper = (title?: string | null) => {
|
||||||
|
const shortUrlDetail = Mock.of<ShortUrlDetail>({
|
||||||
|
shortUrl: {
|
||||||
|
shortUrl: 'https://doma.in/abc123',
|
||||||
|
longUrl,
|
||||||
|
dateCreated,
|
||||||
|
title,
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<ShortUrlVisitsHeader shortUrlDetail={shortUrlDetail} shortUrlVisits={shortUrlVisits} goBack={goBack} />,
|
<ShortUrlVisitsHeader shortUrlDetail={shortUrlDetail} shortUrlVisits={shortUrlVisits} goBack={goBack} />,
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
return wrapper;
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => createWrapper());
|
||||||
afterEach(() => wrapper.unmount());
|
afterEach(() => wrapper.unmount());
|
||||||
|
|
||||||
it('shows when the URL was created', () => {
|
it('shows when the URL was created', () => {
|
||||||
const moment = wrapper.find(Moment).first();
|
const moment = wrapper.find(Moment).first();
|
||||||
|
|
||||||
expect(moment.prop('children')).toEqual(shortUrlDetail.shortUrl?.dateCreated);
|
expect(moment.prop('children')).toEqual(dateCreated);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows the long URL', () => {
|
it.each([
|
||||||
|
[ null, longUrl ],
|
||||||
|
[ undefined, longUrl ],
|
||||||
|
[ 'My cool title', 'My cool title' ],
|
||||||
|
])('shows the long URL and title', (title, expectedContent) => {
|
||||||
|
const wrapper = createWrapper(title);
|
||||||
const longUrlLink = wrapper.find(ExternalLink).last();
|
const longUrlLink = wrapper.find(ExternalLink).last();
|
||||||
|
|
||||||
expect(longUrlLink.prop('href')).toEqual(shortUrlDetail.shortUrl?.longUrl);
|
expect(longUrlLink.prop('href')).toEqual(longUrl);
|
||||||
|
expect(longUrlLink.prop('children')).toEqual(expectedContent);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user