Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ import type { ResourceModel } from '@/api-clients/search/resource/schema/model';
import { useUserWorkspaceStore } from '@/store/app-context/workspace/user-workspace-store';

import ErrorHandler from '@/common/composables/error/errorHandler';
import { useRecentStore } from '@/common/modules/navigations/stores/recent-store';
import { SEARCH_TAB } from '@/common/modules/navigations/top-bar/modules/top-bar-search/config';
import type { SearchTab, StageWorkspace } from '@/common/modules/navigations/top-bar/modules/top-bar-search/type';
import { tabResourceTypeMap } from '@/common/modules/navigations/top-bar/modules/top-bar-search/type';
import type { RecentItem } from '@/common/modules/navigations/type';
import { recentNSearchTabMap } from '@/common/modules/navigations/type';

interface TopBarSearchStoreState {
loading: boolean;
allWorkspacesChecked: boolean;
isActivated: boolean;
inputText: string;
activeTab: SearchTab;
recentMenuList: RecentItem[];
// recentMenuList: RecentItem[];
searchMenuList: ResourceModel[];
// workspace filter
recentAccessedWorkspaces: string[];
Expand All @@ -35,7 +32,7 @@ interface TopBarSearchStoreState {
export const useTopBarSearchStore = defineStore('top-bar-search', () => {
const userWorkspaceStore = useUserWorkspaceStore();
const workspaceStoreState = userWorkspaceStore.$state;
const recentStore = useRecentStore();
// const recentStore = useRecentStore();

const orderWorkspaceList = (workspaceList: any[]) => {
if (!storeState.currentWorkspaceId) return workspaceList;
Expand All @@ -56,7 +53,7 @@ export const useTopBarSearchStore = defineStore('top-bar-search', () => {
isActivated: false,
inputText: '',
activeTab: 'service',
recentMenuList: [],
// recentMenuList: [],
searchMenuList: [],
// workspace filter
recentAccessedWorkspaces: [],
Expand All @@ -70,7 +67,7 @@ export const useTopBarSearchStore = defineStore('top-bar-search', () => {
if (state.inputText) return state.inputText.trim();
return '';
}),
isRecentEmpty: computed<boolean>(() => state.recentMenuList.length === 0),
// isRecentEmpty: computed<boolean>(() => state.recentMenuList.length === 0),
selectedWorkspaces: computed<string[]>(() => state.stagedWorkspaces.filter((workspace) => workspace.isSelected).map((workspace) => workspace.workspaceId)),
});

Expand Down Expand Up @@ -143,7 +140,7 @@ export const useTopBarSearchStore = defineStore('top-bar-search', () => {
};
watch([() => getters.trimmedInputText, () => state.activeTab], (trimmedText) => {
state.loading = true;
state.recentMenuList = [];
// state.recentMenuList = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why annotated all code related of recentMenuList?

if (trimmedText) {
state.searchMenuList = [];
}
Expand All @@ -157,16 +154,16 @@ export const useTopBarSearchStore = defineStore('top-bar-search', () => {
() => state.allWorkspacesChecked,
], debounce(async ([trimmedText, workspaces, tab]) => {
state.loading = true;
state.recentMenuList = [];
if (!trimmedText && storeState.currentWorkspaceId) {
const recentRes = await recentStore.fetchRecent({
type: recentNSearchTabMap[tab],
workspaceIds: [storeState.currentWorkspaceId],
});
if (tab !== SEARCH_TAB.SERVICE) state.recentMenuList = recentRes;
state.loading = false;
return;
}
// state.recentMenuList = [];
// if (!trimmedText && storeState.currentWorkspaceId) {
// const recentRes = await recentStore.fetchRecent({
// type: recentNSearchTabMap[tab],
// workspaceIds: [storeState.currentWorkspaceId],
// });
// if (tab !== SEARCH_TAB.SERVICE) state.recentMenuList = recentRes;
// state.loading = false;
// return;
// }

state.searchMenuList = [];
const isServiceTab = tab === SEARCH_TAB.SERVICE;
Expand All @@ -179,9 +176,9 @@ export const useTopBarSearchStore = defineStore('top-bar-search', () => {
state.loading = false;
}, 500));

watch(() => recentStore.state.totalCount, () => {
state.recentMenuList = recentStore.state.recentMenuList;
});
// watch(() => recentStore.state.totalCount, () => {
// state.recentMenuList = recentStore.state.recentMenuList;
// });


return {
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/common/modules/navigations/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export const RECENT_TYPE = {
DASHBOARD: 'DASHBOARD',
CLOUD_SERVICE: 'CLOUD_SERVICE',
CLOUD_SERVICE_TYPE: 'CLOUD_SERVICE_TYPE',
COST_ANALYSIS: 'COST_ANALYSIS',
METRIC_EXPLORER: 'METRIC_EXPLORER',
SECURITY: 'SECURITY',
COST_ANALYSIS: 'COST_ANALYSIS',
WORKSPACE: 'WORKSPACE',
// METRIC_EXPLORER: 'METRIC_EXPLORER',
} as const;
export type RecentType = typeof RECENT_TYPE[keyof typeof RECENT_TYPE];
export const recentNSearchTabMap = {
Expand All @@ -23,8 +23,8 @@ export const recentNSearchTabMap = {
dashboard: RECENT_TYPE.DASHBOARD,
cloudService: RECENT_TYPE.CLOUD_SERVICE,
cloudServiceType: RECENT_TYPE.CLOUD_SERVICE_TYPE,
costAnalysis: RECENT_TYPE.COST_ANALYSIS,
metricExplorer: RECENT_TYPE.METRIC_EXPLORER,
// costAnalysis: RECENT_TYPE.COST_ANALYSIS,
// metricExplorer: RECENT_TYPE.METRIC_EXPLORER,
} as const;

export interface RecentConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ const state = reactive({
const convertRecentToReferenceData = (recentConfig: ConfigData): ReferenceData|undefined => {
const { itemType } = recentConfig;
if (itemType === RECENT_TYPE.DASHBOARD) {
return convertedRecentConfigData.convertedDashboard.value.find((d) => d.itemId === recentConfig.id);
return convertedRecentConfigData.convertedDashboard.value.find((d) => d.itemId === recentConfig.itemId);
Copy link
Preview

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from recentConfig.id to recentConfig.itemId is correct and fixes a property access bug. The ConfigData interface uses itemId as the property name, not id.

Copilot uses AI. Check for mistakes.

}
if (itemType === RECENT_TYPE.PROJECT) {
return convertedRecentConfigData.convertedProject.value.find((d) => d.itemId === recentConfig.id);
return convertedRecentConfigData.convertedProject.value.find((d) => d.itemId === recentConfig.itemId);
}
if (itemType === RECENT_TYPE.PROJECT_GROUP) {
return convertedRecentConfigData.convertedProjectGroup.value.find((d) => d.itemId === recentConfig.id);
return convertedRecentConfigData.convertedProjectGroup.value.find((d) => d.itemId === recentConfig.itemId);
}
if (itemType === RECENT_TYPE.COST_ANALYSIS) {
return convertedRecentConfigData.convertedCostQuerySet.value.find((d) => d.itemId === recentConfig.id);
return convertedRecentConfigData.convertedCostQuerySet.value.find((d) => d.itemId === recentConfig.itemId);
}
return convertedRecentConfigData.convertedMenu.value.find((d) => d.itemId === recentConfig.id);
return convertedRecentConfigData.convertedMenu.value.find((d) => d.itemId === recentConfig.itemId);
};
</script>

Expand Down