Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Apr 29, 2024
2 parents 911e18e + 966558d commit 857734d
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 30 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/halo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
types:
- published

concurrency:
group: ${{github.workflow}} - ${{github.ref}}
cancel-in-progress: true

jobs:
test:
if: github.event_name == 'pull_request' || github.event_name == 'push'
Expand All @@ -30,6 +34,7 @@ jobs:
- name: Check Halo
run: ./gradlew check
- name: Upload coverage reports to Codecov
if: github.repository == 'halo-dev/halo'
uses: codecov/codecov-action@v4

build:
Expand All @@ -51,6 +56,7 @@ jobs:
- name: Build Halo
run: ./gradlew clean && ./gradlew downloadPluginPresets && ./gradlew build -x check
- name: Upload Artifacts
if: github.repository == 'halo-dev/halo'
uses: actions/upload-artifact@v4
with:
name: halo-artifacts
Expand All @@ -69,6 +75,7 @@ jobs:
name: halo-artifacts
path: application/build/libs
- name: Upload Artifacts
if: github.repository == 'halo-dev/halo'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} application/build/libs/*
Expand Down
56 changes: 52 additions & 4 deletions ui/console-src/modules/contents/pages/SinglePageSnapshots.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<script setup lang="ts">
import {
Dialog,
IconHistoryLine,
Toast,
VButton,
VCard,
VLoading,
VPageHeader,
VSpace,
} from "@halo-dev/components";
import { useQuery } from "@tanstack/vue-query";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRoute } from "vue-router";
import { apiClient } from "@/utils/api-client";
import { computed, watch } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { useRouteQuery } from "@vueuse/router";
import SnapshotContent from "./components/SnapshotContent.vue";
import SnapshotListItem from "./components/SnapshotListItem.vue";
import { useI18n } from "vue-i18n";
const queryClient = useQueryClient();
const route = useRoute();
const { t } = useI18n();
const singlePageName = computed(() => route.query.name as string);
Expand Down Expand Up @@ -70,6 +76,43 @@ watch(
immediate: true,
}
);
function handleCleanup() {
Dialog.warning({
title: t("core.page_snapshots.operations.cleanup.title"),
description: t("core.page_snapshots.operations.cleanup.description"),
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
async onConfirm() {
const { releaseSnapshot, baseSnapshot, headSnapshot } =
singlePage.value?.spec || {};
const snapshotsToDelete = snapshots.value?.filter((snapshot) => {
const { name } = snapshot.metadata;
return ![releaseSnapshot, baseSnapshot, headSnapshot]
.filter(Boolean)
.includes(name);
});
if (!snapshotsToDelete?.length) {
Toast.info(t("core.page_snapshots.operations.cleanup.toast_empty"));
return;
}
for (let i = 0; i < snapshotsToDelete?.length; i++) {
await apiClient.singlePage.deleteSinglePageContent({
name: singlePageName.value,
snapshotName: snapshotsToDelete[i].metadata.name,
});
}
await queryClient.invalidateQueries({
queryKey: ["singlePage-snapshots-by-singlePage-name", singlePageName],
});
Toast.success(t("core.page_snapshots.operations.cleanup.toast_success"));
},
});
}
</script>

<template>
Expand All @@ -78,9 +121,14 @@ watch(
<IconHistoryLine class="mr-2 self-center" />
</template>
<template #actions>
<VButton size="sm" @click="$router.back()">
{{ $t("core.common.buttons.back") }}
</VButton>
<VSpace>
<VButton size="sm" @click="$router.back()">
{{ $t("core.common.buttons.back") }}
</VButton>
<VButton size="sm" type="danger" @click="handleCleanup">
{{ $t("core.page_snapshots.operations.cleanup.button") }}
</VButton>
</VSpace>
</template>
</VPageHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ const isBase = computed(() => {
<VTag v-if="isHead">
{{ $t("core.page_snapshots.status.draft") }}
</VTag>
<VTag v-if="isBase">
{{ $t("core.page_snapshots.status.base") }}
</VTag>
<VStatusDot
v-if="snapshot.metadata.deletionTimestamp"
v-tooltip="$t('core.common.status.deleting')"
Expand Down
56 changes: 52 additions & 4 deletions ui/console-src/modules/contents/posts/PostSnapshots.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<script setup lang="ts">
import {
Dialog,
IconHistoryLine,
Toast,
VButton,
VCard,
VLoading,
VPageHeader,
VSpace,
} from "@halo-dev/components";
import { useQuery } from "@tanstack/vue-query";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRoute } from "vue-router";
import { apiClient } from "@/utils/api-client";
import { computed, watch } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { useRouteQuery } from "@vueuse/router";
import SnapshotContent from "@console/modules/contents/posts/components/SnapshotContent.vue";
import SnapshotListItem from "@console/modules/contents/posts/components/SnapshotListItem.vue";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const route = useRoute();
const queryClient = useQueryClient();
const postName = computed(() => route.query.name as string);
Expand Down Expand Up @@ -70,6 +76,43 @@ watch(
immediate: true,
}
);
function handleCleanup() {
Dialog.warning({
title: t("core.post_snapshots.operations.cleanup.title"),
description: t("core.post_snapshots.operations.cleanup.description"),
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
async onConfirm() {
const { releaseSnapshot, baseSnapshot, headSnapshot } =
post.value?.spec || {};
const snapshotsToDelete = snapshots.value?.filter((snapshot) => {
const { name } = snapshot.metadata;
return ![releaseSnapshot, baseSnapshot, headSnapshot]
.filter(Boolean)
.includes(name);
});
if (!snapshotsToDelete?.length) {
Toast.info(t("core.post_snapshots.operations.cleanup.toast_empty"));
return;
}
for (let i = 0; i < snapshotsToDelete?.length; i++) {
await apiClient.post.deletePostContent({
name: postName.value,
snapshotName: snapshotsToDelete[i].metadata.name,
});
}
await queryClient.invalidateQueries({
queryKey: ["post-snapshots-by-post-name", postName],
});
Toast.success(t("core.post_snapshots.operations.cleanup.toast_success"));
},
});
}
</script>

<template>
Expand All @@ -78,9 +121,14 @@ watch(
<IconHistoryLine class="mr-2 self-center" />
</template>
<template #actions>
<VButton size="sm" @click="$router.back()">
{{ $t("core.common.buttons.back") }}
</VButton>
<VSpace>
<VButton size="sm" @click="$router.back()">
{{ $t("core.common.buttons.back") }}
</VButton>
<VButton size="sm" type="danger" @click="handleCleanup">
{{ $t("core.post_snapshots.operations.cleanup.button") }}
</VButton>
</VSpace>
</template>
</VPageHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ const isBase = computed(() => {
<VTag v-if="isHead">
{{ $t("core.post_snapshots.status.draft") }}
</VTag>
<VTag v-if="isBase">
{{ $t("core.post_snapshots.status.base") }}
</VTag>
<VStatusDot
v-if="snapshot.metadata.deletionTimestamp"
v-tooltip="$t('core.common.status.deleting')"
Expand Down
6 changes: 3 additions & 3 deletions ui/packages/editor/src/components/EditorBubbleMenu.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import type { Editor, AnyExtension } from "@/tiptap/vue-3";
import type { AnyExtension, Editor } from "@/tiptap/vue-3";
import BubbleMenu from "@/components/bubble/BubbleMenu.vue";
import type { NodeBubbleMenu } from "@/types";
import BubbleItem from "@/components/bubble/BubbleItem.vue";
import type { EditorView, EditorState } from "@/tiptap/pm";
import type { EditorState, EditorView } from "@/tiptap/pm";
const props = defineProps({
editor: {
Expand Down Expand Up @@ -71,7 +71,7 @@ const shouldShow = (
:default-animation="bubbleMenu.defaultAnimation"
>
<div
class="bubble-menu bg-white flex items-center rounded-md p-1 border drop-shadow space-x-0.5"
class="bubble-menu bg-white flex items-center rounded-md p-1 border drop-shadow space-x-1"
>
<template v-if="bubbleMenu.items">
<template
Expand Down
10 changes: 5 additions & 5 deletions ui/packages/editor/src/components/EditorHeader.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { Menu as VMenu, Dropdown as VDropdown } from "floating-vue";
import { Editor, type AnyExtension } from "@/tiptap/vue-3";
import { Dropdown as VDropdown, Menu as VMenu } from "floating-vue";
import { type AnyExtension, Editor } from "@/tiptap/vue-3";
import MdiPlusCircle from "~icons/mdi/plus-circle";
import type { ToolbarItem, ToolboxItem } from "@/types";
Expand Down Expand Up @@ -59,11 +59,11 @@ function getToolboxItemsFromExtensions() {
</script>
<template>
<div
class="editor-header flex items-center py-1 space-x-0.5 justify-start px-1 overflow-auto sm:!justify-center border-b drop-shadow-sm bg-white"
class="editor-header flex items-center py-1 space-x-1 justify-start px-1 overflow-auto sm:!justify-center border-b drop-shadow-sm bg-white"
>
<div class="inline-flex items-center justify-center">
<VMenu>
<button class="p-1 rounded-sm hover:bg-gray-100" tabindex="-1">
<button class="p-1.5 rounded-md hover:bg-gray-100" tabindex="-1">
<MdiPlusCircle class="text-[#4CCBA0]" />
</button>
<template #popper>
Expand Down Expand Up @@ -108,7 +108,7 @@ function getToolboxItemsFromExtensions() {
/>
<template #popper>
<div
class="relative rounded-md bg-white overflow-hidden drop-shadow w-48 p-1 max-h-72 overflow-y-auto"
class="relative rounded-md bg-white overflow-hidden drop-shadow w-56 p-1 max-h-96 overflow-y-auto space-y-1.5"
>
<component
v-bind="child.props"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function onColorChange(color: Payload) {
</script>

<template>
<VDropdown class="inline-flex">
<VDropdown class="inline-flex items-center">
<slot />
<template #popper>
<slot name="prefix" />
Expand Down
10 changes: 5 additions & 5 deletions ui/packages/editor/src/components/toolbar/ToolbarItem.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { Component } from "vue";
import { VTooltip } from "floating-vue";
import IconArrowDown from "~icons/ri/arrow-down-s-fill";
import MdiMenuDown from "~icons/mdi/menu-down";
import type { ToolbarItem } from "@/types";
withDefaults(
Expand All @@ -11,7 +11,7 @@ withDefaults(
title?: string;
action?: () => void;
icon?: Component;
children: ToolbarItem[];
children?: ToolbarItem[];
}>(),
{
isActive: false,
Expand All @@ -28,16 +28,16 @@ withDefaults(
<button
v-tooltip="title"
:class="[
{ 'bg-gray-200': isActive },
{ 'bg-gray-200/70': isActive },
{ 'cursor-not-allowed opacity-70': disabled },
{ 'hover:bg-gray-100': !disabled },
]"
class="inline-flex items-center space-x-1 p-1 rounded-sm"
class="inline-flex items-center space-x-1 p-1.5 rounded-md"
:disabled="disabled"
tabindex="-1"
@click="action"
>
<component :is="icon" />
<IconArrowDown v-if="children?.length" />
<MdiMenuDown v-if="children?.length" />
</button>
</template>
6 changes: 3 additions & 3 deletions ui/packages/editor/src/components/toolbar/ToolbarSubItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ const action = () => {
{ 'cursor-not-allowed opacity-70 ': disabled },
{ 'hover:bg-gray-100': !disabled },
]"
class="flex flex-row items-center rounded gap-4 p-1 group cursor-pointer"
class="flex flex-row items-center rounded gap-3 py-1 px-1.5 group cursor-pointer"
@click="action"
>
<component
:is="icon"
class="bg-gray-100 p-1 rounded w-6 h-6"
class="bg-gray-100 p-1.5 rounded w-7 h-7"
:class="[
{ '!bg-white': isActive },
{ 'group-hover:bg-white': !disabled },
]"
/>
<span
class="text-xs text-gray-600"
class="text-sm text-gray-600"
:class="[
{ '!text-gray-900 !font-medium': isActive },
{ 'group-hover:font-medium group-hover:text-gray-900': !disabled },
Expand Down
6 changes: 3 additions & 3 deletions ui/packages/editor/src/extensions/clear-format/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Editor } from "@/tiptap";
import { Extension } from "@/tiptap";
import type { ExtensionOptions } from "@/types";
import type { Editor } from "@/tiptap";
import { markRaw } from "vue";
import IconParkSolidClearFormat from "~icons/icon-park-solid/clear-format";
import MdiEraser from "~icons/mdi/eraser";
import ToolbarItem from "@/components/toolbar/ToolbarItem.vue";
import { i18n } from "@/locales";

Expand All @@ -16,7 +16,7 @@ const clearFormat = Extension.create<ExtensionOptions>({
props: {
editor,
isActive: false,
icon: markRaw(IconParkSolidClearFormat),
icon: markRaw(MdiEraser),
title: i18n.global.t("editor.common.clear_format"),
action: () => editor.chain().focus().unsetAllMarks().run(),
},
Expand Down
4 changes: 2 additions & 2 deletions ui/packages/editor/src/extensions/format-brush/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ToolbarItem from "@/components/toolbar/ToolbarItem.vue";
import { i18n } from "@/locales";
import { CoreEditor, Extension, Plugin, PluginKey } from "@/tiptap";
import { markRaw } from "vue";
import BxsBrushAlt from "~icons/bxs/brush-alt";
import MdiBrushVariant from "~icons/mdi/brush-variant";
import { getMarksByFirstTextNode, setMarks } from "./util";

declare module "@/tiptap" {
Expand Down Expand Up @@ -32,7 +32,7 @@ const formatBrush = Extension.create<any, FormatBrushStore>({
props: {
editor,
isActive: formatBrush,
icon: markRaw(BxsBrushAlt),
icon: markRaw(MdiBrushVariant),
title: formatBrush
? i18n.global.t(
"editor.extensions.format_brush.toolbar_item.cancel"
Expand Down
Loading

0 comments on commit 857734d

Please sign in to comment.