diff --git a/apps/remix-ide/src/app/providers/grid-providers.tsx b/apps/remix-ide/src/app/providers/grid-providers.tsx index 568ce32506..a2d57c7be8 100644 --- a/apps/remix-ide/src/app/providers/grid-providers.tsx +++ b/apps/remix-ide/src/app/providers/grid-providers.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 + } + }} >
{provider.name}
@@ -122,11 +129,18 @@ export class GridProviders extends ViewPlugin { >{this.providers['Remix VMs'].map(provider => { return { - 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 + } + }} >
{provider.name}
@@ -138,11 +152,18 @@ export class GridProviders extends ViewPlugin { >{this.providers['Externals'].map(provider => { return { - 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 + } + }} >
{provider.name}
diff --git a/apps/remix-ide/src/blockchain/blockchain.tsx b/apps/remix-ide/src/blockchain/blockchain.tsx index 73c4c2ef7c..4ac4cae534 100644 --- a/apps/remix-ide/src/blockchain/blockchain.tsx +++ b/apps/remix-ide/src/blockchain/blockchain.tsx @@ -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) } diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx index e7d54b264e..f62c797577 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -54,6 +54,11 @@ export function EnvironmentUI(props: EnvironmentProps) { )} + {props.providers.providerList.length === 0 ? + + No provider pinned + + : ''} {props.providers.providerList.map(({ displayName, name }, index) => (