2022-08-12 08:20:21 +00:00
|
|
|
<script lang="ts" setup>
|
2022-12-20 11:04:29 +00:00
|
|
|
import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
|
2022-09-26 07:48:55 +00:00
|
|
|
import SubmitButton from "@/components/button/SubmitButton.vue";
|
2024-05-21 07:10:44 +00:00
|
|
|
import { computed, nextTick, onMounted, ref, toRaw } from "vue";
|
2022-11-30 03:51:47 +00:00
|
|
|
import type { Menu, MenuItem, Ref } from "@halo-dev/api-client";
|
2022-09-22 08:46:32 +00:00
|
|
|
import { apiClient } from "@/utils/api-client";
|
2022-09-09 13:48:07 +00:00
|
|
|
import { setFocus } from "@/formkit/utils/focus";
|
2022-12-26 15:32:31 +00:00
|
|
|
import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
|
2023-03-23 08:54:33 +00:00
|
|
|
import { useI18n } from "vue-i18n";
|
2022-08-12 08:20:21 +00:00
|
|
|
|
2022-08-15 09:56:13 +00:00
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
2024-05-21 07:10:44 +00:00
|
|
|
menu: Menu;
|
2022-10-11 07:33:51 +00:00
|
|
|
parentMenuItem: MenuItem;
|
|
|
|
menuItem?: MenuItem;
|
2022-08-15 09:56:13 +00:00
|
|
|
}>(),
|
|
|
|
{
|
2022-10-11 07:33:51 +00:00
|
|
|
parentMenuItem: undefined,
|
|
|
|
menuItem: undefined,
|
2022-08-15 09:56:13 +00:00
|
|
|
}
|
|
|
|
);
|
2022-08-12 08:20:21 +00:00
|
|
|
|
2022-08-15 12:31:51 +00:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(event: "close"): void;
|
|
|
|
(event: "saved", menuItem: MenuItem): void;
|
|
|
|
}>();
|
2022-08-12 08:20:21 +00:00
|
|
|
|
2023-03-23 08:54:33 +00:00
|
|
|
const { t } = useI18n();
|
|
|
|
|
2024-05-21 07:10:44 +00:00
|
|
|
const modal = ref();
|
|
|
|
const selectedParentMenuItem = ref<string>("");
|
|
|
|
const formState = ref<MenuItem>({
|
2022-08-12 08:20:21 +00:00
|
|
|
spec: {
|
|
|
|
displayName: "",
|
|
|
|
href: "",
|
2022-12-29 13:50:33 +00:00
|
|
|
target: "_self",
|
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
|
|
|
children: [],
|
2022-08-12 08:20:21 +00:00
|
|
|
priority: 0,
|
|
|
|
},
|
|
|
|
apiVersion: "v1alpha1",
|
|
|
|
kind: "MenuItem",
|
|
|
|
metadata: {
|
2022-11-18 06:00:23 +00:00
|
|
|
name: "",
|
|
|
|
generateName: "menu-item-",
|
2022-08-12 08:20:21 +00:00
|
|
|
},
|
2024-05-21 07:10:44 +00:00
|
|
|
});
|
2022-08-12 08:20:21 +00:00
|
|
|
const saving = ref(false);
|
|
|
|
|
2024-05-21 07:10:44 +00:00
|
|
|
const isUpdateMode = !!props.menuItem;
|
2022-08-12 08:20:21 +00:00
|
|
|
|
2024-05-21 07:10:44 +00:00
|
|
|
const modalTitle = props.menuItem
|
|
|
|
? t("core.menu.menu_item_editing_modal.titles.update")
|
|
|
|
: t("core.menu.menu_item_editing_modal.titles.create");
|
2022-12-22 08:04:29 +00:00
|
|
|
|
2022-12-26 15:32:31 +00:00
|
|
|
const annotationsFormRef = ref<InstanceType<typeof AnnotationsForm>>();
|
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
const handleSaveMenuItem = async () => {
|
2022-12-26 15:32:31 +00:00
|
|
|
annotationsFormRef.value?.handleSubmit();
|
|
|
|
await nextTick();
|
|
|
|
|
|
|
|
const { customAnnotations, annotations, customFormInvalid, specFormInvalid } =
|
|
|
|
annotationsFormRef.value || {};
|
|
|
|
if (customFormInvalid || specFormInvalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
formState.value.metadata.annotations = {
|
|
|
|
...annotations,
|
|
|
|
...customAnnotations,
|
|
|
|
};
|
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
try {
|
|
|
|
saving.value = true;
|
|
|
|
|
2022-11-30 03:51:47 +00:00
|
|
|
const menuItemRef = menuItemRefs.find(
|
|
|
|
(ref) => ref.ref?.kind === selectedRefKind.value
|
2022-09-06 07:24:11 +00:00
|
|
|
);
|
|
|
|
|
2022-12-05 09:42:12 +00:00
|
|
|
if (menuItemRef?.ref) {
|
2022-11-30 03:51:47 +00:00
|
|
|
formState.value.spec.targetRef = {
|
|
|
|
...menuItemRef.ref,
|
|
|
|
name: selectedRefName.value,
|
|
|
|
};
|
2022-12-05 09:42:12 +00:00
|
|
|
formState.value.spec.displayName = undefined;
|
|
|
|
formState.value.spec.href = undefined;
|
2022-09-06 07:24:11 +00:00
|
|
|
}
|
|
|
|
|
2024-05-21 07:10:44 +00:00
|
|
|
if (isUpdateMode) {
|
2022-08-12 08:20:21 +00:00
|
|
|
const { data } =
|
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
|
|
|
await apiClient.extension.menuItem.updatev1alpha1MenuItem({
|
|
|
|
name: formState.value.metadata.name,
|
|
|
|
menuItem: formState.value,
|
|
|
|
});
|
2022-11-28 11:26:17 +00:00
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
emit("saved", data);
|
|
|
|
} else {
|
|
|
|
const { data } =
|
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
|
|
|
await apiClient.extension.menuItem.createv1alpha1MenuItem({
|
|
|
|
menuItem: formState.value,
|
|
|
|
});
|
2022-10-11 07:33:51 +00:00
|
|
|
|
|
|
|
// if parent menu item is selected, add the new menu item to the parent menu item
|
|
|
|
if (selectedParentMenuItem.value) {
|
|
|
|
const { data: menuItemToUpdate } =
|
|
|
|
await apiClient.extension.menuItem.getv1alpha1MenuItem({
|
|
|
|
name: selectedParentMenuItem.value,
|
|
|
|
});
|
|
|
|
|
|
|
|
menuItemToUpdate.spec.children = [
|
|
|
|
...(menuItemToUpdate.spec.children || []),
|
|
|
|
data.metadata.name,
|
|
|
|
];
|
|
|
|
|
|
|
|
await apiClient.extension.menuItem.updatev1alpha1MenuItem({
|
|
|
|
name: menuItemToUpdate.metadata.name,
|
|
|
|
menuItem: menuItemToUpdate,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
emit("saved", data);
|
|
|
|
}
|
2022-12-20 11:04:29 +00:00
|
|
|
|
2024-05-21 07:10:44 +00:00
|
|
|
modal.value.close();
|
|
|
|
|
2023-03-23 08:54:33 +00:00
|
|
|
Toast.success(t("core.common.toast.save_success"));
|
2022-08-12 08:20:21 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error("Failed to create menu item", e);
|
|
|
|
} finally {
|
|
|
|
saving.value = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-11-30 03:51:47 +00:00
|
|
|
interface MenuItemRef {
|
2022-09-06 07:24:11 +00:00
|
|
|
label: string;
|
2022-11-30 03:51:47 +00:00
|
|
|
inputType?: string;
|
|
|
|
ref?: Ref;
|
2022-09-06 07:24:11 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 03:51:47 +00:00
|
|
|
const baseRef: Ref = {
|
|
|
|
group: "content.halo.run",
|
|
|
|
version: "v1alpha1",
|
|
|
|
name: "",
|
|
|
|
};
|
|
|
|
|
|
|
|
const menuItemRefs: MenuItemRef[] = [
|
2022-09-06 07:24:11 +00:00
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: t(
|
|
|
|
"core.menu.menu_item_editing_modal.fields.ref_kind.options.custom"
|
|
|
|
),
|
2022-09-06 07:24:11 +00:00
|
|
|
},
|
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: t("core.menu.menu_item_editing_modal.fields.ref_kind.options.post"),
|
2022-11-30 03:51:47 +00:00
|
|
|
inputType: "postSelect",
|
|
|
|
ref: {
|
|
|
|
...baseRef,
|
|
|
|
kind: "Post",
|
|
|
|
},
|
2022-09-06 07:24:11 +00:00
|
|
|
},
|
2022-09-08 10:32:09 +00:00
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: t(
|
|
|
|
"core.menu.menu_item_editing_modal.fields.ref_kind.options.single_page"
|
|
|
|
),
|
2022-11-30 03:51:47 +00:00
|
|
|
inputType: "singlePageSelect",
|
|
|
|
ref: {
|
|
|
|
...baseRef,
|
|
|
|
kind: "SinglePage",
|
|
|
|
},
|
2022-09-08 10:32:09 +00:00
|
|
|
},
|
2022-09-06 07:24:11 +00:00
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: t(
|
|
|
|
"core.menu.menu_item_editing_modal.fields.ref_kind.options.category"
|
|
|
|
),
|
2022-11-30 03:51:47 +00:00
|
|
|
inputType: "categorySelect",
|
|
|
|
ref: {
|
|
|
|
...baseRef,
|
|
|
|
kind: "Category",
|
|
|
|
},
|
2022-09-06 07:24:11 +00:00
|
|
|
},
|
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: t("core.menu.menu_item_editing_modal.fields.ref_kind.options.tag"),
|
2022-11-30 03:51:47 +00:00
|
|
|
inputType: "tagSelect",
|
|
|
|
ref: {
|
|
|
|
...baseRef,
|
|
|
|
kind: "Tag",
|
|
|
|
},
|
2022-09-06 07:24:11 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-11-30 03:51:47 +00:00
|
|
|
const menuItemRefsMap = menuItemRefs.map((menuItemRef) => {
|
|
|
|
return {
|
|
|
|
label: menuItemRef.label,
|
|
|
|
value: menuItemRef.ref?.kind,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
const selectedRef = computed(() => {
|
|
|
|
return menuItemRefs.find(
|
|
|
|
(menuItemRef) => menuItemRef.ref?.kind === selectedRefKind.value
|
|
|
|
);
|
|
|
|
});
|
2022-09-06 07:24:11 +00:00
|
|
|
|
2022-11-30 03:51:47 +00:00
|
|
|
const selectedRefKind = ref<string>("");
|
|
|
|
const selectedRefName = ref<string>("");
|
2022-09-06 07:24:11 +00:00
|
|
|
|
|
|
|
const onMenuItemSourceChange = () => {
|
2022-11-30 03:51:47 +00:00
|
|
|
selectedRefName.value = "";
|
2022-09-06 07:24:11 +00:00
|
|
|
};
|
2024-05-21 07:10:44 +00:00
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
if (props.menuItem) {
|
|
|
|
formState.value = toRaw(props.menuItem);
|
|
|
|
|
|
|
|
// Set Ref related
|
|
|
|
const { targetRef } = formState.value.spec;
|
|
|
|
|
|
|
|
if (targetRef) {
|
|
|
|
selectedRefName.value = targetRef.name;
|
|
|
|
selectedRefKind.value = targetRef.kind as string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedParentMenuItem.value = props.parentMenuItem?.metadata.name;
|
|
|
|
|
|
|
|
setFocus("displayNameInput");
|
|
|
|
});
|
2022-08-12 08:20:21 +00:00
|
|
|
</script>
|
|
|
|
<template>
|
2024-05-21 07:10:44 +00:00
|
|
|
<VModal ref="modal" :width="700" :title="modalTitle" @close="emit('close')">
|
2022-09-09 13:48:07 +00:00
|
|
|
<FormKit
|
|
|
|
id="menuitem-form"
|
2022-09-23 10:03:55 +00:00
|
|
|
name="menuitem-form"
|
2022-09-09 13:48:07 +00:00
|
|
|
type="form"
|
2022-09-29 14:39:56 +00:00
|
|
|
:preserve="true"
|
2022-09-09 13:48:07 +00:00
|
|
|
:config="{ validationVisibility: 'submit' }"
|
|
|
|
@submit="handleSaveMenuItem"
|
|
|
|
>
|
2022-12-26 15:32:31 +00:00
|
|
|
<div>
|
|
|
|
<div class="md:grid md:grid-cols-4 md:gap-6">
|
|
|
|
<div class="md:col-span-1">
|
|
|
|
<div class="sticky top-0">
|
2023-03-23 08:54:33 +00:00
|
|
|
<span class="text-base font-medium text-gray-900">
|
|
|
|
{{ $t("core.menu.menu_item_editing_modal.groups.general") }}
|
|
|
|
</span>
|
2022-12-26 15:32:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mt-5 divide-y divide-gray-100 md:col-span-3 md:mt-0">
|
|
|
|
<FormKit
|
2024-05-21 07:10:44 +00:00
|
|
|
v-if="!isUpdateMode"
|
2022-12-26 15:32:31 +00:00
|
|
|
v-model="selectedParentMenuItem"
|
2023-03-23 08:54:33 +00:00
|
|
|
:label="
|
|
|
|
$t('core.menu.menu_item_editing_modal.fields.parent.label')
|
|
|
|
"
|
|
|
|
:placeholder="
|
|
|
|
$t(
|
|
|
|
'core.menu.menu_item_editing_modal.fields.parent.placeholder'
|
|
|
|
)
|
|
|
|
"
|
2022-12-26 15:32:31 +00:00
|
|
|
type="menuItemSelect"
|
2024-05-21 07:10:44 +00:00
|
|
|
:menu-items="menu.spec.menuItems || []"
|
2022-12-26 15:32:31 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<FormKit
|
|
|
|
v-model="selectedRefKind"
|
|
|
|
:options="menuItemRefsMap"
|
|
|
|
:disabled="isUpdateMode"
|
2023-03-23 08:54:33 +00:00
|
|
|
:label="
|
|
|
|
$t('core.menu.menu_item_editing_modal.fields.ref_kind.label')
|
|
|
|
"
|
2022-12-26 15:32:31 +00:00
|
|
|
type="select"
|
|
|
|
@change="onMenuItemSourceChange"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<FormKit
|
|
|
|
v-if="!selectedRefKind"
|
|
|
|
id="displayNameInput"
|
|
|
|
v-model="formState.spec.displayName"
|
2023-03-23 08:54:33 +00:00
|
|
|
:label="
|
|
|
|
$t(
|
|
|
|
'core.menu.menu_item_editing_modal.fields.display_name.label'
|
|
|
|
)
|
|
|
|
"
|
2022-12-26 15:32:31 +00:00
|
|
|
type="text"
|
|
|
|
name="displayName"
|
|
|
|
validation="required|length:0,100"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<FormKit
|
|
|
|
v-if="!selectedRefKind"
|
|
|
|
v-model="formState.spec.href"
|
2023-03-23 08:54:33 +00:00
|
|
|
:label="$t('core.menu.menu_item_editing_modal.fields.href.label')"
|
2022-12-26 15:32:31 +00:00
|
|
|
type="text"
|
|
|
|
name="href"
|
|
|
|
validation="required|length:0,1024"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<FormKit
|
|
|
|
v-if="selectedRef?.ref"
|
|
|
|
:id="selectedRef.inputType"
|
|
|
|
:key="selectedRef.inputType"
|
|
|
|
v-model="selectedRefName"
|
2023-03-23 08:54:33 +00:00
|
|
|
:placeholder="
|
|
|
|
$t(
|
|
|
|
'core.menu.menu_item_editing_modal.fields.ref_kind.placeholder',
|
|
|
|
{ label: selectedRef.label }
|
|
|
|
)
|
|
|
|
"
|
2022-12-26 15:32:31 +00:00
|
|
|
:label="selectedRef.label"
|
|
|
|
:type="selectedRef.inputType"
|
|
|
|
validation="required"
|
|
|
|
/>
|
2022-12-29 13:50:33 +00:00
|
|
|
|
|
|
|
<FormKit
|
|
|
|
v-model="formState.spec.target"
|
2023-03-23 08:54:33 +00:00
|
|
|
:label="
|
|
|
|
$t('core.menu.menu_item_editing_modal.fields.target.label')
|
|
|
|
"
|
2022-12-29 13:50:33 +00:00
|
|
|
type="select"
|
|
|
|
name="target"
|
|
|
|
:options="[
|
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: $t(
|
|
|
|
'core.menu.menu_item_editing_modal.fields.target.options.self'
|
|
|
|
),
|
2022-12-29 13:50:33 +00:00
|
|
|
value: '_self',
|
|
|
|
},
|
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: $t(
|
|
|
|
'core.menu.menu_item_editing_modal.fields.target.options.blank'
|
|
|
|
),
|
2022-12-29 13:50:33 +00:00
|
|
|
value: '_blank',
|
|
|
|
},
|
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: $t(
|
|
|
|
'core.menu.menu_item_editing_modal.fields.target.options.parent'
|
|
|
|
),
|
2022-12-29 13:50:33 +00:00
|
|
|
value: '_parent',
|
|
|
|
},
|
|
|
|
{
|
2023-03-23 08:54:33 +00:00
|
|
|
label: $t(
|
|
|
|
'core.menu.menu_item_editing_modal.fields.target.options.top'
|
|
|
|
),
|
2022-12-29 13:50:33 +00:00
|
|
|
value: '_top',
|
|
|
|
},
|
|
|
|
]"
|
|
|
|
/>
|
2022-12-26 15:32:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-12 08:20:21 +00:00
|
|
|
</FormKit>
|
2022-12-26 15:32:31 +00:00
|
|
|
|
|
|
|
<div class="py-5">
|
|
|
|
<div class="border-t border-gray-200"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="md:grid md:grid-cols-4 md:gap-6">
|
|
|
|
<div class="md:col-span-1">
|
|
|
|
<div class="sticky top-0">
|
2023-03-23 08:54:33 +00:00
|
|
|
<span class="text-base font-medium text-gray-900">
|
|
|
|
{{ $t("core.menu.menu_item_editing_modal.groups.annotations") }}
|
|
|
|
</span>
|
2022-12-26 15:32:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mt-5 divide-y divide-gray-100 md:col-span-3 md:mt-0">
|
|
|
|
<AnnotationsForm
|
|
|
|
:key="formState.metadata.name"
|
|
|
|
ref="annotationsFormRef"
|
|
|
|
:value="formState.metadata.annotations"
|
|
|
|
kind="MenuItem"
|
|
|
|
group=""
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-08-12 08:20:21 +00:00
|
|
|
<template #footer>
|
|
|
|
<VSpace>
|
2022-09-26 07:48:55 +00:00
|
|
|
<SubmitButton
|
2022-11-28 11:26:17 +00:00
|
|
|
:loading="saving"
|
2022-09-26 07:48:55 +00:00
|
|
|
type="secondary"
|
2023-03-23 08:54:33 +00:00
|
|
|
:text="$t('core.common.buttons.submit')"
|
2022-09-26 07:48:55 +00:00
|
|
|
@submit="$formkit.submit('menuitem-form')"
|
|
|
|
>
|
|
|
|
</SubmitButton>
|
2024-05-21 07:10:44 +00:00
|
|
|
<VButton @click="modal.close()">
|
2023-03-23 08:54:33 +00:00
|
|
|
{{ $t("core.common.buttons.cancel_and_shortcut") }}
|
|
|
|
</VButton>
|
2022-08-12 08:20:21 +00:00
|
|
|
</VSpace>
|
|
|
|
</template>
|
|
|
|
</VModal>
|
|
|
|
</template>
|