Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@twreporter/universal-header

Package Overview
Dependencies
Maintainers
4
Versions
346
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@twreporter/universal-header - npm Package Compare versions

Comparing version 2.0.0-beta-13 to 2.0.0-beta-14

dist/constants/release-branch.js

5

dist/actions/auth.js

@@ -32,8 +32,9 @@ "use strict";

* @param {string} cookieList - cookieList contains `id_token` cookie
* @param {string} releaseBranch - should be one of 'master', 'test', 'staging' and 'release'
* @return {Function} returned function will get executed by the Redux Thunk middleware
*/
function getAccessToken(cookieList, env) {
function getAccessToken(cookieList, releaseBranch) {
return function (dispatch) {
var endpoint = _url.default.formAPIURL(env, '/v2/auth/token');
var endpoint = _url.default.formAPIURL(releaseBranch, '/v2/auth/token');

@@ -40,0 +41,0 @@ var headers = {};

4

dist/components/header.js

@@ -129,3 +129,3 @@ "use strict";

return _react.default.createElement(Box, null, _react.default.createElement(_headerContext.default.Consumer, null, function (_ref) {
var env = _ref.env,
var releaseBranch = _ref.releaseBranch,
isLinkExternal = _ref.isLinkExternal,

@@ -140,3 +140,3 @@ theme = _ref.theme;

bgColor: bgColor
}, _react.default.createElement(TopRowContent, null, _react.default.createElement(_customizedLink.default, _links.default.getLogoLink(isLinkExternal, env), _react.default.createElement(Logo, null)), _react.default.createElement(_icons.default, null)));
}, _react.default.createElement(TopRowContent, null, _react.default.createElement(_customizedLink.default, _links.default.getLogoLink(isLinkExternal, releaseBranch), _react.default.createElement(Logo, null)), _react.default.createElement(_icons.default, null)));
}), channelJSX);

@@ -143,0 +143,0 @@ }

@@ -236,3 +236,3 @@ "use strict";

