From 830ae1f017255f9218c7173a2d21c69aa1b98dd5 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 21 Nov 2022 20:04:04 +0100 Subject: [PATCH] refactor: remove remains of window.ipfs https://github.com/ipfs/ipfs-companion/issues/589#issuecomment-712356448 --- add-on/_locales/en/messages.json | 60 ------------------ .../src/pages/proxy-access-dialog/index.html | 18 ------ add-on/src/pages/proxy-access-dialog/index.js | 20 ------ add-on/src/pages/proxy-access-dialog/page.js | 63 ------------------- .../proxy-access-dialog.css | 15 ----- add-on/src/pages/proxy-access-dialog/store.js | 33 ---------- webpack.config.js | 31 --------- 7 files changed, 240 deletions(-) delete mode 100644 add-on/src/pages/proxy-access-dialog/index.html delete mode 100644 add-on/src/pages/proxy-access-dialog/index.js delete mode 100644 add-on/src/pages/proxy-access-dialog/page.js delete mode 100644 add-on/src/pages/proxy-access-dialog/proxy-access-dialog.css delete mode 100644 add-on/src/pages/proxy-access-dialog/store.js diff --git a/add-on/_locales/en/messages.json b/add-on/_locales/en/messages.json index 25be0113c..83f433673 100644 --- a/add-on/_locales/en/messages.json +++ b/add-on/_locales/en/messages.json @@ -611,66 +611,6 @@ "message": "Open in Files page", "description": "Checkbox label on the share files page (quickImport_options_openViaWebUI)" }, - "page_proxyAcl_title": { - "message": "Manage Permissions", - "description": "Page title for the IPFS proxy ACL page (page_proxyAcl_title)" - }, - "page_proxyAcl_subtitle": { - "message": "View, change and revoke granted access rights to your IPFS instance.", - "description": "Page sub title for the IPFS proxy ACL page (page_proxyAcl_subtitle)" - }, - "page_proxyAcl_no_perms": { - "message": "No permissions granted.", - "description": "Message displayed when no permissions have been granted (page_proxyAcl_no_perms)" - }, - "page_proxyAcl_confirm_revoke": { - "message": "Revoke permission $1 for $2?", - "description": "Confirmation message for revoking a permission for a scope (page_proxyAcl_confirm_revoke)" - }, - "page_proxyAcl_confirm_revoke_all": { - "message": "Revoke all permissions for $1?", - "description": "Confirmation message for revoking all permissions for an scope (page_proxyAcl_confirm_revoke_all)" - }, - "page_proxyAcl_toggle_to_allow_button_title": { - "message": "Click to allow", - "description": "Button title for toggling permission from deny to allow (page_proxyAcl_toggle_to_allow_button_title)" - }, - "page_proxyAcl_toggle_to_deny_button_title": { - "message": "Click to deny", - "description": "Button title for toggling permission from allow to deny (page_proxyAcl_toggle_to_deny_button_title)" - }, - "page_proxyAcl_allow_button_value": { - "message": "Allow", - "description": "Button value for allow (page_proxyAcl_allow_button_value)" - }, - "page_proxyAcl_deny_button_value": { - "message": "Deny", - "description": "Button value for deny" - }, - "page_proxyAcl_revoke_button_title": { - "message": "Revoke $1", - "description": "Button title for revoking a permission (page_proxyAcl_revoke_button_title)" - }, - "page_proxyAccessDialog_title": { - "message": "Should IPFS Companion allow «$1» to access «$2» at the connected node?", - "description": "Main title of the access permission dialog (page_proxyAccessDialog_title)" - }, - "page_proxyAccessDialog_wildcardCheckbox_label": { - "message": "Apply this decision to all current and future permissions in this scope", - "description": "Label for the apply permissions to all checkbox (page_proxyAccessDialog_wildcardCheckbox_label)" - }, - "page_proxyAcl_revoke_all_button_title": { - "message": "Revoke all permissions", - "description": "Button title for revoking all permissions (page_proxyAcl_revoke_all_button_title)" - }, - "page_proxyAccessDialog_allowButton_text": { - "message": "Allow", - "description": "Button text for allowing a permission (page_proxyAccessDialog_allowButton_text)" - }, - "page_proxyAccessDialog_denyButton_text": { - "message": "Deny", - "description": "Button text for denying a permission (page_proxyAccessDialog_allowButton_text)" - }, "page_landingWelcome_title": { "message": "Welcome | IPFS Companion", "description": "Page title (page_landingWelcome_title)" diff --git a/add-on/src/pages/proxy-access-dialog/index.html b/add-on/src/pages/proxy-access-dialog/index.html deleted file mode 100644 index ae2476560..000000000 --- a/add-on/src/pages/proxy-access-dialog/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - IPFS Companion - - - - - - - -
- - - - - diff --git a/add-on/src/pages/proxy-access-dialog/index.js b/add-on/src/pages/proxy-access-dialog/index.js deleted file mode 100644 index 2dc466d40..000000000 --- a/add-on/src/pages/proxy-access-dialog/index.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict' - -import './proxy-access-dialog.css' - -import browser from 'webextension-polyfill' -import choo from 'choo' -import createProxyAccessDialogStore from './store.js' -import createProxyAccessDialogPage from './page.js' - -const app = choo() - -app.use(createProxyAccessDialogStore(browser.i18n, browser.runtime)) -app.route('*', createProxyAccessDialogPage(browser.i18n)) -app.mount('#root') - -// Fix for Fx57 bug where bundled page loaded using -// browser.windows.create won't show contents unless resized. -// See https://bugzilla.mozilla.org/show_bug.cgi?id=1402110 -browser.windows.getCurrent() - .then(win => browser.windows.update(win.id, { width: win.width + 1 })) diff --git a/add-on/src/pages/proxy-access-dialog/page.js b/add-on/src/pages/proxy-access-dialog/page.js deleted file mode 100644 index 0545d67d9..000000000 --- a/add-on/src/pages/proxy-access-dialog/page.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict' - -import html from 'choo/html/index.js' - -export default function createProxyAccessDialogPage (i18n) { - return function proxyAccessDialogPage (state, emit) { - const onAllow = () => emit('allow') - const onDeny = () => emit('deny') - const onWildcardToggle = () => emit('wildcardToggle') - - const { loading, scope, permissions } = state - - return html` -
-
- ${loading - ? null - : html` -
-

- ${i18n.getMessage('page_proxyAccessDialog_title', [scope, permissions.join(', ')])} -

-

- -

-
- `} -
-
- ${loading - ? html` -
- - ${button({ text: i18n.getMessage('page_proxyAccessDialog_denyButton_text'), disabled: true })} - - ${button({ text: i18n.getMessage('page_proxyAccessDialog_allowButton_text'), disabled: true })} -
` - : html`
- - ${button({ text: i18n.getMessage('page_proxyAccessDialog_denyButton_text'), onClick: onDeny, color: 'red' })} - - ${button({ text: i18n.getMessage('page_proxyAccessDialog_allowButton_text'), onClick: onAllow, color: 'aqua' })} -
`} -
-
- ` - } -} - -function button ({ onClick, color, text, disabled }) { - if (disabled) { - return html` - - ` - } - - return html` - - ` -} diff --git a/add-on/src/pages/proxy-access-dialog/proxy-access-dialog.css b/add-on/src/pages/proxy-access-dialog/proxy-access-dialog.css deleted file mode 100644 index 09fa6d374..000000000 --- a/add-on/src/pages/proxy-access-dialog/proxy-access-dialog.css +++ /dev/null @@ -1,15 +0,0 @@ -@import url('~tachyons/css/tachyons.css'); -@import url('~ipfs-css/ipfs.css'); - -.hover-bg-aqua-muted:hover { - background-color: #9ad4db; -} - -.hover-bg-red-muted:hover { - background-color: #f36149; -} - -label:hover, -button:hover { - cursor: pointer; -} diff --git a/add-on/src/pages/proxy-access-dialog/store.js b/add-on/src/pages/proxy-access-dialog/store.js deleted file mode 100644 index c920894af..000000000 --- a/add-on/src/pages/proxy-access-dialog/store.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict' - -export default function createProxyAccessDialogStore (_i18n, runtime) { - return function proxyAccessDialogStore (state, emitter) { - state.scope = null - state.permissions = null - state.loading = true - state.wildcard = false - - const port = runtime.connect({ name: 'proxy-access-dialog' }) - - const onMessage = (data) => { - if (!data || !data.scope || !data.permissions) return - port.onMessage.removeListener(onMessage) - - state.scope = data.scope - state.permissions = data.permissions - state.loading = false - - emitter.emit('render') - } - - port.onMessage.addListener(onMessage) - - emitter.on('allow', () => port.postMessage({ allow: true, wildcard: state.wildcard })) - emitter.on('deny', () => port.postMessage({ allow: false, wildcard: state.wildcard })) - - emitter.on('wildcardToggle', () => { - state.wildcard = !state.wildcard - emitter.emit('render') - }) - } -} diff --git a/webpack.config.js b/webpack.config.js index 8d24c514a..fe22430b1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -152,8 +152,6 @@ const uiConfig = merge(commonConfig, { browserAction: './add-on/src/popup/browser-action/index.js', importPage: './add-on/src/popup/quick-import.js', optionsPage: './add-on/src/options/options.js', - // TODO: remove or fix (window.ipfs) proxyAclManagerPage: './add-on/src/pages/proxy-acl/index.js', - // TODO: remove or fix (window.ipfs) proxyAclDialog: './add-on/src/pages/proxy-access-dialog/index.js', welcomePage: './add-on/src/landing-pages/welcome/index.js' }, optimization: { @@ -178,43 +176,14 @@ const uiConfig = merge(commonConfig, { const contentScriptsConfig = merge(commonConfig, { name: 'contentScripts', entry: { - // TODO: remove or fix (window.ipfs) ipfsProxyContentScriptPayload: './add-on/src/contentScripts/ipfs-proxy/page.js', linkifyContentScript: './add-on/src/contentScripts/linkifyDOM.js' } }) -// special content script that injects window.ipfs into REAL window object -// (by default scripts executed via tabs.executeScript get a sandbox version) -/* TODO: remove or fix - depending what we do with window.ipfs -const proxyContentScriptConfig = merge(commonConfig, { - name: 'proxyContentScript', - dependencies: ['contentScripts'], - entry: { - // below is just a loader for ipfsProxyContentScriptPayload - ipfsProxyContentScript: './add-on/src/contentScripts/ipfs-proxy/content.js' - }, - module: { - rules: [ - { - exclude: /node_modules/, - test: /\.js$/, - use: ['babel-loader'] - }, - { - // payload is already in bundled form, so we load raw code as-is - test: /ipfsProxyContentScriptPayload\.bundle\.js$/, - loader: 'raw-loader' - } - ] - } -}) -*/ - const config = [ bgConfig, uiConfig, contentScriptsConfig - // TODO: remove or fix (window.ipfs) proxyContentScriptConfig ] export default config