Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/common/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,8 @@
"gestureNameCannotBeEmptyError": "Gesture name cannot be empty",
"gestureInvalidJsonError": "Invalid JSON file. Unable to parse the file content",
"gestureImportedFrom": "Gesture imported from '{{fileName}}'",
"invalidSessionFile": "Invalid session file"
"invalidSessionFile": "Invalid session file",
"Environment Variables": "Environment Variables",
"Variable Name": "Variable Name",
"Delete Variable": "Delete Variable"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific key is not used anymore

}
21 changes: 21 additions & 0 deletions app/common/renderer/actions/Inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ export const TOGGLE_SHOW_ATTRIBUTES = 'TOGGLE_SHOW_ATTRIBUTES';
export const TOGGLE_REFRESHING_STATE = 'TOGGLE_REFRESHING_STATE';

export const SET_GESTURE_UPLOAD_ERROR = 'SET_GESTURE_UPLOAD_ERROR';
export const SET_ENVIRONMENT_VARIABLES = 'SET_ENVIRONMENT_VARIABLES';
export const ADD_ENVIRONMENT_VARIABLE = 'ADD_ENVIRONMENT_VARIABLE';
export const DELETE_ENVIRONMENT_VARIABLE = 'DELETE_ENVIRONMENT_VARIABLE';

const KEEP_ALIVE_PING_INTERVAL = 20 * 1000;
const NO_NEW_COMMAND_LIMIT = 24 * 60 * 60 * 1000; // Set timeout to 24 hours
Expand Down Expand Up @@ -919,6 +922,24 @@ export function setGestureUploadErrors(errors) {
};
}

export function setEnvironmentVariables(envVars) {
return (dispatch) => {
dispatch({type: SET_ENVIRONMENT_VARIABLES, envVars});
};
}

export function addEnvironmentVariable(key, value) {
return (dispatch) => {
dispatch({type: ADD_ENVIRONMENT_VARIABLE, key, value});
};
}

export function deleteEnvironmentVariable(key) {
return (dispatch) => {
dispatch({type: DELETE_ENVIRONMENT_VARIABLE, key});
};
}

