From a0049bc95fe7176d17189ae36670cdea26f4153b Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Sun, 16 Mar 2025 22:26:23 +0530 Subject: [PATCH 01/21] Update ipns.js --- src/bundles/ipns.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/bundles/ipns.js b/src/bundles/ipns.js index d05b8bd1a..7674efac0 100644 --- a/src/bundles/ipns.js +++ b/src/bundles/ipns.js @@ -47,14 +47,12 @@ const ipnsBundle = { doRemoveIpnsKey: (name) => async ({ getIpfs, store }) => { const ipfs = getIpfs() await ipfs.key.rm(name) - store.doFetchIpnsKeys() }, doRenameIpnsKey: (oldName, newName) => async ({ getIpfs, store }) => { const ipfs = getIpfs() await ipfs.key.rename(oldName, newName) - store.doFetchIpnsKeys() }, @@ -63,9 +61,31 @@ const ipnsBundle = { await ipfs.name.publish(cid, { key }) }, + doImportIpnsKey: (file) => async ({ getIpfs, store }) => { + const ipfs = getIpfs() + const reader = new FileReader() + reader.onload = async (event) => { + const key = event.target.result + await ipfs.key.import(file.name, key) + store.doFetchIpnsKeys() + } + reader.readAsText(file) + }, + + doExportIpnsKey: (name) => async ({ getIpfs }) => { + const ipfs = getIpfs() + const key = await ipfs.key.export(name) + const blob = new Blob([key], { type: 'text/plain' }) + const url = URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = `${name}.key` + document.body.appendChild(a) + a.click() + document.body.removeChild(a) + }, + doUpdateExpectedPublishTime: (time) => async ({ store, dispatch }) => { - // moderate expectation: publishing should take no longer than average - // between old expectation and the length of the last publish + some buffer const oldExpectedTime = store.selectExpectedPublishTime() const avg = Math.floor((time * 1.5 + oldExpectedTime) / 2) await writeSetting('expectedPublishTime', avg) From a80c661adb6cb0266da21c136a33a0fd10a958da Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Sun, 16 Mar 2025 22:28:04 +0530 Subject: [PATCH 02/21] Update IpnsManager.js --- src/components/ipns-manager/IpnsManager.js | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/ipns-manager/IpnsManager.js b/src/components/ipns-manager/IpnsManager.js index 95c2075d3..c148423ce 100644 --- a/src/components/ipns-manager/IpnsManager.js +++ b/src/components/ipns-manager/IpnsManager.js @@ -9,7 +9,6 @@ import Overlay from '../overlay/Overlay.js' import GenerateKeyModal from './generate-key-modal/GenerateKeyModal.js' import RenameKeyModal from './rename-key-modal/RenameKeyModal.js' import RemoveKeyModal from './remove-key-modal/RemoveKeyModal.js' - import ContextMenu from '../context-menu/ContextMenu.js' import ContextMenuItem from '../context-menu/ContextMenuItem.js' import GlyphDots from '../../icons/GlyphDots.js' @@ -19,14 +18,14 @@ import StrokeCancel from '../../icons/StrokeCancel.js' const ROW_HEIGHT = 50 const HEADER_HEIGHT = 32 -const AutoOptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal }) => ( +const AutoOptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal, doExportIpnsKey }) => (
{ name !== 'self' && } + name={name} t={t} showRenameKeyModal={showRenameKeyModal} showRemoveKeyModal={showRemoveKeyModal} doExportIpnsKey={doExportIpnsKey} /> }
) -const OptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal }) => { +const OptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal, doExportIpnsKey }) => { const buttonRef = useRef() const [isContextVisible, setContextVisibility] = useState(false) @@ -48,12 +47,15 @@ const OptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal }) => { {t('app:actions.remove')} + + {t('app:actions.export')} + ) } -export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, doRenameIpnsKey, doRemoveIpnsKey, availableGateway, ipnsKeys }) => { +export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, doRenameIpnsKey, doRemoveIpnsKey, doImportIpnsKey, doExportIpnsKey, availableGateway, ipnsKeys }) => { const [isGenerateKeyModalOpen, setGenerateKeyModalOpen] = useState(false) const showGenerateKeyModal = () => setGenerateKeyModalOpen(true) const hideGenerateKeyModal = () => setGenerateKeyModalOpen(false) @@ -81,6 +83,13 @@ export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, (ipnsKeys || []).sort(sortByProperty(sortSettings.sortBy, sortSettings.sortDirection === SortDirection.ASC ? 1 : -1)), [ipnsKeys, sortSettings.sortBy, sortSettings.sortDirection]) + const handleImportKey = (event) => { + const file = event.target.files[0] + if (file) { + doImportIpnsKey(file) + } + } + return (
@@ -125,7 +134,7 @@ export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, dataKey='options' width={width * 0.1} flexShrink={1} - cellRenderer={({ rowData }) => } + cellRenderer={({ rowData }) => doExportIpnsKey(rowData.name)} />} className='pinningManagerColumn charcoal truncate f6 pl2' /> )} @@ -136,6 +145,15 @@ export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, + +
@@ -189,5 +207,7 @@ export default connect( 'doGenerateIpnsKey', 'doRemoveIpnsKey', 'doRenameIpnsKey', + 'doImportIpnsKey', + 'doExportIpnsKey', IpnsManager ) From 4fab5e155961eb2dd4fbc114441d610258f8f71e Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Sun, 16 Mar 2025 22:35:56 +0530 Subject: [PATCH 03/21] Update IpnsManager.js From 06d91758ba2747f220d19e685a1e2f3e8156147a Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Sun, 16 Mar 2025 22:37:49 +0530 Subject: [PATCH 04/21] Update settings.json --- public/locales/en/settings.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/locales/en/settings.json b/public/locales/en/settings.json index b76ed9a7c..ae72e2686 100644 --- a/public/locales/en/settings.json +++ b/public/locales/en/settings.json @@ -66,7 +66,9 @@ "save": "Save", "cancel": "Cancel", "enable": "Enable", - "disable": "Disable" + "disable": "Disable", + "import": "Import Key", + "export": "Export Key" }, "edit": "Edit", "visitService": "Visit service", From 3cbf55b9446c2446dff823b5683de3b911570e0c Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Tue, 18 Mar 2025 23:11:02 +0530 Subject: [PATCH 05/21] Update src/components/ipns-manager/IpnsManager.js Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> --- src/components/ipns-manager/IpnsManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ipns-manager/IpnsManager.js b/src/components/ipns-manager/IpnsManager.js index c148423ce..62e01a656 100644 --- a/src/components/ipns-manager/IpnsManager.js +++ b/src/components/ipns-manager/IpnsManager.js @@ -48,7 +48,7 @@ const OptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal, doExport {t('app:actions.remove')} - {t('app:actions.export')} + {t('app:actions.export')} From d2b141f5d647effd9c78fd77c44cc0b1683db52b Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Tue, 18 Mar 2025 23:11:33 +0530 Subject: [PATCH 06/21] Update src/components/ipns-manager/IpnsManager.js Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> --- src/components/ipns-manager/IpnsManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ipns-manager/IpnsManager.js b/src/components/ipns-manager/IpnsManager.js index 62e01a656..0a7b7e90f 100644 --- a/src/components/ipns-manager/IpnsManager.js +++ b/src/components/ipns-manager/IpnsManager.js @@ -145,7 +145,7 @@ export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, - Date: Wed, 19 Mar 2025 14:04:09 +0530 Subject: [PATCH 07/21] Update ipns.js --- src/bundles/ipns.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/bundles/ipns.js b/src/bundles/ipns.js index 7674efac0..71a31d090 100644 --- a/src/bundles/ipns.js +++ b/src/bundles/ipns.js @@ -72,18 +72,7 @@ const ipnsBundle = { reader.readAsText(file) }, - doExportIpnsKey: (name) => async ({ getIpfs }) => { - const ipfs = getIpfs() - const key = await ipfs.key.export(name) - const blob = new Blob([key], { type: 'text/plain' }) - const url = URL.createObjectURL(blob) - const a = document.createElement('a') - a.href = url - a.download = `${name}.key` - document.body.appendChild(a) - a.click() - document.body.removeChild(a) - }, + doUpdateExpectedPublishTime: (time) => async ({ store, dispatch }) => { const oldExpectedTime = store.selectExpectedPublishTime() From 4e9a56d5dbb486cd115c23c74605a40845c4f66e Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Wed, 19 Mar 2025 14:06:20 +0530 Subject: [PATCH 08/21] Update settings.json --- public/locales/en/settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/locales/en/settings.json b/public/locales/en/settings.json index ae72e2686..d8c4f9825 100644 --- a/public/locales/en/settings.json +++ b/public/locales/en/settings.json @@ -67,8 +67,7 @@ "cancel": "Cancel", "enable": "Enable", "disable": "Disable", - "import": "Import Key", - "export": "Export Key" + "import": "Import Key" }, "edit": "Edit", "visitService": "Visit service", From 6b6bc0df97d2b19135822ab68170dce004f8e5b1 Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Wed, 19 Mar 2025 14:12:11 +0530 Subject: [PATCH 09/21] Update IpnsManager.js --- src/components/ipns-manager/IpnsManager.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/ipns-manager/IpnsManager.js b/src/components/ipns-manager/IpnsManager.js index 0a7b7e90f..6b4d6fd95 100644 --- a/src/components/ipns-manager/IpnsManager.js +++ b/src/components/ipns-manager/IpnsManager.js @@ -18,14 +18,14 @@ import StrokeCancel from '../../icons/StrokeCancel.js' const ROW_HEIGHT = 50 const HEADER_HEIGHT = 32 -const AutoOptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal, doExportIpnsKey }) => ( +const AutoOptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal }) => (
{ name !== 'self' && } + name={name} t={t} showRenameKeyModal={showRenameKeyModal} showRemoveKeyModal={showRemoveKeyModal} /> }
) -const OptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal, doExportIpnsKey }) => { +const OptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal }) => { const buttonRef = useRef() const [isContextVisible, setContextVisibility] = useState(false) @@ -47,15 +47,12 @@ const OptionsCell = ({ t, name, showRenameKeyModal, showRemoveKeyModal, doExport {t('app:actions.remove')} - - {t('app:actions.export')} - ) } -export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, doRenameIpnsKey, doRemoveIpnsKey, doImportIpnsKey, doExportIpnsKey, availableGateway, ipnsKeys }) => { +export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, doRenameIpnsKey, doRemoveIpnsKey, doImportIpnsKey, availableGateway, ipnsKeys }) => { const [isGenerateKeyModalOpen, setGenerateKeyModalOpen] = useState(false) const showGenerateKeyModal = () => setGenerateKeyModalOpen(true) const hideGenerateKeyModal = () => setGenerateKeyModalOpen(false) @@ -134,7 +131,7 @@ export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, dataKey='options' width={width * 0.1} flexShrink={1} - cellRenderer={({ rowData }) => doExportIpnsKey(rowData.name)} />} + cellRenderer={({ rowData }) => } className='pinningManagerColumn charcoal truncate f6 pl2' /> )} @@ -145,7 +142,7 @@ export const IpnsManager = ({ t, ipfsReady, doFetchIpnsKeys, doGenerateIpnsKey, - - - @@ -215,6 +189,5 @@ export default connect( 'doGenerateIpnsKey', 'doRemoveIpnsKey', 'doRenameIpnsKey', - 'doImportIpnsKey', IpnsManager ) From 753a6a486f8f033547b3708f7c6d82d95d23e9c1 Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Mon, 24 Mar 2025 01:33:13 +0530 Subject: [PATCH 19/21] Update cli-tutor-mode.js --- src/bundles/cli-tutor-mode.js | 69 +++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/src/bundles/cli-tutor-mode.js b/src/bundles/cli-tutor-mode.js index 2f428085c..d5b7e4e5c 100644 --- a/src/bundles/cli-tutor-mode.js +++ b/src/bundles/cli-tutor-mode.js @@ -1,45 +1,74 @@ -import { createAsyncResourceBundle, createSelector } from 'redux-bundler'; -import useCliTutorMode from '../../hooks/useCliTutorMode'; +import { createAsyncResourceBundle, createSelector } from 'redux-bundler' const bundle = createAsyncResourceBundle({ name: 'cliTutorMode', actionBaseType: 'CLI_TUTOR_MODE_TOGGLE', persist: true, checkIfOnline: false, - getPromise: () => {}, -}); + getPromise: () => {} +}) bundle.reactIsCliTutorModeEnabled = createSelector( 'selectIsCliTutorModeEnabled', (isCliTutorModeEnabled) => { - const isEnabled = Boolean(JSON.parse(localStorage.getItem('isCliTutorModeEnabled'))); + const isEnabled = Boolean(JSON.parse(localStorage.getItem('isCliTutorModeEnabled'))) if (isCliTutorModeEnabled !== undefined && isCliTutorModeEnabled !== isEnabled) { - localStorage.setItem('isCliTutorModeEnabled', isCliTutorModeEnabled); + localStorage.setItem('isCliTutorModeEnabled', isCliTutorModeEnabled) } } -); +) -bundle.selectIsCliTutorModeEnabled = state => state.cliTutorMode.isCliTutorModeEnabled; -bundle.selectIsCliTutorModalOpen = state => !!state.cliTutorMode.showCliTutorModal; -bundle.selectCliOptions = state => state.cliTutorMode.cliOptions; +bundle.selectIsCliTutorModeEnabled = state => state.cliTutorMode.isCliTutorModeEnabled + +bundle.selectIsCliTutorModalOpen = state => !!state.cliTutorMode.showCliTutorModal + +bundle.selectCliOptions = state => state.cliTutorMode.cliOptions bundle.reducer = (state = {}, action) => { if (action.type === 'CLI_TUTOR_MODE_TOGGLE') { - return { ...state, isCliTutorModeEnabled: action.payload }; + return { ...state, isCliTutorModeEnabled: action.payload } } if (action.type === 'CLI_TUTOR_MODAL_ENABLE') { - return { ...state, showCliTutorModal: action.payload }; + return { ...state, showCliTutorModal: action.payload } } if (action.type === 'CLI_OPTIONS') { - return { ...state, cliOptions: action.payload }; + return { ...state, cliOptions: action.payload } } - return state; -}; -bundle.init = store => { - const isEnabled = Boolean(JSON.parse(localStorage.getItem('isCliTutorModeEnabled'))); - return store.doToggleCliTutorMode(isEnabled); -}; + return state +} + +bundle.doToggleCliTutorMode = key => ({ dispatch }) => { + dispatch({ + type: 'CLI_TUTOR_MODE_TOGGLE', + payload: key + }) +} -export default bundle; +bundle.doSetCliOptions = cliOptions => ({ dispatch }) => { + dispatch({ + type: 'CLI_OPTIONS', + payload: cliOptions + }) +} + +bundle.doOpenCliTutorModal = openModal => ({ dispatch }) => { + dispatch({ + type: 'CLI_TUTOR_MODAL_ENABLE', + payload: openModal + }) +} + +bundle.doOpenCliTutorModal = openModal => ({ dispatch }) => { + dispatch({ + type: 'CLI_TUTOR_MODAL_ENABLE', + payload: openModal + }) +} + +bundle.init = store => { + const isEnabled = Boolean(JSON.parse(localStorage.getItem('isCliTutorModeEnabled'))) + return store.doToggleCliTutorMode(isEnabled) +} +export default bundle From da26389cc8aa4422b70e997891f059f5819b3fd2 Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Mon, 24 Mar 2025 01:35:01 +0530 Subject: [PATCH 20/21] Update CliTutorMode.js --- src/components/cli-tutor-mode/CliTutorMode.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/cli-tutor-mode/CliTutorMode.js b/src/components/cli-tutor-mode/CliTutorMode.js index b03b3c44f..6c7ae41e1 100644 --- a/src/components/cli-tutor-mode/CliTutorMode.js +++ b/src/components/cli-tutor-mode/CliTutorMode.js @@ -1,7 +1,6 @@ import React, { Fragment } from 'react' import PropTypes from 'prop-types' import { connect } from 'redux-bundler-react' -import useCliTutorMode from '../../hooks/useCliTutorMode' // Import the custom hook // Components import { Modal, ModalBody, ModalActions } from '../modal/Modal.js' @@ -57,14 +56,8 @@ export const CliTutorialModal = ({ command, t, onLeave, className, downloadConfi } const CliTutorMode = ({ - t, filesPage, onLeave, command, config, showIcon + t, filesPage, isCliTutorModeEnabled, onLeave, isCliTutorModalOpen, command, config, showIcon, doOpenCliTutorModal }) => { - const { - isCliTutorModeEnabled, - isCliTutorModalOpen, - doOpenCliTutorModal, - } = useCliTutorMode() // Use the custom hook - const downloadConfig = (config) => { const url = window.URL.createObjectURL(new Blob([config])) const link = document.createElement('a') @@ -109,5 +102,8 @@ CliTutorialModal.defaultProps = { } export default connect( + 'doOpenCliTutorModal', + 'selectIsCliTutorModalOpen', + 'selectIsCliTutorModeEnabled', CliTutorMode ) From 4c0b3c751a88106fe8166434250412a741507b54 Mon Sep 17 00:00:00 2001 From: Shobit garg <122355051+shobit000@users.noreply.github.com> Date: Wed, 2 Apr 2025 17:23:01 +0530 Subject: [PATCH 21/21] Update ipns.js --- src/bundles/ipns.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundles/ipns.js b/src/bundles/ipns.js index 71a31d090..8fc31362f 100644 --- a/src/bundles/ipns.js +++ b/src/bundles/ipns.js @@ -72,8 +72,8 @@ const ipnsBundle = { reader.readAsText(file) }, - - + // moderate expectation: publishing should take no longer than average + // between old expectation and the length of the last publish + some buffer doUpdateExpectedPublishTime: (time) => async ({ store, dispatch }) => { const oldExpectedTime = store.selectExpectedPublishTime() const avg = Math.floor((time * 1.5 + oldExpectedTime) / 2)