|
164 | 164 | :status="zoneSelected ? 'process' : 'wait'"> |
165 | 165 | <template #description> |
166 | 166 | <div v-if="zoneSelected" style="margin-top: 15px"> |
| 167 | + <div v-if="showTemplateOsIdWarning" style="color: red"> |
| 168 | + {{ $t('message.create.instance.from.backup.template.osid.different') }} |
| 169 | + </div> |
167 | 170 | <a-card |
168 | 171 | :tabList="tabList" |
169 | 172 | :activeTabKey="tabKey" |
@@ -933,6 +936,7 @@ export default { |
933 | 936 | dataPreFill: {}, |
934 | 937 | showDetails: false, |
935 | 938 | showRootDiskSizeChanger: false, |
| 939 | + showTemplateOsIdWarning: false, |
936 | 940 | showOverrideDiskOfferingOption: false, |
937 | 941 | securitygroupids: [], |
938 | 942 | rootDiskSizeFixed: 0, |
@@ -975,6 +979,10 @@ export default { |
975 | 979 | crossZoneInstanceCreationEnabled () { |
976 | 980 | return this.dataPreFill.crosszoneinstancecreation |
977 | 981 | }, |
| 982 | + showTemplateOsIdWarning2 () { |
| 983 | + console.log('showTemplateOsIdWarning called with templateid:', this.form.templateid) |
| 984 | + return this.form.templateid && this.templateOsIdIsDifferent(this.form.templateid) |
| 985 | + }, |
978 | 986 | isNormalUserOrProject () { |
979 | 987 | return ['User'].includes(this.$store.getters.userInfo.roletype) || store.getters.project.id |
980 | 988 | }, |
@@ -1613,6 +1621,46 @@ export default { |
1613 | 1621 | { id: 'storage_specific', description: 'storage_specific' } |
1614 | 1622 | ] |
1615 | 1623 | }, |
| 1624 | + templateOsIdIsDifferent (templateid) { |
| 1625 | + console.log('templateOsIdIsDifferent called with templateid:', templateid) |
| 1626 | + console.log('dataPreFill:', this.dataPreFill) |
| 1627 | + if (!templateid) { |
| 1628 | + console.log('No templateid provided, returning false') |
| 1629 | + return false |
| 1630 | + } |
| 1631 | + if (!this.dataPreFill || !this.dataPreFill.osid) { |
| 1632 | + console.log('No dataPreFill.osid available, returning false') |
| 1633 | + return false |
| 1634 | + } |
| 1635 | + console.log('Looking for template with id:', templateid) |
| 1636 | + console.log('Available template options:', this.options.templates) |
| 1637 | + // Find the selected template by ID |
| 1638 | + let selectedTemplate = null |
| 1639 | + for (const key in this.options.templates) { |
| 1640 | + const templateList = _.get(this.options.templates[key], 'template', []) |
| 1641 | + console.log(`Searching in template category ${key}:`, templateList) |
| 1642 | + const template = _.find(templateList, (option) => option.id === templateid) |
| 1643 | + if (template) { |
| 1644 | + selectedTemplate = template |
| 1645 | + console.log('Found template:', selectedTemplate) |
| 1646 | + break |
| 1647 | + } |
| 1648 | + } |
| 1649 | + if (!selectedTemplate) { |
| 1650 | + console.log('Template not found with id:', templateid) |
| 1651 | + return false |
| 1652 | + } |
| 1653 | + if (!selectedTemplate.ostypeid) { |
| 1654 | + console.log('Selected template has no osid:', selectedTemplate) |
| 1655 | + return false |
| 1656 | + } |
| 1657 | + const isDifferent = selectedTemplate.ostypeid !== this.dataPreFill.osid |
| 1658 | + console.log('Template osid:', selectedTemplate.ostypeid) |
| 1659 | + console.log('DataPreFill osid:', this.dataPreFill.osid) |
| 1660 | + console.log('Are they different?', isDifferent) |
| 1661 | + // Return true if the template's osid is different from dataPreFill.osid |
| 1662 | + return isDifferent |
| 1663 | + }, |
1616 | 1664 | fetchInstaceGroups () { |
1617 | 1665 | this.options.instanceGroups = [] |
1618 | 1666 | getAPI('listInstanceGroups', { |
@@ -1658,6 +1706,13 @@ export default { |
1658 | 1706 | if (name === 'templateid') { |
1659 | 1707 | this.tabKey = 'templateid' |
1660 | 1708 | this.form.templateid = value |
| 1709 | + if (this.templateOsIdIsDifferent(value)) { |
| 1710 | + console.log('Showing template osid warning') |
| 1711 | + this.showTemplateOsIdWarning = true |
| 1712 | + } else { |
| 1713 | + console.log('Hiding template osid warning') |
| 1714 | + this.showTemplateOsIdWarning = false |
| 1715 | + } |
1661 | 1716 | this.form.isoid = null |
1662 | 1717 | this.resetFromTemplateConfiguration() |
1663 | 1718 | let template = '' |
|
0 commit comments