Skip to content

Commit

Permalink
fix: hide unused options when embedded node is active
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Jun 15, 2018
1 parent 032ebdd commit 7706f62
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
67 changes: 36 additions & 31 deletions add-on/src/options/forms/gateways-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const html = require('choo/html')
const { normalizeGatewayURL } = require('../../lib/options')

function gatewaysForm ({
ipfsNodeType,
customGatewayUrl,
useCustomGateway,
publicGatewayUrl,
Expand All @@ -19,37 +20,41 @@ function gatewaysForm ({
<form>
<fieldset>
<legend>${browser.i18n.getMessage('option_header_gateways')}</legend>
<div>
<label for="customGatewayUrl">
<dl>
<dt>${browser.i18n.getMessage('option_customGatewayUrl_title')}</dt>
<dd>${browser.i18n.getMessage('option_customGatewayUrl_description')}</dd>
</dl>
</label>
<input
id="customGatewayUrl"
type="url"
inputmode="url"
required
pattern="^https?://[^/]+$"
spellcheck="false"
title="Enter URL without any sub-path"
onchange=${onCustomGatewayUrlChange}
value=${customGatewayUrl} />
</div>
<div>
<label for="useCustomGateway">
<dl>
<dt>${browser.i18n.getMessage('option_useCustomGateway_title')}</dt>
<dd>${browser.i18n.getMessage('option_useCustomGateway_description')}</dd>
</dl>
</label>
<input
id="useCustomGateway"
type="checkbox"
onchange=${onUseCustomGatewayChange}
checked=${useCustomGateway} />
</div>
${ipfsNodeType === 'external' ? html`
<div>
<label for="customGatewayUrl">
<dl>
<dt>${browser.i18n.getMessage('option_customGatewayUrl_title')}</dt>
<dd>${browser.i18n.getMessage('option_customGatewayUrl_description')}</dd>
</dl>
</label>
<input
id="customGatewayUrl"
type="url"
inputmode="url"
required
pattern="^https?://[^/]+$"
spellcheck="false"
title="Enter URL without any sub-path"
onchange=${onCustomGatewayUrlChange}
value=${customGatewayUrl} />
</div>
` : null}
${ipfsNodeType === 'external' ? html`
<div>
<label for="useCustomGateway">
<dl>
<dt>${browser.i18n.getMessage('option_useCustomGateway_title')}</dt>
<dd>${browser.i18n.getMessage('option_useCustomGateway_description')}</dd>
</dl>
</label>
<input
id="useCustomGateway"
type="checkbox"
onchange=${onUseCustomGatewayChange}
checked=${useCustomGateway} />
</div>
` : null}
<div>
<label for="publicGatewayUrl">
<dl>
Expand Down
3 changes: 2 additions & 1 deletion add-on/src/options/forms/ipfs-node-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function ipfsNodeForm ({ ipfsNodeType, ipfsNodeConfig, onOptionChange }) {
<dl>
<dt>${browser.i18n.getMessage('option_ipfsNodeType_title')}</dt>
<dd>
${browser.i18n.getMessage('option_ipfsNodeType_description')}
<p>${browser.i18n.getMessage('option_ipfsNodeType_external_description')}</p>
<p>${browser.i18n.getMessage('option_ipfsNodeType_embedded_description')}</p>
<p><a href="https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/node-types.md" target="_blank">
${browser.i18n.getMessage('option_legend_readMore')}
</a></p>
Expand Down
1 change: 1 addition & 0 deletions add-on/src/options/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = function optionsPage (state, emit) {
onOptionChange
})}
${gatewaysForm({
ipfsNodeType: state.options.ipfsNodeType,
customGatewayUrl: state.options.customGatewayUrl,
useCustomGateway: state.options.useCustomGateway,
publicGatewayUrl: state.options.publicGatewayUrl,
Expand Down

0 comments on commit 7706f62

Please sign in to comment.