From 5a9e5ae8bc462b44a0edd7c07d0d2b16e576e11e Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Tue, 25 Aug 2020 16:36:41 -0700 Subject: [PATCH] fix: tidy up bookmarks, add tests --- bin/build-svg.js | 3 +- bin/svgs.js | 4 +- .../components/StatusOptionsDialog.html | 10 +-- src/routes/_pages/community/index.html | 72 ++++++++++--------- .../white/svg/bookmark.svg | 3 +- tests/spec/135-bookmarks.js | 25 +++++++ 6 files changed, 76 insertions(+), 41 deletions(-) create mode 100644 tests/spec/135-bookmarks.js diff --git a/bin/build-svg.js b/bin/build-svg.js index 86f6f785..fd211e0c 100755 --- a/bin/build-svg.js +++ b/bin/build-svg.js @@ -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 = $('') .attr('id', svg.id) - .attr('viewBox', $optimized.attr('viewBox')) + .attr('viewBox', viewBox) .append($path) return $.xml($symbol) } diff --git a/bin/svgs.js b/bin/svgs.js index ee2bb94d..683ebeef 100644 --- a/bin/svgs.js +++ b/bin/svgs.js @@ -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' } ] diff --git a/src/routes/_components/dialog/components/StatusOptionsDialog.html b/src/routes/_components/dialog/components/StatusOptionsDialog.html index d8d75588..25b95042 100644 --- a/src/routes/_components/dialog/components/StatusOptionsDialog.html +++ b/src/routes/_components/dialog/components/StatusOptionsDialog.html @@ -124,6 +124,11 @@ export default { label: 'Delete and redraft', icon: '#fa-pencil' }, + { + key: 'bookmark', + label: bookmarkLabel, + icon: '#fa-bookmark' + }, !isUser && { key: 'report', label: 'Report toot', @@ -138,11 +143,6 @@ export default { key: 'copy', label: 'Copy link to toot', icon: '#fa-link' - }, - { - key: 'bookmark', - label: bookmarkLabel, - icon: '#fa-bookmark' } ].filter(Boolean)) }, diff --git a/src/routes/_pages/community/index.html b/src/routes/_pages/community/index.html index e5e4b55e..8754e62d 100644 --- a/src/routes/_pages/community/index.html +++ b/src/routes/_pages/community/index.html @@ -12,36 +12,14 @@ - - - - - + {#each staticPinnables as staticPinnable, i} + + {/each} {#if listsLength} @@ -56,7 +34,7 @@ label={list.title} icon="#fa-bars" pinnable="true" - pinIndex={4 + i} + pinIndex={staticPinnablesLength + i} /> {/each} @@ -152,13 +130,43 @@ 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 } } diff --git a/src/thirdparty/font-awesome-svg-png/white/svg/bookmark.svg b/src/thirdparty/font-awesome-svg-png/white/svg/bookmark.svg index 33ff1026..2a409d8e 100644 --- a/src/thirdparty/font-awesome-svg-png/white/svg/bookmark.svg +++ b/src/thirdparty/font-awesome-svg-png/white/svg/bookmark.svg @@ -1 +1,2 @@ - + + \ No newline at end of file diff --git a/tests/spec/135-bookmarks.js b/tests/spec/135-bookmarks.js new file mode 100644 index 00000000..310708f7 --- /dev/null +++ b/tests/spec/135-bookmarks.js @@ -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')) +})