Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

chore: filter templates jump from catalog list #758

Merged
merged 1 commit into from
Mar 13, 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
19 changes: 18 additions & 1 deletion src/views/application-management/projects/pages/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
import { Resources, Actions } from '@/permissions/config';
import { PROJECT } from '@/router/config';
import { ProjectTabs } from '@/views/config';
import { ref, onMounted, reactive } from 'vue';
import { ref, onMounted, onBeforeUnmount, reactive } from 'vue';
import _ from 'lodash';
import useTabActive, { TabPage } from '@/hooks/use-tab-active';
import useCallCommon from '@/hooks/use-call-common';
Expand All @@ -147,6 +147,11 @@
import TemplateList from '@/views/application-management/templates/pages/list.vue';
import CatalogList from '@/views/application-management/catalogs/pages/list.vue';
import WorkflowList from '@/views/application-management/workflows/pages/list.vue';
import {
listenFilterCatalogAction,
removeFilterCatalogActionListener,
emitFilterTemplateAction
} from '@/views/operation-hub/hooks/filter-catalog-listener';
import { queryItemProject } from '../api';
import { projectDetailTabs } from '../config';
import userProjectBreadcrumbData from '../hooks/use-project-breadcrumb-data';
Expand Down Expand Up @@ -238,6 +243,13 @@
initActiveTab();
breadCrumbList.value = await initBreadValues([]);
};
listenFilterCatalogAction((data) => {
handleTabChange(ProjectTabs.TEMPLATES);
setTimeout(() => {
emitFilterTemplateAction(data);
}, 100);
});

onMounted(() => {
initBread();
projectStore.setEnterProjectDefault({
Expand All @@ -246,6 +258,11 @@
list: false
});
});

onBeforeUnmount(() => {
removeFilterCatalogActionListener();
});

init();
</script>

Expand Down
10 changes: 9 additions & 1 deletion src/views/operation-hub/catalogs/components/list-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:pagination="false"
row-key="id"
:row-selection="rowSelectionRef"
@cell-click="handleCellClick"
@sorter-change="handleSortChange"
@selection-change="handleSelectChange"
>
Expand All @@ -28,7 +29,7 @@
}"
>
<template #cell="{ record }">
<span>{{ record.name }}</span>
<a-link :hoverable="false">{{ record.name }}</a-link>
</template>
</a-table-column>

Expand Down Expand Up @@ -154,6 +155,7 @@
import StatusLabel from '../../connectors/components/status-label.vue';
import { queryCatalogs, refreshCatalog, deleteCatalogs } from '../api';
import { actionList } from '../config';
import { emitFilterCatalogAction } from '../../hooks/filter-catalog-listener';

const props = defineProps({
list: {
Expand Down Expand Up @@ -214,6 +216,12 @@
: null;
});

const handleCellClick = (row, col) => {
if (col.dataIndex === 'name') {
emitFilterCatalogAction(row);
}
};

const setActionList = (row) => {
const list = _.filter(actionList, (item) => {
return item.filterFun ? item.filterFun(row) : true;
Expand Down
35 changes: 35 additions & 0 deletions src/views/operation-hub/hooks/filter-catalog-listener.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import mitt, { Handler } from 'mitt';

const emitter = mitt();

const key = Symbol('FILTER_CATALOG_LIST_KEY');

const key2 = Symbol('FILTER_TEMPLATE_LIST_KEY');

// trigger the event
export function emitFilterCatalogAction(data: any) {
emitter.emit(key, data);
}

export function listenFilterCatalogAction(handler: (data) => void) {
emitter.on(key, handler as Handler);
}

export function removeFilterCatalogActionListener() {
emitter.off(key);
}

// filter template
export function emitFilterTemplateAction(data: any) {
emitter.emit(key2, data);
}

export function listenFilterTemplateAction(handler: (data) => void) {
emitter.on(key2, handler as Handler);
}

export function removeFilterTemplateActionListener() {
emitter.off(key2);
}

export default {};
24 changes: 15 additions & 9 deletions src/views/operation-hub/pages/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@
>
<Connectors></Connectors>
</a-tab-pane>

<!-- <template #extra>
<IconBtnGroup
v-if="activeKey === OperatorHubTabs.TEMPLATES"
v-model:active="dataView[activeKey]"
:icon-list="iconList"
></IconBtnGroup>
</template> -->
</a-tabs>
</ComCard>
</ComCard>
Expand All @@ -69,7 +61,7 @@

<script lang="ts" setup>
import { OPERATIONHUB } from '@/router/config';
import { ref, reactive } from 'vue';
import { ref, nextTick, reactive, onBeforeUnmount } from 'vue';
import useTabActive, { TabPage } from '@/hooks/use-tab-active';
import { OperatorHubTabs } from '@/views/config';
import HeaderInfo from '@/components/header-info/index.vue';
Expand All @@ -79,6 +71,11 @@
import Catalogs from '../catalogs/pages/list.vue';
import GlobalVariables from '../variables/pages/list.vue';
import ResourceDefinition from '../resource-definitions/pages/list.vue';
import {
listenFilterCatalogAction,
removeFilterCatalogActionListener,
emitFilterTemplateAction
} from '../hooks/filter-catalog-listener';

const iconList = [
{
Expand All @@ -105,6 +102,15 @@
const handleTabChange = (val) => {
setPageTabActive(val);
};
listenFilterCatalogAction((data) => {
handleTabChange(OperatorHubTabs.TEMPLATES);
setTimeout(() => {
emitFilterTemplateAction(data);
}, 100);
});
onBeforeUnmount(() => {
removeFilterCatalogActionListener();
});
</script>

<script lang="ts">
Expand Down
26 changes: 25 additions & 1 deletion src/views/operation-hub/templates/components/table-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,15 @@
import { Resources, Actions } from '@/permissions/config';
import { useUserStore, useAppStore } from '@/store';
import _, { map, pickBy, remove } from 'lodash';
import { ref, reactive, onMounted, nextTick, computed, PropType } from 'vue';
import {
ref,
reactive,
onMounted,
onBeforeUnmount,
nextTick,
computed,
PropType
} from 'vue';
import useCallCommon from '@/hooks/use-call-common';
import { UseSortDirection } from '@/utils/common';
import FilterBox from '@/components/filter-box/index.vue';
Expand All @@ -196,6 +204,10 @@
TEMPLATE_API,
PROJECT_API_PREFIX
} from '../api';
import {
listenFilterTemplateAction,
removeFilterTemplateActionListener
} from '../../hooks/filter-catalog-listener';

const props = defineProps({
currentView: {
Expand Down Expand Up @@ -512,6 +524,15 @@
// ignore
}
};

listenFilterTemplateAction((data) => {
setTimeout(() => {
queryParams.catalogID = data.id;
handleSearch();
}, 100);
console.log('template list listenFilterCatalogAction', data);
});

onMounted(() => {
fetchData();
getCatalogList();
Expand All @@ -520,6 +541,9 @@
createCatalogChunkRequest();
});
});
onBeforeUnmount(() => {
removeFilterTemplateActionListener();
});
</script>

<style lang="less" scoped>
Expand Down
Loading