parent
1940bd9245
commit
a3eb3f548b
@ -0,0 +1,30 @@ |
|||||||
|
export function alert(title: any, text: any): { |
||||||
|
container: HTMLElement; |
||||||
|
okListener: () => void; |
||||||
|
cancelListener: () => void; |
||||||
|
hide: () => void; |
||||||
|
}; |
||||||
|
export function prompt(title: any, text: any, inputValue: any, ok: any, cancel: any, focus: any): void; |
||||||
|
export function promptPassphrase(title: any, text: any, inputValue: any, ok: any, cancel: any): void; |
||||||
|
export function promptPassphraseCreation(ok: any, cancel: any): { |
||||||
|
container: HTMLElement; |
||||||
|
okListener: () => void; |
||||||
|
cancelListener: () => void; |
||||||
|
hide: () => void; |
||||||
|
}; |
||||||
|
export function promptMulti({ title, text, inputValue }: { |
||||||
|
title: any; |
||||||
|
text: any; |
||||||
|
inputValue: any; |
||||||
|
}, ok: any, cancel: any): { |
||||||
|
container: HTMLElement; |
||||||
|
okListener: () => void; |
||||||
|
cancelListener: () => void; |
||||||
|
hide: () => void; |
||||||
|
}; |
||||||
|
export function confirm(title: any, text: any, ok: any, cancel: any): { |
||||||
|
container: HTMLElement; |
||||||
|
okListener: () => void; |
||||||
|
cancelListener: () => void; |
||||||
|
hide: () => void; |
||||||
|
}; |
@ -0,0 +1,7 @@ |
|||||||
|
declare function _exports(title: any, content: any, ok: any, cancel: any, focusSelector: any, opts: any): { |
||||||
|
container: HTMLElement; |
||||||
|
okListener: () => void; |
||||||
|
cancelListener: () => void; |
||||||
|
hide: () => void; |
||||||
|
}; |
||||||
|
export = _exports; |
@ -0,0 +1,36 @@ |
|||||||
|
export class PermissionHandler { |
||||||
|
permissions: any; |
||||||
|
currentVersion: number; |
||||||
|
_getFromLocal(): any; |
||||||
|
persistPermissions(): void; |
||||||
|
clear(): void; |
||||||
|
/** |
||||||
|
* Show a message to ask the user for a permission |
||||||
|
* @param {PluginProfile} from The name and hash of the plugin that make the call |
||||||
|
* @param {ModuleProfile} to The name of the plugin that receive the call |
||||||
|
* @param {string} method The name of the function to be called |
||||||
|
* @param {string} message from the caller plugin to add more details if needed |
||||||
|
* @returns {Promise<{ allow: boolean; remember: boolean }} Answer from the user to the permission |
||||||
|
*/ |
||||||
|
openPermission(from: any, to: any, method: string, message: string): Promise<{ |
||||||
|
allow: boolean; |
||||||
|
remember: boolean; |
||||||
|
}>; |
||||||
|
/** |
||||||
|
* Check if a plugin has the permission to call another plugin and askPermission if needed |
||||||
|
* @param {PluginProfile} from the profile of the plugin that make the call |
||||||
|
* @param {ModuleProfile} to The profile of the module that receive the call |
||||||
|
* @param {string} method The name of the function to be called |
||||||
|
* @param {string} message from the caller plugin to add more details if needed |
||||||
|
* @returns {Promise<boolean>} |
||||||
|
*/ |
||||||
|
askPermission(from: any, to: any, method: string, message: string): Promise<boolean>; |
||||||
|
/** |
||||||
|
* The permission form |
||||||
|
* @param {PluginProfile} from The name and hash of the plugin that make the call |
||||||
|
* @param {ModuleProfile} to The name of the plugin that receive the call |
||||||
|
* @param {string} method The name of te methode to be called |
||||||
|
* @param {string} message from the caller plugin to add more details if needed |
||||||
|
*/ |
||||||
|
form(from: any, to: any, method: string, message: string): any; |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
export = css; |
||||||
|
declare var css: any; |
@ -0,0 +1,2 @@ |
|||||||
|
export = css; |
||||||
|
declare var css: any; |
@ -0,0 +1,2 @@ |
|||||||
|
export = css; |
||||||
|
declare var css: any; |
@ -0,0 +1,2 @@ |
|||||||
|
declare function _exports(tooltipText: string, action?: Function, opts: any): any; |
||||||
|
export = _exports; |
@ -0,0 +1,9 @@ |
|||||||
|
declare const _exports: { |
||||||
|
state: {}; |
||||||
|
put({ api, name }: { |
||||||
|
api: any; |
||||||
|
name: any; |
||||||
|
}): any; |
||||||
|
get(name: any): any; |
||||||
|
}; |
||||||
|
export = _exports; |
@ -0,0 +1,7 @@ |
|||||||
|
export = QueryParams; |
||||||
|
declare function QueryParams(_window: any): void; |
||||||
|
declare class QueryParams { |
||||||
|
constructor(_window: any); |
||||||
|
get: () => {}; |
||||||
|
update: (params: any) => void; |
||||||
|
} |
@ -1,36 +0,0 @@ |
|||||||
import React, { createContext, useState } from 'react' |
|
||||||
import { Profile } from '../../customTypes' |
|
||||||
import * as packageJson from '../../../../../../package.json' |
|
||||||
// export interface RemixUiPluginManagerProps {
|
|
||||||
// activatePlugin: (name: string) => void
|
|
||||||
// deActivatePlugin: (name: string) => void
|
|
||||||
// isActive: () => void
|
|
||||||
// openLocalPlugin: () => Promise<void>
|
|
||||||
// filterPlugins: () => void
|
|
||||||
// reRender: () => void
|
|
||||||
// profile: Profile
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const PluginManagerContext = createContext({}) |
|
||||||
|
|
||||||
function PluginManagerContextProvider ({ children }) { |
|
||||||
const [profile] = useState<Profile>({ |
|
||||||
name: 'pluginManager', |
|
||||||
displayName: 'Plugin manager', |
|
||||||
methods: [], |
|
||||||
events: [], |
|
||||||
icon: 'assets/img/pluginManager.webp', |
|
||||||
description: 'Start/stop services, modules and plugins', |
|
||||||
kind: 'settings', |
|
||||||
location: 'sidePanel', |
|
||||||
documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', |
|
||||||
version: packageJson.version |
|
||||||
}) |
|
||||||
return ( |
|
||||||
<PluginManagerContext.Provider value={profile}> |
|
||||||
{children} |
|
||||||
</PluginManagerContext.Provider> |
|
||||||
) |
|
||||||
} |
|
||||||
|
|
||||||
export default PluginManagerContextProvider |
|
@ -0,0 +1,54 @@ |
|||||||
|
import React, { useEffect, useState } from 'react' |
||||||
|
import { Profile } from '../../customTypes' |
||||||
|
import PluginCard from './pluginCard' |
||||||
|
|
||||||
|
interface RenderItemProps { |
||||||
|
profile: Profile |
||||||
|
} |
||||||
|
|
||||||
|
function RenderItem ({ profile }: RenderItemProps) { |
||||||
|
const [displayName, setDisplayName] = useState('') |
||||||
|
const [docLink, setDocLink] = useState<any>() |
||||||
|
const [versionWarning, setVersionWarning] = useState<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>>() |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
const checkPluginVersion = (version: string) => { |
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
let versionWarning: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> |
||||||
|
if (version && version.match(/\b(\w*alpha\w*)\b/g)) { |
||||||
|
versionWarning = <small title="Version Alpha" className="remixui_versionWarning plugin-version">alpha</small> |
||||||
|
} |
||||||
|
// Beta
|
||||||
|
if (version && version.match(/\b(\w*beta\w*)\b/g)) { |
||||||
|
versionWarning = <small title="Version Beta" className="remixui_versionWarning plugin-version">beta</small> |
||||||
|
} |
||||||
|
return versionWarning |
||||||
|
} |
||||||
|
|
||||||
|
setDisplayName((profile.displayName) ? profile.displayName : profile.name) |
||||||
|
setDocLink( |
||||||
|
profile.documentation ? ( |
||||||
|
<a href={profile.documentation} |
||||||
|
className="px-1" |
||||||
|
title="link to documentation" |
||||||
|
// eslint-disable-next-line react/jsx-no-target-blank
|
||||||
|
target="_blank"> |
||||||
|
<i aria-hidden="true" className="fas fa-book"></i> |
||||||
|
</a> |
||||||
|
) : '') |
||||||
|
setVersionWarning(checkPluginVersion(profile.version)) |
||||||
|
}, [profile.displayName, profile.documentation, profile.name, profile.version, versionWarning]) |
||||||
|
|
||||||
|
return ( |
||||||
|
<PluginCard |
||||||
|
displayName={displayName} |
||||||
|
docLink={docLink} |
||||||
|
versionWarning={versionWarning} |
||||||
|
profileDescription={profile.description} |
||||||
|
profileIcon={profile.icon} |
||||||
|
profileName={profile.name} |
||||||
|
/> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
export default RenderItem |
@ -1,22 +1,92 @@ |
|||||||
import React from 'react' |
import React, { createContext, useEffect, useState } from 'react' |
||||||
import { Profile } from '../customTypes' |
import { Profile } from '../customTypes' |
||||||
|
import { RemixAppManager, RemixEngine, _Paq } from '../types' |
||||||
|
import RootView from './components/rootView' |
||||||
import './remix-ui-plugin-manager.css' |
import './remix-ui-plugin-manager.css' |
||||||
|
|
||||||
/* eslint-disable-next-line */ |
/* eslint-disable-next-line */ |
||||||
export interface RemixUiPluginManagerProps { |
export interface RemixUiPluginManagerProps { |
||||||
|
appManager: RemixAppManager |
||||||
|
engine: RemixEngine |
||||||
|
_paq: _Paq |
||||||
|
filter: string |
||||||
activatePlugin: (name: string) => void |
activatePlugin: (name: string) => void |
||||||
deActivatePlugin: (name: string) => void |
deActivatePlugin: (name: string) => void |
||||||
isActive: () => void |
isActive: (name: string) => void |
||||||
openLocalPlugin: () => Promise<void> |
openLocalPlugin: () => Promise<void> |
||||||
filterPlugins: () => void |
filterPlugins: () => void |
||||||
reRender: () => void |
|
||||||
profile: Profile |
profile: Profile |
||||||
} |
} |
||||||
|
|
||||||
|
export const PluginManagerContext = createContext({}) |
||||||
|
|
||||||
|
function PluginManagerContextProvider ({ children }) { |
||||||
|
const [globalState] = useState<RemixUiPluginManagerProps>({} as RemixUiPluginManagerProps) |
||||||
|
return ( |
||||||
|
<PluginManagerContext.Provider value={globalState}> |
||||||
|
{children} |
||||||
|
</PluginManagerContext.Provider> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
// // Filtering helpers
|
||||||
|
// const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter)
|
||||||
|
// const isNotRequired = (profile) => !this.appManager.isRequired(profile.name)
|
||||||
|
// const isNotDependent = (profile) => !this.appManager.isDependent(profile.name)
|
||||||
|
// const isNotHome = (profile) => profile.name !== 'home'
|
||||||
|
// const sortByName = (profileA, profileB) => {
|
||||||
|
// const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase()
|
||||||
|
// const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase()
|
||||||
|
// return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Filter all active and inactive modules that are not required
|
||||||
|
// const { actives, inactives } = this.appManager.getAll()
|
||||||
|
// .filter(isFiltered)
|
||||||
|
// .filter(isNotRequired)
|
||||||
|
// .filter(isNotDependent)
|
||||||
|
// .filter(isNotHome)
|
||||||
|
// .sort(sortByName)
|
||||||
|
// .reduce(({ actives, inactives }, profile) => {
|
||||||
|
// return this.isActive(profile.name)
|
||||||
|
// ? { actives: [...actives, profile], inactives }
|
||||||
|
// : { inactives: [...inactives, profile], actives }
|
||||||
|
// }, { actives: [], inactives: [] })
|
||||||
|
|
||||||
export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { |
export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { |
||||||
|
const [isFiltered] = useState((profile) => |
||||||
|
(profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(props.filter)) |
||||||
|
const [isNotRequired, setIsNotRequired] = useState<boolean>(false) |
||||||
|
const [isNotDependent, setIsNotDependent] = useState((profile) => !props.appManager.isDependent(profile.name)) |
||||||
|
const [isNotHome, setIsNotHome] = useState((profile) => profile.name !== 'home') |
||||||
|
const [sortByName, setSortByName] = useState<1 | -1 | 0>((profileA, profileB) => { |
||||||
|
const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() |
||||||
|
const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() |
||||||
|
return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 |
||||||
|
}) |
||||||
|
const { actives, inactives } = props.appManager.getAll() |
||||||
|
.filter(isFiltered) |
||||||
|
.filter(isNotRequired) |
||||||
|
.filter(isNotDependent) |
||||||
|
.filter(isNotHome) |
||||||
|
.sort(sortByName) |
||||||
|
.reduce(({ actives, inactives }, profile) => { |
||||||
|
return this.isActive(profile.name) |
||||||
|
? { actives: [...actives, profile], inactives } |
||||||
|
: { inactives: [...inactives, profile], actives } |
||||||
|
}, { actives: [], inactives: [] }) |
||||||
|
useEffect(() => { |
||||||
|
const notRequired = (profile: Profile) => !props.appManager.isRequired(profile.name) |
||||||
|
setIsNotRequired(notRequired(props.profile)) |
||||||
|
}) |
||||||
|
|
||||||
return ( |
return ( |
||||||
<div> |
<PluginManagerContextProvider> |
||||||
<h1>Welcome to remix-ui-plugin-manager!</h1> |
<RootView |
||||||
</div> |
openLocalPlugins={props.openLocalPlugin} |
||||||
|
filterPlugins={props.filterPlugins} |
||||||
|
activeProfiles |
||||||
|
/> |
||||||
|
</PluginManagerContextProvider> |
||||||
) |
) |
||||||
} |
} |
||||||
|
@ -0,0 +1,10 @@ |
|||||||
|
declare class registry { |
||||||
|
state: {}; |
||||||
|
put({ api, name }: { |
||||||
|
api: any; |
||||||
|
name: any; |
||||||
|
}): any |
||||||
|
|
||||||
|
get(name: any): any; |
||||||
|
} |
||||||
|
export = registry; |
Loading…
Reference in new issue