Merge pull request #4953 from ethereum/statusbarfix

fix plugin api & statusbar
pull/5370/head
bunsenstraat 5 months ago committed by GitHub
commit f54a0a5d48
  1. 5
      apps/remix-ide/src/app/components/status-bar.tsx
  2. 12
      libs/remix-api/src/lib/plugins/filePanel-api.ts
  3. 2
      libs/remix-api/src/lib/plugins/fileSystem-api.ts
  4. 2
      libs/remix-api/src/lib/plugins/settings-api.ts
  5. 3
      libs/remix-api/src/lib/remix-api.ts
  6. 4
      libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx
  7. 2
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -7,6 +7,7 @@ import { PluginProfile, StatusBarInterface } from '../../types'
import { RemixUIStatusBar } from '@remix-ui/statusbar' import { RemixUIStatusBar } from '@remix-ui/statusbar'
import { FilePanelType } from '@remix-ui/workspace' import { FilePanelType } from '@remix-ui/workspace'
import { VerticalIcons } from './vertical-icons' import { VerticalIcons } from './vertical-icons'
import { CustomRemixApi } from '@remix-api'
const statusBarProfile: PluginProfile = { const statusBarProfile: PluginProfile = {
name: 'statusBar', name: 'statusBar',
@ -16,7 +17,7 @@ const statusBarProfile: PluginProfile = {
version: packageJson.version, version: packageJson.version,
} }
export class StatusBar extends Plugin implements StatusBarInterface { export class StatusBar extends Plugin<any, CustomRemixApi> implements StatusBarInterface {
htmlElement: HTMLDivElement htmlElement: HTMLDivElement
events: EventEmitter events: EventEmitter
filePanelPlugin: FilePanelType filePanelPlugin: FilePanelType
@ -75,7 +76,7 @@ export class StatusBar extends Plugin implements StatusBarInterface {
const workspaceName = localStorage.getItem('currentWorkspace') const workspaceName = localStorage.getItem('currentWorkspace')
workspaceName && workspaceName.length > 0 ? this.currentWorkspaceName = workspaceName : this.currentWorkspaceName = 'error' workspaceName && workspaceName.length > 0 ? this.currentWorkspaceName = workspaceName : this.currentWorkspaceName = 'error'
}) })
this.on('settings', 'copilotChoiceChanged', (isAiActive) => { this.on('settings', 'copilotChoiceChanged', (isAiActive: boolean) => {
this.isAiActive = isAiActive this.isAiActive = isAiActive
}) })
this.renderComponent() this.renderComponent()

@ -0,0 +1,12 @@
import { IFilePanel } from '@remixproject/plugin-api'
import { StatusEvents } from '@remixproject/plugin-utils'
export interface IFilePanelApi {
events: IFilePanel['events'] & {
workspaceInitializationCompleted: () => void;
switchToWorkspace: (workspace: string) => Promise<void>;
} & StatusEvents
methods: IFilePanel['methods'] & {
}
}

@ -4,7 +4,7 @@ import { IFileSystem } from "@remixproject/plugin-api"
// Extended interface with 'diff' method // Extended interface with 'diff' method
export interface IExtendedFileSystem extends IFileSystem { export interface IExtendedFileSystem extends IFileSystem {
methods: IFileSystem['methods'] & { methods: IFileSystem['methods'] & {
/** Compare the differences between two files */
diff(change: commitChange): Promise<void> diff(change: commitChange): Promise<void>
isGitRepo(): Promise<boolean>
}; };
} }

@ -3,6 +3,8 @@ import { StatusEvents } from '@remixproject/plugin-utils'
export interface ISettings { export interface ISettings {
events: { events: {
configChanged: () => void, configChanged: () => void,
copilotChoiceUpdated: (isChecked: boolean) => void,
copilotChoiceChanged: (isChecked: boolean) => void,
} & StatusEvents } & StatusEvents
methods: { methods: {
getGithubAccessToken(): string getGithubAccessToken(): string

@ -6,6 +6,8 @@ import { IFileDecoratorApi } from "./plugins/filedecorator-api"
import { IExtendedFileSystem } from "./plugins/fileSystem-api" import { IExtendedFileSystem } from "./plugins/fileSystem-api"
import { INotificationApi } from "./plugins/notification-api" import { INotificationApi } from "./plugins/notification-api"
import { ISettings } from "./plugins/settings-api" import { ISettings } from "./plugins/settings-api"
import { IFilePanelApi } from "./plugins/filePanel-api"
import { Plugin } from "@remixproject/engine"
export interface ICustomRemixApi extends IRemixApi { export interface ICustomRemixApi extends IRemixApi {
dgitApi: IGitApi dgitApi: IGitApi
@ -14,6 +16,7 @@ export interface ICustomRemixApi extends IRemixApi {
settings: ISettings settings: ISettings
fileDecorator: IFileDecoratorApi fileDecorator: IFileDecoratorApi
fileManager: IExtendedFileSystem fileManager: IExtendedFileSystem
filePanel: IFilePanelApi
} }
export declare type CustomRemixApi = Readonly<ICustomRemixApi> export declare type CustomRemixApi = Readonly<ICustomRemixApi>

@ -32,7 +32,7 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
setGitBranchName('Not a git repo') setGitBranchName('Not a git repo')
} }
}) })
plugin.on('dGitProvider', 'init', async () => { plugin.on('dgitApi', 'init', async () => {
const isGit = await plugin.call('fileManager', 'isGitRepo') const isGit = await plugin.call('fileManager', 'isGitRepo')
if (isGit) { if (isGit) {
const workspace = localStorage.getItem('currentWorkspace') const workspace = localStorage.getItem('currentWorkspace')
@ -52,7 +52,7 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
} }
const initializeNewGitRepo = async () => { const initializeNewGitRepo = async () => {
await plugin.call('dGitProvider', 'init') await plugin.call('dgitApi', 'init')
const isActive = await plugin.call('manager', 'isActive', 'dgit') const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (isLocalHost === false) { if (isLocalHost === false) {
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')

@ -257,7 +257,7 @@ export function Workspace() {
} }
} }
global.plugin.on('dGitProvider', 'repositoryWithSubmodulesCloned', () => { global.plugin.on('dgitApi', 'repositoryWithSubmodulesCloned', () => {
setHighlightUpdateSubmodules(true) setHighlightUpdateSubmodules(true)
}) })
}, []) }, [])

Loading…
Cancel
Save