2022-08-12 08:20:21 +00:00
|
|
|
<script lang="ts" setup>
|
2024-06-26 10:42:50 +00:00
|
|
|
import type { Menu, MenuItem } from "@halo-dev/api-client";
|
|
|
|
import { coreApiClient } from "@halo-dev/api-client";
|
2022-08-12 08:20:21 +00:00
|
|
|
import {
|
2024-05-21 07:10:44 +00:00
|
|
|
Dialog,
|
2022-08-22 08:49:07 +00:00
|
|
|
IconAddCircle,
|
2022-08-12 08:20:21 +00:00
|
|
|
IconListSettings,
|
2024-05-21 07:10:44 +00:00
|
|
|
Toast,
|
2022-08-12 08:20:21 +00:00
|
|
|
VButton,
|
|
|
|
VCard,
|
2022-08-22 08:49:07 +00:00
|
|
|
VEmpty,
|
2024-05-21 07:10:44 +00:00
|
|
|
VLoading,
|
2022-08-12 08:20:21 +00:00
|
|
|
VPageHeader,
|
|
|
|
VSpace,
|
|
|
|
} from "@halo-dev/components";
|
2024-06-26 10:42:50 +00:00
|
|
|
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
|
|
|
import { useDebounceFn } from "@vueuse/core";
|
|
|
|
import { computed, ref } from "vue";
|
|
|
|
import { useI18n } from "vue-i18n";
|
2022-08-12 08:20:21 +00:00
|
|
|
import MenuItemEditingModal from "./components/MenuItemEditingModal.vue";
|
|
|
|
import MenuItemListItem from "./components/MenuItemListItem.vue";
|
|
|
|
import MenuList from "./components/MenuList.vue";
|
|
|
|
import type { MenuTreeItem } from "./utils";
|
|
|
|
import {
|
|
|
|
buildMenuItemsTree,
|
|
|
|
convertMenuTreeItemToMenuItem,
|
|
|
|
convertTreeToMenuItems,
|
|
|
|
getChildrenNames,
|
|
|
|
resetMenuItemsTreePriority,
|
|
|
|
} from "./utils";
|
2023-03-23 08:54:33 +00:00
|
|
|
|
|
|
|
const { t } = useI18n();
|
2023-04-16 15:12:13 +00:00
|
|
|
const queryClient = useQueryClient();
|
2022-08-12 08:20:21 +00:00
|
|
|
|
|
|
|
const menuTreeItems = ref<MenuTreeItem[]>([] as MenuTreeItem[]);
|
2022-10-11 07:33:51 +00:00
|
|
|
const selectedMenu = ref<Menu>();
|
|
|
|
const selectedMenuItem = ref<MenuItem>();
|
|
|
|
const selectedParentMenuItem = ref<MenuItem>();
|
2022-08-12 08:20:21 +00:00
|
|
|
const menuItemEditingModal = ref();
|
2022-08-22 08:49:07 +00:00
|
|
|
|
2023-04-16 15:12:13 +00:00
|
|
|
const {
|
|
|
|
data: menuItems,
|
|
|
|
isLoading,
|
|
|
|
refetch,
|
|
|
|
} = useQuery<MenuItem[]>({
|
|
|
|
queryKey: ["menu-items", selectedMenu],
|
|
|
|
queryFn: async () => {
|
2022-08-12 08:20:21 +00:00
|
|
|
if (!selectedMenu.value?.spec.menuItems) {
|
2023-04-16 15:12:13 +00:00
|
|
|
return [];
|
2022-08-12 08:20:21 +00:00
|
|
|
}
|
2023-04-16 15:12:13 +00:00
|
|
|
|
|
|
|
const menuItemNames = selectedMenu.value.spec.menuItems.filter(Boolean);
|
2024-06-25 04:31:44 +00:00
|
|
|
const { data } = await coreApiClient.menuItem.listMenuItem({
|
refactor: method parameters of api client (halo-dev/console#605)
<!-- Thanks for sending a pull request! Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->
#### What type of PR is this?
/kind improvement
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind optimization
适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->
#### What this PR does / why we need it:
修改 api-client 的请求参数结构,改为所有参数由一个对象包裹,而不是将各个参数作为方法的参数,防止因为后端参数结构发生改变,或者生成 api-client 时参数顺序发生改变导致请求异常。如:
```diff
await apiClient.extension.storage.group.updatestorageHaloRunV1alpha1Group(
- formState.value.metadata.name,
- formState.value
+ {
+ name: formState.value.metadata.name,
+ group: formState.value,
+ }
);
```
#### Which issue(s) this PR fixes:
<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.
用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
None
#### Screenshots:
<!--
如果此 PR 有 UI 的改动,最好截图说明这个 PR 的改动。
If there are UI changes to this PR, it is best to take a screenshot to illustrate the changes to this PR.
eg.
Before:

After:

-->
None
#### Special notes for your reviewer:
/cc @halo-dev/sig-halo-admin
#### Does this PR introduce a user-facing change?
<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note
None
```
2022-09-06 02:26:11 +00:00
|
|
|
page: 0,
|
|
|
|
size: 0,
|
|
|
|
fieldSelector: [`name=(${menuItemNames.join(",")})`],
|
|
|
|
});
|
2022-10-24 14:10:10 +00:00
|
|
|
|
2023-04-16 15:12:13 +00:00
|
|
|
return data.items;
|
|
|
|
},
|
|
|
|
onSuccess(data) {
|
|
|
|
menuTreeItems.value = buildMenuItemsTree(data);
|
|
|
|
},
|
|
|
|
refetchInterval(data) {
|
|
|
|
const deletingMenuItems = data?.filter(
|
2022-10-24 14:10:10 +00:00
|
|
|
(menuItem) => !!menuItem.metadata.deletionTimestamp
|
|
|
|
);
|
2023-07-19 03:44:12 +00:00
|
|
|
return deletingMenuItems?.length ? 1000 : false;
|
2023-04-16 15:12:13 +00:00
|
|
|
},
|
|
|
|
enabled: computed(() => !!selectedMenu.value),
|
2022-10-24 14:10:10 +00:00
|
|
|
});
|
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
const handleOpenEditingModal = (menuItem: MenuTreeItem) => {
|
2024-06-25 04:31:44 +00:00
|
|
|
coreApiClient.menuItem
|
|
|
|
.getMenuItem({
|
2022-11-28 11:26:17 +00:00
|
|
|
name: menuItem.metadata.name,
|
|
|
|
})
|
|
|
|
.then((response) => {
|
|
|
|
selectedMenuItem.value = response.data;
|
|
|
|
menuItemEditingModal.value = true;
|
|
|
|
});
|
2022-08-12 08:20:21 +00:00
|
|
|
};
|
|
|
|
|
2022-10-11 07:33:51 +00:00
|
|
|
const handleOpenCreateByParentModal = (menuItem: MenuTreeItem) => {
|
|
|
|
selectedParentMenuItem.value = convertMenuTreeItemToMenuItem(menuItem);
|
|
|
|
menuItemEditingModal.value = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
const onMenuItemEditingModalClose = () => {
|
|
|
|
selectedParentMenuItem.value = undefined;
|
|
|
|
selectedMenuItem.value = undefined;
|
2024-05-21 07:10:44 +00:00
|
|
|
menuItemEditingModal.value = false;
|
2022-10-11 07:33:51 +00:00
|
|
|
};
|
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
const onMenuItemSaved = async (menuItem: MenuItem) => {
|
2024-08-16 14:42:33 +00:00
|
|
|
if (!selectedMenu.value) {
|
|
|
|
return;
|
|
|
|
}
|
2022-08-12 08:20:21 +00:00
|
|
|
|
2022-11-28 11:26:17 +00:00
|
|
|
// update menu items
|
2024-08-16 14:42:33 +00:00
|
|
|
await coreApiClient.menu.patchMenu({
|
|
|
|
name: selectedMenu.value.metadata.name,
|
|
|
|
jsonPatchInner: [
|
|
|
|
{
|
|
|
|
op: "add",
|
|
|
|
path: "/spec/menuItems",
|
|
|
|
value: Array.from(
|
|
|
|
new Set([
|
|
|
|
...(selectedMenu.value.spec.menuItems || []),
|
|
|
|
menuItem.metadata.name,
|
|
|
|
])
|
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2022-08-12 08:20:21 +00:00
|
|
|
|
2023-04-16 15:12:13 +00:00
|
|
|
await queryClient.invalidateQueries({ queryKey: ["menus"] });
|
|
|
|
await refetch();
|
2022-08-12 08:20:21 +00:00
|
|
|
};
|
|
|
|
|
2024-05-21 07:10:44 +00:00
|
|
|
const batchUpdating = ref(false);
|
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
const handleUpdateInBatch = useDebounceFn(async () => {
|
|
|
|
const menuTreeItemsToUpdate = resetMenuItemsTreePriority(menuTreeItems.value);
|
|
|
|
const menuItemsToUpdate = convertTreeToMenuItems(menuTreeItemsToUpdate);
|
|
|
|
try {
|
2024-05-21 07:10:44 +00:00
|
|
|
batchUpdating.value = true;
|
2022-08-12 08:20:21 +00:00
|
|
|
const promises = menuItemsToUpdate.map((menuItem) =>
|
2024-08-16 14:42:33 +00:00
|
|
|
coreApiClient.menuItem.patchMenuItem({
|
refactor: method parameters of api client (halo-dev/console#605)
<!-- Thanks for sending a pull request! Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->
#### What type of PR is this?
/kind improvement
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind optimization
适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->
#### What this PR does / why we need it:
修改 api-client 的请求参数结构,改为所有参数由一个对象包裹,而不是将各个参数作为方法的参数,防止因为后端参数结构发生改变,或者生成 api-client 时参数顺序发生改变导致请求异常。如:
```diff
await apiClient.extension.storage.group.updatestorageHaloRunV1alpha1Group(
- formState.value.metadata.name,
- formState.value
+ {
+ name: formState.value.metadata.name,
+ group: formState.value,
+ }
);
```
#### Which issue(s) this PR fixes:
<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.
用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
None
#### Screenshots:
<!--
如果此 PR 有 UI 的改动,最好截图说明这个 PR 的改动。
If there are UI changes to this PR, it is best to take a screenshot to illustrate the changes to this PR.
eg.
Before:

After:

-->
None
#### Special notes for your reviewer:
/cc @halo-dev/sig-halo-admin
#### Does this PR introduce a user-facing change?
<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note
None
```
2022-09-06 02:26:11 +00:00
|
|
|
name: menuItem.metadata.name,
|
2024-08-16 14:42:33 +00:00
|
|
|
jsonPatchInner: [
|
|
|
|
{
|
|
|
|
op: "add",
|
|
|
|
path: "/spec/priority",
|
|
|
|
value: menuItem.spec.priority || 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
op: "add",
|
|
|
|
path: "/spec/children",
|
|
|
|
value: menuItem.spec.children || [],
|
|
|
|
},
|
|
|
|
],
|
refactor: method parameters of api client (halo-dev/console#605)
<!-- Thanks for sending a pull request! Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->
#### What type of PR is this?
/kind improvement
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind optimization
适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->
#### What this PR does / why we need it:
修改 api-client 的请求参数结构,改为所有参数由一个对象包裹,而不是将各个参数作为方法的参数,防止因为后端参数结构发生改变,或者生成 api-client 时参数顺序发生改变导致请求异常。如:
```diff
await apiClient.extension.storage.group.updatestorageHaloRunV1alpha1Group(
- formState.value.metadata.name,
- formState.value
+ {
+ name: formState.value.metadata.name,
+ group: formState.value,
+ }
);
```
#### Which issue(s) this PR fixes:
<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.
用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
None
#### Screenshots:
<!--
如果此 PR 有 UI 的改动,最好截图说明这个 PR 的改动。
If there are UI changes to this PR, it is best to take a screenshot to illustrate the changes to this PR.
eg.
Before:

After:

-->
None
#### Special notes for your reviewer:
/cc @halo-dev/sig-halo-admin
#### Does this PR introduce a user-facing change?
<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note
None
```
2022-09-06 02:26:11 +00:00
|
|
|
})
|
2022-08-12 08:20:21 +00:00
|
|
|
);
|
|
|
|
await Promise.all(promises);
|
|
|
|
} catch (e) {
|
2023-02-17 06:36:15 +00:00
|
|
|
console.error("Failed to update menu items", e);
|
2022-08-12 08:20:21 +00:00
|
|
|
} finally {
|
2023-04-16 15:12:13 +00:00
|
|
|
await queryClient.invalidateQueries({ queryKey: ["menus"] });
|
|
|
|
await refetch();
|
2024-05-21 07:10:44 +00:00
|
|
|
batchUpdating.value = false;
|
2022-08-12 08:20:21 +00:00
|
|
|
}
|
2022-11-28 11:26:17 +00:00
|
|
|
}, 300);
|
2022-08-12 08:20:21 +00:00
|
|
|
|
|
|
|
const handleDelete = async (menuItem: MenuTreeItem) => {
|
2022-10-18 01:58:09 +00:00
|
|
|
Dialog.info({
|
2023-03-23 08:54:33 +00:00
|
|
|
title: t("core.menu.operations.delete_menu_item.title"),
|
|
|
|
description: t("core.menu.operations.delete_menu_item.description"),
|
2022-08-12 08:20:21 +00:00
|
|
|
confirmType: "danger",
|
2023-03-23 08:54:33 +00:00
|
|
|
confirmText: t("core.common.buttons.confirm"),
|
|
|
|
cancelText: t("core.common.buttons.cancel"),
|
2022-08-12 08:20:21 +00:00
|
|
|
onConfirm: async () => {
|
2024-06-25 04:31:44 +00:00
|
|
|
await coreApiClient.menuItem.deleteMenuItem({
|
refactor: method parameters of api client (halo-dev/console#605)
<!-- Thanks for sending a pull request! Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->
#### What type of PR is this?
/kind improvement
/milestone 2.0
<!--
添加其中一个类别:
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind optimization
适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->
#### What this PR does / why we need it:
修改 api-client 的请求参数结构,改为所有参数由一个对象包裹,而不是将各个参数作为方法的参数,防止因为后端参数结构发生改变,或者生成 api-client 时参数顺序发生改变导致请求异常。如:
```diff
await apiClient.extension.storage.group.updatestorageHaloRunV1alpha1Group(
- formState.value.metadata.name,
- formState.value
+ {
+ name: formState.value.metadata.name,
+ group: formState.value,
+ }
);
```
#### Which issue(s) this PR fixes:
<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.
用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
None
#### Screenshots:
<!--
如果此 PR 有 UI 的改动,最好截图说明这个 PR 的改动。
If there are UI changes to this PR, it is best to take a screenshot to illustrate the changes to this PR.
eg.
Before:

After:

-->
None
#### Special notes for your reviewer:
/cc @halo-dev/sig-halo-admin
#### Does this PR introduce a user-facing change?
<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note
None
```
2022-09-06 02:26:11 +00:00
|
|
|
name: menuItem.metadata.name,
|
|
|
|
});
|
2022-08-12 08:20:21 +00:00
|
|
|
|
|
|
|
const childrenNames = getChildrenNames(menuItem);
|
|
|
|
|
|
|
|
if (childrenNames.length) {
|
2022-11-28 11:26:17 +00:00
|
|
|
const deleteChildrenRequests = childrenNames.map((name) =>
|
2024-06-25 04:31:44 +00:00
|
|
|
coreApiClient.menuItem.deleteMenuItem({
|
2022-11-28 11:26:17 +00:00
|
|
|
name,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
await Promise.all(deleteChildrenRequests);
|
2022-08-12 08:20:21 +00:00
|
|
|
}
|
|
|
|
|
2023-04-16 15:12:13 +00:00
|
|
|
await refetch();
|
2022-11-28 11:26:17 +00:00
|
|
|
|
2023-04-16 15:12:13 +00:00
|
|
|
// update items under menu
|
2024-08-16 14:42:33 +00:00
|
|
|
await coreApiClient.menu.patchMenu({
|
|
|
|
name: selectedMenu.value?.metadata.name as string,
|
|
|
|
jsonPatchInner: [
|
|
|
|
{
|
|
|
|
op: "add",
|
|
|
|
path: "/spec/menuItems",
|
|
|
|
value:
|
|
|
|
selectedMenu.value?.spec.menuItems?.filter(
|
|
|
|
(name) =>
|
|
|
|
![menuItem.metadata.name, ...childrenNames].includes(name)
|
|
|
|
) || [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2022-11-28 11:26:17 +00:00
|
|
|
|
2023-04-16 15:12:13 +00:00
|
|
|
await queryClient.invalidateQueries({ queryKey: ["menus"] });
|
2022-11-28 11:26:17 +00:00
|
|
|
|
2023-04-16 15:12:13 +00:00
|
|
|
Toast.success(t("core.common.toast.delete_success"));
|
|
|
|
},
|
2022-11-28 11:26:17 +00:00
|
|
|
});
|
|
|
|
};
|
2022-08-12 08:20:21 +00:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<MenuItemEditingModal
|
2024-05-21 07:10:44 +00:00
|
|
|
v-if="menuItemEditingModal && selectedMenu"
|
2022-08-12 08:20:21 +00:00
|
|
|
:menu-item="selectedMenuItem"
|
2022-10-11 07:33:51 +00:00
|
|
|
:parent-menu-item="selectedParentMenuItem"
|
|
|
|
:menu="selectedMenu"
|
|
|
|
@close="onMenuItemEditingModalClose"
|
2022-08-12 08:20:21 +00:00
|
|
|
@saved="onMenuItemSaved"
|
|
|
|
/>
|
2023-03-23 08:54:33 +00:00
|
|
|
<VPageHeader :title="$t('core.menu.title')">
|
2022-08-12 08:20:21 +00:00
|
|
|
<template #icon>
|
|
|
|
<IconListSettings class="mr-2 self-center" />
|
|
|
|
</template>
|
|
|
|
</VPageHeader>
|
|
|
|
<div class="m-0 md:m-4">
|
|
|
|
<div class="flex flex-col gap-4 sm:flex-row">
|
2024-05-21 07:10:44 +00:00
|
|
|
<div class="w-96 flex-none">
|
2023-09-22 09:10:24 +00:00
|
|
|
<MenuList v-model:selected-menu="selectedMenu" />
|
2022-08-12 08:20:21 +00:00
|
|
|
</div>
|
|
|
|
<div class="flex-1">
|
|
|
|
<VCard :body-class="['!p-0']">
|
|
|
|
<template #header>
|
|
|
|
<div class="block w-full bg-gray-50 px-4 py-3">
|
|
|
|
<div
|
|
|
|
class="relative flex flex-col items-start sm:flex-row sm:items-center"
|
|
|
|
>
|
|
|
|
<div class="flex w-full flex-1 sm:w-auto">
|
|
|
|
<span class="text-base font-medium">
|
|
|
|
{{ selectedMenu?.spec.displayName }}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="mt-4 flex sm:mt-0">
|
|
|
|
<VSpace>
|
|
|
|
<VButton
|
2022-09-30 09:48:19 +00:00
|
|
|
v-permission="['system:menus:manage']"
|
2022-08-12 08:20:21 +00:00
|
|
|
size="xs"
|
|
|
|
type="default"
|
|
|
|
@click="menuItemEditingModal = true"
|
|
|
|
>
|
2023-03-23 08:54:33 +00:00
|
|
|
{{ $t("core.common.buttons.new") }}
|
2022-08-12 08:20:21 +00:00
|
|
|
</VButton>
|
|
|
|
</VSpace>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-04-16 15:12:13 +00:00
|
|
|
<VLoading v-if="isLoading" />
|
|
|
|
<Transition v-else-if="!menuItems?.length" appear name="fade">
|
2022-11-24 03:46:10 +00:00
|
|
|
<VEmpty
|
2023-03-23 08:54:33 +00:00
|
|
|
:message="$t('core.menu.menu_item_empty.message')"
|
|
|
|
:title="$t('core.menu.menu_item_empty.title')"
|
2022-11-24 03:46:10 +00:00
|
|
|
>
|
|
|
|
<template #actions>
|
|
|
|
<VSpace>
|
2023-04-16 15:12:13 +00:00
|
|
|
<VButton @click="refetch()">
|
2023-03-23 08:54:33 +00:00
|
|
|
{{ $t("core.common.buttons.refresh") }}
|
|
|
|
</VButton>
|
2022-11-24 03:46:10 +00:00
|
|
|
<VButton
|
|
|
|
v-permission="['system:menus:manage']"
|
|
|
|
type="primary"
|
|
|
|
@click="menuItemEditingModal = true"
|
|
|
|
>
|
|
|
|
<template #icon>
|
|
|
|
<IconAddCircle class="h-full w-full" />
|
|
|
|
</template>
|
2023-03-23 08:54:33 +00:00
|
|
|
{{ $t("core.common.buttons.new") }}
|
2022-11-24 03:46:10 +00:00
|
|
|
</VButton>
|
|
|
|
</VSpace>
|
|
|
|
</template>
|
|
|
|
</VEmpty>
|
|
|
|
</Transition>
|
|
|
|
<Transition v-else appear name="fade">
|
|
|
|
<MenuItemListItem
|
2024-05-21 07:10:44 +00:00
|
|
|
v-model="menuTreeItems"
|
|
|
|
:class="{
|
|
|
|
'cursor-progress opacity-60': batchUpdating,
|
|
|
|
}"
|
2022-11-24 03:46:10 +00:00
|
|
|
@change="handleUpdateInBatch"
|
|
|
|
@delete="handleDelete"
|
|
|
|
@open-editing="handleOpenEditingModal"
|
|
|
|
@open-create-by-parent="handleOpenCreateByParentModal"
|
|
|
|
/>
|
|
|
|
</Transition>
|
2022-08-12 08:20:21 +00:00
|
|
|
</VCard>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|