-
Notifications
You must be signed in to change notification settings - Fork 514
fix(files): prefer subdomain gw in copied share links #2255
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
cdde888
Fix issue #2244: Updated public gateway settings, added subdomain gat…
acul71 b3cbe79
Merge pull request #1 from ipfs/main
acul71 3373d44
Update src/bundles/gateway.js
acul71 c3de5c3
Update src/bundles/gateway.js
acul71 b0d128f
Update src/settings/SettingsPage.js
acul71 7a64e72
Update src/settings/SettingsPage.js
acul71 fda5381
Incorporated review suggestions for issue #2244: Updated constants, r…
acul71 64e95f6
Merge branch 'main' into fix-issue-2244
SgtPooki b013645
Update src/bundles/gateway.js
acul71 08d2073
Update src/bundles/gateway.js
acul71 39840d0
Update src/bundles/gateway.js
acul71 318285e
Update src/bundles/gateway.js
acul71 ef940f6
Update src/lib/files.js
acul71 8cdafe6
Update src/lib/files.test.js
acul71 e22ddb0
Update src/lib/files.test.js
acul71 61f8e20
Update src/settings/SettingsPage.js
acul71 a31026c
Update src/lib/files.test.js
acul71 0d8fc4b
Update src/components/public-subdomain-gateway-form/PublicSubdomainGa…
acul71 5cab67d
Update src/components/public-subdomain-gateway-form/PublicSubdomainGa…
acul71 c3c96e2
Update src/components/public-subdomain-gateway-form/PublicSubdomainGa…
acul71 05e4841
Update src/components/public-subdomain-gateway-form/PublicSubdomainGa…
acul71 5c9ec59
Update src/components/public-subdomain-gateway-form/PublicSubdomainGa…
acul71 9b512a4
nit: moved kind helper functions outside the test blocks
acul71 7c96305
Fix submit subdomain gateway check validity test
acul71 ee529a9
Update src/bundles/gateway.js
acul71 d8e81bc
Update src/lib/files.test.js
acul71 2de3310
fix: settings.test.js workaround for no button
acul71 44a43be
fix(settings): avoid probing dweb.link on load
lidel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/components/public-subdomain-gateway-form/PublicSubdomainGatewayForm.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import { connect } from 'redux-bundler-react' | ||
import { withTranslation } from 'react-i18next' | ||
import Button from '../button/Button.js' | ||
import { checkValidHttpUrl, checkSubdomainGateway, DEFAULT_SUBDOMAIN_GATEWAY } from '../../bundles/gateway.js' | ||
|
||
const PublicSubdomainGatewayForm = ({ t, doUpdatePublicSubdomainGateway, publicSubdomainGateway }) => { | ||
const [value, setValue] = useState(publicSubdomainGateway) | ||
const initialIsValidGatewayUrl = !checkValidHttpUrl(value) | ||
const [showFailState, setShowFailState] = useState(initialIsValidGatewayUrl) | ||
const [isValidGatewayUrl, setIsValidGatewayUrl] = useState(initialIsValidGatewayUrl) | ||
acul71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Updates the border of the input to indicate validity | ||
useEffect(() => { | ||
setShowFailState(!isValidGatewayUrl) | ||
}, [isValidGatewayUrl]) | ||
acul71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Updates the border of the input to indicate validity | ||
useEffect(() => { | ||
const isValid = checkSubdomainGateway(value) | ||
setIsValidGatewayUrl(isValid) | ||
setShowFailState(!isValid) | ||
acul71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, [value]) | ||
|
||
const onChange = (event) => setValue(event.target.value) | ||
|
||
const onSubmit = async (event) => { | ||
event.preventDefault() | ||
|
||
let isValid = false | ||
try { | ||
isValid = await checkSubdomainGateway(value) | ||
setShowFailState(!isValid) | ||
} catch (e) { | ||
setShowFailState(true) | ||
acul71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
} | ||
|
||
isValid && doUpdatePublicSubdomainGateway(value) | ||
} | ||
|
||
const onReset = async (event) => { | ||
event.preventDefault() | ||
setValue(DEFAULT_SUBDOMAIN_GATEWAY) | ||
doUpdatePublicSubdomainGateway(DEFAULT_SUBDOMAIN_GATEWAY) | ||
} | ||
|
||
const onKeyPress = (event) => { | ||
if (event.key === 'Enter') { | ||
onSubmit(event) | ||
} | ||
} | ||
|
||
return ( | ||
<form onSubmit={onSubmit}> | ||
<input | ||
id='public-subdomain-gateway' | ||
aria-label={t('terms.publicSubdomainGateway')} | ||
placeholder={t('publicSubdomainGatewayForm.placeholder')} | ||
type='text' | ||
className={`w-100 lh-copy monospace f5 pl1 pv1 mb2 charcoal input-reset ba b--black-20 br1 ${showFailState ? 'focus-outline-red b--red-muted' : 'focus-outline-green b--green-muted'}`} | ||
acul71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
onChange={onChange} | ||
onKeyPress={onKeyPress} | ||
value={value} | ||
/> | ||
<div className='tr'> | ||
<Button | ||
id='public-subdomain-gateway-reset-button' | ||
minWidth={100} | ||
height={40} | ||
bg='bg-charcoal' | ||
className='tc' | ||
disabled={value === DEFAULT_SUBDOMAIN_GATEWAY} | ||
onClick={onReset}> | ||
{t('app:actions.reset')} | ||
</Button> | ||
<Button | ||
id='public-subdomain-gateway-submit-button' | ||
minWidth={100} | ||
height={40} | ||
className='mt2 mt0-l ml2-l tc' | ||
disabled={!isValidGatewayUrl || value === publicSubdomainGateway}> | ||
{t('actions.submit')} | ||
</Button> | ||
</div> | ||
</form> | ||
) | ||
} | ||
|
||
export default connect( | ||
'doUpdatePublicSubdomainGateway', | ||
'selectPublicSubdomainGateway', | ||
withTranslation('app')(PublicSubdomainGatewayForm) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.