Skip to content

Commit

Permalink
chore: remove filepath input type in capability builder (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
eglitise authored Jul 10, 2024
1 parent 6478f3c commit 48b7781
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 88 deletions.
1 change: 0 additions & 1 deletion app/common/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
"boolean": "boolean",
"number": "number",
"JSON object": "JSON object",
"filepath": "filepath",
"connectToExistingSessionInstructions": "If you have an already-running session of the above server type, you can attach an inspector to it directly.",
"selectSessionIDInDropdown": "Select the Session ID in the dropdown below.",
"allowUnauthorizedCerts": "Allow Unauthorized Certificates",
Expand Down
36 changes: 1 addition & 35 deletions app/common/components/Session/CapabilityControl.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import {FileOutlined} from '@ant-design/icons';
import {Input, Switch} from 'antd';
import _ from 'lodash';
import React from 'react';

import {INPUT} from '../../constants/antd-types';
import {remote} from '../../shared/polyfills';
import {log} from '../../utils/logger';
import SessionStyles from './Session.module.css';

const getLocalFilePath = async () => {
try {
const {canceled, filePaths} = await remote.dialog.showOpenDialog({properties: ['openFile']});
if (!canceled && !_.isEmpty(filePaths)) {
return filePaths[0];
}
} catch (e) {
log.error(e);
}
};

const CapabilityControl = ({
cap,
onSetCapabilityParam,
Expand All @@ -29,6 +14,7 @@ const CapabilityControl = ({
}) => {
switch (cap.type) {
case 'text':
case 'file':
return (
<Input
disabled={isEditingDesiredCaps}
Expand Down Expand Up @@ -82,26 +68,6 @@ const CapabilityControl = ({
className={SessionStyles.capsBoxFont}
/>
);
case 'file':
return (
<div className={SessionStyles.fileControlWrapper}>
<Input
disabled={isEditingDesiredCaps}
id={id}
placeholder={t('Value')}
value={cap.value}
onChange={(e) => onSetCapabilityParam(e.target.value)}
onPressEnter={onPressEnter}
className={SessionStyles.capsBoxFont}
addonAfter={
<FileOutlined
className={SessionStyles['filepath-button']}
onClick={async () => onSetCapabilityParam((await getLocalFilePath()) || cap.value)}
/>
}
/>
</div>
);
default:
throw new Error(t('invalidCapType', {type: cap.type}));
}
Expand Down
4 changes: 0 additions & 4 deletions app/common/components/Session/CapabilityEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ const handleSetType = (setCapabilityParam, caps, index, type) => {
case 'object':
translatedValue = translatedValue + '';
break;
case 'file':
translatedValue = '';
break;
default:
break;
}
Expand Down Expand Up @@ -120,7 +117,6 @@ const CapabilityEditor = (props) => {
<Select.Option value="boolean">{t('boolean')}</Select.Option>
<Select.Option value="number">{t('number')}</Select.Option>
<Select.Option value="object">{t('JSON object')}</Select.Option>
<Select.Option value="file">{t('filepath')}</Select.Option>
</Select>
</Form.Item>
</Col>
Expand Down
5 changes: 0 additions & 5 deletions app/common/components/Session/Session.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@
margin-left: 1em;
}

.filepath-button {
cursor: pointer;
}

.capsFormCol {
min-width: 420px;
height: 100%;
Expand All @@ -214,7 +210,6 @@
width: 142px;
}

.fileControlWrapper :global(.ant-input-group),
.capsValueControl textarea {
max-width: 142px;
}
Expand Down
24 changes: 2 additions & 22 deletions app/common/shared/polyfills.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
let settings,
clipboard,
shell,
remote,
ipcRenderer,
i18NextBackend,
i18NextBackendOptions,
fs,
util;
let settings, clipboard, shell, ipcRenderer, i18NextBackend, i18NextBackendOptions, fs, util;

function buildForBrowser() {
if (process.env.BUILD_BROWSER) {
Expand All @@ -25,7 +17,6 @@ if (buildForBrowser()) {
settings,
clipboard,
shell,
remote,
ipcRenderer,
i18NextBackend,
i18NextBackendOptions,
Expand All @@ -37,7 +28,6 @@ if (buildForBrowser()) {
settings,
clipboard,
shell,
remote,
ipcRenderer,
i18NextBackend,
i18NextBackendOptions,
Expand All @@ -46,14 +36,4 @@ if (buildForBrowser()) {
} = require('../../electron/renderer/polyfills'));
}

export {
clipboard,
shell,
remote,
ipcRenderer,
settings,
i18NextBackend,
i18NextBackendOptions,
fs,
util,
};
export {settings, clipboard, shell, ipcRenderer, i18NextBackend, i18NextBackendOptions, fs, util};
14 changes: 2 additions & 12 deletions app/electron/renderer/polyfills.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {clipboard, ipcRenderer, remote, shell} from 'electron';
import {clipboard, ipcRenderer, shell} from 'electron';
import settings from 'electron-settings';
import fs from 'fs';
import i18NextBackend from 'i18next-fs-backend';
Expand All @@ -11,14 +11,4 @@ const i18NextBackendOptions = {
jsonIndent: 2,
};

export {
clipboard,
shell,
remote,
ipcRenderer,
settings,
i18NextBackend,
i18NextBackendOptions,
fs,
util,
};
export {settings, clipboard, shell, ipcRenderer, i18NextBackend, i18NextBackendOptions, fs, util};
9 changes: 2 additions & 7 deletions app/web/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ const browser = {
shell: {
openExternal: (url) => window.open(url, ''),
},
remote: {
getCurrentWindow: () => ({
getSize: () => [window.innerWidth, window.innerHeight],
}),
},
ipcRenderer: {
on: (evt) => {
console.warn(`Cannot listen for IPC event ${evt} in browser context`); // eslint-disable-line no-console
Expand Down Expand Up @@ -42,7 +37,7 @@ class BrowserSettings {
}

const settings = new BrowserSettings();
const {clipboard, shell, remote, ipcRenderer} = browser;
const {clipboard, shell, ipcRenderer} = browser;
const i18NextBackendOptions = {
backends: [LocalStorageBackend, HttpApi],
backendOptions: [
Expand All @@ -53,4 +48,4 @@ const i18NextBackendOptions = {
],
};

export {settings, clipboard, shell, remote, ipcRenderer, i18NextBackend, i18NextBackendOptions};
export {settings, clipboard, shell, ipcRenderer, i18NextBackend, i18NextBackendOptions};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions docs/session-builder/capability-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ fields for specifying each capability in parts: its name, value type, and the va
Changing the name or value of any capability will automatically adjust the contents of
[the JSON structure](#capability-json-structure) on the right side of the Session Builder.

There are 5 options for the value type:
There are 4 options for the value type:

- text
- boolean
- number
- JSON object
- filepath

Selecting a different option may change the value input field.

Expand Down

0 comments on commit 48b7781

Please sign in to comment.