Files
qiming/qiming-mobile/subpackages/components/chat-input-phone/sandbox-select-modal/sandbox-select-modal.uvue

67 lines
1.7 KiB
Plaintext

<template>
<radio-list-drawer
:visible="visible"
:title="t('Mobile.Sandbox.selectorTitle')"
:list="computedSandboxList"
:current-value="currentSandboxId"
:readonly="readonly"
@onClose="handleClose"
@onChange="handleSandboxChange"
/>
</template>
<script lang="uts" setup>
import { SandboxInfo } from "@/types/interfaces/sandbox";
import { useI18n } from "@/utils/i18n";
import { RadioListItem } from "@/types/interfaces/radio";
import RadioListDrawer from "@/components/radio-list-drawer/radio-list-drawer.uvue";
const { t } = useI18n();
const props = withDefaults(
defineProps<{
visible: boolean;
sandboxList: SandboxInfo[];
currentSandboxId?: string;
isSandboxSwitchDisabled?: boolean;
readonly?: boolean;
}>(),
{
visible: false,
sandboxList: () => [] as SandboxInfo[],
currentSandboxId: "",
isSandboxSwitchDisabled: false,
readonly: false,
},
);
const emit = defineEmits<{
onClose: () => void;
onSandboxChange: (sandboxId: string) => void;
}>();
const computedSandboxList = computed(() => {
return props.sandboxList.map((item) : RadioListItem => {
const isDisabled = props.isSandboxSwitchDisabled && item.sandboxId !== props.currentSandboxId;
return {
label: item.name,
value: item.sandboxId,
desc: item.description || '',
disabled: isDisabled,
warningDesc: item.sandboxId !== '-1'
} as RadioListItem;
});
});
const handleClose = () => {
emit("onClose");
};
const handleSandboxChange = (value: string) => {
emit("onSandboxChange", value);
};
</script>
<style lang="scss" scoped>
</style>