Skip to content

Commit 0f50376

Browse files
author
ci-bot
committed
create template explorer modal. modify app context.
1 parent d9af0cf commit 0f50376

File tree

31 files changed

+2089
-97
lines changed

31 files changed

+2089
-97
lines changed

apps/remix-ide/src/app.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import Terminal from './app/panels/terminal'
111111
import TabProxy from './app/panels/tab-proxy.js'
112112
import { Plugin } from '@remixproject/engine'
113113
import BottomBarPanel from './app/components/bottom-bar-panel'
114+
import { TemplateExplorerModalPlugin } from './app/plugins/remix-generic-modal'
114115

115116
const _paq = (window._paq = window._paq || [])
116117

@@ -157,6 +158,7 @@ class AppComponent {
157158
popupPanel: PopupPanel
158159
statusBar: StatusBar
159160
topBar: Topbar
161+
templateExplorerModal: TemplateExplorerModalPlugin
160162
settings: SettingsTab
161163
params: any
162164
desktopClientMode: boolean
@@ -401,6 +403,8 @@ class AppComponent {
401403

402404
const templateSelection = new TemplatesSelectionPlugin()
403405

406+
const templateExplorerModal = new TemplateExplorerModalPlugin()
407+
404408
const walletConnect = new WalletConnect()
405409

406410
this.engine.register([
@@ -456,6 +460,7 @@ class AppComponent {
456460
pluginStateLogger,
457461
matomo,
458462
templateSelection,
463+
templateExplorerModal,
459464
scriptRunnerUI,
460465
remixAI,
461466
remixAiAssistant,

apps/remix-ide/src/app/plugins/notification.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ import { LibraryProfile, MethodApi, StatusEvents } from '@remixproject/plugin-ut
44
import { AppModal } from '@remix-ui/app'
55
import { AlertModal } from '@remix-ui/app'
66
import { dispatchModalInterface } from '@remix-ui/app'
7-
import { TemplateExplorerModal } from 'libs/remix-ui/app/src/lib/remix-app/interface'
87

98
interface INotificationApi {
109
events: StatusEvents
1110
methods: {
1211
modal: (args: AppModal) => void
1312
alert: (args: AlertModal) => void
1413
toast: (message: string) => void
15-
templateExplorer: (args: TemplateExplorerModal) => void
14+
1615
}
1716
}
1817

1918
const profile: LibraryProfile<INotificationApi> = {
2019
name: 'notification',
2120
displayName: 'Notification',
2221
description: 'Displays notifications',
23-
methods: ['modal', 'alert', 'toast', 'templateExplorer']
22+
methods: ['modal', 'alert', 'toast']
2423
}
2524

2625
export class NotificationPlugin extends Plugin implements MethodApi<INotificationApi> {
@@ -37,11 +36,6 @@ export class NotificationPlugin extends Plugin implements MethodApi<INotificatio
3736
return this.dispatcher.modal(args)
3837
}
3938

40-
async templateExplorer(args: TemplateExplorerModal) {
41-
console.log('templateExplorer', args)
42-
return this.dispatcher.templateExplorer(args)
43-
}
44-
4539
async alert(args: AlertModal) {
4640
return this.dispatcher.alert(args)
4741
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* eslint-disable @nrwl/nx/enforce-module-boundaries */
2+
import React from 'react'
3+
import { AppAction, AppState } from '@remix-ui/app'
4+
import { PluginViewWrapper } from '@remix-ui/helper'
5+
import { Plugin } from '@remixproject/engine'
6+
import { EventEmitter } from 'events'
7+
import { RemixUiGenericModal, RemixUiGenericModalProps } from 'libs/remix-ui/generic-modal/src/lib/remix-ui-generic-modal'
8+
9+
const pluginProfile = {
10+
name: 'remix-generic-modal',
11+
displayName: 'Remix Generic Modal',
12+
description: 'Remix Generic Modal for every type of content meant for a modal',
13+
methods: ['openModal']
14+
}
15+
16+
export class TemplateExplorerModalPlugin extends Plugin {
17+
element: HTMLDivElement
18+
dispatch: React.Dispatch<any> = () => { }
19+
event: any
20+
appStateDispatch: any
21+
constructor() {
22+
super(pluginProfile)
23+
this.element = document.createElement('div')
24+
this.element.setAttribute('id', 'remix-generic-modal')
25+
this.dispatch = () => { }
26+
this.event = new EventEmitter()
27+
}
28+
29+
async onActivation(): Promise<void> {
30+
31+
}
32+
33+
onDeactivation(): void {
34+
this.element.remove()
35+
}
36+
37+
setDispatch(dispatch: React.Dispatch<any>) {
38+
this.dispatch = dispatch
39+
this.renderComponent()
40+
}
41+
42+
setAppStateDispatch(appStateDispatch: React.Dispatch<AppAction>) {
43+
this.appStateDispatch = appStateDispatch
44+
}
45+
46+
render() {
47+
return (
48+
<div id="inner-remix-generic-modal">
49+
<PluginViewWrapper plugin={this} useAppContext={true} />
50+
</div>
51+
)
52+
}
53+
54+
renderComponent(): void {
55+
this.dispatch({
56+
element: this.element,
57+
})
58+
}
59+
60+
updateComponent(state: RemixUiGenericModalProps, appState: AppState) {
61+
return (
62+
<RemixUiGenericModal
63+
appState={appState}
64+
dispatch={this.dispatch}
65+
plugin={this}
66+
/>
67+
)
68+
}
69+
}

apps/remix-ide/src/app/plugins/remixGuide.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class RemixGuidePlugin extends ViewPlugin {
121121
>
122122
{ section.cells.map((cell, index) => {
123123
return <RemixUIGridCell
124-
plugin={this}
124+
// plugin={this}
125125
title={cell.title}
126126
titleTooltip={cell.titleTooltip}
127127
tagList={cell.tagList}

apps/remix-ide/src/app/plugins/templates-selection/templates-selection-plugin.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
272272
if (!item.opts) {
273273
return (
274274
<RemixUIGridCell
275-
plugin={this}
275+
// plugin={this}
276276
title={item.displayName}
277277
key={item.name || index}
278278
id={item.name}
@@ -353,7 +353,7 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
353353
}
354354
})}
355355
{template.name === 'Cookbook' && <RemixUIGridCell
356-
plugin={this}
356+
// plugin={this}
357357
title={"More from Cookbook"}
358358
key={"cookbookMore"}
359359
id={"cookBookMore"}

apps/remix-ide/src/remixAppManager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ let requiredModules = [
9595
'remixAID',
9696
'remixaiassistant',
9797
'topbar',
98+
'remix-generic-modal',
9899
'githubAuthHandler',
99100
'desktopClient'
100101
]
@@ -162,7 +163,8 @@ export function isNative(name) {
162163
'desktopClient',
163164
'LearnEth',
164165
'noir-compiler',
165-
'remixaiassistant'
166+
'remixaiassistant',
167+
'remix-generic-modal'
166168
]
167169
return nativePlugins.includes(name) || requiredModules.includes(name) || isInjectedProvider(name) || isVM(name) || isScriptRunner(name)
168170
}

libs/remix-ui/app/src/lib/remix-app/actions/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { branch, desktopConnection, GitHubUser } from '@remix-api';
2+
import { GenericModal } from '../interface';
23

34
type ActionMap<M extends { [index: string]: any }> = {
45
[Key in keyof M]: M[Key] extends undefined
@@ -18,6 +19,7 @@ export const enum appActionTypes {
1819
setCanUseGit = 'SET_CAN_USE_GIT',
1920
setShowPopupPanel = 'SET_SHOW_POPUP_PANEL',
2021
setConnectedToDesktop = 'SET_CONNECTED_TO_DESKTOP',
22+
showGenericModal = 'SHOW_GENERIC_MODAL',
2123
}
2224

2325
type AppPayload = {
@@ -26,7 +28,8 @@ type AppPayload = {
2628
[appActionTypes.setNeedsGitInit]: boolean,
2729
[appActionTypes.setCanUseGit]: boolean,
2830
[appActionTypes.setShowPopupPanel]: boolean,
29-
[appActionTypes.setConnectedToDesktop]: desktopConnection
31+
[appActionTypes.setConnectedToDesktop]: desktopConnection,
32+
[appActionTypes.showGenericModal]: boolean
3033
}
3134

3235
export type AppAction = ActionMap<AppPayload>[keyof ActionMap<

libs/remix-ui/app/src/lib/remix-app/actions/modals.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppModal, TemplateExplorerModal } from '../interface'
1+
import { AppModal, GenericModal } from '../interface'
22

33
type ActionMap<M extends { [index: string]: any }> = {
44
[Key in keyof M]: M[Key] extends undefined
@@ -13,20 +13,20 @@ type ActionMap<M extends { [index: string]: any }> = {
1313

1414
export const enum modalActionTypes {
1515
setModal = 'SET_MODAL',
16-
setTemplateExplorer = 'SET_TEMPLATE_EXPLORER',
1716
setToast = 'SET_TOAST',
1817
processQueue = 'PROCESS_QUEUEU',
1918
handleHideModal = 'HANDLE_HIDE_MODAL',
20-
handleToaster = 'HANDLE_HIDE_TOAST'
19+
handleToaster = 'HANDLE_HIDE_TOAST',
20+
setTemplateExplorer = 'SET_TEMPLATE_EXPLORER'
2121
}
2222

2323
type ModalPayload = {
2424
[modalActionTypes.setModal]: AppModal
25-
[modalActionTypes.setTemplateExplorer]: TemplateExplorerModal
2625
[modalActionTypes.handleHideModal]: any
2726
[modalActionTypes.setToast]: { message: string | JSX.Element, timestamp: number }
2827
[modalActionTypes.handleToaster]: any,
29-
[modalActionTypes.processQueue]: any
28+
[modalActionTypes.processQueue]: any,
29+
[modalActionTypes.setTemplateExplorer]: GenericModal
3030
}
3131

3232
export type ModalAction = ActionMap<ModalPayload>[keyof ActionMap<

libs/remix-ui/app/src/lib/remix-app/components/modals/dialogViewPlugin.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { AppContext } from '../../context/context'
33
import { useDialogDispatchers } from '../../context/provider'
44

55
const DialogViewPlugin = () => {
6-
const { modal, alert, toast, templateExplorer } = useDialogDispatchers()
6+
const { modal, alert, toast } = useDialogDispatchers()
77
const app = useContext(AppContext)
88

99
useEffect(() => {
10-
app.modal.setDispatcher({ modal, alert, toast, templateExplorer })
10+
app.modal.setDispatcher({ modal, alert, toast })
1111
}, [])
1212
return <></>
1313
}

libs/remix-ui/app/src/lib/remix-app/context/context.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { AlertModal, AppModal, AppState, TemplateExplorerModal } from '../interface'
2+
import { AlertModal, AppModal, AppState } from '../interface'
33
import { ModalInitialState } from '../state/modals'
44
import { AppAction } from '../actions/app'
55

@@ -26,7 +26,6 @@ export interface dispatchModalInterface {
2626
modal: (data: AppModal) => void
2727
toast: (message: string | JSX.Element) => void
2828
alert: (data: AlertModal) => void
29-
templateExplorer: (data: TemplateExplorerModal) => void
3029
handleHideModal: () => void
3130
handleToaster: () => void
3231
}
@@ -35,7 +34,6 @@ export const dispatchModalContext = React.createContext<dispatchModalInterface>(
3534
modal: (data: AppModal) => {},
3635
toast: (message: string | JSX.Element) => {},
3736
alert: (data: AlertModal) => {},
38-
templateExplorer: (data: TemplateExplorerModal) => {},
3937
handleHideModal: () => {},
4038
handleToaster: () => {}
4139
})

0 commit comments

Comments
 (0)