Skip to content

Commit

Permalink
Extension 2.1.0 (#432)
Browse files Browse the repository at this point in the history
* update package extension version

* add logout button

* fix loading spinner

* remember active extension tab

* update content script

* new extension version

* expand when data is missing

* update package version

* add button styles

* update package lock version
  • Loading branch information
nthiebes committed Jun 25, 2021
1 parent eb9f284 commit 0eca86a
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 54 deletions.
13 changes: 13 additions & 0 deletions _source/organisms/customize/Customize.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@
.customize__max-columns {
width: 5rem;
}

.customize__logout {
&:hover,
&:focus {
background-color: $color-font--primary;
color: $color-font--white;
}

&:hover .icon,
&:focus .icon {
color: $color-font--white;
}
}
6 changes: 5 additions & 1 deletion _source/pages/add/Add.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ class Add extends Component {
<Expandable
headline={<FormattedMessage id="extension.data" />}
className="add__section"
open={localStorage.getItem('showData') === 'true'}
open={Boolean(
localStorage.getItem('showData') === 'true' ||
!stateName ||
!stateUrl
)}
onClick={this.toggleData}
>
<>
Expand Down
47 changes: 45 additions & 2 deletions _source/pages/customize/Customize.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
import React, { Component } from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import { FormattedMessage, injectIntl } from 'react-intl';

import { postMessage } from '../../_utils/extension';
import Extension from '../../templates/extension';
import Section from '../../molecules/section';
import CustomizeComponent from '../../organisms/customize';
import LanguageSwitcher from '../../molecules/language-switcher';
import { H3 } from '../../atoms/headline';
import { ButtonSmallPrimary } from '../../atoms/button';

class Customize extends Component {
static propTypes = {
history: PropTypes.object.isRequired,
logout: PropTypes.func.isRequired
};

state = {
logoutPending: false
};

handleLogout = () => {
const { history, logout } = this.props;

this.setState({
logoutPending: true
});

logout({
onSuccess: () => {
postMessage({
darkMode: false
});

history.push('/extension/login');
}
});
};

export default class Customize extends Component {
render() {
const { logoutPending } = this.state;

return (
<Extension>
<Section noMargin className="customize--extension">
Expand All @@ -17,8 +49,19 @@ export default class Customize extends Component {
<FormattedMessage id="customize.language" />
</H3>
<LanguageSwitcher />
<ButtonSmallPrimary
className="customize__logout"
contentBefore
onClick={this.handleLogout}
icon="logout"
pending={logoutPending}
>
<FormattedMessage id="menu.logout" />
</ButtonSmallPrimary>
</Section>
</Extension>
);
}
}

export default injectIntl(Customize);
10 changes: 10 additions & 0 deletions _source/pages/customize/CustomizeContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { connect } from 'react-redux';
import Component from './Customize';
import { logout } from '../../_state/user/actions';

const mapDispatchToProps = {
logout
};
const Container = connect(null, mapDispatchToProps)(Component);

export default Container;
2 changes: 1 addition & 1 deletion _source/pages/customize/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import component from './Customize';
import component from './CustomizeContainer';

export default component;
50 changes: 20 additions & 30 deletions _source/pages/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ class Login extends Component {

if (action) {
history.push('/account');
} else if (isExtension) {
const activeTab = localStorage.getItem('activeTab') || 'add';

history.push(`/extension/${activeTab}`);
} else {
history.push(isExtension ? '/extension/add' : '/');
history.push('/');
}
},
onError: (error) => {
Expand All @@ -155,6 +159,7 @@ class Login extends Component {
});
};

// eslint-disable-next-line complexity
render() {
const { intl, match, isExtension } = this.props;
const { token, action } = match.params;
Expand Down Expand Up @@ -236,42 +241,27 @@ class Login extends Component {
pending={pending}
disabled={pending}
contentBefore
className="login__button"
>
<FormattedMessage
id="header.login"
values={{ b: (msg) => <b>{msg}</b> }}
/>
</ButtonLargeBlue>
{error && <ErrorMessage message={error} hasIcon />}
{isExtension ? (
<>
<Link
className="login__forgot"
href="/forgot"
target="_blank"
>
<FormattedMessage id="login.forgot" />
</Link>
<P className="login__join">
<FormattedMessage id="login.new" />{' '}
<Link href="/join" target="_blank">
<FormattedMessage id="login.join" />
</Link>
</P>
</>
) : (
<>
<Link className="login__forgot" to="/forgot">
<FormattedMessage id="login.forgot" />
</Link>
<P className="login__join">
<FormattedMessage id="login.new" />{' '}
<Link to="/join">
<FormattedMessage id="login.join" />
</Link>
</P>
</>
)}
<Link
className="login__forgot"
to="/forgot"
target={isExtension ? '_blank' : '_self'}
>
<FormattedMessage id="login.forgot" />
</Link>
<P className="login__join">
<FormattedMessage id="login.new" />{' '}
<Link to="/join" target={isExtension ? '_blank' : '_self'}>
<FormattedMessage id="login.join" />
</Link>
</P>
</Form>
)}
</Section>
Expand Down
14 changes: 14 additions & 0 deletions _source/pages/login/Login.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@
margin-top: calc(3rem + 6px);
left: calc(50% - 18px);
}

.login__button {
&:hover,
&:focus,
&.button--pending {
background-color: lighten($color--blue, 5%);
color: $color-font--white;

.icon,
.icon__svg {
color: $color-font--white;
}
}
}
13 changes: 11 additions & 2 deletions _source/templates/extension/Extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';
import { FormattedMessage } from 'react-intl';

// import { config } from '../../config';
import { postMessage } from '../../_utils/extension';
import Link from '../../atoms/link';
import Icon from '../../atoms/icon';
Expand Down Expand Up @@ -36,19 +35,26 @@ export default class Extension extends PureComponent {
});
}

