Skip to content

Commit 88d8e5a

Browse files
committed
fix: work around dot in pin service name
This is a temporary workaround that maintains most of functionality and works with go-ipfs 0.8.0 Context: #1770
1 parent 0cc03b7 commit 88d8e5a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/bundles/pinning.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ const parseService = async (service, remoteServiceTemplates, ipfs) => {
2020
}
2121

2222
const mfsPolicyEnableFlag = memoize(async (serviceName, ipfs) => {
23-
return await ipfs.config.get(`Pinning.RemoteServices.${serviceName}.Policies.MFS.Enable`)
23+
try {
24+
return await ipfs.config.get(`Pinning.RemoteServices.${serviceName}.Policies.MFS.Enable`)
25+
} catch (e) {
26+
console.error(`unexpected config.get error for "${serviceName}"`, e)
27+
return false
28+
}
2429
}, { maxAge: 3000 })
2530

2631
const uniqueCidBatches = (arrayOfCids, size) => {
@@ -223,6 +228,9 @@ const pinningBundle = {
223228
doAddPinningService: ({ apiEndpoint, nickname, secretApiKey }) => async ({ getIpfs }) => {
224229
const ipfs = getIpfs()
225230

231+
// temporary mitigation for https://github.com/ipfs/ipfs-webui/issues/1770
232+
nickname = nickname.replaceAll('.', '_')
233+
226234
await ipfs.pin.remote.service.add(nickname, {
227235
endpoint: apiEndpoint,
228236
key: secretApiKey

src/components/pinning-manager/PinningManager.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,20 @@ const OptionsCell = ({ doRemovePinningService, name, visitServiceUrl, autoUpload
163163
setContextVisibility(false)
164164
}
165165

166+
const showAutoUpload = !name.includes('.') // temporary mitigation for https://github.com/ipfs/ipfs-webui/issues/1770
167+
166168
return (
167169
<div>
168170
<button className="button-inside-focus" onClick={() => setContextVisibility(true)} ref={buttonRef} aria-label={t('showOptions')}>
169171
<GlyphDots width={24} className='fill-gray-muted hover-fill-gray transition-all'/>
170172
</button>
171173
<ContextMenu className="pv2 ph1" style={{ zIndex: 1001 }} visible={isContextVisible}
172174
target={buttonRef} onDismiss={() => setContextVisibility(false)} arrowAlign="right">
173-
<ContextMenuItem className='pv2 ph1' onClick={ () => onToggleModalOpen(name) }>
174-
<StrokeCloud width="28" className='fill-aqua'/> <span className="ph1">{autoUpload ? t('pinningServices.removeAutoUpload') : t('pinningServices.addAutoUpload')}</span>
175-
</ContextMenuItem>
175+
{ showAutoUpload && (
176+
<ContextMenuItem className='pv2 ph1' onClick={ () => onToggleModalOpen(name) }>
177+
<StrokeCloud width="28" className='fill-aqua'/> <span className="ph1">{autoUpload ? t('pinningServices.removeAutoUpload') : t('pinningServices.addAutoUpload')}</span>
178+
</ContextMenuItem>)
179+
}
176180
{ visitServiceUrl && (
177181
<a className='link flex items-center' href={visitServiceUrl} target='_blank' rel='noopener noreferrer'>
178182
<ContextMenuItem className='pv2 ph1' onClick={ () => setContextVisibility(false) }>

0 commit comments

Comments
 (0)