Skip to content

Commit 652029c

Browse files
committed
Fix : Creatial issues
1 parent 9a72ff2 commit 652029c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4622
-2
lines changed

gatsby-config.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13+
const { createProxyMiddleware } = require("http-proxy-middleware");
14+
1315
module.exports = {
1416
siteMetadata: {
1517
pages: [
@@ -224,5 +226,26 @@ module.exports = {
224226
]
225227
},
226228
plugins: [`@adobe/gatsby-theme-aio`],
227-
pathPrefix: process.env.PATH_PREFIX || "/developer-console/docs/"
229+
pathPrefix: process.env.PATH_PREFIX || "/developer-console/docs/",
230+
developMiddleware: app => {
231+
app.use(
232+
"/console/api",
233+
createProxyMiddleware({
234+
target: "https://developer-stage.adobe.com/console/api",
235+
secure: false,
236+
changeOrigin: true,
237+
})
238+
);
239+
app.use("/templates", createProxyMiddleware({
240+
target: "https://developer-stage.adobe.com/templates",
241+
secure: false,
242+
changeOrigin: true,
243+
}));
244+
245+
app.use("/ims", createProxyMiddleware({
246+
target: "https://ims-na1-stg1.adobelogin.com/ims",
247+
secure: false,
248+
changeOrigin: true,
249+
}));
250+
},
228251
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
"url": "https://github.com/icaraps"
1313
},
1414
"dependencies": {
15-
"@adobe/gatsby-theme-aio": "^4.14.4",
15+
"@adobe/gatsby-theme-aio": "^4.14.12",
1616
"gatsby": "4.22.0",
17+
"http-proxy-middleware": "^3.0.3",
1718
"react": "^17.0.2",
1819
"react-dom": "^17.0.2"
1920
},
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import React, { useContext, useEffect, useState } from 'react';
2+
import { css } from '@emotion/react';
3+
import { ProgressCircle } from "@adobe/gatsby-theme-aio/src/components/ProgressCircle";
4+
import { Button } from "@adobe/gatsby-theme-aio/src/components/Button";
5+
import { CopyIcon } from '../Icons';
6+
import { Toast } from '@adobe/gatsby-theme-aio/src/components/Toast';
7+
import GetCredentialContext from '../GetCredentialContext';
8+
import { generateToken, getCredentialSecrets } from '../Service';
9+
import { ActionButton } from '@adobe/gatsby-theme-aio/src/components/ActionButton';
10+
11+
const AccessToken = ({ accessToken, response, scopesDetails }) => {
12+
const [credentialToken, setCredentialToken] = useState(null);
13+
const { selectedOrganization } = useContext(GetCredentialContext);
14+
const [isCopiedTooltip, setIsCopiedTooltip] = useState(false);
15+
const [isHoveringCopyButton, setIsHoveringCopyButton] = useState(false);
16+
17+
const handleGenerateToken = async () => {
18+
setCredentialToken('loading');
19+
const secrets = await getCredentialSecrets(response, selectedOrganization);
20+
if (secrets) {
21+
let clientId = response?.workspaces ? response?.workspaces[0]?.credentials[0]?.clientId : response?.apiKey;
22+
const tokenVal = await generateToken(clientId, secrets?.clientSecret, scopesDetails);
23+
navigator.clipboard.writeText(tokenVal);
24+
setCredentialToken(tokenVal);
25+
}
26+
};
27+
28+
const handleSecretCopyCode = (copiedVal) => {
29+
setIsCopiedTooltip(true);
30+
navigator.clipboard.writeText(copiedVal);
31+
setTimeout(() => setIsCopiedTooltip(false), 1000); // Hide tooltip after 1 second
32+
};
33+
34+
useEffect(() => {
35+
setCredentialToken(null);
36+
}, [response]);
37+
38+
return (
39+
<>
40+
{accessToken && (
41+
<div
42+
css={css`
43+
display: flex;
44+
flex-direction: column;
45+
gap: 16px;
46+
`}>
47+
{accessToken?.heading && (
48+
<h4 className="spectrum-Heading spectrum-Heading--sizeS">{accessToken?.heading}</h4>
49+
)}
50+
{credentialToken === null ? (
51+
accessToken?.buttonLabel && (
52+
<div
53+
data-cy="generate-token"
54+
onClick={() => handleGenerateToken()}
55+
css={css`
56+
width: fit-content;
57+
& > button {
58+
background-color : #0265dc !important;
59+
}
60+
`}>
61+
<Button variant="accent" style="fill">
62+
{accessToken?.buttonLabel}
63+
</Button>
64+
</div>
65+
)
66+
) : (
67+
credentialToken === 'loading' ? (
68+
<ProgressCircle size="S" aria-label="Loading…" isIndeterminate />
69+
) : (
70+
<div
71+
css={css`
72+
display: flex;
73+
align-items: center;
74+
gap: 16px;
75+
`}>
76+
<p
77+
className="spectrum-Body spectrum-Body--sizeS"
78+
css={css`
79+
white-space: nowrap;
80+
overflow: hidden;
81+
text-overflow: ellipsis;
82+
color: #000000;
83+
width: 320px;
84+
`}>
85+
{credentialToken}
86+
</p>
87+
<div
88+
data-cy="copy-token"
89+
onClick={() => handleSecretCopyCode(credentialToken)}
90+
css={css`
91+
position: relative;
92+
& > button {
93+
border: 1px solid rgba(177, 177, 177) !important;
94+
padding: 4px !important;
95+
border-radius: 2px !important;
96+
}
97+
`}>
98+
<ActionButton
99+
onMouseEnter={() => setIsHoveringCopyButton(true)}
100+
onMouseLeave={() => setIsHoveringCopyButton(false)}
101+
>
102+
<CopyIcon />
103+
</ActionButton>
104+
{isHoveringCopyButton && (
105+
<div
106+
className="spectrum-Tooltip spectrum-Tooltip--top is-open"
107+
css={css`
108+
position: absolute;
109+
top: -30px;
110+
transform: translateX(-50%);
111+
background: #333;
112+
color: #fff;
113+
border-radius: 4px;
114+
white-space: nowrap;
115+
z-index: 10;
116+
`}
117+
>
118+
<div className="spectrum-Tooltip-label">Copy</div>
119+
<div className="spectrum-Tooltip-tip" ></div>
120+
</div>
121+
)}
122+
</div >
123+
</div >
124+
)
125+
)}
126+
</div >
127+
)}
128+
{
129+
isCopiedTooltip && (
130+
<Toast
131+
variant="success"
132+
message="Copied to clipboard"
133+
disable={1000}
134+
customDisableFunction={setIsCopiedTooltip}
135+
/>
136+
)
137+
}
138+
</>
139+
);
140+
};
141+
142+
export { AccessToken };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import ShowCard from './ShowCard';
3+
4+
const CardAPIKey = ({ cardAPIKey, apiKey }) => {
5+
return (
6+
<ShowCard heading={cardAPIKey?.heading} value={apiKey} />
7+
)
8+
}
9+
10+
export { CardAPIKey };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import ShowCard from './ShowCard';
3+
4+
const CardAllowedOrigins = ({ cardAllowedOrigins, allowedOrigins }) => {
5+
return (
6+
<ShowCard heading={cardAllowedOrigins?.heading} value={allowedOrigins} />
7+
)
8+
}
9+
10+
export { CardAllowedOrigins };
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import React, { useContext } from 'react';
2+
import { css } from "@emotion/react";
3+
import { CardAPIKey } from './CardAPIKey';
4+
import { CardClientId } from './CardClientId';
5+
import { CardAllowedOrigins } from './CardAllowedOrigins';
6+
import { CardClientSecret } from './CardClientSecret';
7+
import { CardOrganizationName } from './CardOrganizationName';
8+
import { CardScopes } from './CardScopes';
9+
import { CardImsOrgID } from './CardImsOrgID';
10+
import GetCredentialContext from '../GetCredentialContext';
11+
12+
const CardClientDetails = ({
13+
clientDetails,
14+
clientIdDetails,
15+
clientSecretDetails,
16+
organizationDetails,
17+
scopesDetails,
18+
apiKeyDetails,
19+
allowedOriginsDetails,
20+
organizationName,
21+
allowedOrigins,
22+
response,
23+
imsOrgID,
24+
}) => {
25+
26+
const { selectedOrganization } = useContext(GetCredentialContext);
27+
28+
return (
29+
<div
30+
css={css`
31+
display: flex;
32+
flex-direction: column;
33+
gap: 32px;
34+
`}>
35+
<h4 className="spectrum-Heading spectrum-Heading--sizeS">{clientDetails?.heading}</h4>
36+
37+
{clientDetails.children.map((element) => {
38+
switch (element?.type?.name) {
39+
case "CardAllowedOrigins":
40+
return (
41+
<CardAllowedOrigins
42+
cardClientDetails={clientDetails}
43+
cardAllowedOrigins={allowedOrigins}
44+
allowedOrigins={allowedOriginsDetails}
45+
/>
46+
);
47+
case "CardOrganizationName":
48+
return (
49+
<CardOrganizationName
50+
cardClientDetails={clientDetails}
51+
cardOrganizationName={organizationDetails}
52+
organization={organizationName?.name}
53+
/>
54+
);
55+
case "CardImsOrgID":
56+
return (
57+
<CardImsOrgID cardClientDetails={clientDetails} cardImsOrgID={imsOrgID} imsOrgId={selectedOrganization?.code} />
58+
);
59+
case "CardAPIKey":
60+
return (
61+
<CardAPIKey
62+
cardClientDetails={clientDetails}
63+
cardAPIKey={apiKeyDetails}
64+
apiKey={response?.['apiKey']}
65+
/>
66+
);
67+
case "CardClientId":
68+
return (
69+
<CardClientId
70+
cardClientDetails={clientDetails}
71+
cardClientId={clientIdDetails}
72+
clientId={response?.['apiKey']}
73+
/>
74+
);
75+
case "CardClientSecret":
76+
return (
77+
<CardClientSecret
78+
cardClientDetails={clientDetails}
79+
cardClientSecret={clientSecretDetails}
80+
response={response}
81+
/>
82+
);
83+
case "CardScopes":
84+
return (
85+
<CardScopes cardClientDetails={clientDetails} cardScopes={scopesDetails} />
86+
);
87+
default:
88+
return null;
89+
}
90+
})}
91+
</div>
92+
);
93+
};
94+
95+
export { CardClientDetails };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import ShowCard from './ShowCard'
3+
4+
const CardClientId = ({ cardClientId, clientId }) => {
5+
return (
6+
<ShowCard heading={cardClientId?.heading} value={clientId} />
7+
)
8+
}
9+
10+
export { CardClientId }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import ShowCard from './ShowCard';
3+
4+
const CardClientSecret = ({ cardClientSecret, response }) => {
5+
return (
6+
<ShowCard heading={cardClientSecret?.heading} isClientSecret buttonLabel={cardClientSecret?.buttonLabel} response={response} />
7+
)
8+
}
9+
10+
export { CardClientSecret };
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import ShowCard from './ShowCard';
3+
4+
const CardImsOrgID = ({ cardImsOrgID, imsOrgId }) => {
5+
return <ShowCard heading={cardImsOrgID?.heading} value={imsOrgId} />;
6+
};
7+
8+
export { CardImsOrgID };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import ShowCard from './ShowCard';
3+
4+
const CardOrganizationName = ({ cardOrganizationName, organization }) => {
5+
return (
6+
<ShowCard heading={cardOrganizationName?.heading} value={organization} isOraganization />
7+
)
8+
}
9+
10+
export { CardOrganizationName };

0 commit comments

Comments
 (0)