_this._handleLogIconClick = function (e, isAuthed, env) {
_this._handleLogIconClick = function (e, isAuthed, branch) {
e.preventDefault();

@@ -246,7 +246,7 @@ var redirectURL = window.location.href;

if (isAuthed) {
window.location = _links.default.getLogoutLink(env).to + '?' + query;
window.location = _links.default.getLogoutLink(branch).to + '?' + query;
return;
}
window.location = _links.default.getLoginLink(env).to + '?' + query;
window.location = _links.default.getLoginLink(branch).to + '?' + query;
};

@@ -286,6 +286,6 @@

var isAuthed = _ref.isAuthed,
env = _ref.env;
branch = _ref.branch;
return _react.default.createElement("a", {
onClick: function onClick(e) {
_this2._handleLogIconClick(e, isAuthed, env);
_this2._handleLogIconClick(e, isAuthed, branch);
}

@@ -302,6 +302,6 @@ }, isAuthed ? _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(LogOutIcon, null), _react.default.createElement("span", null, _services.default.serviceLabels.logout)) : _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(LogInIcon, null), _react.default.createElement("span", null, _services.default.serviceLabels.login)));

}), _react.default.createElement(HideOnDesktop, null, _react.default.createElement(_headerContext.default.Consumer, null, function (_ref2) {
var env = _ref2.env,
var branch = _ref2.branch,
isLinkExternal = _ref2.isLinkExternal;
var link = _links.default.getSearchLink(isLinkExternal, env);
var link = _links.default.getSearchLink(isLinkExternal, branch);

@@ -312,6 +312,6 @@ return _react.default.createElement(_customizedLink.default, link, _react.default.createElement(SearchIcon, null), _react.default.createElement("span", null, _services.default.serviceLabels.search));

}, _react.default.createElement(_headerContext.default.Consumer, null, function (_ref3) {
var env = _ref3.env,
var branch = _ref3.branch,
isLinkExternal = _ref3.isLinkExternal;
var link = _links.default.getBookmarksLink(isLinkExternal, env);
var link = _links.default.getBookmarksLink(isLinkExternal, branch);

@@ -318,0 +318,0 @@ return _react.default.createElement(_customizedLink.default, link, _react.default.createElement(BookmarkIcon, null), _react.default.createElement("span", null, _services.default.serviceLabels.bookmarks));

@@ -102,3 +102,3 @@ "use strict";

return _react.default.createElement(_react.default.Fragment, null, slideDownPanelJSX, _react.default.createElement(_headerContext.default.Consumer, null, function (_ref) {
var env = _ref.env,
var branch = _ref.branch,
isLinkExternal = _ref.isLinkExternal,

@@ -113,3 +113,3 @@ theme = _ref.theme;

bgColor: bgColor
}, _react.default.createElement(_customizedLink.default, _links.default.getLogoLink(isLinkExternal, env), _react.default.createElement(Logo, null)), _react.default.createElement(Hamburger, {
}, _react.default.createElement(_customizedLink.default, _links.default.getLogoLink(isLinkExternal, branch), _react.default.createElement(Logo, null)), _react.default.createElement(Hamburger, {
onClick: _this2.handleOnHamburgerClick

@@ -116,0 +116,0 @@ }, _react.default.createElement(Stroke, null), _react.default.createElement(Stroke, null), _react.default.createElement(Stroke, null)));

@@ -139,3 +139,3 @@ "use strict";

key: "_handleSubmit",
value: function _handleSubmit(e, env, isLinkExternal) {
value: function _handleSubmit(e, branch, isLinkExternal) {
e.preventDefault();

@@ -145,3 +145,3 @@ var keywords = this.state.keywords;

if (window) {
window.location = "".concat(_links.default.getSearchLink(isLinkExternal, env).to, "?q=").concat(keywords);
window.location = "".concat(_links.default.getSearchLink(isLinkExternal, branch).to, "?q=").concat(keywords);
}

@@ -179,7 +179,7 @@ }

}, !isSearchOpened ? null : _react.default.createElement(_headerContext.default.Consumer, null, function (_ref) {
var env = _ref.env,
var branch = _ref.branch,
isLinkExternal = _ref.isLinkExternal;
return _react.default.createElement(SearchBoxContainer, {
onSubmit: function onSubmit(e) {
_this2._handleSubmit(e, env, isLinkExternal);
_this2._handleSubmit(e, branch, isLinkExternal);
},

@@ -186,0 +186,0 @@ onReset: _this2._onReset,

@@ -8,3 +8,3 @@ "use strict";

var _env = _interopRequireDefault(require("./env"));
var _releaseBranch = _interopRequireDefault(require("./release-branch"));

@@ -17,9 +17,9 @@ var _accounts, _main, _support, _api;

var accounts = (_accounts = {}, _defineProperty(_accounts, _env.default.master, 'http://localhost:3000'), _defineProperty(_accounts, _env.default.test, 'http://localhost:3000'), _defineProperty(_accounts, _env.default.staging, 'https://staging-accounts.twreporter.org'), _defineProperty(_accounts, _env.default.release, 'https://accounts.twreporter.org'), _accounts);
var accounts = (_accounts = {}, _defineProperty(_accounts, _releaseBranch.default.master, 'http://localhost:3000'), _defineProperty(_accounts, _releaseBranch.default.test, 'http://localhost:3000'), _defineProperty(_accounts, _releaseBranch.default.staging, 'https://staging-accounts.twreporter.org'), _defineProperty(_accounts, _releaseBranch.default.release, 'https://accounts.twreporter.org'), _accounts);
exports.accounts = accounts;
var main = (_main = {}, _defineProperty(_main, _env.default.master, 'http://localhost:3000'), _defineProperty(_main, _env.default.test, 'http://localhost:3000'), _defineProperty(_main, _env.default.staging, 'https://staging.twreporter.org'), _defineProperty(_main, _env.default.release, 'https://www.twreporter.org'), _main);
var main = (_main = {}, _defineProperty(_main, _releaseBranch.default.master, 'http://localhost:3000'), _defineProperty(_main, _releaseBranch.default.test, 'http://localhost:3000'), _defineProperty(_main, _releaseBranch.default.staging, 'https://staging.twreporter.org'), _defineProperty(_main, _releaseBranch.default.release, 'https://www.twreporter.org'), _main);
exports.main = main;
var support = (_support = {}, _defineProperty(_support, _env.default.master, 'http://localhost:3000'), _defineProperty(_support, _env.default.test, 'http://localhost:3000'), _defineProperty(_support, _env.default.staging, 'https://staging-support.twreporter.org'), _defineProperty(_support, _env.default.release, 'https://support.twreporter.org'), _support);
var support = (_support = {}, _defineProperty(_support, _releaseBranch.default.master, 'http://localhost:3000'), _defineProperty(_support, _releaseBranch.default.test, 'http://localhost:3000'), _defineProperty(_support, _releaseBranch.default.staging, 'https://staging-support.twreporter.org'), _defineProperty(_support, _releaseBranch.default.release, 'https://support.twreporter.org'), _support);
exports.support = support;
var api = (_api = {}, _defineProperty(_api, _env.default.master, 'http://localhost:8080'), _defineProperty(_api, _env.default.test, 'http://localhost:8080'), _defineProperty(_api, _env.default.staging, 'https://staging-go-api.twreporter.org'), _defineProperty(_api, _env.default.release, 'https://go-api.twreporter.org'), _api);
var api = (_api = {}, _defineProperty(_api, _releaseBranch.default.master, 'http://localhost:8080'), _defineProperty(_api, _releaseBranch.default.test, 'http://localhost:8080'), _defineProperty(_api, _releaseBranch.default.staging, 'https://staging-go-api.twreporter.org'), _defineProperty(_api, _releaseBranch.default.release, 'https://go-api.twreporter.org'), _api);
exports.api = api;

@@ -26,0 +26,0 @@ var _default = {

@@ -10,3 +10,3 @@ "use strict";

var _env = _interopRequireDefault(require("./env"));
var _releaseBranch = _interopRequireDefault(require("./release-branch"));

@@ -17,3 +17,3 @@ var _theme = _interopRequireDefault(require("./theme"));

var envPropTypes = _propTypes.default.oneOf([_env.default.master, _env.default.test, _env.default.staging, _env.default.release]);
var branchPropTypes = _propTypes.default.oneOf([_releaseBranch.default.master, _releaseBranch.default.test, _releaseBranch.default.staging, _releaseBranch.default.release]);

@@ -24,3 +24,3 @@ var themePropTypes = _propTypes.default.oneOf([_theme.default.normal, _theme.default.transparent, _theme.default.photography, _theme.default.index]);

theme: themePropTypes,
env: envPropTypes,
branch: branchPropTypes,
isLinkExternal: _propTypes.default.bool

@@ -30,3 +30,3 @@ };

theme: _theme.default.normal,
env: _env.default.master,
branch: _releaseBranch.default.master,
isLinkExternal: false

@@ -33,0 +33,0 @@ };

@@ -322,4 +322,4 @@ "use strict";

key: "__prepareServiceProps",
value: function __prepareServiceProps(env, isAuthed, isLinkExternal) {
var serviceLinks = _links.default.getServiceLinks(isLinkExternal, env);
value: function __prepareServiceProps(branch, isAuthed, isLinkExternal) {
var serviceLinks = _links.default.getServiceLinks(isLinkExternal, branch);

@@ -357,3 +357,3 @@ var serviceProps = _services.default.serviceOrder.map(function (key) {

key: "__prepareChannelProps",
value: function __prepareChannelProps(env, isLinkExternal) {
value: function __prepareChannelProps(branch, isLinkExternal) {
var channelProps = _channels.default.channelOrder.map(function (key) {

@@ -365,3 +365,3 @@ return {

pathname: _channels.default.channelPathnames[key],
link: _links.default.getChannelLinks(isLinkExternal, env)[key]
link: _links.default.getChannelLinks(isLinkExternal, branch)[key]
};

@@ -374,3 +374,3 @@ });

key: "__prepareCategoriesProps",
value: function __prepareCategoriesProps(env, isLinkExternal, channelProps) {
value: function __prepareCategoriesProps(branch, isLinkExternal, channelProps) {
channelProps[channelProps.length - 1].dropDownMenu = _categories.default.categoryOrder.map(function (key) {

@@ -381,3 +381,3 @@ return {

pathname: _categories.default.categoryPathnames[key],
link: _links.default.getCategoryLinks(isLinkExternal, env)[key]
link: _links.default.getCategoryLinks(isLinkExternal, branch)[key]
};

@@ -390,10 +390,10 @@ });

var _this$props = this.props,
env = _this$props.env,
branch = _this$props.branch,
isAuthed = _this$props.isAuthed,
isLinkExternal = _this$props.isLinkExternal,
theme = _this$props.theme,
passThrough = _objectWithoutProperties(_this$props, ["env", "isAuthed", "isLinkExternal", "theme"]);
passThrough = _objectWithoutProperties(_this$props, ["branch", "isAuthed", "isLinkExternal", "theme"]);
var contextValue = {
env: env,
branch: branch,
isAuthed: isAuthed,

@@ -404,9 +404,9 @@ isLinkExternal: isLinkExternal,

var serviceProps = this.__prepareServiceProps(env, isAuthed, isLinkExternal);
var serviceProps = this.__prepareServiceProps(branch, isAuthed, isLinkExternal);
var channelProps = this.__prepareChannelProps(env, isLinkExternal);
var channelProps = this.__prepareChannelProps(branch, isLinkExternal);
var mobileMenu = mergeTwoArraysInOrder(channelProps, serviceProps);
this.__prepareCategoriesProps(env, isLinkExternal, channelProps);
this.__prepareCategoriesProps(branch, isLinkExternal, channelProps);

@@ -413,0 +413,0 @@ return _react.default.createElement(_headerContext.default.Provider, {

@@ -64,3 +64,3 @@ "use strict";

value: function componentDidMount() {
this.store.dispatch((0, _auth.getAccessToken)(null, this.props.env));
this.store.dispatch((0, _auth.getAccessToken)(null, this.props.branch));
}

@@ -67,0 +67,0 @@ }, {

@@ -8,3 +8,3 @@ "use strict";

var _env = _interopRequireDefault(require("../constants/env"));
var _releaseBranch = _interopRequireDefault(require("../constants/release-branch"));

@@ -25,13 +25,13 @@ var _externalLinks = _interopRequireDefault(require("../constants/external-links"));

var defaultEnv = _env.default.master;
var defaultBranch = _releaseBranch.default.master;
var defaultIsExternal = false;
function __getLinks(isExternal, env, baseURL, paths) {
function __getLinks(isExternal, branch, baseURL, paths) {
var rtn = {};
if (isExternal) {
if (baseURL.hasOwnProperty(env)) {
if (baseURL.hasOwnProperty(branch)) {
for (var key in paths) {
rtn[key] = {
to: baseURL[env] + paths[key],
to: baseURL[branch] + paths[key],
isExternal: isExternal

@@ -55,7 +55,7 @@ };

function __getLink(isExternal, env, baseURL, path) {
function __getLink(isExternal, branch, baseURL, path) {
if (isExternal) {
if (baseURL.hasOwnProperty(env)) {
if (baseURL.hasOwnProperty(branch)) {
return {
to: baseURL[env] + path,
to: baseURL[branch] + path,
isExternal: isExternal

@@ -78,4 +78,4 @@ };

var isExternal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultIsExternal;
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEnv;
return __getLinks(isExternal, env, _baseUrl.main, _categories.categoryPathnames);
var branch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultBranch;
return __getLinks(isExternal, branch, _baseUrl.main, _categories.categoryPathnames);
}

@@ -85,10 +85,10 @@

var isExternal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultIsExternal;
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEnv;
return __getLinks(isExternal, env, _baseUrl.main, _channels.channelPathnames);
var branch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultBranch;
return __getLinks(isExternal, branch, _baseUrl.main, _channels.channelPathnames);
}
function getLogoutLink() {
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultEnv;
var branch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultBranch;
return {
to: _baseUrl.api[env] + _services.servicePathnames.logout,
to: _baseUrl.api[branch] + _services.servicePathnames.logout,
isExternal: true

@@ -99,5 +99,5 @@ };

function getLoginLink() {
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultEnv;
var branch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultBranch;
return {
to: _baseUrl.accounts[env] + _services.servicePathnames.login,
to: _baseUrl.accounts[branch] + _services.servicePathnames.login,
isExternal: true

@@ -109,4 +109,4 @@ };

var isExternal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultIsExternal;
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEnv;
return __getLink(isExternal, env, _baseUrl.main, _services.servicePathnames.bookmarks);
var branch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultBranch;
return __getLink(isExternal, branch, _baseUrl.main, _services.servicePathnames.bookmarks);
}

@@ -116,4 +116,4 @@

var isExternal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultIsExternal;
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEnv;
return __getLink(isExternal, env, _baseUrl.main, _services.servicePathnames.search);
var branch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultBranch;
return __getLink(isExternal, branch, _baseUrl.main, _services.servicePathnames.search);
}

@@ -123,4 +123,4 @@

var isExternal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultIsExternal;
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEnv;
return __getLink(isExternal, env, _baseUrl.main, '');
var branch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultBranch;
return __getLink(isExternal, branch, _baseUrl.main, '');
}

@@ -132,4 +132,4 @@

var isExternal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultIsExternal;
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEnv;
return _ref = {}, _defineProperty(_ref, _services.serviceKeys.bookmarks, getBookmarksLink(isExternal, env)), _defineProperty(_ref, _services.serviceKeys.login, getLoginLink(env)), _defineProperty(_ref, _services.serviceKeys.logout, getLogoutLink(env)), _defineProperty(_ref, _services.serviceKeys.search, getSearchLink(isExternal, env)), _defineProperty(_ref, _services.serviceKeys.support, {
var branch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultBranch;
return _ref = {}, _defineProperty(_ref, _services.serviceKeys.bookmarks, getBookmarksLink(isExternal, branch)), _defineProperty(_ref, _services.serviceKeys.login, getLoginLink(branch)), _defineProperty(_ref, _services.serviceKeys.logout, getLogoutLink(branch)), _defineProperty(_ref, _services.serviceKeys.search, getSearchLink(isExternal, branch)), _defineProperty(_ref, _services.serviceKeys.support, {
to: __getExternalLinks().monthlyDonation,

@@ -136,0 +136,0 @@ isExternal: true

@@ -9,3 +9,3 @@ "use strict";

var _env = _interopRequireDefault(require("../constants/env"));
var _releaseBranch = _interopRequireDefault(require("../constants/release-branch"));

@@ -19,3 +19,3 @@ var _querystring = _interopRequireDefault(require("querystring"));

function formAPIURL() {
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _env.default.master;
var branch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _releaseBranch.default.master;
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

@@ -26,3 +26,3 @@ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

return "".concat(_baseUrl.api[env]).concat(path).concat(query ? '?' + query : '');
return "".concat(_baseUrl.api[branch]).concat(path).concat(query ? '?' + query : '');
}

@@ -29,0 +29,0 @@

{
"name": "@twreporter/universal-header",
"version": "2.0.0-beta-13",
"version": "2.0.0-beta-14",
"description": "Universal header of TWReporter sites",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -36,8 +36,8 @@ # TWReporter Universal Header

render() {
// see the `isLinkExternal and env` section for more info
const env = 'master'
// see the `isLinkExternal and releaseBranch` section for more info
const releaseBranch = 'master'
return (
<React.Fragment>
<StandaloneHeader
env={env}
releaseBranch={releaseBranch}
/>

@@ -97,3 +97,3 @@ </React.Fragment>

const store = store.configureStore()
const env = process.env.RELEASE_BRANCH
const releaseBranch = process.env.RELEASE_BRANCH
const isLinkExternal = false

@@ -105,3 +105,3 @@ store.dispatch(authActions.getAccessToken(cookie))

<HeaderConatiner
env={env}
releaseBranch={releaseBranch}
isLinkExternal={false}

@@ -139,4 +139,4 @@ />

// see the `isLinkExternal and env` section for more info
const env = process.env.RELEASE_BRANCH
// see the `isLinkExternal and releaseBranch` section for more info
const releaseBranch = process.env.RELEASE_BRANCH
const isLinkExternal = false

@@ -147,3 +147,3 @@

<HeaderContainer
env={env}
releaseBranch={releaseBranch}
isLinkExternal={isLinkExternal}

@@ -156,3 +156,3 @@ />

### isLinkExternal, env and theme
### isLinkExternal, releaseBranch and theme
#### isLinkExternal

@@ -167,13 +167,13 @@ `isLinkExternal` is a bool.

#### env
Currently, `env` works with `isLinkExternal={true}`.
#### releaseBranch
Currently, `releaseBranch` works with `isLinkExternal={true}`.
`env` is used to provide different links for different environments.
`env` could be `master`, `test`, `staging` and `release`,
`releaseBranch` is used to provide different links for different environments.
`releaseBranch` could be `master`, `test`, `staging` and `release`,
and each would generate corresponding links.
EX:
If you pass `env="master"`, then the logo link would be `http://localhost:3000`.
If you pass `env="test"`, then the logo link would be `http://localhost:3000`.
If you pass `env="staging"`, then the logo link would be `https://staging.twreporter.org`
If you pass `env="release"`, then the logo link would be `https://www.twreporter.org`
If you pass `releaseBranch="master"`, then the logo link would be `http://localhost:3000`.
If you pass `releaseBranch="test"`, then the logo link would be `http://localhost:3000`.
If you pass `releaseBranch="staging"`, then the logo link would be `https://staging.twreporter.org`
If you pass `releaseBranch="release"`, then the logo link would be `https://www.twreporter.org`
If you want to know more about how we generate links, please check `src/utils/links.js` out

@@ -180,0 +180,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc