Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CW-463 fixed enable/disable function for Apps. #380

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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