export function uploadGesturesFromFile(fileList) {
return async (dispatch) => {
const gestures = await readTextFromUploadedFiles(fileList);
Expand Down
6 changes: 6 additions & 0 deletions app/common/renderer/actions/Session.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {notification} from 'antd';

Check failure on line 1 in app/common/renderer/actions/Session.js

View workflow job for this annotation

GitHub Actions / Lint & Format

Run autofix to sort these imports!
import {includes, isPlainObject, isUndefined, toPairs, union, values, without} from 'lodash';
import {interpolateEnvironmentVariables} from '../utils/env-utils';
import moment from 'moment';
import {Web2Driver} from 'web2driver';

Expand Down Expand Up @@ -229,7 +230,12 @@

dispatch({type: NEW_SESSION_REQUESTED, caps});

// Get environment variables from state
const environmentVariables = getState().inspector.environmentVariables || [];

Check failure on line 235 in app/common/renderer/actions/Session.js

View workflow job for this annotation

GitHub Actions / Lint & Format

Trailing spaces not allowed
// Get capabilities and interpolate environment variables
let desiredCapabilities = caps ? getCapsObject(caps) : {};
desiredCapabilities = interpolateEnvironmentVariables(desiredCapabilities, environmentVariables);
let host, port, username, accessKey, https, path, token;
desiredCapabilities = addCustomCaps(desiredCapabilities);

Expand Down
93 changes: 93 additions & 0 deletions app/common/renderer/components/Inspector/EnvironmentVariables.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {PlusOutlined, DeleteOutlined} from '@ant-design/icons';

Check failure on line 1 in app/common/renderer/components/Inspector/EnvironmentVariables.jsx

View workflow job for this annotation

GitHub Actions / Lint & Format

Run autofix to sort these imports!
import {Button, Input, Space, Table, Tooltip} from 'antd';
import {useState} from 'react';
import {useDispatch, useSelector} from 'react-redux';
import {setEnvironmentVariables, addEnvironmentVariable, deleteEnvironmentVariable} from '../../actions/Inspector';

Check warning on line 5 in app/common/renderer/components/Inspector/EnvironmentVariables.jsx

View workflow job for this annotation

GitHub Actions / Lint & Format

'setEnvironmentVariables' is defined but never used
import styles from './EnvironmentVariables.module.css';

const EnvironmentVariables = ({t}) => {
const dispatch = useDispatch();
const envVars = useSelector(state => state.inspector.environmentVariables || []);

Check warning on line 10 in app/common/renderer/components/Inspector/EnvironmentVariables.jsx

View workflow job for this annotation

GitHub Actions / Lint & Format

Expected parentheses around arrow function argument
const [newVar, setNewVar] = useState({key: '', value: ''});

const columns = [
{
title: t('Variable Name'),
dataIndex: 'key',
key: 'key',
width: '40%',
},
{
title: t('Value'),
dataIndex: 'value',
key: 'value',
width: '40%',
render: (text) => <Input.Password value={text} readOnly />,
},
{
title: t('Actions'),
key: 'action',
width: '20%',
render: (_, record) => (
<Tooltip title={t('Delete Variable')}>
<Button
type="text"
danger
icon={<DeleteOutlined />}
onClick={() => {
dispatch(deleteEnvironmentVariable(record.key));
}}
/>
</Tooltip>
),
},
];

const handleAddVariable = () => {
if (!newVar.key || !newVar.value) return;

Check failure on line 47 in app/common/renderer/components/Inspector/EnvironmentVariables.jsx

View workflow job for this annotation

GitHub Actions / Lint & Format

Expected { after 'if' condition

Check failure on line 48 in app/common/renderer/components/Inspector/EnvironmentVariables.jsx

View workflow job for this annotation

GitHub Actions / Lint & Format

Trailing spaces not allowed
// Check for duplicate keys
if (envVars.some((v) => v.key === newVar.key)) {
return;
}

dispatch(addEnvironmentVariable(newVar.key, newVar.value));
setNewVar({key: '', value: ''});
};

return (
<div className={styles.container}>
<div className={styles.addForm}>
<Space.Compact style={{width: '100%'}}>
<Input
placeholder={t('Variable Name')}
value={newVar.key}
onChange={(e) => setNewVar({...newVar, key: e.target.value})}
/>
<Input.Password
placeholder={t('Value')}
value={newVar.value}
onChange={(e) => setNewVar({...newVar, value: e.target.value})}
/>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={handleAddVariable}
disabled={!newVar.key || !newVar.value}
>
{t('Add')}
</Button>
</Space.Compact>
</div>
<Table
columns={columns}
dataSource={envVars}
pagination={false}
rowKey="key"
size="small"
/>
</div>
);
};

export default EnvironmentVariables;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.container {
display: flex;
flex-direction: column;
gap: 16px;
}

.addForm {
padding: 8px 0;
}
26 changes: 13 additions & 13 deletions app/common/renderer/components/Inspector/Inspector.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check failure on line 1 in app/common/renderer/components/Inspector/Inspector.jsx

View workflow job for this annotation

GitHub Actions / Lint & Format

Run autofix to sort these imports!
CheckCircleOutlined,
CloseCircleOutlined,
CodeOutlined,
Expand All @@ -15,6 +15,7 @@
import {Button, Card, Modal, Space, Spin, Switch, Tabs, Tooltip} from 'antd';
import {debounce} from 'lodash';
import {useEffect, useRef, useState} from 'react';
import styles from './Inspector.module.css';
import {useNavigate} from 'react-router';

import {BUTTON} from '../../constants/antd-types';
Expand All @@ -30,7 +31,6 @@
import Commands from './Commands.jsx';
import GestureEditor from './GestureEditor.jsx';
import HeaderButtons from './HeaderButtons.jsx';
import InspectorStyles from './Inspector.module.css';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the changes in this file are renaming and can be omitted in this PR

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not resolved

import Recorder from './Recorder.jsx';
import SavedGestures from './SavedGestures.jsx';
import Screenshot from './Screenshot.jsx';
Expand Down Expand Up @@ -221,7 +221,7 @@
}, [showKeepAlivePrompt]);

const screenShotControls = (
<div className={InspectorStyles['screenshot-controls']}>
<div className={styles['screenshot-controls']}>
<Space size="middle">
<Tooltip
title={t(showCentroids ? 'Hide Element Handles' : 'Show Element Handles')}
Expand Down Expand Up @@ -263,22 +263,22 @@
);

const main = (
<div className={InspectorStyles['inspector-main']}>
<div className={styles['inspector-main']}>
<div
id="screenshotContainer"
className={InspectorStyles['screenshot-container']}
className={styles['screenshot-container']}
ref={screenshotContainerEl}
>
{screenShotControls}
{showScreenshot && <Screenshot {...props} scaleRatio={scaleRatio} />}
{screenshotError && t('couldNotObtainScreenshot', {screenshotError})}
{!showScreenshot && (
<Spin size="large" spinning={true}>
<div className={InspectorStyles.screenshotBox} />
<div className={styles.screenshotBox} />
</Spin>
)}
</div>
<div id="sourceTreeContainer" className={InspectorStyles['interaction-tab-container']}>
<div id="sourceTreeContainer" className={styles['interaction-tab-container']}>
<Tabs
activeKey={selectedInspectorTab}
size="small"
Expand Down Expand Up @@ -331,15 +331,15 @@
</div>
<div
id="selectedElementContainer"
className={`${InspectorStyles['interaction-tab-container']} ${InspectorStyles['element-detail-container']} action-col`}
className={`${styles['interaction-tab-container']} ${styles['element-detail-container']} action-col`}
>
<Card
title={
<span>
<TagOutlined /> {t('selectedElement')}
</span>
}
className={InspectorStyles['selected-element-card']}
className={styles['selected-element-card']}
>
{selectedElement.path && <SelectedElement {...props} />}
{!selectedElement.path && <i>{t('selectElementInSource')}</i>}
Expand All @@ -359,7 +359,7 @@
<ThunderboltOutlined /> {t('Execute Commands')}
</span>
}
className={InspectorStyles['interaction-tab-card']}
className={styles['interaction-tab-card']}
>
<Commands {...props} />
</Card>
Expand All @@ -376,7 +376,7 @@
<HighlightOutlined /> {t('Gesture Builder')}
</span>
}
className={InspectorStyles['interaction-tab-card']}
className={styles['interaction-tab-card']}
>
<GestureEditor {...props} />
</Card>
Expand All @@ -387,7 +387,7 @@
<HighlightOutlined /> {t('Saved Gestures')}
</span>
}
className={InspectorStyles['interaction-tab-card']}
className={styles['interaction-tab-card']}
>
<SavedGestures {...props} />
</Card>
Expand All @@ -410,7 +410,7 @@
<InfoCircleOutlined /> {t('Session Information')}
</span>
}
className={InspectorStyles['interaction-tab-card']}
className={styles['interaction-tab-card']}
>
<SessionInfo {...props} />
</Card>
Expand All @@ -423,7 +423,7 @@
);

return (
<div className={InspectorStyles['inspector-container']}>
<div className={styles['inspector-container']}>
<HeaderButtons quitCurrentSession={quitCurrentSession} {...props} />
{main}
<Modal
Expand Down
Loading
Loading