Commit 4d94476a authored by joseph izang's avatar joseph izang

refactor useEffect to boot page load times

parent d2f893e9
...@@ -17,6 +17,7 @@ module.exports = { ...@@ -17,6 +17,7 @@ module.exports = {
browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]') browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]')
.pause(3000) .pause(3000)
.click('*[plugin="pluginManager"]') .click('*[plugin="pluginManager"]')
.pause(3000)
.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]') .waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'PLUGIN MANAGER') .assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'PLUGIN MANAGER')
}, },
......
...@@ -58,8 +58,6 @@ function RootView ({ pluginComponent }: RootViewProps) { ...@@ -58,8 +58,6 @@ function RootView ({ pluginComponent }: RootViewProps) {
const GetNewlyActivatedPlugins = useCallback((pluginComponent: PluginManagerComponent) => { const GetNewlyActivatedPlugins = useCallback((pluginComponent: PluginManagerComponent) => {
// const profiles: Profile[] = JSON.parse(window.localStorage.getItem('newActivePlugins')) // const profiles: Profile[] = JSON.parse(window.localStorage.getItem('newActivePlugins'))
let isValid: boolean = false let isValid: boolean = false
// eslint-disable-next-line no-debugger
debugger
pluginComponent.activeProfiles.forEach(profileName => { pluginComponent.activeProfiles.forEach(profileName => {
isValid = validActiveProfiles.some(profile => profile.name === profileName) isValid = validActiveProfiles.some(profile => profile.name === profileName)
}) })
...@@ -89,11 +87,6 @@ function RootView ({ pluginComponent }: RootViewProps) { ...@@ -89,11 +87,6 @@ function RootView ({ pluginComponent }: RootViewProps) {
}, [GetNewlyActivatedPlugins, activeP, pluginComponent, pluginComponent.activePlugins, syncInactiveProfiles]) }, [GetNewlyActivatedPlugins, activeP, pluginComponent, pluginComponent.activePlugins, syncInactiveProfiles])
useEffect(() => { useEffect(() => {
pluginComponent.getAndFilterPlugins(filterPlugins)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [filterPlugins])
useEffect(() => {
if (pluginComponent.activePlugins && pluginComponent.activePlugins.length) { if (pluginComponent.activePlugins && pluginComponent.activePlugins.length) {
setActiveP(pluginComponent.activePlugins) setActiveP(pluginComponent.activePlugins)
} }
...@@ -114,6 +107,11 @@ function RootView ({ pluginComponent }: RootViewProps) { ...@@ -114,6 +107,11 @@ function RootView ({ pluginComponent }: RootViewProps) {
} }
}, [pluginComponent.activePlugins, pluginComponent.inactivePlugins, pluginComponent.activeProfiles, pluginComponent, validInactiveProfiles, inactiveP.length, validActiveProfiles]) }, [pluginComponent.activePlugins, pluginComponent.inactivePlugins, pluginComponent.activeProfiles, pluginComponent, validInactiveProfiles, inactiveP.length, validActiveProfiles])
useEffect(() => {
pluginComponent.getAndFilterPlugins(filterPlugins)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [filterPlugins])
// useEffect(() => { // useEffect(() => {
// if (validInactiveProfiles && validInactiveProfiles.length && // if (validInactiveProfiles && validInactiveProfiles.length &&
// inactiveP.length > validInactiveProfiles.length) { // inactiveP.length > validInactiveProfiles.length) {
...@@ -142,6 +140,50 @@ function RootView ({ pluginComponent }: RootViewProps) { ...@@ -142,6 +140,50 @@ function RootView ({ pluginComponent }: RootViewProps) {
return ( return (
<Fragment> <Fragment>
<div id="pluginManager" data-id="pluginManagerComponentPluginManager">
<header className="form-group remixui_pluginSearch plugins-header py-3 px-4 border-bottom" data-id="pluginManagerComponentPluginManagerHeader">
<input
type="text"
onChange={(event) => {
setFilterPlugin(event.target.value.toLowerCase())
}}
className="form-control"
placeholder="Search"
data-id="pluginManagerComponentSearchInput"
/>
<button onClick={openModal} className="remixui_pluginSearchButton btn bg-transparent text-dark border-0 mt-2 text-underline" data-id="pluginManagerComponentPluginSearchButton">
Connect to a Local Plugin
</button>
</header>
<section data-id="pluginManagerComponentPluginManagerSection">
{(activeP && activeP.length > 0) && <Fragment>
<ModuleHeading headingLabel="Active Modules" count={activeP.length} />
{activeP.map((profile) => (
<ActivePluginCard
buttonText="Deactivate"
key={profile.name}
profile={profile}
syncInactiveProfiles={syncInactiveProfiles}
pluginComponent={pluginComponent}
/>
))}
</Fragment>
}
{inactiveP && <Fragment>
<ModuleHeading headingLabel="Inactive Modules" count={inactiveP.length} />
{inactiveP.map((profile) => (
<InactivePluginCard
buttonText="Activate"
key={profile.name}
profile={profile}
pluginComponent={pluginComponent}
/>
))}
</Fragment>
}
</section>
<PermisssionsSettings pluginSettings={pluginComponent.pluginSettings}/>
</div>
<form id="local-plugin-form"> <form id="local-plugin-form">
<ModalDialog <ModalDialog
handleHide={closeModal} handleHide={closeModal}
...@@ -278,53 +320,8 @@ function RootView ({ pluginComponent }: RootViewProps) { ...@@ -278,53 +320,8 @@ function RootView ({ pluginComponent }: RootViewProps) {
<label className="form-check-label" htmlFor="none">None</label> <label className="form-check-label" htmlFor="none">None</label>
</div> </div>
</div> </div>
</ModalDialog> </ModalDialog>
</form> </form>
<div id="pluginManager" data-id="pluginManagerComponentPluginManager">
<header className="form-group remixui_pluginSearch plugins-header py-3 px-4 border-bottom" data-id="pluginManagerComponentPluginManagerHeader">
<input
type="text"
onChange={(event) => {
setFilterPlugin(event.target.value.toLowerCase())
}}
className="form-control"
placeholder="Search"
data-id="pluginManagerComponentSearchInput"
/>
<button onClick={openModal} className="remixui_pluginSearchButton btn bg-transparent text-dark border-0 mt-2 text-underline" data-id="pluginManagerComponentPluginSearchButton">
Connect to a Local Plugin
</button>
</header>
<section data-id="pluginManagerComponentPluginManagerSection">
{(activeP && activeP.length > 0) && <Fragment>
<ModuleHeading headingLabel="Active Modules" count={activeP.length} />
{activeP.map((profile) => (
<ActivePluginCard
buttonText="Deactivate"
key={profile.name}
profile={profile}
syncInactiveProfiles={syncInactiveProfiles}
pluginComponent={pluginComponent}
/>
))}
</Fragment>
}
{inactiveP && <Fragment>
<ModuleHeading headingLabel="Inactive Modules" count={inactiveP.length} />
{inactiveP.map((profile) => (
<InactivePluginCard
buttonText="Activate"
key={profile.name}
profile={profile}
pluginComponent={pluginComponent}
/>
))}
</Fragment>
}
</section>
<PermisssionsSettings pluginSettings={pluginComponent.pluginSettings}/>
</div>
</Fragment> </Fragment>
) )
} }
......
...@@ -84,26 +84,26 @@ export async function UpdateInactivePluginList (deactivatedPlugin: Profile, plug ...@@ -84,26 +84,26 @@ export async function UpdateInactivePluginList (deactivatedPlugin: Profile, plug
return tempArray return tempArray
} }
export function GetNewlyActivatedPlugins (pluginComponent: PluginManagerComponent) { // export function GetNewlyActivatedPlugins (pluginComponent: PluginManagerComponent) {
const profiles: Profile[] = JSON.parse(window.localStorage.getItem('newActivePlugins')) // const profiles: Profile[] = JSON.parse(window.localStorage.getItem('newActivePlugins'))
let isValid: boolean = false // let isValid: boolean = false
// eslint-disable-next-line no-debugger // // eslint-disable-next-line no-debugger
debugger // debugger
pluginComponent.activeProfiles.forEach(profileName => { // pluginComponent.activeProfiles.forEach(profileName => {
isValid = profiles.some(profile => profile.name === profileName) // isValid = profiles.some(profile => profile.name === profileName)
}) // })
if (isValid) { // if (isValid) {
return profiles // return profiles
} else { // } else {
profiles.forEach(profile => { // profiles.forEach(profile => {
if (!pluginComponent.activeProfiles.includes(profile.name)) { // if (!pluginComponent.activeProfiles.includes(profile.name)) {
RemoveActivatedPlugin(profile.name) // RemoveActivatedPlugin(profile.name)
} // }
}) // })
const newProfiles = JSON.parse(window.localStorage.getItem('newActivePlugins')) // const newProfiles = JSON.parse(window.localStorage.getItem('newActivePlugins'))
return newProfiles // return newProfiles
} // }
} // }
async function FetchAndPersistPlugin (pluginComponent: PluginManagerComponent, newPlugin: Profile<any>, newlyActivatedPlugins: Profile<any>[]) { async function FetchAndPersistPlugin (pluginComponent: PluginManagerComponent, newPlugin: Profile<any>, newlyActivatedPlugins: Profile<any>[]) {
try { try {
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
"nightwatch_local_gist": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/gist.spec.js --env=chrome", "nightwatch_local_gist": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/gist.spec.js --env=chrome",
"nightwatch_local_workspace": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/workspace.test.js --env=chrome", "nightwatch_local_workspace": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/workspace.test.js --env=chrome",
"nightwatch_local_defaultLayout": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/defaultLayout.test.js --env=chrome", "nightwatch_local_defaultLayout": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/defaultLayout.test.js --env=chrome",
"nightwatch_local_pluginManager": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/pluginManager.spec.js --env=chrome", "nightwatch_local_pluginManager": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/pluginManager.spec.js --env=firefox",
"nightwatch_local_publishContract": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/publishContract.test.js --env=chrome", "nightwatch_local_publishContract": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/publishContract.test.js --env=chrome",
"nightwatch_local_generalSettings": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/generalSettings.test.js --env=chrome", "nightwatch_local_generalSettings": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/generalSettings.test.js --env=chrome",
"nightwatch_local_fileExplorer": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/fileExplorer.test.js --env=chrome", "nightwatch_local_fileExplorer": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/fileExplorer.test.js --env=chrome",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment