Skip to content

Commit

Permalink
Remove status text
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Wang <i@ryanc.cc>
  • Loading branch information
ruibaby committed Apr 23, 2024
1 parent 9158edf commit 6047b76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Expand Up @@ -10,7 +10,7 @@ import {
import type { Ref } from "vue";
import { computed, inject, markRaw, ref, toRefs } from "vue";
import { usePluginLifeCycle } from "../composables/use-plugin";
import { PluginStatusPhaseEnum, type Plugin } from "@halo-dev/api-client";
import { type Plugin, PluginStatusPhaseEnum } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission";
import { apiClient } from "@/utils/api-client";
Expand Down Expand Up @@ -43,7 +43,7 @@ const { plugin } = toRefs(props);
const selectedNames = inject<Ref<string[]>>("selectedNames", ref([]));
const { getFailedMessage, uninstall } = usePluginLifeCycle(plugin);
const { getStatusMessage, uninstall } = usePluginLifeCycle(plugin);
const pluginUpgradeModalVisible = ref(false);
Expand Down Expand Up @@ -153,12 +153,6 @@ const { startFields, endFields } = useEntityFieldItemExtensionPoint<Plugin>(
const shouldHideStatusDot =
!enabled || (enabled && phase === PluginStatusPhaseEnum.Started);
const statusDotText =
enabled &&
phase !== (PluginStatusPhaseEnum.Started || PluginStatusPhaseEnum.Failed)
? t("core.common.status.starting_up")
: undefined;
const getStatusDotState = () => {
if (
enabled &&
Expand Down Expand Up @@ -197,10 +191,9 @@ const { startFields, endFields } = useEntityFieldItemExtensionPoint<Plugin>(
priority: 10,
component: markRaw(StatusDotField),
props: {
tooltip: getFailedMessage(),
tooltip: getStatusMessage(),
state: getStatusDotState(),
animate: true,
text: statusDotText,
},
hidden: shouldHideStatusDot,
},
Expand Down
20 changes: 16 additions & 4 deletions ui/console-src/modules/system/plugins/composables/use-plugin.ts
@@ -1,6 +1,6 @@
import type { ComputedRef, Ref } from "vue";
import { computed } from "vue";
import { PluginStatusPhaseEnum, type Plugin } from "@halo-dev/api-client";
import { type Plugin, PluginStatusPhaseEnum } from "@halo-dev/api-client";
import { cloneDeep } from "lodash-es";
import { apiClient } from "@/utils/api-client";
import { Dialog, Toast } from "@halo-dev/components";
Expand All @@ -9,7 +9,7 @@ import { useMutation } from "@tanstack/vue-query";

interface usePluginLifeCycleReturn {
isStarted: ComputedRef<boolean | undefined>;
getFailedMessage: () => string | undefined;
getStatusMessage: () => string | undefined;
changeStatus: () => void;
changingStatus: Ref<boolean>;
uninstall: (deleteExtensions?: boolean) => void;
Expand All @@ -27,9 +27,21 @@ export function usePluginLifeCycle(
);
});

const getFailedMessage = () => {
const getStatusMessage = () => {
if (!plugin?.value) return;

const { enabled } = plugin.value.spec || {};
const { phase } = plugin.value.status || {};

// Starting up
if (
enabled &&
phase !== (PluginStatusPhaseEnum.Started || PluginStatusPhaseEnum.Failed)
) {
return t("core.common.status.starting_up");
}

// Starting failed
if (!isStarted.value) {
const lastCondition = plugin.value.status?.conditions?.[0];

Expand Down Expand Up @@ -141,7 +153,7 @@ export function usePluginLifeCycle(

return {
isStarted,
getFailedMessage,
getStatusMessage,
changeStatus,
changingStatus,
uninstall,
Expand Down

0 comments on commit 6047b76

Please sign in to comment.