Skip to content

Commit

Permalink
Sync samples from downstream repo
Browse files Browse the repository at this point in the history
OKTA-440019
<<<Jenkins Check-In of Tested SHA: 2534ffb for [email protected]>>>
Artifact: okta-react
Files changed count: 24
PR Link: "#171"
  • Loading branch information
shuowu authored and eng-prod-CI-bot-okta committed Oct 22, 2021
1 parent 9a2e9a6 commit 8b75562
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 38 deletions.
2 changes: 2 additions & 0 deletions generated/samples/custom-login/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions generated/samples/custom-login/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/samples/custom-login/src/Login.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions generated/samples/custom-login/src/Navbar.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion generated/samples/custom-login/src/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion generated/samples/custom-login/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions generated/samples/doc-direct-auth/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/samples/doc-direct-auth/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions generated/samples/doc-embedded-widget/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions generated/samples/doc-embedded-widget/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions generated/samples/okta-hosted-login/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/samples/okta-hosted-login/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions generated/samples/okta-hosted-login/src/Navbar.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion generated/samples/okta-hosted-login/src/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion generated/samples/okta-hosted-login/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions generator/_templates/samples/config/.gitignore.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ to: ../generated/<%= dest %>/.gitignore

# dependencies
/node_modules
package-lock.json
yarn.lock

# testing
/coverage
Expand Down
11 changes: 3 additions & 8 deletions generator/_templates/samples/github-sample/src/Navbar.jsx.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ to: ../generated/<%= dest %>/src/Navbar.jsx

import { useOktaAuth } from '@okta/okta-react';
import React from 'react';
<% if (useSiw === 'true') { -%>
import { useHistory, Link } from 'react-router-dom';
<% } else { -%>
import { Link } from 'react-router-dom';
<% } -%>
import { Container, Icon, Image, Menu } from 'semantic-ui-react';

