|
83 | 83 | </script> |
84 | 84 |
|
85 | 85 | <script> |
86 | | -window.toggleSegmentDropdown=function(){ |
| 86 | +toggleSegmentDropdown=function(){ |
87 | 87 | constselect=document.querySelector('.custom-select'); |
88 | 88 | select.classList.toggle('open'); |
89 | 89 | }; |
90 | 90 |
|
91 | | -window.handleDropdownKeydown=function(event){ |
| 91 | +handleDropdownKeydown=function(event){ |
92 | 92 | constselect=document.querySelector('.custom-select'); |
93 | 93 | constoptions=select.querySelectorAll('.option'); |
94 | 94 | constisOpen=select.classList.contains('open'); |
|
110 | 110 | } |
111 | 111 | }; |
112 | 112 |
|
113 | | -window.handleOptionKeydown=function(event,option,selectedValue){ |
| 113 | +handleOptionKeydown=function(event,option,selectedValue){ |
114 | 114 | constselect=document.querySelector('.custom-select'); |
115 | 115 | constoptions=select.querySelectorAll('.option'); |
116 | 116 | constcurrentIndex=Array.from(options).indexOf(option); |
|
140 | 140 | } |
141 | 141 | }; |
142 | 142 |
|
143 | | -window.selectSegmentOption=function(option,selectedValue){ |
| 143 | +selectSegmentOption=asyncfunction(option,selectedValue){ |
144 | 144 | constselectDisplay=document.querySelector('.select-display'); |
145 | | -constoptions=document.querySelectorAll('.option'); |
146 | 145 |
|
147 | | -// Update the display text |
148 | 146 | selectDisplay.textContent=option.textContent; |
149 | 147 |
|
| 148 | +constredirectMap=awaitfetchRedirectMap(); |
| 149 | + |
| 150 | +constcurrentPath=window.location.pathname; |
| 151 | + |
150 | 152 | if(selectedValue==='enterprise'){ |
151 | 153 | localStorage.setItem(enterpriseDocTypeLockKey,'true'); |
152 | | -location.href=`${SITE_BASE_URL}/?ent`; |
| 154 | + |
| 155 | +constenterprisePath=Object.keys(redirectMap).find( |
| 156 | +key=>redirectMap[key]===currentPath |
| 157 | +); |
| 158 | + |
| 159 | +if(enterprisePath){ |
| 160 | +window.location.href=`${SITE_BASE_URL}${enterprisePath}`; |
| 161 | +}else{ |
| 162 | +window.location.href=`${SITE_BASE_URL}/`; |
| 163 | +} |
153 | 164 | }elseif(selectedValue==='gitops'){ |
154 | 165 | localStorage.setItem(enterpriseDocTypeLockKey,'false'); |
155 | | -location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`; |
| 166 | + |
| 167 | +constgitOpsPath=redirectMap[currentPath]; |
| 168 | + |
| 169 | +if(gitOpsPath){ |
| 170 | +window.location.href=`${SITE_BASE_URL}${gitOpsPath}`; |
| 171 | +}else{ |
| 172 | +window.location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`; |
| 173 | +} |
156 | 174 | } |
157 | 175 | }; |
158 | | - |
159 | 176 | // Close dropdown when clicking outside |
160 | 177 | document.addEventListener('click',(e)=>{ |
161 | 178 | constselect=document.querySelector('.custom-select'); |
|