Skip to content

Commit

Permalink
- don't unpin if selected provider
Browse files Browse the repository at this point in the history
 - focus on gridprovider
 - show no provider pinned
  • Loading branch information
yann300 committed May 13, 2024
1 parent 2b98039 commit c63731e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
43 changes: 32 additions & 11 deletions apps/remix-ide/src/app/providers/grid-providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/blockchain/blockchain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions libs/remix-ui/grid-view/src/lib/remix-ui-grid-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ export const RemixUIGridCell = (props: RemixUIGridCellProps) => {
</div>
{ filterCon.showPin && <button
className={`${pinned ? 'fa-duotone' : 'fa-light'}` + ` fa-map-pin text-info border-0 mb-0 remixui_grid_cell_pin`}
onClick={() => {
setPinned(!pinned)
props.pinStateCallback(!pinned)
onClick={async () => {
if (await props.pinStateCallback(!pinned)) setPinned(!pinned)
}}
></button>}
{ props.tagList && <div className='d-flex flex-column align-items-begin remixui_grid_cell_tags'>
Expand Down
5 changes: 5 additions & 0 deletions libs/remix-ui/run-tab/src/lib/components/environment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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}
Expand Down

0 comments on commit c63731e

Please sign in to comment.