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 Feb 2, 2024
2 parents cc97fb7 + 5b93667 commit 445ff87
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 49 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://halo.run" target="_blank" rel="noopener noreferrer">
<img width="100" src="https://halo.run/logo" alt="Halo logo" />
<a href="https://www.halo.run" target="_blank" rel="noopener noreferrer">
<img width="100" src="https://www.halo.run/logo" alt="Halo logo" />
</a>
</p>

Expand All @@ -14,7 +14,7 @@
<a href="https://codecov.io/gh/halo-dev/halo"><img alt="Codecov percentage" src="https://img.shields.io/codecov/c/github/halo-dev/halo/main?style=flat-square&token=YsRUg9fall"/></a>
<a href="https://www.producthunt.com/posts/halo-6b401e75-bb58-4dff-9fe9-2ada3323c874?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-halo&#0045;6b401e75&#0045;bb58&#0045;4dff&#0045;9fe9&#0045;2ada3323c874" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=407442&theme=light" alt="Halo - Powerful&#0032;and&#0032;easy&#0045;to&#0045;use&#0032;Open&#0045;Source&#0032;website&#0032;building&#0032;tool | Product Hunt" style="height: 20px;" height="20px" /></a>
<br />
<a href="https://halo.run">官网</a>
<a href="https://www.halo.run">官网</a>
<a href="https://docs.halo.run">文档</a>
<a href="https://bbs.halo.run">社区</a>
<a href="https://gitee.com/halo-dev">Gitee</a>
Expand All @@ -26,7 +26,7 @@
## 快速开始

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

以上仅作为体验使用,详细部署文档请查阅:<https://docs.halo.run/getting-started/install/docker-compose>
Expand All @@ -40,8 +40,7 @@ docker run -it -d --name halo -p 8090:8090 -v ~/.halo2:/root/.halo2 halohub/halo

## 生态

