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 Mar 27, 2024
2 parents 4902481 + 867d86b commit 5ce8461
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 155 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
## 快速开始

```bash
docker run -it -d --name halo -p 8090:8090 -v ~/.halo2:/root/.halo2 halohub/halo:2.13
docker run -d --name halo -p 8090:8090 -v ~/.halo2:/root/.halo2 halohub/halo:2.13
```

以上仅作为体验使用,详细部署文档请查阅:<https://docs.halo.run/getting-started/install/docker-compose>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package run.halo.app.content;

import java.security.Principal;
import java.time.Duration;
import java.time.Instant;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.lang.Nullable;
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.util.Assert;
import reactor.core.publisher.Mono;
import reactor.util.retry.Retry;
import run.halo.app.core.extension.content.Snapshot;
import run.halo.app.extension.MetadataUtil;
import run.halo.app.extension.ReactiveExtensionClient;
Expand Down Expand Up @@ -94,20 +97,23 @@ protected Mono<ContentWrapper> updateContent(String baseSnapshotName,
Assert.notNull(contentRequest, "The contentRequest must not be null");
Assert.notNull(baseSnapshotName, "The baseSnapshotName must not be null");
Assert.notNull(contentRequest.headSnapshotName(), "The headSnapshotName must not be null");
return client.fetch(Snapshot.class, contentRequest.headSnapshotName())
.flatMap(headSnapshot -> client.fetch(Snapshot.class, baseSnapshotName)
.map(baseSnapshot -> determineRawAndContentPatch(headSnapshot, baseSnapshot,
contentRequest)
return Mono.defer(() -> client.fetch(Snapshot.class, contentRequest.headSnapshotName())
.flatMap(headSnapshot -> client.fetch(Snapshot.class, baseSnapshotName)
.map(baseSnapshot -> determineRawAndContentPatch(headSnapshot, baseSnapshot,
contentRequest)
)
)
.flatMap(headSnapshot -> getContextUsername()
.map(username -> {
Snapshot.addContributor(headSnapshot, username);
return headSnapshot;
})
.defaultIfEmpty(headSnapshot)
)
.flatMap(client::update)
)
.flatMap(headSnapshot -> getContextUsername()
.map(username -> {
Snapshot.addContributor(headSnapshot, username);
return headSnapshot;
})
.defaultIfEmpty(headSnapshot)
)
.flatMap(client::update)
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException))
.flatMap(head -> restoredContent(baseSnapshotName, head));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,11 @@ public Mono<Post> updatePost(PostRequest postRequest) {
return client.update(post);
});
}
return Mono.defer(() -> updateContent(baseSnapshot, postRequest.contentRequest())
.flatMap(contentWrapper -> {
post.getSpec().setHeadSnapshot(contentWrapper.getSnapshotName());
return client.update(post);
}))
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException));
return updateContent(baseSnapshot, postRequest.contentRequest())
.flatMap(contentWrapper -> {
post.getSpec().setHeadSnapshot(contentWrapper.getSnapshotName());
return client.update(post);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ public Mono<SinglePage> update(SinglePageRequest pageRequest) {
return client.update(page);
});
}
return Mono.defer(() -> updateContent(baseSnapshot, pageRequest.contentRequest())
.flatMap(contentWrapper -> {
page.getSpec().setHeadSnapshot(contentWrapper.getSnapshotName());
return client.update(page);
}))
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException));
return updateContent(baseSnapshot, pageRequest.contentRequest())
.flatMap(contentWrapper -> {
page.getSpec().setHeadSnapshot(contentWrapper.getSnapshotName());
return client.update(page);
});
}

