Skip to content

Commit

Permalink
auditorium: explicitly pick params to forward
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 committed Apr 29, 2024
1 parent eca75fe commit dd2afd8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
10 changes: 8 additions & 2 deletions auditorium/src/views/components/_shared/forwarding-anchor.js
Expand Up @@ -14,20 +14,21 @@ const ForwardingAnchor = (props) => {
queryParams,
values = {},
skip = [],
pick = [],
...rest
} = props

return (
<a
href={forward(href, queryParams, values, skip)}
href={forward(href, queryParams, values, skip, pick)}
{...rest}
>
{children}
</a>
)
}

function forward (href, queryParams, values = {}, skip = []) {
function forward (href, queryParams, values = {}, skip = [], pick = []) {
let updatedHref = href
if (queryParams) {
let isFullUrl = false
Expand All @@ -41,6 +42,11 @@ function forward (href, queryParams, values = {}, skip = []) {
: new window.URL(href, window.location.origin)

for (const key in queryParams) {
if (pick.length) {
if (pick.indexOf(key) === -1) {
continue
}
}
forwardedHref.searchParams.set(key, queryParams[key])
}

Expand Down
2 changes: 1 addition & 1 deletion auditorium/src/views/components/_shared/with-layout.js
Expand Up @@ -32,7 +32,7 @@ const Layout = (props) => {
<div class='f5 roboto dark-gray'>
<div class='w-100 bg-black-05'>
<div class='mw8 center flex pb3 pt2 viewport-padding' id='headline'>
<ForwardingAnchor href='/' class='dim link flex'>
<ForwardingAnchor pick={['locale']} href='/' class='dim link flex'>
<img src={urify(path.join(__dirname, 'offen-icon-black.svg'))} alt='Offen logo' width='37' height='40' class='ma0 mt1 mr3' />
<h1 class='dib dark-gray f3 f2-ns normal ma0 margin-header'>{props.headline || __('Offen Fair Web Analytics')}</h1>
</ForwardingAnchor>
Expand Down
6 changes: 4 additions & 2 deletions auditorium/src/views/components/auditorium/go-settings.js
Expand Up @@ -7,6 +7,7 @@
const { h } = require('preact')

const Collapsible = require('./../_shared/collapsible')
const ForwardingAnchor = require('./../_shared/forwarding-anchor')
const classnames = require('classnames')

const GoSettings = (props) => {
Expand Down Expand Up @@ -45,13 +46,14 @@ const GoSettings = (props) => {
{__('Share all accounts, create a new one, change your email address and password, log out from Offen Fair Web Analytics')}
</p>
<div class='link dim'>
<a
<ForwardingAnchor
href='/console/'
pick={['locale']}
data-testid='auditorium/console-link'
class='w-100 w-auto-ns f5 tc no-underline bn dib br1 ph3 pv2 mr0 mr2-ns mb3 white bg-mid-gray'
>
{__('Open admin console')}
</a>
</ForwardingAnchor>
</div>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion auditorium/src/views/components/index/operator-login.js
Expand Up @@ -16,7 +16,7 @@ const OperatorLogin = (props) => {
</h3>
</div>
<div class='w-100 w-40-ns link dim tc'>
<ForwardingAnchor href='/login/' class='f5 tc no-underline bn ph3 pv2 dib br1 white bg-mid-gray'>
<ForwardingAnchor pick={['locale']} href='/login/' class='f5 tc no-underline bn ph3 pv2 dib br1 white bg-mid-gray'>
{__('Log in as operator')}
</ForwardingAnchor>
</div>
Expand Down
2 changes: 1 addition & 1 deletion auditorium/src/views/components/login/form.js
Expand Up @@ -55,7 +55,7 @@ const Form = forwardRef((props, ref) => {
{__('Log in')}
</SubmitButton>
<div class='mb3'>
<ForwardingAnchor class='b link dim dark-green' href='/forgot-password/'>
<ForwardingAnchor pick={['locale']} class='b link dim dark-green' href='/forgot-password/'>
{__('Forgot password?')}
</ForwardingAnchor>
</div>
Expand Down

0 comments on commit dd2afd8

Please sign in to comment.