Skip to content

Commit

Permalink
Refine ui
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Wang <[email protected]>
  • Loading branch information
ruibaby committed Jan 23, 2024
1 parent 7a55860 commit a42261b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ const {
return data.items;
},
refetchInterval: (data) => {
const deletingPosts = data?.filter(
const deletingPosts = data?.some(
(post) =>
!!post.post.metadata.deletionTimestamp || !post.post.spec.deleted
);
return deletingPosts?.length ? 1000 : false;
return deletingPosts ? 1000 : false;
},
});
Expand Down
31 changes: 15 additions & 16 deletions console/console-src/modules/contents/posts/PostList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,23 @@ const {
keyword,
],
queryFn: async () => {
let categories: string[] | undefined;
let tags: string[] | undefined;
let contributors: string[] | undefined;
const labelSelector: string[] = ["content.halo.run/deleted=false"];
const fieldSelector: string[] = [];
if (selectedCategory.value) {
categories = [selectedCategory.value];
fieldSelector.push(`spec.categories=${selectedCategory.value}`);
}
if (selectedTag.value) {
tags = [selectedTag.value];
fieldSelector.push(`spec.tags=${selectedTag.value}`);
}
if (selectedContributor.value) {
contributors = [selectedContributor.value];
fieldSelector.push(`status.contributors=${selectedContributor.value}`);
}
if (selectedVisible.value) {
fieldSelector.push(`spec.visible=${selectedVisible.value}`);
}
if (selectedPublishStatus.value !== undefined) {
Expand All @@ -138,14 +140,11 @@ const {
const { data } = await apiClient.post.listPosts({
labelSelector,
fieldSelector,
page: page.value,
size: size.value,
visible: selectedVisible.value,
sort: [selectedSort.value].filter(Boolean) as string[],
keyword: keyword.value,
category: categories,
tag: tags,
contributor: contributors,
});
total.value = data.total;
Expand All @@ -155,7 +154,7 @@ const {
return data.items;
},
refetchInterval: (data) => {
const abnormalPosts = data?.filter((post) => {
const abnormalPosts = data?.some((post) => {
const { spec, metadata, status } = post.post;
return (
spec.deleted ||
Expand All @@ -164,7 +163,7 @@ const {
);
});
return abnormalPosts?.length ? 1000 : false;
return abnormalPosts ? 1000 : false;
},
});
Expand Down Expand Up @@ -407,19 +406,19 @@ watch(selectedPostNames, (newValue) => {
},
{
label: t('core.post.filters.sort.items.publish_time_desc'),
value: 'publishTime,desc',
value: 'spec.publishTime,desc',
},
{
label: t('core.post.filters.sort.items.publish_time_asc'),
value: 'publishTime,asc',
value: 'spec.publishTime,asc',
},
{
label: t('core.post.filters.sort.items.create_time_desc'),
value: 'creationTimestamp,desc',
value: 'metadata.creationTimestamp,desc',
},
{
label: t('core.post.filters.sort.items.create_time_asc'),
value: 'creationTimestamp,asc',
value: 'metadata.creationTimestamp,asc',
},
]"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { data } = useQuery<ListedPost[]>({
`${postLabels.DELETED}=false`,
`${postLabels.PUBLISHED}=true`,
],
sort: ["publishTime,desc"],
sort: ["spec.publishTime,desc"],
page: 1,
size: 10,
});
Expand Down

0 comments on commit a42261b

Please sign in to comment.