feat(admin-web/articles): show partial-success publish status from records
ArticlePublishStatus now derives partial_success when both succeeded and failed records are present, fetches publish_records eagerly with a 30s stale window so the popover lights up without a click, and ArticleDetail Drawer reuses the component instead of its own tag. Relabel partial_ success copy to 部分发布 / Partially Published to match the new bucket. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,8 @@ const props = withDefaults(defineProps<{
|
||||
|
||||
const { t } = useI18n();
|
||||
const popoverOpen = ref(false);
|
||||
const shouldLoadPlatforms = computed(() => props.showPlatforms && Boolean(props.articleId) && props.status !== "unpublished");
|
||||
const shouldLoadRecords = computed(() => Boolean(props.articleId) && props.status !== "unpublished");
|
||||
const shouldLoadPlatforms = computed(() => props.showPlatforms && shouldLoadRecords.value);
|
||||
|
||||
const platformsQuery = useQuery({
|
||||
queryKey: ["media", "platforms", "publish-status"],
|
||||
@@ -50,12 +51,13 @@ const platformsQuery = useQuery({
|
||||
});
|
||||
|
||||
const publishRecordsQuery = useQuery({
|
||||
queryKey: computed(() => ["articles", "publish-records", props.articleId, "publish-status"]),
|
||||
enabled: computed(() => popoverOpen.value && shouldLoadPlatforms.value),
|
||||
queryKey: computed(() => ["articles", "publish-records", props.articleId]),
|
||||
enabled: shouldLoadRecords,
|
||||
queryFn: () => articlesApi.publishRecords(props.articleId as number),
|
||||
staleTime: 30 * 1000,
|
||||
});
|
||||
|
||||
const hasPopover = computed(() => shouldLoadPlatforms.value);
|
||||
const hasPopover = computed(() => props.showPlatforms && shouldLoadRecords.value);
|
||||
|
||||
const platformMap = computed(() => {
|
||||
return new Map(
|
||||
@@ -108,6 +110,10 @@ const pendingEntries = computed(() =>
|
||||
);
|
||||
|
||||
const displayStatus = computed(() => {
|
||||
if (successEntries.value.length > 0 && failedEntries.value.length > 0) {
|
||||
return "partial_success";
|
||||
}
|
||||
|
||||
if (failedEntries.value.length > 0) {
|
||||
return "failed";
|
||||
}
|
||||
@@ -121,7 +127,7 @@ const displayStatus = computed(() => {
|
||||
}
|
||||
|
||||
if (props.status === "partial_success") {
|
||||
return "failed";
|
||||
return "partial_success";
|
||||
}
|
||||
|
||||
if (props.status === "publish_success" || props.status === "published") {
|
||||
@@ -149,6 +155,8 @@ const statusTone = computed(() => {
|
||||
return "failed";
|
||||
case "publishing":
|
||||
return "processing";
|
||||
case "partial_success":
|
||||
return "warning";
|
||||
default:
|
||||
return "default";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user