Skip to content

Commit

Permalink
feat: add query attachments by ungrouped parameter support (halo-dev/…
Browse files Browse the repository at this point in the history
…console#706)

#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

附件管理支持通过参数筛选出未分组的附件。适配 halo-dev#2752

#### Which issue(s) this PR fixes:

Fixes halo-dev#2451

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:

1. Halo 需要切换到 halo-dev#2752 分支。
2. Console 需要 `pnpm install`
3. 上传若干未分组附件,然后切换到未分组的标签,检查是否查询正确。
4. 将部分附件移动至某个分组,在切换到未分组的标签,检查附件是否正确。

#### Does this PR introduce a user-facing change?


```release-note
附件管理支持未分组的筛选条件。
```
  • Loading branch information
ruibaby authored Nov 24, 2022
1 parent 831a071 commit 65919c3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@formkit/themes": "^1.0.0-beta.11",
"@formkit/vue": "^1.0.0-beta.11",
"@formkit/utils": "^1.0.0-beta.11",
"@halo-dev/api-client": "^0.0.50",
"@halo-dev/api-client": "^0.0.51",
"@halo-dev/components": "workspace:*",
"@halo-dev/console-shared": "workspace:*",
"@halo-dev/richtext-editor": "^0.0.0-alpha.11",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/modules/contents/attachments/AttachmentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,16 @@ const onDetailModalClose = () => {
selectedAttachment.value = undefined;
nameQuery.value = undefined;
nameQueryAttachment.value = undefined;
handleFetchAttachments();
setTimeout(() => {
handleFetchAttachments();
}, 200);
};
const onUploadModalClose = () => {
routeQueryAction.value = undefined;
handleFetchAttachments();
setTimeout(() => {
handleFetchAttachments();
}, 200);
};
const onGroupChange = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const defaultGroups: Group[] = [
apiVersion: "",
kind: "",
metadata: {
name: "none",
name: "ungrouped",
},
},
];
Expand All @@ -68,7 +68,7 @@ const groupToUpdate = ref<Group | null>(null);
const loading = ref<boolean>(false);
const editingModal = ref(false);
const routeQuery = useRouteQuery("group");
const routeQuery = useRouteQuery<string>("group");
const handleSelectGroup = (group: Group) => {
emit("update:selectedGroup", group);
Expand Down Expand Up @@ -166,7 +166,8 @@ const handleDeleteWithAttachments = (group: Group) => {
watch(
() => groups.value.length,
() => {
const groupIndex = groups.value.findIndex(
const allGroups = [...defaultGroups, ...groups.value];
const groupIndex = allGroups.findIndex(
(group) => group.metadata.name === routeQuery.value
);
Expand All @@ -186,8 +187,8 @@ onMounted(async () => {
);
if (group) {
handleSelectGroup(group);
return;
}
return;
}
handleSelectGroup(defaultGroups[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function useAttachmentControl(filterOptions?: {
policy: policy?.value?.metadata.name,
displayName: keyword?.value,
group: group?.value?.metadata.name,
ungrouped: group?.value?.metadata.name === "ungrouped",
uploadedBy: user?.value?.metadata.name,
page: attachments.value.page,
size: attachments.value.size,
Expand Down

0 comments on commit 65919c3

Please sign in to comment.