This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch cloud-service
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/cloud-service by this push:
new 37d40eff3 Feat configui support cognito (#4875)
37d40eff3 is described below
commit 37d40eff396f5968f29ebc21c4e49025bcf68bb7
Author: Warren Chen <[email protected]>
AuthorDate: Fri Apr 7 12:19:07 2023 +0800
Feat configui support cognito (#4875)
* revert(dockercompose): revert docker compose file
* fix for build
---
config-ui/index.html | 12 +++++++++---
config-ui/src/App.tsx | 5 +++--
config-ui/src/utils/request.ts | 6 ++++--
config-ui/vite.config.ts | 7 ++++---
4 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/config-ui/index.html b/config-ui/index.html
index e868c60a2..06ac22699 100644
--- a/config-ui/index.html
+++ b/config-ui/index.html
@@ -16,10 +16,10 @@ limitations under the License.
-->
<!--
-____ _______ __ _ _ _ _______
+____ _______ __ _ _ _ _______
| _ \| ____\ \ / / | | / \ | |/ / ____|
-| | | | _| \ \ / / | | / _ \ | ' /| _|
-| |_| | |___ \ V / | |___ / ___ \| . \| |___
+| | | | _| \ \ / / | | / _ \ | ' /| _|
+| |_| | |___ \ V / | |___ / ___ \| . \| |___
|____/|_____| \_/ |_____/_/ \_\_|\_\_____|
@@ -44,6 +44,12 @@ https://github.com/apache/incubator-devlake/wiki
</head>
<body>
<div id="root"></div>
+ <script>
+ if (typeof window.global === 'undefined') {
+ window.global = window;
+ }
+ </script>
+ }
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
diff --git a/config-ui/src/App.tsx b/config-ui/src/App.tsx
index 2f6b16774..8a50bff6e 100644
--- a/config-ui/src/App.tsx
+++ b/config-ui/src/App.tsx
@@ -36,14 +36,15 @@ import { withAuthenticator } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';
import { Auth } from '@aws-amplify/auth';
import { awsExports } from './aws-exports';
+import { WithAuthenticatorProps } from
'@aws-amplify/ui-react/dist/types/components/Authenticator/withAuthenticator';
Amplify.configure(awsExports);
-function App({ signOut, user }) {
+function App({ signOut, user }: WithAuthenticatorProps) {
Auth.currentSession().then((data) => console.log('test', data.getIdToken()));
return (
<BaseLayout>
- <h1>Hello {user.username}</h1>
+ <h1>Hello {user?.username}</h1>
<button onClick={signOut}>Sign out</button>
<Switch>
<Route path="/" exact component={() => <Redirect to="/projects" />} />
diff --git a/config-ui/src/utils/request.ts b/config-ui/src/utils/request.ts
index 376333708..b664f076f 100644
--- a/config-ui/src/utils/request.ts
+++ b/config-ui/src/utils/request.ts
@@ -54,6 +54,7 @@ export const request = (path: string, config?: ReuqestConfig)
=> {
params.data = data;
}
+ // Return the request result to the outer Promise
instance.request(params).then((resp) => resolve(resp.data));
if (signal) {
@@ -61,7 +62,8 @@ export const request = (path: string, config?: ReuqestConfig)
=> {
cancelTokenSource?.cancel();
});
}
- });
+ }); // If Auth.currentSession fails, pass the error to the outer Promise
});
- return requestPromise;
+
+ return requestPromise as Promise<any>;
};
diff --git a/config-ui/vite.config.ts b/config-ui/vite.config.ts
index c8c392362..e074b57f4 100644
--- a/config-ui/vite.config.ts
+++ b/config-ui/vite.config.ts
@@ -34,12 +34,13 @@ export default defineConfig({
},
},
- define: {
- global: {},
- },
resolve: {
alias: {
'@': path.join(__dirname, './src'),
+ './runtimeConfig': './runtimeConfig.browser',
},
},
+ optimizeDeps: {
+ exclude: ['@juggle/resize-observer'],
+ },
});