Skip to content

Commit

Permalink
Merge pull request #380 from cytoscape/app-disable
Browse files Browse the repository at this point in the history
CW-463 fixed enable/disable function for Apps.
  • Loading branch information
d2fong authored Dec 23, 2024
2 parents a5ce39b + 4a471a9 commit 7647b27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/components/ToolBar/AppMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const AppMenu = (props: DropdownMenuProps) => {
(id) => apps[id].status === AppStatus.Active,
)
if (activeIds.length === 0) {
setComponentList([])
return
}

Expand All @@ -110,7 +111,10 @@ export const AppMenu = (props: DropdownMenuProps) => {
components.forEach((component: ComponentMetadata) => {
const componentId: string = component.id
const componentType: string = component.type
if (componentType === ComponentType.Menu) {
if (
componentType === ComponentType.Menu &&
app.status === AppStatus.Active
) {
// Add menu only
componentList.push([appId, componentId])
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Workspace/SidePanel/TabContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../../models/AppModel'
import { ComponentMetadata } from '../../../models/AppModel/ComponentMetadata'
import ExternalComponent from '../../../components/AppManager/ExternalComponent'
import { AppStatus } from '../../../models/AppModel/AppStatus'

/**
* Actual contents of the side panel
Expand All @@ -26,7 +27,10 @@ export const getTabContents = (selectedIndex: number): JSX.Element[] => {
if (components === undefined) return

components.forEach((component: ComponentMetadata) => {
if (component.type === AppComponentType.Panel) {
if (
component.type === AppComponentType.Panel &&
app.status === AppStatus.Active
) {
const PanelComponent: any = ExternalComponent(
app.id,
'./' + component.id,
Expand Down Expand Up @@ -58,6 +62,7 @@ export const getTabContents = (selectedIndex: number): JSX.Element[] => {
},
)
}

return [
<TabPanel
label="Sub Network Viewer"
Expand Down
4 changes: 2 additions & 2 deletions src/store/AppStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export const useAppStore = create(
// Add app only when it is not already present
if (state.apps[app.id] === undefined) {
state.apps[id] = app
// Will be activated by default
state.apps[id].status = AppStatus.Active
// Will be inactive by default
state.apps[id].status = AppStatus.Inactive
console.info(`App registered: ${app.id}`)
putAppToDb(app)
} else {
Expand Down

0 comments on commit 7647b27

Please sign in to comment.