Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba100da

Browse files
CR-29590
1 parent6dcd0ca commitba100da

File tree

3 files changed

+138
-153
lines changed

3 files changed

+138
-153
lines changed

‎README.md‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,13 @@ By default, users are redirected from the Enterprise segment to the GitOps (Argo
7171

7272
For more details, refer to the "Auto Redirect from Enterprise to ArgoHub Collection" section below.
7373

74-
####To switch segments in production:
74+
####Switching Between Segments
7575

76-
-To switch totheGitOpssegment, log into Codefresh and switch to an account withtheGitOps type. This will clear the Enterprise cookie.
77-
-To switch to the Enterprise segment, log intoCodefresh andswitchto an account with any other type. This will set the Enterprise cookie.
76+
-Usethe segment selector in thedocumentation header.
77+
-Use a cookietoautomaticallyswitchsegments (production only):
7878

79-
####To switch segments in local development:
80-
81-
In the local documentation site (`http://localhost:3131/`), open the console in developer tools and inject the appropriate cookie:
82-
83-
-**Switch to Enterprise Segment:**
84-
```js
85-
document.cookie='cfdoctype=enterprise; SameSite=Strict; Domain=localhost; Max-age=2592000; Path=/';
86-
```
87-
88-
-**Switch to GitOps Segment:**
89-
```js
90-
document.cookie='cfdoctype=enterprise; SameSite=Strict; Domain=localhost; Max-age=0; Path=/';
91-
```
79+
-**To switch to the GitOps segment:** Log in to Codefresh and switch to an account with the GitOps type. This will set the GitOps cookie.
80+
-**To switch to the Enterprise segment:** Log in to Codefresh and switch to an account with any other type. This will clear the GitOps cookie.
9281

9382
###Reusing Existing Documents
9483

‎_includes/scripts.html‎

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
<!-- End of Doc Search Embed Code -->
6060

6161
<script>
62-
constisEnterpriseDocumentationCookieSet=document.cookie.includes('cfdoctype=enterprise')
63-
constcommandbarSegment=isEnterpriseDocumentationCookieSet ?'3033bf7f' :'43836ac3'
62+
constcommandbarSegment=IS_ENTERPRISE_DOC_COOKIE_SET ?'3033bf7f' :'43836ac3'
6463

6564
varo=commandbarSegment,n=["Object.assign","Symbol","Symbol.for"].join("%2C"),a=window;functionr(o,n){void0===n&&(n=!1),"complete"!==document.readyState&&window.addEventListener("load",r.bind(null,o,n),{capture:!1,once:!0});vara=document.createElement("script");a.type="text/javascript",a.async=n,a.src=o,document.head.appendChild(a)}functiont(){varn;if(void0===a.CommandBar){deletea.__CommandBarBootstrap__;vart=Symbol.for("CommandBar::configuration"),e=Symbol.for("CommandBar::orgConfig"),i=Symbol.for("CommandBar::disposed"),c=Symbol.for("CommandBar::isProxy"),m=Symbol.for("CommandBar::queue"),d=Symbol.for("CommandBar::unwrap"),l=Symbol.for("CommandBar::eventSubscriptions"),s=[],u=localStorage.getItem("commandbar.lc"),f=u&&u.includes("local")?"http://localhost:8000":"https://api.commandbar.com",p=Object.assign(((n={})[t]={uuid:o},n[e]={},n[i]=!1,n[c]=!0,n[m]=newArray,n[d]=function(){returnp},n[l]=void0,n),a.CommandBar),b=["addCommand","boot","addEventSubscriber","addRecordAction","setFormFactor"],y=p;Object.assign(p,{shareCallbacks:function(){return{}},shareContext:function(){return{}}}),a.CommandBar=newProxy(p,{get:function(o,n){returnniny?p[n]:"then"!==n?b.includes(n)?function(){varo=Array.prototype.slice.call(arguments);returnnewPromise((function(a,r){o.unshift(n,a,r),p[m].push(o)}))}:function(){varo=Array.prototype.slice.call(arguments);o.unshift(n),p[m].push(o)}:void0}}),null!==u&&s.push("lc=".concat(u)),s.push("version=2"),r("".concat(f,"/latest/").concat(o,"?").concat(s.join("&")),!0)}}void0===Object.assign||"undefined"==typeofSymbol||void0===Symbol.for?(a.__CommandBarBootstrap__=t,r("https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features="+n)):t();
6665
window.CommandBar.setThemeMode('dark_mode')
@@ -81,105 +80,3 @@
8180
}
8281
});
8382
</script>
84-
85-
<script>
86-
toggleSegmentDropdown=function(){
87-
constselect=document.querySelector('.custom-select');
88-
select.classList.toggle('open');
89-
};
90-
91-
handleDropdownKeydown=function(event){
92-
constselect=document.querySelector('.custom-select');
93-
constoptions=select.querySelectorAll('.option');
94-
constisOpen=select.classList.contains('open');
95-
96-
switch(event.key){
97-
case'Enter':
98-
case' ':
99-
event.preventDefault();
100-
toggleSegmentDropdown();
101-
break;
102-
case'ArrowDown':
103-
event.preventDefault();
104-
if(!isOpen)toggleSegmentDropdown();
105-
options[0].focus();
106-
break;
107-
case'Escape':
108-
if(isOpen)toggleSegmentDropdown();
109-
break;
110-
}
111-
};
112-
113-
handleOptionKeydown=function(event,option,selectedValue){
114-
constselect=document.querySelector('.custom-select');
115-
constoptions=select.querySelectorAll('.option');
116-
constcurrentIndex=Array.from(options).indexOf(option);
117-
118-
switch(event.key){
119-
case'Enter':
120-
case' ':
121-
event.preventDefault();
122-
selectSegmentOption(option,selectedValue);
123-
break;
124-
case'ArrowDown':
125-
event.preventDefault();
126-
if(currentIndex<options.length-1){
127-
options[currentIndex+1].focus();
128-
}
129-
break;
130-
case'ArrowUp':
131-
event.preventDefault();
132-
if(currentIndex>0){
133-
options[currentIndex-1].focus();
134-
}
135-
break;
136-
case'Escape':
137-
select.classList.remove('open');
138-
select.querySelector('.select-display').focus();
139-
break;
140-
}
141-
};
142-
143-
selectSegmentOption=asyncfunction(option,selectedValue){
144-
constselectDisplay=document.querySelector('.select-display');
145-
146-
selectDisplay.textContent=option.textContent;
147-
148-
constredirectMap=awaitfetchRedirectMap();
149-
150-
constpathname=window.location.pathname;
151-
constcurrentPath=pathname.replace(SITE_BASE_URL,"");
152-
153-
if(selectedValue==='enterprise'){
154-
localStorage.setItem(enterpriseDocTypeLockKey,'true');
155-
156-
constenterprisePath=Object.keys(redirectMap).find(
157-
key=>redirectMap[key]===currentPath
158-
);
159-
160-
if(enterprisePath){
161-
window.location.href=`${SITE_BASE_URL}${enterprisePath}`;
162-
}else{
163-
window.location.href=`${SITE_BASE_URL}/`;
164-
}
165-
}elseif(selectedValue==='gitops'){
166-
localStorage.setItem(enterpriseDocTypeLockKey,'false');
167-
168-
constgitOpsPath=redirectMap[currentPath];
169-
170-
if(gitOpsPath){
171-
window.location.href=`${SITE_BASE_URL}${gitOpsPath}`;
172-
}else{
173-
window.location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`;
174-
}
175-
}
176-
};
177-
// Close dropdown when clicking outside
178-
document.addEventListener('click',(e)=>{
179-
constselect=document.querySelector('.custom-select');
180-
if(!select.contains(e.target)){
181-
select.classList.remove('open');
182-
}
183-
});
184-
</script>
185-

‎assets/js/src/argohub-redirect.js‎

Lines changed: 132 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,157 @@
1-
constenterpriseDocumentationCookie="cfdoctype=enterprise";
2-
constARGOHUB_MAIN_PATH=`/${SITE_GITOPS_COLLECTION}/`;
3-
constenterpriseDocTypeLockKey="enterpriseDocTypeLock";
1+
constGITOPS_DOC_COOKIE='cfdoctype=gitops'
2+
constIS_GITOPS_DOC_COOKIE_SET=document.cookie.includes(GITOPS_DOC_COOKIE)
43

5-
functioncheckIfEnterpriseDocumentationCookieSet(){
6-
returndocument.cookie.includes(enterpriseDocumentationCookie);
7-
}
4+
handleRedirect()
85

96
asyncfunctiongetArgoHubRedirectURL(currentPath){
10-
currentPath=currentPath.replace(SITE_BASE_URL,"");
7+
currentPath=currentPath.replace(SITE_BASE_URL,'')
118

12-
constredirectMap=awaitfetchRedirectMap();
9+
constredirectMap=awaitfetchRedirectMap()
1310

14-
constnewPath=redirectMap[currentPath];
15-
if(!newPath)returnnull;
11+
constnewPath=redirectMap[currentPath]
12+
if(!newPath)returnnull
1613

1714
constnewURL=
18-
newPath===ARGOHUB_MAIN_PATH
15+
newPath===`/${SITE_GITOPS_COLLECTION}/`
1916
?`${location.href}${SITE_GITOPS_COLLECTION}`
20-
:location.href.replace(currentPath,newPath);
17+
:location.href.replace(currentPath,newPath)
2118

22-
returnnewURL;
19+
returnnewURL
2320
}
2421

2522
asyncfunctionhandleRedirect(){
26-
if(shouldSkipRedirect())return;
23+
if(SITE_IS_GITOPS_COLLECTION||!IS_GITOPS_DOC_COOKIE_SET)return
2724

28-
constargoHubRedirectURL=awaitgetArgoHubRedirectURL(location.pathname);
29-
if(!argoHubRedirectURL)return;
25+
constargoHubRedirectURL=awaitgetArgoHubRedirectURL(location.pathname)
26+
if(!argoHubRedirectURL)return
3027

31-
location.href=argoHubRedirectURL;
28+
location.href=argoHubRedirectURL
3229
}
3330

3431
asyncfunctionfetchRedirectMap(){
35-
constresponse=awaitfetch(
36-
`${SITE_BASE_URL}/assets/js/src/argohub-redirect-mapping.json`
37-
);
32+
constresponse=awaitfetch(`${SITE_BASE_URL}/assets/js/src/argohub-redirect-mapping.json`)
3833
if(!response.ok){
39-
thrownewError("Failed to fetch the collections redirect map.");
34+
thrownewError('Failed to fetch the collections redirect map.')
35+
}
36+
returnresponse.json()
37+
}
38+
39+
functionsetGitOpsDocumentationCookie(){
40+
constmaxAge=2592000
41+
configureGitOpsDocumentationCookie(maxAge)
42+
}
43+
44+
functionremoveGitOpsDocumentationCookie(){
45+
configureGitOpsDocumentationCookie(0)
46+
}
47+
48+
functionconfigureGitOpsDocumentationCookie(maxAge){
49+
letcookie=`${GITOPS_DOC_COOKIE}; Max-Age=${maxAge}; Path=/; SameSite=Strict`
50+
51+
if(location.protocol==='https:'){
52+
cookie+='; Secure'
53+
}
54+
55+
if(location.hostname.endsWith('.codefresh.io')){
56+
cookie+='; Domain=.codefresh.io'
57+
}
58+
59+
document.cookie=cookie
60+
}
61+
62+
functiontoggleSegmentDropdown(){
63+
constselect=document.querySelector('.custom-select')
64+
select.classList.toggle('open')
65+
}
66+
67+
functionhandleDropdownKeydown(event){
68+
constselect=document.querySelector('.custom-select')
69+
constoptions=select.querySelectorAll('.option')
70+
constisOpen=select.classList.contains('open')
71+
72+
switch(event.key){
73+
case'Enter':
74+
case' ':
75+
event.preventDefault()
76+
toggleSegmentDropdown()
77+
break
78+
case'ArrowDown':
79+
event.preventDefault()
80+
if(!isOpen)toggleSegmentDropdown()
81+
options[0].focus()
82+
break
83+
case'Escape':
84+
if(isOpen)toggleSegmentDropdown()
85+
break
4086
}
41-
returnresponse.json();
4287
}
4388

44-
functionisEnterpriseLockPresent(){
45-
constenterpriseDocTypeLock=localStorage.getItem(enterpriseDocTypeLockKey);
46-
return!!enterpriseDocTypeLock;
89+
functionhandleOptionKeydown(event,option,selectedValue){
90+
constselect=document.querySelector('.custom-select')
91+
constoptions=select.querySelectorAll('.option')
92+
constcurrentIndex=Array.from(options).indexOf(option)
93+
94+
switch(event.key){
95+
case'Enter':
96+
case' ':
97+
event.preventDefault()
98+
selectSegmentOption(option,selectedValue)
99+
break
100+
case'ArrowDown':
101+
event.preventDefault()
102+
if(currentIndex<options.length-1){
103+
options[currentIndex+1].focus()
104+
}
105+
break
106+
case'ArrowUp':
107+
event.preventDefault()
108+
if(currentIndex>0){
109+
options[currentIndex-1].focus()
110+
}
111+
break
112+
case'Escape':
113+
select.classList.remove('open')
114+
select.querySelector('.select-display').focus()
115+
break
116+
}
47117
}
48118

49-
functionshouldSkipRedirect(){
50-
returntrue;// Redirect temporarily disabled. Will be re-enabled with a new cookie-based mechanism.
51-
// return (
52-
// isEnterpriseLockPresent() ||
53-
// SITE_IS_GITOPS_COLLECTION ||
54-
// checkIfEnterpriseDocumentationCookieSet()
55-
// );
119+
asyncfunctionselectSegmentOption(option,selectedValue){
120+
constselectDisplay=document.querySelector('.select-display')
121+
122+
selectDisplay.textContent=option.textContent
123+
124+
constredirectMap=awaitfetchRedirectMap()
125+
126+
constpathname=window.location.pathname
127+
constcurrentPath=pathname.replace(SITE_BASE_URL,'')
128+
129+
if(selectedValue==='enterprise'){
130+
removeGitOpsDocumentationCookie()
131+
132+
constenterprisePath=Object.keys(redirectMap).find((key)=>redirectMap[key]===currentPath)
133+
134+
if(enterprisePath){
135+
window.location.href=`${SITE_BASE_URL}${enterprisePath}`
136+
}else{
137+
window.location.href=`${SITE_BASE_URL}/`
138+
}
139+
}elseif(selectedValue==='gitops'){
140+
setGitOpsDocumentationCookie()
141+
142+
constgitOpsPath=redirectMap[currentPath]
143+
144+
if(gitOpsPath){
145+
window.location.href=`${SITE_BASE_URL}${gitOpsPath}`
146+
}else{
147+
window.location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`
148+
}
149+
}
56150
}
57151

58-
handleRedirect();
152+
document.addEventListener('click',(e)=>{
153+
constselect=document.querySelector('.custom-select')
154+
if(!select.contains(e.target)){
155+
select.classList.remove('open')
156+
}
157+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp