Skip to content

Commit

Permalink
contextual right click
Browse files Browse the repository at this point in the history
  • Loading branch information
toddtarsi committed Jan 13, 2024
1 parent 33c6637 commit 766d617
Show file tree
Hide file tree
Showing 95 changed files with 562 additions and 573 deletions.
4 changes: 2 additions & 2 deletions packages/selenium-ide/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "selenium-ide",
"version": "4.0.1-alpha.75",
"version": "4.0.1-alpha.76",
"private": false,
"description": "Selenium IDE electron app",
"author": "Todd <[email protected]>",
Expand Down Expand Up @@ -111,7 +111,7 @@
"@seleniumhq/code-export-python-pytest": "^4.0.0-alpha.4",
"@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.3",
"@seleniumhq/get-driver": "^4.0.0-alpha.3",
"@seleniumhq/side-api": "^4.0.0-alpha.43",
"@seleniumhq/side-api": "^4.0.0-alpha.44",
"@seleniumhq/side-commons": "^4.0.0-alpha.2",
"@seleniumhq/side-model": "^4.0.0-alpha.5",
"@seleniumhq/side-runtime": "^4.0.0-alpha.35",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import TabPanel from '../Tab/Panel'
import SuiteControls from '../../tabs/Suites/Controls'
import TestControls from '../../tabs/Tests/Controls'
import SuiteControls from '../../windows/ProjectEditor/tabs/Suites/Controls'
import TestControls from '../../windows/ProjectEditor/tabs/Tests/Controls'
import { SUITES_TAB, TESTS_TAB } from '../../enums/tab'
import { SIDEMainProps } from '../types'
import AppBarTabs from './AppBarTabs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,30 @@ import baseControlProps from '../Controls/BaseProps'
export interface EditorToolbarIconsProps {
disabled?: boolean
onAdd?: () => void
addText?: string
onEdit?: () => void
editText?: string
onRemove?: () => void
removeText?: string
onView?: () => void
viewText?: string
}