const Navbar = ({ setCorsErrorModalOpen }) => {
<% if (useSiw === 'true') { -%>
const history = useHistory();
<% } -%>
const { authState, oktaAuth } = useOktaAuth();

// Note: Can't distinguish CORS error from other network errors
Expand All @@ -24,8 +18,9 @@ const Navbar = ({ setCorsErrorModalOpen }) => {
const login = async () => <%- useSiw === 'true' ? `history.push('/login')` : 'oktaAuth.signInWithRedirect()' %>;

const logout = async () => {
const basename = window.location.origin + history.createHref({ pathname: '/' });
try {
await oktaAuth.signOut();
await oktaAuth.signOut({ postLogoutRedirectUri: basename });
} catch (err) {
if (isCorsError(err)) {
setCorsErrorModalOpen(true);
Expand All @@ -44,7 +39,7 @@ const Navbar = ({ setCorsErrorModalOpen }) => {
<Menu fixed="top" inverted>
<Container>
<Menu.Item header>
<Image size="mini" src="/react.svg" />
<Image size="mini" src={`${process.env.PUBLIC_URL}/react.svg`} />
&nbsp;
<Link to="/">Okta-React Sample Project</Link>
</Menu.Item>
Expand Down
6 changes: 5 additions & 1 deletion generator/_templates/samples/github-sample/src/config.js.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ to: ../generated/<%= dest %>/src/config.js
const CLIENT_ID = process.env.CLIENT_ID || '{clientId}';
const ISSUER = process.env.ISSUER || 'https://{yourOktaDomain}.com/oauth2/default';
const OKTA_TESTING_DISABLEHTTPSCHECK = process.env.OKTA_TESTING_DISABLEHTTPSCHECK || false;
const REDIRECT_URI = `${window.location.origin}/login/callback`;
const BASENAME = process.env.PUBLIC_URL || '';
const REDIRECT_URI = `${window.location.origin}${BASENAME}/login/callback`;
<% if (useSiw === 'true') { -%>
const USE_INTERACTION_CODE = process.env.USE_INTERACTION_CODE === 'true' || false;
<% } -%>
Expand All @@ -26,4 +27,7 @@ export default {
resourceServer: {
messagesUrl: 'http://localhost:8000/api/messages',
},
app: {
basename: BASENAME,
},
};
3 changes: 2 additions & 1 deletion generator/_templates/samples/github-sample/src/index.js.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { BrowserRouter as Router } from 'react-router-dom';
import 'semantic-ui-css/semantic.min.css';
import './polyfills';
import App from './App';
import config from './config';
import './index.css';

/* eslint-disable react/jsx-filename-extension */
ReactDOM.render(
<Router>
<Router basename={config.app.basename}>
<App />
</Router>,
document.getElementById('root'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Login = ({ setCorsErrorModalOpen }) => {
baseUrl: issuer.split('/oauth2')[0],
clientId,
redirectUri,
logo: '/react.svg',
logo: `${process.env.PUBLIC_URL}/react.svg`,
i18n: {
en: {
'primaryauth.title': 'Sign in to React & Company',
Expand Down
2 changes: 1 addition & 1 deletion generator/gulpfile.js/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const watchTask = () => {
}
// get action from change path and execute build action
const action = getHygenAction(actions, path);
console.info(`\nFile ${path} has been changed, build start ... \n`);
console.info(`\nFile ${path} has been changed, action: ${action}, build start ... \n`);
if (action === ACTION_OVERWRITE) {
samplesConfig
.filter(config => path.includes(config.name))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.8",
"private": true,
"dependencies": {
"@okta/okta-auth-js": "^5.4.0",
"@okta/okta-auth-js": "^5.6.0",
"@okta/okta-react": "*",
"@types/node": "^14.14.7",
"@types/react": "^16.9.56",
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/harness/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
"jsx": "react-jsx",
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2056,10 +2056,10 @@
mkdirp "^1.0.4"
rimraf "^3.0.2"

"@okta/okta-auth-js@^5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@okta/okta-auth-js/-/okta-auth-js-5.4.0.tgz#f57519b2bc8ea1200c43e31cb4924d576ec6d059"
integrity sha512-JXFAhEM0cTjsn9SzhhmZK6bDlat93E8KC8c8v2XeZBJYDDuIrbyS9h2psN4K/gmaGoSu0v+vmFVXBlLBwiaEHA==
"@okta/okta-auth-js@^5.6.0":
version "5.6.0"
resolved "https://registry.yarnpkg.com/@okta/okta-auth-js/-/okta-auth-js-5.6.0.tgz#0a0b46dbd679ab0777bf338e0ab81ff1dcca1a7f"
integrity sha512-FwGJ2tFAl7matIcIoWA6FuwHXkcaMJhV7b7ENPoB6ftcFQHFItm/S5vf5G7g6wIep0ZTHOA7I8loIOE+TtzEBw==
dependencies:
"@babel/runtime" "^7.12.5"
"@okta/okta-idx-js" "0.19.0"
Expand Down Expand Up @@ -2087,10 +2087,10 @@
core-js "^3.15.1"
jsonpath-plus "^5.1.0"

"@okta/okta-signin-widget@^5.10.0":
version "5.10.0"
resolved "https://registry.yarnpkg.com/@okta/okta-signin-widget/-/okta-signin-widget-5.10.0.tgz#b8d57344b64db18fdf34587eece739d17699d584"
integrity sha512-ZvkUTF/bnWV6M3zEFU+zQ+MhwfOmT8jbvjRZARFs46iZBrx4V73FvbEuDA0MeUtQK1HF0PSB2mQkJDAhqGQYug==
"@okta/okta-signin-widget@^5.12.2":
version "5.12.2"
resolved "https://registry.yarnpkg.com/@okta/okta-signin-widget/-/okta-signin-widget-5.12.2.tgz#979384e082d29b56528532c3f0a078ba6f3dbd66"
integrity sha512-0vpSBYiW6lHRWOtqYYAfQ1etevg6yuC3hvC/V9MIXEWCQ9fkFZDtCzPRzIclMyeEplZJZYohGRs2sxOmNa/dYQ==
dependencies:
"@babel/polyfill" "^7.10.1"
"@babel/runtime" "^7.10.3"
Expand Down

0 comments on commit 8b75562

Please sign in to comment.