setActiveTab = (tab) => {
localStorage.setItem('activeTab', tab);
postMessage({
activeTab: tab
});
};

render() {
const { children, className, darkMode, color } = this.props;

return (
<>
<Modal />
<header className={`extension__header header--color${color}`}>
<nav className="extension__nav">
<Link
to="/extension/add"
isNavLink
className="extension__nav-item"
activeClassName="extension__nav-item--active"
onClick={() => this.setActiveTab('add')}
>
<Icon icon="add-link" color="light" />
<FormattedMessage id="extension.add" />
Expand All @@ -58,6 +64,7 @@ export default class Extension extends PureComponent {
isNavLink
className="extension__nav-item"
activeClassName="extension__nav-item--active"
onClick={() => this.setActiveTab('open')}
>
<Icon icon="open" color="light" />
<FormattedMessage id="extension.open" />
Expand All @@ -67,6 +74,7 @@ export default class Extension extends PureComponent {
isNavLink
className="extension__nav-item"
activeClassName="extension__nav-item--active"
onClick={() => this.setActiveTab('customize')}
>
<Icon icon="customize" color="light" />
<FormattedMessage id="extension.customize" />
Expand All @@ -82,6 +90,7 @@ export default class Extension extends PureComponent {
>
<ErrorBoundary>{children}</ErrorBoundary>
</main>
<Modal />
</>
);
}
Expand Down
Binary file added extension/_public/chrome/chrome_2.1.0.zip
Binary file not shown.
Binary file added extension/_public/edge/edge_2.1.0.zip
Binary file not shown.
Binary file added extension/_public/firefox/firefox_2.1.0.zip
Binary file not shown.
Binary file added extension/_public/opera/opera_2.1.0.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions extension/_source/content.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable no-var */
function getDescription() {
function getDescriptionForBooky() {
var meta = document.querySelector('meta[name=description]'),
description = meta ? meta.getAttribute('content') : '';

return description;
}

chrome.runtime.connect().postMessage({
description: getDescription()
description: getDescriptionForBooky()
});

/* eslint-enable no-var */
4 changes: 2 additions & 2 deletions extension/_source/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "__MSG_appName__",
"version": "2.0.5",
"version": "2.1.0",
"author": "Nico Thiebes",
"description": "__MSG_appDesc__",
"default_locale": "en",
"content_security_policy": "default-src 'self'; frame-src 'self' http://localhost:3000 https://*.booky.io https://booky.io",
"permissions": ["activeTab", "management"],
"permissions": ["activeTab", "management", "storage"],
"browser_action": {
"default_title": "booky.io Extension",
"default_popup": "popup.html",
Expand Down
4 changes: 2 additions & 2 deletions extension/_source/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ body {
position: absolute;
color: #657786;
pointer-events: none;
left: calc(50vw - 18px);
top: calc(50vh);
left: calc(50% - 18px);
top: 50%;
}

.loading__spinner--hide {
Expand Down
8 changes: 7 additions & 1 deletion extension/_source/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ chrome.management.getSelf(function (extensionInfo) {
host = devHost;
}

iframe.src = host + '/extension/add';
chrome.storage.local.get(['activeTab'], function ({ activeTab }) {
iframe.src = host + `/extension/${activeTab || 'add'}`;
});
});

function transitionEndCallback() {
Expand Down Expand Up @@ -68,6 +70,10 @@ window.addEventListener('message', function (event) {
if (message.close) {
window.close();
}

if (message.activeTab) {
chrome.storage.local.set({ activeTab: message.activeTab });
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions extension/manifest.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

browser="$1"
version="$2"
version="2.1.0"

if [ "$browser" == "chrome" ]
then
Expand Down Expand Up @@ -45,7 +45,7 @@ manifest="{
\"description\": \"__MSG_appDesc__\",
\"default_locale\": \"en\",
\"content_security_policy\": \"default-src 'self'; frame-src 'self' http://localhost:3000 https://*.booky.io https://booky.io\",
\"permissions\": [\"activeTab\", \"management\"],${applications}
\"permissions\": [\"activeTab\", \"management\", \"storage\"],${applications}
\"browser_action\": {
\"default_title\": \"booky.io Extension\",
\"default_popup\": \"popup.html\",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "booky.io",
"version": "2.7.0",
"extensionVersion": "2.0.5",
"version": "2.8.0",
"description": "Online bookmarking service with high focus on performance, mobile support and customizability.",
"homepage": "https://booky.io",
"email": "hello@booky.io",
Expand All @@ -27,11 +26,11 @@
"test:watch": "jest --watchAll",
"qa": "npm-run-all test lint",
"prettier": "prettier --write .",
"extension": "cd extension && ./manifest.sh firefox $npm_package_extensionVersion && ./manifest.sh opera $npm_package_extensionVersion && ./manifest.sh edge $npm_package_extensionVersion && ./manifest.sh chrome $npm_package_extensionVersion",
"extension:chrome": "cd extension && ./manifest.sh chrome $npm_package_extensionVersion",
"extension:firefox": "cd extension && ./manifest.sh firefox $npm_package_extensionVersion",
"extension:opera": "cd extension && ./manifest.sh opera $npm_package_extensionVersion",
"extension:edge": "cd extension && ./manifest.sh edge $npm_package_extensionVersion",
"extensions": "cd extension && ./manifest.sh firefox && ./manifest.sh opera && ./manifest.sh edge && ./manifest.sh chrome",
"extension:chrome": "cd extension && ./manifest.sh chrome",
"extension:firefox": "cd extension && ./manifest.sh firefox",
"extension:opera": "cd extension && ./manifest.sh opera",
"extension:edge": "cd extension && ./manifest.sh edge",
"cypress:open": "./node_modules/.bin/cypress open"
},
"proxy": "http://localhost:8001/",
Expand Down

0 comments on commit 0eca86a

Please sign in to comment.