export const EditorToolbarIcons: FC<EditorToolbarIconsProps> = ({
disabled = false,
editText = 'Edit',
onAdd,
addText = "Add",
onEdit,
editText = 'Edit',
onRemove,
removeText = 'Remove',
onView,
viewText = 'View',
}) => (
<>
{onRemove ? (
<Box sx={{ flex: 0 }}>
<Tooltip title="Remove">
<Tooltip title={removeText}>
<IconButton
{...baseControlProps}
color="warning"
Expand All @@ -56,30 +62,30 @@ export const EditorToolbarIcons: FC<EditorToolbarIconsProps> = ({
</Tooltip>
</Box>
) : null}
{onAdd ? (
{onView ? (
<Box sx={{ flex: 0 }}>
<Tooltip title="Add">
<Tooltip title={viewText}>
<IconButton
{...baseControlProps}
color="success"
color="info"
disabled={disabled}
onClick={onAdd}
onClick={onView}
>
<AddIcon />
<VisibilityIcon />
</IconButton>
</Tooltip>
</Box>
) : null}
{onView ? (
{onAdd ? (
<Box sx={{ flex: 0 }}>
<Tooltip title="View Playback Results">
<Tooltip title={addText}>
<IconButton
{...baseControlProps}
color="info"
color="success"
disabled={disabled}
onClick={onView}
onClick={onAdd}
>
<VisibilityIcon />
<AddIcon />
</IconButton>
</Tooltip>
</Box>
Expand Down Expand Up @@ -111,9 +117,13 @@ const EditorToolbar: FC<EditorToolbarProps> = ({
disabled = false,
elevation = 7,
onAdd,
addText = "Add",
onEdit,
editText = 'Edit',
onRemove,
removeText = 'Remove',
onView,
viewText = 'View',
...props
}) => (
<DrawerHeader
Expand All @@ -126,9 +136,13 @@ const EditorToolbar: FC<EditorToolbarProps> = ({
<EditorToolbarIcons
disabled={disabled}
onAdd={onAdd}
addText={addText}
onEdit={onEdit}
editText={editText}
onRemove={onRemove}
removeText={removeText}
onView={onView}
viewText={viewText}
/>
</DrawerHeader>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ListItemText from '@mui/material/ListItemText'
import TextField from '@mui/material/TextField'
import { CommandState } from '@seleniumhq/side-runtime'
import React, { FC } from 'react'
import CommandOverlay from '../../tabs/Tests/TestCommandOverlay'
import CommandOverlay from '../../windows/ProjectEditor/tabs/Tests/TestCommandOverlay'

export interface TestListProps {
id: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const SIDELogger: React.FC = () => {
const handleLog = (level: LogLevel, log: string) => {
const el = logContainer.current
if (!el) return;
console.info(el.scrollHeight)
el.append(
`${new Date().toLocaleTimeString()} [${level}] ${log}\n`
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Box, {BoxProps} from '@mui/material/Box'
import { styled } from '@mui/material/styles'

const MainHeader = styled('div')(() => ({
const MainHeader: React.FC<BoxProps> = styled(Box)(() => ({
alignItems: 'center',
display: 'flex',
// necessary for content to be below app bar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import TabPanel from '../Tab/Panel'
import { PROJECT_TAB, SUITES_TAB, TESTS_TAB } from '../../enums/tab'
import ProjectTab from '../../tabs/Project/ProjectTab'
import SuitesTab from '../../tabs/Suites/SuitesTab'
import TestsTab from '../../tabs/Tests/TestsTab'
import ProjectTab from '../../windows/ProjectEditor/tabs/Project/ProjectTab'
import SuitesTab from '../../windows/ProjectEditor/tabs/Suites/SuitesTab'
import TestsTab from '../../windows/ProjectEditor/tabs/Tests/TestsTab'
import { SIDEMainProps } from '../types'

const SIDEMain: React.FC<Pick<SIDEMainProps, 'session' | 'setTab' | 'tab'>> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { loadingID } from '@seleniumhq/side-api/dist/constants/loadingID'
import React from 'react'
import { DndProvider } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'
import Main from './components/Main'
import { TAB, TESTS_TAB } from './enums/tab'
import { SIDEMainProps } from './components/types'
import Main from '../Main'
import { TAB, TESTS_TAB } from '../../enums/tab'
import { SIDEMainProps } from '../types'

const ProjectEditor: React.FC<Pick<SIDEMainProps, 'session'>> = ({
session,
Expand Down
4 changes: 4 additions & 0 deletions packages/selenium-ide/src/browser/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,7 @@ body,
-webkit-transform: rotate(360deg);
}
}

.justify-content-start {
justify-content: flex-start !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const window: WindowConfig['window'] = () => ({
maximizable: false,
show: false,
skipTaskbar: true,
alwaysOnTop: false,
useContentSize: false,
modal: true,
title: 'Window Prompt Polyfill',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const window: WindowConfig['window'] = () => ({
maximizable: false,
show: false,
skipTaskbar: true,
alwaysOnTop: false,
useContentSize: false,
modal: true,
title: 'Window Prompt Polyfill',
Expand Down
25 changes: 0 additions & 25 deletions packages/selenium-ide/src/browser/windows/Logger/controller.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/selenium-ide/src/browser/windows/Logger/preload.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/selenium-ide/src/browser/windows/Logger/renderer.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { WindowConfig } from 'browser/types'

export const window: WindowConfig['window'] = () => ({
alwaysOnTop: true,
frame: false,
resizable: false,
roundedCorners: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ function injectRecorder() {
preload(
{
channels: api.channels,
menus: {
openSync: () => api.menus.openSync('playback'),
},
plugins: {
addRecorderPreprocessor: (fn) => {
recorderProcessors.push(fn)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,64 @@
// import { ipcRenderer } from 'electron'
import Recorder from './recorder'
import {singleton as locatorBuilders} from './locator-builders'
import { singleton as locatorBuilders } from './locator-builders'

let recorder: Recorder
let eleTarget: HTMLElement | null

const shortcutHandler = new Map

shortcutHandler.set('verifyText', function () {
return (eleTarget as any).innerText
})
shortcutHandler.set('verifyChecked', function () {
return ''
})
shortcutHandler.set('verifyElementPresent', function () {
return ''
})
shortcutHandler.set('waitForElementVisible', function () {
return '1000'
})

async function onContextMenu (event: any) {
eleTarget = event.target as HTMLElement
/*
const result = await ipcRenderer.invoke('show-shortcut-menu')
if (!result) {
eleTarget = null
return
async function onContextMenu(event: any) {
const el = event.target as HTMLElement
const targets = locatorBuilders.buildAll(el);
const selectedCommand = await window.sideAPI.menus.openSync('playback')
switch (selectedCommand) {
case 'Record Wait For Element Present':
recorder.record(
event,
'waitForElementPresent',
targets,
'',
false,
null,
true
)
break
case 'Record Wait For Element Visible':
recorder.record(
event,
'waitForElementVisible',
targets,
'',
false,
null,
true
)
break
case 'Record Wait For Element Text':
recorder.record(
event,
'waitForElementText',
targets,
el.innerText,
false,
null,
true
)
break
case 'Record Wait For Element Editable':
recorder.record(
event,
'waitForElementEditable',
targets,
'',
false,
null,
true
)
break
}
recorder.record(
event,
result.cmd,
locatorBuilders.buildAll(eleTarget),
shortcutHandler.get(result.cmd)(result.params)
)
*/
recorder.record(
event,
'click',
locatorBuilders.buildAll(eleTarget),
shortcutHandler.get('click')([])
)
}

export function attach (_recorder: Recorder) {
export function attach(_recorder: Recorder) {
recorder = _recorder
window.addEventListener('contextmenu', onContextMenu)
}

export function detach () {
export function detach() {
window.removeEventListener('contextmenu', onContextMenu)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ export default class Recorder {
command: string,
target: string | [string, string][],
value: string | [string, string][],
insertBeforeLastCommand: boolean = false,
actualFrameLocation?: string
insertBeforeLastCommand = false,
actualFrameLocation: string | null = null,
overrideRecorder = false
) {
console.log('record', event, command, target, value, insertBeforeLastCommand)
let newCommand: RecordNewCommandInput = {
command,
target,
Expand All @@ -115,7 +115,7 @@ export default class Recorder {
newCommand = result.command
}
}
window.sideAPI.recorder.recordNewCommand(newCommand)
window.sideAPI.recorder.recordNewCommand(newCommand, overrideRecorder)
}

setWindowHandle(event: ExpandedMessageEvent) {
Expand Down
Loading

0 comments on commit 766d617

Please sign in to comment.