add statusbar context.

pull/4960/head
Joseph Izang 5 months ago
parent 88e16ab41f
commit 5c2beb1879
  1. 17
      libs/remix-ui/statusbar/src/contexts/statusbarcontext.tsx
  2. 31
      libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx
  3. 12
      libs/remix-ui/statusbar/src/lib/types/index.ts
  4. 0
      libs/remix-ui/statusbar/src/utils/index.ts

@ -0,0 +1,17 @@
import React, { createContext } from 'react'
import { defaultStatusBarContext, StatusBarContextType, StatusBarInterface } from '../lib/types'
export const StatusBarContext = createContext<StatusBarContextType>(defaultStatusBarContext)
export function StatusBarContextProvider ({ children }) {
const statusBarProviderValues = {
test: true
}
return (
<>
<StatusBarContext.Provider value={statusBarProviderValues}>
{children}
</StatusBarContext.Provider>
</>
)
}

@ -7,6 +7,7 @@ import { FloatingFocusManager, autoUpdate, flip, offset, shift, size, useClick,
import axios from 'axios'
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { StatusBar } from 'apps/remix-ide/src/app/components/status-bar'
import { StatusBarContextProvider } from '../contexts/statusbarcontext'
export interface RemixUIStatusBarProps {
statusBarPlugin: StatusBar
@ -66,21 +67,23 @@ export function RemixUIStatusBar({ statusBarPlugin }: RemixUIStatusBarProps) {
return (
<>
{showScamDetails && (
<FloatingFocusManager context={context} modal={false}>
<ScamDetails refs={refs} floatStyle={{ ...floatingStyles, minHeight: 'auto', alignContent: 'center', paddingRight: '0.5rem' }} getFloatingProps={getFloatingProps} scamAlerts={scamAlerts} />
</FloatingFocusManager>
)}
<div className="d-flex remixui_statusbar_height flex-row bg-info justify-content-between align-items-center">
<div className="remixui_statusbar remixui_statusbar_gitstatus">
<GitStatus plugin={statusBarPlugin} gitBranchName={gitBranchName} setGitBranchName={setGitBranchName} />
<StatusBarContextProvider>
{showScamDetails && (
<FloatingFocusManager context={context} modal={false}>
<ScamDetails refs={refs} floatStyle={{ ...floatingStyles, minHeight: 'auto', alignContent: 'center', paddingRight: '0.5rem' }} getFloatingProps={getFloatingProps} scamAlerts={scamAlerts} />
</FloatingFocusManager>
)}
<div className="d-flex remixui_statusbar_height flex-row bg-info justify-content-between align-items-center">
<div className="remixui_statusbar remixui_statusbar_gitstatus">
<GitStatus plugin={statusBarPlugin} gitBranchName={gitBranchName} setGitBranchName={setGitBranchName} />
</div>
<div className="remixui_statusbar"></div>
<div className="remixui_statusbar d-flex flex-row">
<ScamAlertStatus refs={refs} getReferenceProps={getReferenceProps} />
<AIStatus plugin={statusBarPlugin} aiActive={lightAiUp} isAiActive={isAiActive} setIsAiActive={setIsAiActive} />
</div>
</div>
<div className="remixui_statusbar"></div>
<div className="remixui_statusbar d-flex flex-row">
<ScamAlertStatus refs={refs} getReferenceProps={getReferenceProps} />
<AIStatus plugin={statusBarPlugin} aiActive={lightAiUp} isAiActive={isAiActive} setIsAiActive={setIsAiActive} />
</div>
</div>
</StatusBarContextProvider>
</>
)
}

@ -3,6 +3,7 @@ import { Plugin } from '@remixproject/engine'
import { FilePanelType } from '@remix-ui/workspace'
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { VerticalIcons } from 'apps/remix-ide/src/app/components/vertical-icons'
import { CustomRemixApi } from '@remix-api'
export interface PluginProfile {
name: string
displayName: string
@ -15,7 +16,7 @@ export interface PluginProfile {
version?: string
}
export interface StatusBarInterface extends Plugin {
export interface StatusBarInterface extends Plugin<any, CustomRemixApi> {
htmlElement: HTMLDivElement
events: EventEmitter
dispatch: React.Dispatch<any>
@ -25,3 +26,12 @@ export interface StatusBarInterface extends Plugin {
getGitBranchName: () => Promise<any>
currentWorkspaceName: string
}
export const defaultStatusBarContext: StatusBarContextType = {
test: false
}
export type StatusBarContextType = {
test: boolean
}

Loading…
Cancel
Save