From d93a1821987e47c39b3666ae0270b12dc4a743c0 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 20 May 2024 20:46:00 +0100 Subject: [PATCH] update to statusbar plugin --- apps/remix-ide/src/app.js | 2 +- apps/remix-ide/src/app/components/status-bar.tsx | 5 ++++- apps/remix-ide/src/types/index.d.ts | 1 + .../statusbar/src/lib/components/gitStatus.tsx | 10 ++++++++++ libs/remix-ui/workspace/src/index.ts | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 40171e877a..9a0d53e898 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -382,12 +382,12 @@ class AppComponent { // those views depend on app_manager this.menuicons = new VerticalIcons() this.sidePanel = new SidePanel() - this.statusBar = new StatusBar() this.hiddenPanel = new HiddenPanel() this.pinnedPanel = new PinnedPanel() const pluginManagerComponent = new PluginManagerComponent(appManager, this.engine) const filePanel = new FilePanel(appManager) + this.statusBar = new StatusBar(filePanel) const landingPage = new LandingPage(appManager, this.menuicons, fileManager, filePanel, contentImport) this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor, appManager) diff --git a/apps/remix-ide/src/app/components/status-bar.tsx b/apps/remix-ide/src/app/components/status-bar.tsx index 786333a91e..87e621e7b4 100644 --- a/apps/remix-ide/src/app/components/status-bar.tsx +++ b/apps/remix-ide/src/app/components/status-bar.tsx @@ -5,6 +5,7 @@ import packageJson from '../../../../../package.json' import { PluginViewWrapper } from '@remix-ui/helper' import { PluginProfile, StatusBarInterface } from '../../types' import { RemixUIStatusBar } from '@remix-ui/statusbar' +import { FilePanelType } from '@remix-ui/workspace' const statusBarProfile: PluginProfile = { name: 'statusBar', @@ -17,10 +18,12 @@ const statusBarProfile: PluginProfile = { export class StatusBar extends Plugin implements StatusBarInterface { htmlElement: HTMLDivElement events: EventEmitter + filePanelPlugin: FilePanelType dispatch: React.Dispatch = () => {} currentWorkspaceName: string = '' - constructor() { + constructor(filePanel: FilePanelType) { super(statusBarProfile) + this.filePanelPlugin = filePanel this.events = new EventEmitter() this.htmlElement = document.createElement('div') this.htmlElement.setAttribute('id', 'status-bar') diff --git a/apps/remix-ide/src/types/index.d.ts b/apps/remix-ide/src/types/index.d.ts index 768a5fc9fb..f7b041ca15 100644 --- a/apps/remix-ide/src/types/index.d.ts +++ b/apps/remix-ide/src/types/index.d.ts @@ -13,6 +13,7 @@ export interface PluginProfile { export interface StatusBarInterface { htmlElement: HTMLDivElement events: EventEmitter + filePanelPlugin: FilePanelType dispatch: React.Dispatch setDispatch(dispatch: React.Dispatch): void getGitBranchName: () => Promise diff --git a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx index 3270c5ce71..a5a95b9d01 100644 --- a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx @@ -9,6 +9,16 @@ export default function GitStatus({ plugin }: GitStatusProps) { const [gitBranchName, setGitBranchName] = useState('') + useEffect(() => { + plugin.on('filePanel', 'setWorkspace', async (workspace) => { + const isGit = await plugin.call('fileManager', 'isGitRepo') + console.log('workspacenow', workspace) + if (!isGit) return + workspace && workspace?.name.length > 0 ? setGitBranchName(workspace.name) : setGitBranchName('') + }) + // console.log('testing', plugin) + }, []) + return (