Skip to content

Commit

Permalink
fix: tidy up bookmarks, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Aug 26, 2020
1 parent 2113ab3 commit 5a9e5ae
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 41 deletions.
3 changes: 2 additions & 1 deletion bin/build-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ async function readSvg (svg) {
const optimized = (await svgo.optimize(content))
const $optimized = $(optimized.data)
const $path = $optimized.find('path, circle').removeAttr('fill')
const viewBox = $optimized.attr('viewBox') || `0 0 ${$optimized.attr('width')} ${$optimized.attr('height')}`
const $symbol = $('<symbol></symbol>')
.attr('id', svg.id)
.attr('viewBox', $optimized.attr('viewBox'))
.attr('viewBox', viewBox)
.append($path)
return $.xml($symbol)
}
Expand Down
4 changes: 2 additions & 2 deletions bin/svgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ module.exports = [
{ id: 'fa-info-circle', src: 'src/thirdparty/font-awesome-svg-png/white/svg/info-circle.svg' },
{ id: 'fa-crosshairs', src: 'src/thirdparty/font-awesome-svg-png/white/svg/crosshairs.svg' },
{ id: 'fa-magic', src: 'src/thirdparty/font-awesome-svg-png/white/svg/magic.svg' },
{ id: 'fa-hashtag', src: 'src/thirdparty/font-awesome-svg-png/white/svg/hashtag.svg' },
{ id: 'fa-bookmark', src: 'src/thirdparty/font-awesome-svg-png/white/svg/bookmark.svg' },
{ id: 'fa-hashtag', src: 'src/thirdparty/font-awesome-svg-png/white/svg/hashtag.svg' },
{ id: 'fa-bookmark', src: 'src/thirdparty/font-awesome-svg-png/white/svg/bookmark.svg' }
]
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@
label: 'Delete and redraft',
icon: '#fa-pencil'
},
{
key: 'bookmark',
label: bookmarkLabel,
icon: '#fa-bookmark'
},
!isUser && {
key: 'report',
label: 'Report toot',
Expand All @@ -138,11 +143,6 @@
key: 'copy',
label: 'Copy link to toot',
icon: '#fa-link'
},
{
key: 'bookmark',
label: bookmarkLabel,
icon: '#fa-bookmark'
}
].filter(Boolean))
},
Expand Down
72 changes: 40 additions & 32 deletions src/routes/_pages/community/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,14 @@ <h2 class="community-header">
</h2>

<PageList label="Timelines">
<PageListItem href="/local"
label="Local Timeline"
icon="#fa-users"
pinnable="true"
pinIndex={0}
/>
<PageListItem href="/federated"
label="Federated Timeline"
icon="#fa-globe"
pinnable="true"
pinIndex={1}
/>
<PageListItem href="/favorites"
label="Favorites"
icon="#fa-star"
pinnable="true"
pinIndex={2}
/>
<PageListItem href="/direct"
label="Direct messages"
icon="#fa-envelope"
pinnable="true"
pinIndex={3}
/>
<PageListItem href="/bookmarks"
label="Bookmarks"
icon="#fa-bookmark"
pinnable="true"
pinIndex={4}
/>
{#each staticPinnables as staticPinnable, i}
<PageListItem href={staticPinnable.href}
label={staticPinnable.label}
icon={staticPinnable.icon}
pinnable="true"
pinIndex={i}
/>
{/each}
</PageList>

{#if listsLength}
Expand All @@ -56,7 +34,7 @@ <h2 class="community-header">
label={list.title}
icon="#fa-bars"
pinnable="true"
pinIndex={4 + i}
pinIndex={staticPinnablesLength + i}
/>
{/each}
</PageList>
Expand Down Expand Up @@ -152,13 +130,43 @@ <h1>Community</h1>
RadioGroup,
FocusRestoration
},
data: () => ({
staticPinnables: [
{
href: '/local',
label: 'Local Timeline',
icon: '#fa-users'
},
{
href: '/federated',
label: 'Federated Timeline',
icon: '#fa-globe'
},
{
href: '/favorites',
label: 'Favorites',
icon: '#fa-star'
},
{
href: '/direct',
label: 'Direct messages',
icon: '#fa-envelope'
},
{
href: '/bookmarks',
label: 'Bookmarks',
icon: '#fa-bookmark'
}
]
}),
computed: {
isLockedAccount: ({ $currentVerifyCredentials }) => $currentVerifyCredentials && $currentVerifyCredentials.locked,
followRequestsLabel: ({ $hasFollowRequests, $numberOfFollowRequests }) => (
`Follow requests${$hasFollowRequests ? ` (${$numberOfFollowRequests})` : ''}`
),
listsLength: ({ $lists }) => $lists ? $lists.length : 0,
numPinnable: ({ listsLength }) => listsLength + 4 // 4 because of local/federated/favs/direct
staticPinnablesLength: ({ staticPinnables }) => staticPinnables.length,
numPinnable: ({ listsLength, staticPinnablesLength }) => listsLength + staticPinnablesLength
}
}
</script>
3 changes: 2 additions & 1 deletion src/thirdparty/font-awesome-svg-png/white/svg/bookmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions tests/spec/135-bookmarks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
communityNavButton, getNthStatus,
getNthStatusOptionsButton, homeNavButton
} from '../utils'
import { loginAsFoobar } from '../roles'
import { Selector as $ } from 'testcafe'
import { postAs } from '../serverActions'

fixture`135-bookmarks.js`
.page`http://localhost:4002`

test('Can open a report UI from a status', async t => {
await postAs('admin', 'hey bookmark this')
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
.click(getNthStatusOptionsButton(1))
.click($('.modal-dialog button').withText('Bookmark'))
.click(communityNavButton)
.click($('a').withText('Bookmarks'))
.expect(getNthStatus(1).innerText).contains('hey bookmark this')
.click(homeNavButton)
.click(getNthStatusOptionsButton(1))
.click($('.modal-dialog button').withText('Unbookmark'))
})

0 comments on commit 5a9e5ae

Please sign in to comment.