private Mono<ListedSinglePage> getListedSinglePage(SinglePage singlePage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ Mono<ServerResponse> draftPost(ServerRequest request) {
Mono<ServerResponse> updateContent(ServerRequest request) {
String postName = request.pathVariable("name");
return request.bodyToMono(Content.class)
.flatMap(content -> client.fetch(Post.class, postName)
.flatMap(post -> {
PostRequest postRequest = new PostRequest(post, content);
return postService.updatePost(postRequest);
})
.flatMap(content -> Mono.defer(() -> client.fetch(Post.class, postName)
.flatMap(post -> {
PostRequest postRequest = new PostRequest(post, content);
return postService.updatePost(postRequest);
}))
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException))
)
.flatMap(post -> ServerResponse.ok().bodyValue(post));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ Mono<ServerResponse> draftSinglePage(ServerRequest request) {
Mono<ServerResponse> updateContent(ServerRequest request) {
String pageName = request.pathVariable("name");
return request.bodyToMono(Content.class)
.flatMap(content -> client.fetch(SinglePage.class, pageName)
.flatMap(page -> {
SinglePageRequest pageRequest = new SinglePageRequest(page, content);
return singlePageService.update(pageRequest);
})
.flatMap(content -> Mono.defer(() -> client.fetch(SinglePage.class, pageName)
.flatMap(page -> {
SinglePageRequest pageRequest = new SinglePageRequest(page, content);
return singlePageService.update(pageRequest);
}))
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(throwable -> throwable instanceof OptimisticLockingFailureException))
)
.flatMap(post -> ServerResponse.ok().bodyValue(post));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ private Mono<ServerResponse> updateMyPost(ServerRequest request) {
var spec = post.getSpec();
spec.setOwner(oldSpec.getOwner());
spec.setPublish(oldSpec.getPublish());
spec.setPublishTime(oldSpec.getPublishTime());
spec.setHeadSnapshot(oldSpec.getHeadSnapshot());
spec.setBaseSnapshot(oldSpec.getBaseSnapshot());
spec.setReleaseSnapshot(oldSpec.getReleaseSnapshot());
Expand Down
19 changes: 10 additions & 9 deletions ui/console-src/modules/contents/pages/SinglePageEditor.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<script lang="ts" setup>
import {
VPageHeader,
Dialog,
IconEye,
IconPages,
IconSettings,
IconSendPlaneFill,
VSpace,
VButton,
IconSave,
IconSendPlaneFill,
IconSettings,
Toast,
Dialog,
IconEye,
VButton,
VPageHeader,
VSpace,
} from "@halo-dev/components";
import SinglePageSettingModal from "./components/SinglePageSettingModal.vue";
import type { SinglePage, SinglePageRequest } from "@halo-dev/api-client";
import {
computed,
type ComputedRef,
nextTick,
onMounted,
provide,
ref,
toRef,
type ComputedRef,
watch,
} from "vue";
import { apiClient } from "@/utils/api-client";
Expand Down Expand Up @@ -271,7 +271,8 @@ const handleFetchContent = async () => {
const provider =
preferredEditor ||
editorProviders.value.find(
(provider) => provider.rawType === data.rawType
(provider) =>
provider.rawType.toLowerCase() === data.rawType?.toLowerCase()
);
if (provider) {
currentEditorProvider.value = provider;
Expand Down
13 changes: 7 additions & 6 deletions ui/console-src/modules/contents/posts/PostEditor.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<script lang="ts" setup>
import {
Dialog,
IconBookRead,
IconEye,
IconSave,
IconSettings,
IconSendPlaneFill,
IconSettings,
Toast,
VButton,
VPageHeader,
VSpace,
Toast,
Dialog,
IconEye,
} from "@halo-dev/components";
import PostSettingModal from "./components/PostSettingModal.vue";
import type { Post, PostRequest } from "@halo-dev/api-client";
import {
computed,
type ComputedRef,
nextTick,
onMounted,
provide,
ref,
toRef,
type ComputedRef,
watch,
} from "vue";
import { apiClient } from "@/utils/api-client";
Expand Down Expand Up @@ -291,7 +291,8 @@ const handleFetchContent = async () => {
const provider =
preferredEditor ||
editorProviders.value.find(
(provider) => provider.rawType === data.rawType
(provider) =>
provider.rawType.toLowerCase() === data.rawType?.toLowerCase()
);
if (provider) {
Expand Down
37 changes: 15 additions & 22 deletions ui/console-src/modules/system/plugins/PluginList.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
<script lang="ts" setup>
import {
Dialog,
IconAddCircle,
IconPlug,
IconRefreshLine,
VButton,
VCard,
VDropdown,
VDropdownItem,
VEmpty,
VLoading,
VPageHeader,
VSpace,
VLoading,
Dialog,
VDropdown,
VDropdownItem,
} from "@halo-dev/components";
import PluginListItem from "./components/PluginListItem.vue";
import PluginInstallationModal from "./components/PluginInstallationModal.vue";
import { computed, ref, onMounted } from "vue";
import type { Ref } from "vue";
import { computed, onMounted, provide, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client";
import { usePermission } from "@/utils/permission";
import { useQuery } from "@tanstack/vue-query";
import type { Plugin } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n";
import { useRouteQuery } from "@vueuse/router";
import { watch } from "vue";
import { provide } from "vue";
import type { Ref } from "vue";
import { usePluginBatchOperations } from "./composables/use-plugin";
const { t } = useI18n();
const { currentUserHasPermission } = usePermission();
const pluginInstallationModal = ref(false);
const pluginToUpgrade = ref<Plugin>();
function handleOpenUploadModal(plugin?: Plugin) {
pluginToUpgrade.value = plugin;
pluginInstallationModal.value = true;
}
const pluginInstallationModalVisible = ref(false);
const keyword = ref("");
Expand Down Expand Up @@ -120,7 +112,7 @@ onMounted(() => {
confirmText: t("core.common.buttons.download"),
cancelText: t("core.common.buttons.cancel"),
onConfirm() {
handleOpenUploadModal();
pluginInstallationModalVisible.value = true;
},
onCancel() {
routeRemoteDownloadUrl.value = null;
Expand All @@ -131,9 +123,11 @@ onMounted(() => {
</script>
<template>
<PluginInstallationModal
v-if="currentUserHasPermission(['system:plugins:manage'])"
v-model:visible="pluginInstallationModal"
:plugin-to-upgrade="pluginToUpgrade"
v-if="
pluginInstallationModalVisible &&
currentUserHasPermission(['system:plugins:manage'])
"
@close="pluginInstallationModalVisible = false"
/>

<VPageHeader :title="$t('core.plugin.title')">
Expand All @@ -144,7 +138,7 @@ onMounted(() => {
<VButton
v-permission="['system:plugins:manage']"
type="secondary"
@click="handleOpenUploadModal()"
@click="pluginInstallationModalVisible = true"
>
<template #icon>
<IconAddCircle class="h-full w-full" />
Expand Down Expand Up @@ -276,7 +270,7 @@ onMounted(() => {
<VButton
v-permission="['system:plugins:manage']"
type="secondary"
@click="handleOpenUploadModal"
@click="pluginInstallationModalVisible = true"
>
<template #icon>
<IconAddCircle class="h-full w-full" />
Expand All @@ -297,7 +291,6 @@ onMounted(() => {
<PluginListItem
:plugin="plugin"
:is-selected="selectedNames.includes(plugin.metadata.name)"
@open-upgrade-modal="handleOpenUploadModal"
/>
</li>
</ul>
Expand Down
Loading

0 comments on commit 5ce8461

Please sign in to comment.