- don't unpin if selected provider

- focus on gridprovider
 - show no provider pinned
pull/5370/head
yann300 7 months ago committed by Aniket
parent 588b6739dd
commit 162b1f8cd5
  1. 43
      apps/remix-ide/src/app/providers/grid-providers.tsx
  2. 2
      apps/remix-ide/src/blockchain/blockchain.tsx
  3. 5
      libs/remix-ui/run-tab/src/lib/components/environment.tsx

@ -107,9 +107,16 @@ export class GridProviders extends ViewPlugin {
plugin={this}
title={provider.name}
pinned={this.pinnedProviders.includes(provider.name)}
pinStateCallback={(pinned: boolean) => {
this.emit(pinned ? 'providerPinned' : 'providerUnpinned', provider.name, provider)}
}
pinStateCallback={async (pinned: boolean) => {
const providerName = await this.call('blockchain', 'getProvider')
if (providerName !== provider.name) {
this.emit(pinned ? 'providerPinned' : 'providerUnpinned', provider.name, provider)
return true
} else {
this.call('notification', 'toast', 'Cannot unpin the current selected provider')
return false
}
}}
>
<div>{provider.name}</div>
</RemixUIGridCell>
@ -122,11 +129,18 @@ export class GridProviders extends ViewPlugin {
>{this.providers['Remix VMs'].map(provider => {
return <RemixUIGridCell
plugin={this}
pinned={this.pinnedProviders.includes(provider.name)}
pinStateCallback={(pinned: boolean) => {
this.emit(pinned ? 'providerPinned' : 'providerUnpinned', provider.name, provider)}
}
title={provider.name}
pinned={this.pinnedProviders.includes(provider.name)}
pinStateCallback={async (pinned: boolean) => {
const providerName = await this.call('blockchain', 'getProvider')
if (providerName !== provider.name) {
this.emit(pinned ? 'providerPinned' : 'providerUnpinned', provider.name, provider)
return true
} else {
this.call('notification', 'toast', 'Cannot unpin the current selected provider')
return false
}
}}
>
<div>{provider.name}</div>
</RemixUIGridCell>
@ -138,11 +152,18 @@ export class GridProviders extends ViewPlugin {
>{this.providers['Externals'].map(provider => {
return <RemixUIGridCell
plugin={this}
pinned={this.pinnedProviders.includes(provider.name)}
pinStateCallback={(pinned: boolean) => {
this.emit(pinned ? 'providerPinned' : 'providerUnpinned', provider.name, provider)}
}
title={provider.name}
pinned={this.pinnedProviders.includes(provider.name)}
pinStateCallback={async (pinned: boolean) => {
const providerName = await this.call('blockchain', 'getProvider')
if (providerName !== provider.name) {
this.emit(pinned ? 'providerPinned' : 'providerUnpinned', provider.name, provider)
return true
} else {
this.call('notification', 'toast', 'Cannot unpin the current selected provider')
return false
}
}}
>
<div>{provider.name}</div>
</RemixUIGridCell>

@ -531,7 +531,7 @@ export class Blockchain extends Plugin {
changeExecutionContext(context, confirmCb, infoCb, cb) {
if (context.context === 'item-another-chain') {
this.call('manager', 'activatePlugin', 'gridProviders')
this.call('manager', 'activatePlugin', 'gridProviders').then(() => this.call('tabs', 'focus', 'gridProviders'))
} else {
return this.executionContext.executionContextChange(context, null, confirmCb, infoCb, cb)
}

@ -54,6 +54,11 @@ export function EnvironmentUI(props: EnvironmentProps) {
)}
</Dropdown.Toggle>
<Dropdown.Menu as={CustomMenu} className="w-100 custom-dropdown-items" data-id="custom-dropdown-items">
{props.providers.providerList.length === 0 ? <Dropdown.Item>
<span className="">
No provider pinned
</span>
</Dropdown.Item> : ''}
{props.providers.providerList.map(({ displayName, name }, index) => (
<Dropdown.Item
key={index}

Loading…
Cancel
Save