Skip to content

Commit 808bbfa

Browse files
authored
Merge branch 'master' into ollama
2 parents 6a2358e + 4424963 commit 808bbfa

File tree

10 files changed

+204
-68
lines changed

10 files changed

+204
-68
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict'
2+
import { NightwatchBrowser } from 'nightwatch'
3+
import init from '../helpers/init'
4+
5+
module.exports = {
6+
'@disabled': true,
7+
before: function (browser: NightwatchBrowser, done: VoidFunction) {
8+
init(browser, done)
9+
},
10+
11+
'Check if RemixAI plugin is pinned #group1': function (browser: NightwatchBrowser) {
12+
browser
13+
.waitForElementVisible('*[data-id="movePluginToLeft"]')
14+
.waitForElementVisible('*[data-id="remix-ai-assistant-starter-0"]')
15+
.click('*[data-id="movePluginToLeft"]')
16+
.waitForElementVisible('*[data-pinnedPlugin="movePluginToRight-remixaiassistant"]')
17+
},
18+
'Pin Solidity Compiler plugin #group1': function (browser: NightwatchBrowser) {
19+
browser
20+
.clickLaunchIcon('solidity')
21+
.pause(2000)
22+
.waitForElementVisible('*[data-id="movePluginToRight"]')
23+
.click('*[data-id="movePluginToRight"]')
24+
.waitForElementVisible('*[data-pinnedPlugin="movePluginToLeft-solidity"]')
25+
.clickLaunchIcon('filePanel')
26+
},
27+
'Close Solidity Compiler Plugin and restore it #group1': function (browser: NightwatchBrowser) {
28+
browser
29+
.waitForElementVisible('*[data-id="closePinnedPlugin"]')
30+
.click('*[data-id="closePinnedPlugin"]')
31+
.waitForElementNotVisible('*[data-pinnedplugin="movePluginToLeft-solidity"]')
32+
.waitForElementVisible('*[data-id="restoreClosedPlugin"')
33+
.click('*[data-id="restoreClosedPlugin"]')
34+
.waitForElementVisible('*[data-pinnedplugin="movePluginToLeft-solidity"]')
35+
},
36+
'Swap pinned Solidity Compiler Plugin with RemixAI Assistant when pinned plugin is closed #group1': function (browser: NightwatchBrowser) {
37+
browser
38+
.refreshPage()
39+
.waitForElementVisible('*[data-pinnedplugin="movePluginToLeft-solidity"]')
40+
.waitForElementVisible('*[data-id="closePinnedPlugin"]')
41+
.click('*[data-id="closePinnedPlugin"]')
42+
.waitForElementVisible('*[data-id="restoreClosedPlugin"]')
43+
.clickLaunchIcon('udapp')
44+
.waitForElementVisible('*[data-pinnedplugin="movePluginToRight-udapp"]')
45+
.click('*[data-id="movePluginToRight"]')
46+
.waitForElementVisible('*[data-pinnedplugin="movePluginToLeft-udapp"]')
47+
.waitForElementVisible('*[data-id="movePluginToRight"]')
48+
.click('*[data-pinnedplugin="movePluginToLeft-udapp"]')
49+
.end()
50+
}
51+
}

apps/remix-ide/src/app/components/pinned-panel.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ const pinnedPanel = {
1111
displayName: 'Pinned Panel',
1212
description: 'Remix IDE pinned panel',
1313
version: packageJson.version,
14-
methods: ['addView', 'removeView', 'currentFocus', 'pinView', 'unPinView', 'highlight']
14+
methods: ['addView', 'removeView', 'currentFocus', 'pinView', 'unPinView', 'highlight', 'closePlugin', 'maximizePlugin',
15+
'getClosedPlugin'
16+
],
17+
events: ['pluginClosed', 'pluginMaximized']
1518
}
1619

