Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: Add a link from settings page to individual sources #1329

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Search will be carried out using regular expressions when the search query is wrapped in forward slashes, e.g. `/regex/`. The expression syntax is database specific. ([#1205](https://github.com/fossar/selfoss/pull/1205))
- YouTube spout now supports following playlists. ([#1260](https://github.com/fossar/selfoss/pull/1260))
- Confirmation is now required when leaving the setting page with unsaved source changes. ([#1300](https://github.com/fossar/selfoss/pull/1300))
- Add link from settings page to individual sources. ([#1329](https://github.com/fossar/selfoss/pull/1329))
- Translations into several new languages were added:
- English (United Kingdom): `en-GB`
- French (Canada): `fr-CA`
Expand Down
79 changes: 55 additions & 24 deletions assets/js/templates/Source.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React from 'react';
import { Button as MenuButton, Wrapper as MenuWrapper, Menu, MenuItem } from 'react-aria-menubutton';
import { useHistory, useLocation } from 'react-router-dom';
import { makeEntriesLinkLocation } from '../helpers/uri';
import PropTypes from 'prop-types';
import nullable from 'prop-types-nullable';
import { unescape } from 'html-escaper';
Expand Down Expand Up @@ -562,16 +565,24 @@ export default function Source({ source, setSources, spouts, setSpouts, dirty, s
[source.id, setDirtySources]
);

const deleteOnClick = React.useCallback(
(event) =>
handleDelete({
event,
source,
setSources,
setSourceBeingDeleted,
setDirty,
}),
[source, setSources, setDirty]
const history = useHistory();
const location = useLocation();

const extraMenuOnSelection = React.useCallback(
(value, event) => {
if (value === 'delete') {
handleDelete({
event,
source,
setSources,
setSourceBeingDeleted,
setDirty,
});
} else if (value === 'browse') {
history.push(makeEntriesLinkLocation(location, { category: `source-${source.id}` }));
}
},
[source, setSources, setDirty, location, history]
);

const _ = React.useContext(LocalizationContext);
Expand Down Expand Up @@ -612,21 +623,41 @@ export default function Source({ source, setSources, spouts, setSpouts, dirty, s
{' • '}
</React.Fragment>
}
<button
type="button"
accessKey="d"
className="source-delete"
onClick={deleteOnClick}
<MenuWrapper
className="popup-menu-wrapper"
onSelection={extraMenuOnSelection}
>
{_('source_delete')}

{sourceBeingDeleted &&
<React.Fragment>
{' '}
<Spinner />
</React.Fragment>
}
</button>
<MenuButton
className="source-menu-button"
>
{_('source_menu')}
</MenuButton>
<Menu
className="popup-menu"
>
<MenuItem
accessKey="d"
className="popup-menu-item source-browse"
value="browse"
>
{_('source_browse')}
</MenuItem>
<MenuItem
accessKey="d"
className="popup-menu-item source-delete"
value="delete"
>
{_('source_delete')}

{sourceBeingDeleted &&
<React.Fragment>
{' '}
<Spinner />
</React.Fragment>
}
</MenuItem>
</Menu>
</MenuWrapper>
</div>
<div className="source-days">
{source.lastentry
Expand Down
2 changes: 2 additions & 0 deletions assets/locale/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"lang_source_export": "Export zdrojů",
"lang_source_edit": "Upravit",
"lang_source_filter": "Filtr",
"lang_source_menu": "Více akcí",
"lang_source_browse": "Prohlížet",
"lang_source_delete": "Smazat",
"lang_source_warn": "Opravdu chcete tento zdroj smazat?",
"lang_source_warn_cancel_dirty": "Opravdu chcete zahodit neuložené změny?",
Expand Down
2 changes: 2 additions & 0 deletions assets/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"lang_source_export": "Export sources",
"lang_source_edit": "Edit",
"lang_source_filter": "Filter",
"lang_source_menu": "More actions",
"lang_source_browse": "Browse",
"lang_source_delete": "Delete",
"lang_source_warn": "Really delete this source?",
"lang_source_warn_cancel_dirty": "Discard unsaved changes?",
Expand Down
44 changes: 44 additions & 0 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"prop-types-nullable": "^1.0.1",
"ramda": "^0.28.0",
"react": "^17.0.1",
"react-aria-menubutton": "^7.0.3",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"reset-css": "^5.0.1",
Expand Down
5 changes: 4 additions & 1 deletion assets/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $text-color: black;
// Sass does not interportate code in CSS variable definitions unless explicitly unescaped.
// https://github.com/sass/libsass/issues/2621
--primary: #{$primary};
--primary-contrast: #ffffff;
--primary-highlight: #{$primary-highlight};
--primary-highlight-shadow: #{$primary-highlight-shadow};
--text-color: #{$text-color};
Expand Down Expand Up @@ -58,6 +59,8 @@ button::-moz-focus-inner {
border: 0;
}

@import 'popup-menu';

#js-loading-message {
margin: 1em;
text-align: center;
Expand Down Expand Up @@ -715,7 +718,7 @@ span.offline-count.diff {
}

.source-showparams,
.source-delete,
.source-menu-button,
.source-save,
.source-cancel {
padding: 0;
Expand Down
27 changes: 27 additions & 0 deletions assets/styles/popup-menu.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.popup-menu-wrapper {
display: inline-block;
position: relative;
}

.popup-menu {
background: var(--background-color);
color: var(--text-color);
border: 1px solid rgb(200 200 200 / 40%);
position: absolute;
top: 100%;
left: -1em;
z-index: 100;
margin: 0.25em 0 0;
box-shadow: 0 0.2em 1em rgb(0 0 0 / 15%);
}

.popup-menu-item {
cursor: pointer;
padding: 0.3em 1em;
}

.popup-menu-item:hover,
.popup-menu-item:focus {
background-color: var(--primary);
color: var(--primary-contrast);
}