|
@@ -17,7 +17,9 @@ import { WebviewMessage } from "../../../../src/shared/WebviewMessage"
|
|
|
|
|
|
|
|
export interface ViewState {
|
|
export interface ViewState {
|
|
|
allItems: MarketplaceItem[]
|
|
allItems: MarketplaceItem[]
|
|
|
|
|
+ organizationMcps: MarketplaceItem[]
|
|
|
displayItems?: MarketplaceItem[] // Items currently being displayed (filtered or all)
|
|
displayItems?: MarketplaceItem[] // Items currently being displayed (filtered or all)
|
|
|
|
|
+ displayOrganizationMcps?: MarketplaceItem[] // Organization MCPs currently being displayed (filtered or all)
|
|
|
isFetching: boolean
|
|
isFetching: boolean
|
|
|
activeTab: "mcp" | "mode"
|
|
activeTab: "mcp" | "mode"
|
|
|
filters: {
|
|
filters: {
|
|
@@ -54,7 +56,9 @@ export class MarketplaceViewStateManager {
|
|
|
private getDefaultState(): ViewState {
|
|
private getDefaultState(): ViewState {
|
|
|
return {
|
|
return {
|
|
|
allItems: [],
|
|
allItems: [],
|
|
|
|
|
+ organizationMcps: [],
|
|
|
displayItems: [], // Always initialize as empty array, not undefined
|
|
displayItems: [], // Always initialize as empty array, not undefined
|
|
|
|
|
+ displayOrganizationMcps: [], // Always initialize as empty array, not undefined
|
|
|
isFetching: true, // Start with loading state for initial load
|
|
isFetching: true, // Start with loading state for initial load
|
|
|
activeTab: "mcp",
|
|
activeTab: "mcp",
|
|
|
filters: {
|
|
filters: {
|
|
@@ -96,16 +100,22 @@ export class MarketplaceViewStateManager {
|
|
|
public getState(): ViewState {
|
|
public getState(): ViewState {
|
|
|
// Only create new arrays if they exist and have items
|
|
// Only create new arrays if they exist and have items
|
|
|
const allItems = this.state.allItems.length ? [...this.state.allItems] : []
|
|
const allItems = this.state.allItems.length ? [...this.state.allItems] : []
|
|
|
|
|
+ const organizationMcps = this.state.organizationMcps.length ? [...this.state.organizationMcps] : []
|
|
|
// Ensure displayItems is always an array, never undefined
|
|
// Ensure displayItems is always an array, never undefined
|
|
|
// If displayItems is undefined or null, fall back to allItems
|
|
// If displayItems is undefined or null, fall back to allItems
|
|
|
const displayItems = this.state.displayItems ? [...this.state.displayItems] : [...allItems]
|
|
const displayItems = this.state.displayItems ? [...this.state.displayItems] : [...allItems]
|
|
|
|
|
+ const displayOrganizationMcps = this.state.displayOrganizationMcps
|
|
|
|
|
+ ? [...this.state.displayOrganizationMcps]
|
|
|
|
|
+ : [...organizationMcps]
|
|
|
const tags = this.state.filters.tags.length ? [...this.state.filters.tags] : []
|
|
const tags = this.state.filters.tags.length ? [...this.state.filters.tags] : []
|
|
|
|
|
|
|
|
// Create minimal new state object
|
|
// Create minimal new state object
|
|
|
return {
|
|
return {
|
|
|
...this.state,
|
|
...this.state,
|
|
|
allItems,
|
|
allItems,
|
|
|
|
|
+ organizationMcps,
|
|
|
displayItems,
|
|
displayItems,
|
|
|
|
|
+ displayOrganizationMcps,
|
|
|
filters: {
|
|
filters: {
|
|
|
...this.state.filters,
|
|
...this.state.filters,
|
|
|
tags,
|
|
tags,
|
|
@@ -177,11 +187,14 @@ export class MarketplaceViewStateManager {
|
|
|
|
|
|
|
|
// Calculate display items based on current filters
|
|
// Calculate display items based on current filters
|
|
|
let newDisplayItems: MarketplaceItem[]
|
|
let newDisplayItems: MarketplaceItem[]
|
|
|
|
|
+ let newDisplayOrganizationMcps: MarketplaceItem[]
|
|
|
if (this.isFilterActive()) {
|
|
if (this.isFilterActive()) {
|
|
|
newDisplayItems = this.filterItems([...items])
|
|
newDisplayItems = this.filterItems([...items])
|
|
|
|
|
+ newDisplayOrganizationMcps = this.filterItems([...this.state.organizationMcps])
|
|
|
} else {
|
|
} else {
|
|
|
// No filters active - show all items
|
|
// No filters active - show all items
|
|
|
newDisplayItems = [...items]
|
|
newDisplayItems = [...items]
|
|
|
|
|
+ newDisplayOrganizationMcps = [...this.state.organizationMcps]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Update allItems as source of truth
|
|
// Update allItems as source of truth
|
|
@@ -189,6 +202,7 @@ export class MarketplaceViewStateManager {
|
|
|
...this.state,
|
|
...this.state,
|
|
|
allItems: [...items],
|
|
allItems: [...items],
|
|
|
displayItems: newDisplayItems,
|
|
displayItems: newDisplayItems,
|
|
|
|
|
+ displayOrganizationMcps: newDisplayOrganizationMcps,
|
|
|
isFetching: false,
|
|
isFetching: false,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -245,13 +259,15 @@ export class MarketplaceViewStateManager {
|
|
|
filters: updatedFilters,
|
|
filters: updatedFilters,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Apply filters to displayItems with the updated filters
|
|
|
|
|
|
|
+ // Apply filters to displayItems and displayOrganizationMcps with the updated filters
|
|
|
const newDisplayItems = this.filterItems(this.state.allItems)
|
|
const newDisplayItems = this.filterItems(this.state.allItems)
|
|
|
|
|
+ const newDisplayOrganizationMcps = this.filterItems(this.state.organizationMcps)
|
|
|
|
|
|
|
|
// Update state with filtered items
|
|
// Update state with filtered items
|
|
|
this.state = {
|
|
this.state = {
|
|
|
...this.state,
|
|
...this.state,
|
|
|
displayItems: newDisplayItems,
|
|
displayItems: newDisplayItems,
|
|
|
|
|
+ displayOrganizationMcps: newDisplayOrganizationMcps,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Send filter message
|
|
// Send filter message
|
|
@@ -337,11 +353,14 @@ export class MarketplaceViewStateManager {
|
|
|
// If no filters are active, show all items
|
|
// If no filters are active, show all items
|
|
|
// If filters are active, apply filtering
|
|
// If filters are active, apply filtering
|
|
|
let newDisplayItems: MarketplaceItem[]
|
|
let newDisplayItems: MarketplaceItem[]
|
|
|
|
|
+ let newDisplayOrganizationMcps: MarketplaceItem[]
|
|
|
if (this.isFilterActive()) {
|
|
if (this.isFilterActive()) {
|
|
|
newDisplayItems = this.filterItems(items)
|
|
newDisplayItems = this.filterItems(items)
|
|
|
|
|
+ newDisplayOrganizationMcps = this.filterItems(this.state.organizationMcps)
|
|
|
} else {
|
|
} else {
|
|
|
// No filters active - show all items
|
|
// No filters active - show all items
|
|
|
newDisplayItems = items
|
|
newDisplayItems = items
|
|
|
|
|
+ newDisplayOrganizationMcps = this.state.organizationMcps
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Update state in a single operation
|
|
// Update state in a single operation
|
|
@@ -350,6 +369,7 @@ export class MarketplaceViewStateManager {
|
|
|
isFetching: false,
|
|
isFetching: false,
|
|
|
allItems: items,
|
|
allItems: items,
|
|
|
displayItems: newDisplayItems,
|
|
displayItems: newDisplayItems,
|
|
|
|
|
+ displayOrganizationMcps: newDisplayOrganizationMcps,
|
|
|
}
|
|
}
|
|
|
// Notification is handled below after all state parts are processed
|
|
// Notification is handled below after all state parts are processed
|
|
|
}
|
|
}
|
|
@@ -390,19 +410,24 @@ export class MarketplaceViewStateManager {
|
|
|
// Handle marketplace data updates (fetched on demand)
|
|
// Handle marketplace data updates (fetched on demand)
|
|
|
if (message.type === "marketplaceData") {
|
|
if (message.type === "marketplaceData") {
|
|
|
const marketplaceItems = message.marketplaceItems
|
|
const marketplaceItems = message.marketplaceItems
|
|
|
|
|
+ const organizationMcps = message.organizationMcps || []
|
|
|
|
|
|
|
|
if (marketplaceItems !== undefined) {
|
|
if (marketplaceItems !== undefined) {
|
|
|
// Always use the marketplace items from the extension when they're provided
|
|
// Always use the marketplace items from the extension when they're provided
|
|
|
// This ensures fresh data is always displayed
|
|
// This ensures fresh data is always displayed
|
|
|
const items = [...marketplaceItems]
|
|
const items = [...marketplaceItems]
|
|
|
|
|
+ const orgMcps = [...organizationMcps]
|
|
|
const newDisplayItems = this.isFilterActive() ? this.filterItems(items) : items
|
|
const newDisplayItems = this.isFilterActive() ? this.filterItems(items) : items
|
|
|
|
|
+ const newDisplayOrganizationMcps = this.isFilterActive() ? this.filterItems(orgMcps) : orgMcps
|
|
|
|
|
|
|
|
// Update state in a single operation
|
|
// Update state in a single operation
|
|
|
this.state = {
|
|
this.state = {
|
|
|
...this.state,
|
|
...this.state,
|
|
|
isFetching: false,
|
|
isFetching: false,
|
|
|
allItems: items,
|
|
allItems: items,
|
|
|
|
|
+ organizationMcps: orgMcps,
|
|
|
displayItems: newDisplayItems,
|
|
displayItems: newDisplayItems,
|
|
|
|
|
+ displayOrganizationMcps: newDisplayOrganizationMcps,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|