1720
export class PinnedPanel extends AbstractPanel {
1821
dispatch: React.Dispatch<any> = () => {}
1922
loggedState: Record<string, any>
2023
highlightStamp: number
24+
closedPlugin: any
2125

2226
constructor() {
2327
super(pinnedPanel)
@@ -35,6 +39,9 @@ export class PinnedPanel extends AbstractPanel {
3539
}
3640

3741
async pinView (profile, view) {
42+
if (this.closedPlugin) {
43+
this.maximizePlugin(this.closedPlugin)
44+
}
3845
const activePlugin = this.currentFocus()
3946

4047
if (activePlugin === profile.name) throw new Error(`Plugin ${profile.name} already pinned`)
@@ -62,6 +69,26 @@ export class PinnedPanel extends AbstractPanel {
6269
this.emit('unPinnedPlugin', profile)
6370
}
6471

72+
getClosedPlugin() {
73+
return this.closedPlugin
74+
}
75+
76+
async closePlugin (profile) {
77+
const pinnedPanel = document.querySelector('#pinned-panel')
78+
pinnedPanel.classList.add('d-none')
79+
this.closedPlugin = profile
80+
this.events.emit('pluginClosed', profile)
81+
this.emit('pluginClosed', profile)
82+
}
83+
84+
async maximizePlugin (profile) {
85+
const pinnedPanel = document.querySelector('#pinned-panel')
86+
pinnedPanel.classList.remove('d-none')
87+
this.closedPlugin = null
88+
this.events.emit('pluginMaximized', profile)
89+
this.emit('pluginMaximized', profile)
90+
}
91+
6592
highlight () {
6693
this.highlightStamp = Date.now()
6794
this.renderComponent()
@@ -78,7 +105,7 @@ export class PinnedPanel extends AbstractPanel {
78105
}
79106

80107
updateComponent(state: any) {
81-
return <RemixPluginPanel header={<RemixUIPanelHeader plugins={state.plugins} pinView={this.pinView.bind(this)} unPinView={this.unPinView.bind(this)}></RemixUIPanelHeader>} { ...state } />
108+
return <RemixPluginPanel header={<RemixUIPanelHeader plugins={state.plugins} pinView={this.pinView.bind(this)} unPinView={this.unPinView.bind(this)} closePlugin={this.closePlugin.bind(this)} maximizePlugin={this.maximizePlugin.bind(this)}></RemixUIPanelHeader>} { ...state } />
82109
}
83110

84111
renderComponent() {

apps/remix-ide/src/app/components/side-panel.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ export class SidePanel extends AbstractPanel {
100100
*/
101101
async showContent(name) {
102102
super.showContent(name)
103-
if (name === 'remixaiassistant') {
104-
await this.call('sidePanel', 'pinView', this.plugins[name].profile)
105-
return
106-
}
107103
this.emit('focusChanged', name)
108104
this.renderComponent()
109105
}

apps/remix-ide/src/app/components/top-bar.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Topbar extends Plugin {
3030
dispatch: React.Dispatch<any> = () => { }
3131
appStateDispatch: React.Dispatch<AppAction> = () => { }
3232
htmlElement: HTMLDivElement
33-
events: EventEmitter
33+
event: EventEmitter
3434
topbarExpandPath: string
3535
filePanel: FilePanel
3636
git: GitPlugin
@@ -44,6 +44,7 @@ export class Topbar extends Plugin {
4444
super(TopBarProfile)
4545
this.filePanel = filePanel
4646
this.registry = Registry.getInstance()
47+
this.event = new EventEmitter()
4748
this.fileProviders = this.registry.get('fileproviders').api
4849
this.fileManager = this.registry.get('filemanager').api
4950
this.git = git
@@ -52,6 +53,12 @@ export class Topbar extends Plugin {
5253
}
5354

5455
onActivation(): void {
56+
this.on('pinnedPanel', 'pluginClosed', (profile) => {
57+
this.event.emit('pluginIsClosed', profile)
58+
})
59+
this.on('pinnedPanel', 'pluginMaximized', (profile) => {
60+
this.event.emit('pluginIsMaximized', profile)
61+
})
5562
this.renderComponent()
5663
}
5764

@@ -69,12 +76,6 @@ export class Topbar extends Plugin {
6976
}
7077

7178
async createWorkspace(workspaceName, workspaceTemplateName, isEmpty) {
72-
// return new Promise((resolve, reject) => {
73-
// this.emit('createWorkspaceReducerEvent', workspaceName, workspaceTemplateName, isEmpty, (err, data) => {
74-
// if (err) reject(err)
75-
// else resolve(data || true)
76-
// })
77-
// })
7879
try {
7980
await createWorkspace(workspaceName, workspaceTemplateName, isEmpty)
8081
this.emit('workspaceCreated', workspaceName, workspaceTemplateName, isEmpty)
@@ -84,12 +85,6 @@ export class Topbar extends Plugin {
8485
}
8586

8687
async renameWorkspace(oldName, workspaceName) {
87-
// return new Promise((resolve, reject) => {
88-
// this.emit('renameWorkspaceReducerEvent', oldName, workspaceName, (err, data) => {
89-
// if (err) reject(err)
90-
// else resolve(data || true)
91-
// })
92-
// })
9388
try {
9489
await renameWorkspace(oldName, workspaceName)
9590
this.emit('workspaceRenamed', oldName, workspaceName)
@@ -99,12 +94,6 @@ export class Topbar extends Plugin {
9994
}
10095

10196
async deleteWorkspace(workspaceName) {
102-
// return new Promise((resolve, reject) => {
103-
// this.emit('deleteWorkspaceReducerEvent', workspaceName, (err, data) => {
104-
// if (err) reject(err)
105-
// else resolve(data || true)
106-
// })
107-
// })
10897
try {
10998
await deleteWorkspace(workspaceName)
11099
this.emit('workspaceDeleted', workspaceName)

apps/remix-ide/src/app/panels/tab-proxy.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class TabProxy extends Plugin {
2222
this.loadedTabs = []
2323
this.dispatch = null
2424
this.themeQuality = 'dark'
25+
this.maximize = false
2526
}
2627

2728
async onActivation () {
@@ -31,6 +32,13 @@ export default class TabProxy extends Plugin {
3132
this.renderComponent()
3233
})
3334

35+
this.on('pinnedPanel', 'pluginClosed', (profile) => {
36+
this.event.emit('pluginIsClosed', profile)
37+
})
38+
this.on('pinnedPanel', 'pluginMaximized', (profile) => {
39+
this.event.emit('pluginIsMaximized', profile)
40+
})
41+
3442
this.on('fileManager', 'filesAllClosed', () => {
3543
this.call('manager', 'activatePlugin', 'home')
3644
this.focus('home')
@@ -357,6 +365,7 @@ export default class TabProxy extends Plugin {
357365
onZoomOut={state.onZoomOut}
358366
onReady={state.onReady}
359367
themeQuality={state.themeQuality}
368+
maximize={this.maximize}
360369
/>
361370
}
362371

apps/remix-ide/src/remixAppManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export function isNative(name) {
147147
'foundry-provider',
148148
'basic-http-provider',
149149
'tabs',
150+
'pinnedPanel',
150151
'doc-gen',
151152
'doc-viewer',
152153
'circuit-compiler',

libs/remix-ui/panel/src/lib/plugins/panel-header.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ const _paq = (window._paq = window._paq || [])
88
export interface RemixPanelProps {
99
plugins: Record<string, PluginRecord>,
1010
pinView?: (profile: PluginRecord['profile'], view: PluginRecord['view']) => void,
11-
unPinView?: (profile: PluginRecord['profile']) => void
11+
unPinView?: (profile: PluginRecord['profile']) => void,
12+
closePlugin?: (profile: PluginRecord['profile']) => void,
13+
maximizePlugin?: (profile: PluginRecord['profile']) => void
1214
}
1315
const RemixUIPanelHeader = (props: RemixPanelProps) => {
1416
const [plugin, setPlugin] = useState<PluginRecord>()
@@ -38,6 +40,10 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
3840
_paq.push(['trackEvent', 'PluginPanel', 'pinToLeft', plugin.profile.name])
3941
}
4042

43+
const closePlugin = async () => {
44+
props.closePlugin && props.closePlugin(plugin.profile)
45+
}
46+
4147
const tooltipChild = <i className={`px-1 ms-2 pt-1 pb-2 ${!toggleExpander ? 'fas fa-angle-right' : 'fas fa-angle-down bg-light'}`} aria-hidden="true"></i>
4248

4349
return (
@@ -71,14 +77,23 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
7177
<RenderIfNot condition={plugin.profile.name === 'filePanel'}>
7278
<>
7379
<RenderIf condition={plugin.pinned}>
74-
<div className='d-flex' data-id="movePluginToLeft" onClick={unPinPlugin}>
75-
<CustomTooltip placement="auto-end" tooltipId="unPinnedMsg" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.unPinnedMsg" />}>
76-
<i aria-hidden="true" className="mt-1 px-2 fak fa-fa-dock-l"></i>
80+
<>
81+
<div className='d-flex' data-id="movePluginToLeft" data-pinnedplugin={`movePluginToLeft-${plugin.profile.name}`} onClick={unPinPlugin}>
82+
<CustomTooltip placement="auto-end" tooltipId="unPinnedMsg" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.unPinnedMsg" />}>
83+
<i aria-hidden="true" className="mt-1 px-2 fak fa-fa-dock-l"></i>
84+
</CustomTooltip>
85+
</div>
86+
<CustomTooltip placement="bottom-end" tooltipText="Hide pinned Plugin">
87+
<i
88+
className="fa-solid fa-compress ms-2 fs-5"
89+
onClick={closePlugin}
90+
data-id="closePinnedPlugin"
91+
></i>
7792
</CustomTooltip>
78-
</div>
93+
</>
7994
</RenderIf>
8095
<RenderIfNot condition={plugin.pinned}>
81-
<div className='d-flex' data-id="movePluginToRight" onClick={pinPlugin}>
96+
<div className='d-flex' data-id="movePluginToRight" data-pinnedplugin={`movePluginToRight-${plugin.profile.name}`} onClick={pinPlugin}>
8297
<CustomTooltip placement="auto-end" tooltipId="pinnedMsg" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.pinnedMsg" />}>
8398
<i aria-hidden="true" className="mt-1 px-1 ps-2 fak fa-fa-dock-r"></i>
8499
</CustomTooltip>
@@ -121,13 +136,6 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
121136
</a>
122137
</span>
123138
)}
124-
125-
{plugin?.profile?.documentation && (
126-
<a href={plugin.profile.documentation} target="_blank" rel="noreferrer" className="btn btn-secondary w-100 d-flex align-items-center justify-content-center text-decoration-none">
127-
<i className="fas fa-book me-2"></i>
128-
<FormattedMessage id="panel.openDocumentation" defaultMessage="Open documentation" />
129-
</a>
130-
)}
131139
</div>
132140
</div>
133141

libs/remix-ui/plugin-manager/src/lib/components/PluginCard.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@ function PluginCard({ profile, isActive, isLoading, togglePlugin }: PluginCardPr
3434
<span className="fw-bold" style={{ color: isDark ? 'white' : 'black' }}>{profile.displayName || profile.name}</span>
3535
</div>
3636
<div className="toggle-container">
37-
<button
38-
type="button"
39-
className="btn btn-link p-0 m-0"
37+
<div
4038
data-id={`pluginManagerComponent${isActive ? 'Deactivate' : 'Activate'}Button${profile.name}`}
4139
onClick={() => togglePlugin(profile.name)}
42-
aria-label={`${isActive ? 'Deactivate' : 'Activate'} ${profile.displayName || profile.name}`}
43-
>
40+
aria-label={`${isActive ? 'Deactivate' : 'Activate'} ${profile.displayName || profile.name}`}>
4441
<ToggleSwitch
4542
id={`toggleSwitch-${profile.name}`}
4643
isOn={isActive}
4744
/>
48-
</button>
45+
</div>
4946
</div>
5047
</div>
5148

libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ import { values } from 'lodash'
99
import { AppContext } from '@remix-ui/app'
1010
import { desktopConnectionType } from '@remix-api'
1111
import { CompileDropdown, RunScriptDropdown } from '@remix-ui/tabs'
12+
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
13+
import TabProxy from 'apps/remix-ide/src/app/panels/tab-proxy'
1214

1315
const _paq = (window._paq = window._paq || [])
1416

1517
/* eslint-disable-next-line */
1618
export interface TabsUIProps {
1719
tabs: Array<Tab>
18-
plugin: Plugin
20+
plugin: TabProxy
1921
onSelect: (index: number) => void
2022
onClose: (index: number) => void
2123
onZoomOut: () => void
2224
onZoomIn: () => void
2325
onReady: (api: any) => void
2426
themeQuality: string
27+
maximize: boolean
2528
}
2629

2730
export interface Tab {
@@ -86,6 +89,8 @@ export const TabsUI = (props: TabsUIProps) => {
8689
const compileSeq = useRef(0)
8790
const compileWatchdog = useRef<number | null>(null)
8891
const settledSeqRef = useRef<number>(0)
92+
const [maximized, setMaximized] = useState<boolean>(false)
93+
const [closedPlugin, setClosedPlugin] = useState<any>(null)
8994

9095
const [compileState, setCompileState] = useState<'idle' | 'compiling' | 'compiled'>('idle')
9196

@@ -98,6 +103,19 @@ export const TabsUI = (props: TabsUIProps) => {
98103
}
99104
}, [tabsState.selectedIndex])
100105

106+
useEffect(() => {
107+
props.plugin.event.on('pluginIsClosed', (profile) => {
108+
setClosedPlugin(profile)
109+
if (maximized) {
110+
setMaximized(false)
111+
}
112+
})
113+
props.plugin.event.on('pluginIsMaximized', () => {
114+
setClosedPlugin(null)
115+
setMaximized(true)
116+
})
117+
}, [])
118+
101119
// Toggle the copilot in editor when clicked to update in status bar
102120
useEffect(() => {
103121
const run = async () => {
@@ -490,7 +508,7 @@ export const TabsUI = (props: TabsUIProps) => {
490508

491509
return (
492510
<div
493-
className={`remix-ui-tabs justify-content-between border-0 header nav-tabs ${
511+
className={`remix-ui-tabs justify-content-between border-0 header nav-tabs ${
494512
appContext.appState.connectedToDesktop === desktopConnectionType .disabled ? 'd-flex' : 'd-none'
495513
}`}
496514
data-id="tabs-component"
@@ -606,8 +624,8 @@ export const TabsUI = (props: TabsUIProps) => {
606624
<TabPanel key={tab.name}></TabPanel>
607625
))}
608626
</Tabs>
609-
</div>
610627

628+
</div>
611629
</div>
612630
)
613631
}

0 commit comments

Comments
 (0)