可访问 [官方应用市场](https://halo.run/store/apps)[awesome-halo 仓库](https://github.com/halo-sigs/awesome-halo) 查看已经适用于 Halo 2.x 的主题和插件,以及适用于 Halo
1.x 的相关仓库。
可访问 [官方应用市场](https://www.halo.run/store/apps)[awesome-halo 仓库](https://github.com/halo-sigs/awesome-halo) 查看适用于 Halo 2.x 的主题和插件。

## 许可证

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder;
import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder;

import com.fasterxml.jackson.core.type.TypeReference;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.springdoc.webflux.core.fn.SpringdocRouteBuilder;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
Expand All @@ -25,12 +28,15 @@
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import reactor.util.function.Tuples;
import run.halo.app.core.extension.Role;
import run.halo.app.core.extension.endpoint.CustomEndpoint;
import run.halo.app.core.extension.notification.NotifierDescriptor;
import run.halo.app.core.extension.notification.ReasonType;
import run.halo.app.extension.Comparators;
import run.halo.app.extension.GroupVersion;
import run.halo.app.extension.MetadataUtil;
import run.halo.app.extension.ReactiveExtensionClient;
import run.halo.app.infra.utils.JsonUtils;
import run.halo.app.notification.UserNotificationPreference;
import run.halo.app.notification.UserNotificationPreferenceService;

Expand Down Expand Up @@ -135,10 +141,7 @@ private static <T> Map<String, Integer> toNameIndexMap(List<T> collection,

Mono<ReasonTypeNotifierMatrix> listReasonTypeNotifierMatrix(String username) {
return client.list(ReasonType.class, null, Comparators.defaultComparator())
.map(reasonType -> new ReasonTypeInfo(reasonType.getMetadata().getName(),
reasonType.getSpec().getDisplayName(),
reasonType.getSpec().getDescription())
)
.map(ReasonTypeInfo::from)
.collectList()
.flatMap(reasonTypes -> client.list(NotifierDescriptor.class, null,
Comparators.defaultComparator())
Expand Down Expand Up @@ -188,7 +191,23 @@ static class ReasonTypeNotifierMatrix {
private boolean[][] stateMatrix;
}

record ReasonTypeInfo(String name, String displayName, String description) {
record ReasonTypeInfo(String name, String displayName, String description,
Set<String> uiPermissions) {

public static ReasonTypeInfo from(ReasonType reasonType) {
var uiPermissions = Optional.of(MetadataUtil.nullSafeAnnotations(reasonType))
.map(annotations -> annotations.get(Role.UI_PERMISSIONS_ANNO))
.filter(StringUtils::isNotBlank)
.map(uiPermissionStr -> JsonUtils.jsonToObject(uiPermissionStr,
new TypeReference<Set<String>>() {
})
)
.orElse(Set.of());
return new ReasonTypeInfo(reasonType.getMetadata().getName(),
reasonType.getSpec().getDisplayName(),
reasonType.getSpec().getDescription(),
uiPermissions);
}
}

record NotifierInfo(String name, String displayName, String description) {
Expand Down
6 changes: 6 additions & 0 deletions application/src/main/resources/extensions/notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ apiVersion: notification.halo.run/v1alpha1
kind: ReasonType
metadata:
name: new-comment-on-post
annotations:
rbac.authorization.halo.run/ui-permissions: |
[ "uc:posts:publish" ]
spec:
displayName: "我的文章收到新评论"
description: "如果有读者在你的文章下方留下了新的评论,你将会收到一条通知,告诉你有新的评论。
Expand All @@ -90,6 +93,9 @@ apiVersion: notification.halo.run/v1alpha1
kind: ReasonType
metadata:
name: new-comment-on-single-page
annotations:
rbac.authorization.halo.run/ui-permissions: |
[ "system:singlepages:manage" ]
spec:
displayName: "我的自定义页面收到新评论"
description: "当你创建的自定义页面收到新评论时,你将会收到一条通知,告诉你有新的评论。"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ metadata:
halo.run/hidden: "true"
rules:
- apiGroups: [ "api.security.halo.run" ]
resources: [ "authentications", "authentications/totp" ]
resources: [ "authentications", "authentications/totp", "authentications/settings" ]
verbs: [ "*" ]
---
apiVersion: v1alpha1
Expand Down
2 changes: 1 addition & 1 deletion console/packages/api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@halo-dev/api-client",
"version": "2.12.0",
"version": "2.13.0",
"description": "",
"scripts": {
"build": "unbuild",
Expand Down
6 changes: 6 additions & 0 deletions console/packages/api-client/src/models/post-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export interface PostStatus {
* @memberof PostStatus
*/
lastModifyTime?: string;
/**
*
* @type {number}
* @memberof PostStatus
*/
observedVersion?: number;
/**
*
* @type {string}
Expand Down
6 changes: 6 additions & 0 deletions console/packages/api-client/src/models/reason-type-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ export interface ReasonTypeInfo {
* @memberof ReasonTypeInfo
*/
name?: string;
/**
*
* @type {Array<string>}
* @memberof ReasonTypeInfo
*/
uiPermissions?: Array<string>;
}
6 changes: 6 additions & 0 deletions console/packages/api-client/src/models/single-page-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export interface SinglePageStatus {
* @memberof SinglePageStatus
*/
lastModifyTime?: string;
/**
*
* @type {number}
* @memberof SinglePageStatus
*/
observedVersion?: number;
/**
*
* @type {string}
Expand Down
2 changes: 1 addition & 1 deletion console/packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@halo-dev/components",
"version": "2.12.0",
"version": "2.13.0",
"description": "",
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion console/packages/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@halo-dev/richtext-editor",
"version": "2.12.0",
"version": "2.13.0",
"description": "Default editor for Halo",
"homepage": "https://github.com/halo-dev/halo/tree/main/console/packages/editor#readme",
"bugs": {
Expand Down
3 changes: 3 additions & 0 deletions console/packages/editor/src/dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ const editor = useEditor({
ExtensionListKeymap,
ExtensionSearchAndReplace,
],
parseOptions: {
preserveWhitespace: true,
},
onUpdate: () => {
content.value = editor.value?.getHTML() + "";
},
Expand Down
2 changes: 1 addition & 1 deletion console/packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@halo-dev/console-shared",
"version": "2.12.0",
"version": "2.13.0",
"description": "",
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion console/packages/ui-plugin-bundler-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@halo-dev/ui-plugin-bundler-kit",
"version": "2.12.0",
"version": "2.13.0",
"homepage": "https://github.com/halo-dev/halo/tree/main/console/packages/ui-plugin-bundler-kit#readme",
"bugs": {
"url": "https://github.com/halo-dev/halo/issues"
Expand Down
3 changes: 3 additions & 0 deletions console/src/components/editor/DefaultEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ onMounted(() => {
ExtensionSearchAndReplace,
],
autofocus: "start",
parseOptions: {
preserveWhitespace: true,
},
onUpdate: () => {
debounceOnUpdate();
},
Expand Down
1 change: 1 addition & 0 deletions console/src/constants/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum pluginLabels {
// role
export enum roleLabels {
TEMPLATE = "halo.run/role-template",
HIDDEN = "halo.run/hidden",
SYSTEM_RESERVED = "rbac.authorization.halo.run/system-reserved",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { Dialog, Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import { useMutation, useQueryClient } from "@tanstack/vue-query";
import { useClipboard } from "@vueuse/core";
import type { PatSpec, PersonalAccessToken } from "@halo-dev/api-client";
import { ref } from "vue";
import { computed, ref } from "vue";
import { useRoleTemplateSelection } from "@/composables/use-role";
import { useRoleStore } from "@/stores/role";
import { toRefs } from "vue";
import { useI18n } from "vue-i18n";
import { roleLabels } from "@/constants/labels";
const queryClient = useQueryClient();
const { t } = useI18n();
Expand Down Expand Up @@ -45,8 +45,17 @@ const formState = ref<
const { permissions } = useRoleStore();
const availableRoleTemplates = computed(() => {
return permissions.permissions.filter((role) => {
return (
role.metadata.labels?.[roleLabels.TEMPLATE] === "true" &&
role.metadata.labels?.[roleLabels.HIDDEN] !== "true"
);
});
});
const { roleTemplateGroups, handleRoleTemplateSelect, selectedRoleTemplates } =
useRoleTemplateSelection(toRefs(permissions).permissions);
useRoleTemplateSelection(availableRoleTemplates);
const { copy } = useClipboard({
legacy: true,
Expand Down
61 changes: 33 additions & 28 deletions console/uc-src/modules/profile/tabs/NotificationPreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { computed } from "vue";
import { inject } from "vue";
import { cloneDeep } from "lodash-es";
import type { ReasonTypeNotifierRequest } from "@halo-dev/api-client";
import HasPermission from "@/components/permission/HasPermission.vue";
const queryClient = useQueryClient();
Expand Down Expand Up @@ -114,37 +115,41 @@ const {
</tr>
</thead>
<tbody class="divide-y divide-gray-100 bg-white">
<tr
<template
v-for="(reasonType, index) in data?.reasonTypes"
:key="reasonType.name"
>
<td
class="whitespace-nowrap px-4 py-3 text-sm font-medium text-gray-900"
>
{{ reasonType.displayName }}
</td>
<td
v-for="(notifier, notifierIndex) in data?.notifiers"
:key="notifier.name"
class="whitespace-nowrap px-4 py-3 text-sm text-gray-500"
>
<VSwitch
:model-value="data?.stateMatrix?.[index][notifierIndex]"
:loading="
mutating &&
variables?.reasonTypeIndex === index &&
variables?.notifierIndex === notifierIndex
"
@change="
mutate({
state: !data?.stateMatrix?.[index][notifierIndex],
reasonTypeIndex: index,
notifierIndex: notifierIndex,
})
"
/>
</td>
</tr>
<HasPermission :permissions="reasonType.uiPermissions || []">
<tr>
<td
class="whitespace-nowrap px-4 py-3 text-sm font-medium text-gray-900"
>
{{ reasonType.displayName }}
</td>
<td
v-for="(notifier, notifierIndex) in data?.notifiers"
:key="notifier.name"
class="whitespace-nowrap px-4 py-3 text-sm text-gray-500"
>
<VSwitch
:model-value="data?.stateMatrix?.[index][notifierIndex]"
:loading="
mutating &&
variables?.reasonTypeIndex === index &&
variables?.notifierIndex === notifierIndex
"
@change="
mutate({
state: !data?.stateMatrix?.[index][notifierIndex],
reasonTypeIndex: index,
notifierIndex: notifierIndex,
})
"
/>
</td>
</tr>
</HasPermission>
</template>
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.12.0-SNAPSHOT
version=2.13.0-SNAPSHOT

0 comments on commit 445ff87

Please sign in to comment.