refactor(web): use oauth client instead of app auth client
This commit is contained in:
@@ -21,9 +21,9 @@ import AppIcon from 'components/AppIcon';
|
||||
import Container from 'components/Container';
|
||||
import PageTitle from 'components/PageTitle';
|
||||
import AdminApplicationSettings from 'components/AdminApplicationSettings';
|
||||
import AdminApplicationAuthClients from 'components/AdminApplicationAuthClients';
|
||||
import AdminApplicationCreateAuthClient from 'components/AdminApplicationCreateAuthClient';
|
||||
import AdminApplicationUpdateAuthClient from 'components/AdminApplicationUpdateAuthClient';
|
||||
import AdminApplicationOAuthClients from 'components/AdminApplicationOAuthClients';
|
||||
import AdminApplicationCreateOAuthClient from 'components/AdminApplicationCreateOAuthClient';
|
||||
import AdminApplicationUpdateOAuthClient from 'components/AdminApplicationUpdateOAuthClient';
|
||||
import useApp from 'hooks/useApp';
|
||||
|
||||
export default function AdminApplication() {
|
||||
@@ -39,7 +39,7 @@ export default function AdminApplication() {
|
||||
path: URLS.ADMIN_APP_SETTINGS_PATTERN,
|
||||
end: false,
|
||||
});
|
||||
const authClientsPathMatch = useMatch({
|
||||
const oauthClientsPathMatch = useMatch({
|
||||
path: URLS.ADMIN_APP_AUTH_CLIENTS_PATTERN,
|
||||
end: false,
|
||||
});
|
||||
@@ -49,7 +49,7 @@ export default function AdminApplication() {
|
||||
|
||||
const app = data?.data || {};
|
||||
|
||||
const goToAuthClientsPage = () => navigate('auth-clients');
|
||||
const goToAuthClientsPage = () => navigate('oauth-clients');
|
||||
|
||||
if (loading) return null;
|
||||
|
||||
@@ -77,7 +77,7 @@ export default function AdminApplication() {
|
||||
value={
|
||||
settingsPathMatch?.pattern?.path ||
|
||||
connectionsPathMatch?.pattern?.path ||
|
||||
authClientsPathMatch?.pattern?.path
|
||||
oauthClientsPathMatch?.pattern?.path
|
||||
}
|
||||
>
|
||||
<Tab
|
||||
@@ -87,8 +87,8 @@ export default function AdminApplication() {
|
||||
component={Link}
|
||||
/>
|
||||
<Tab
|
||||
data-test="auth-clients-tab"
|
||||
label={formatMessage('adminApps.authClients')}
|
||||
data-test="oauth-clients-tab"
|
||||
label={formatMessage('adminApps.oauthClients')}
|
||||
to={URLS.ADMIN_APP_AUTH_CLIENTS(appKey)}
|
||||
value={URLS.ADMIN_APP_AUTH_CLIENTS_PATTERN}
|
||||
component={Link}
|
||||
@@ -102,8 +102,8 @@ export default function AdminApplication() {
|
||||
element={<AdminApplicationSettings appKey={appKey} />}
|
||||
/>
|
||||
<Route
|
||||
path={`/auth-clients/*`}
|
||||
element={<AdminApplicationAuthClients appKey={appKey} />}
|
||||
path={`/oauth-clients/*`}
|
||||
element={<AdminApplicationOAuthClients appKey={appKey} />}
|
||||
/>
|
||||
<Route
|
||||
path="/"
|
||||
@@ -118,9 +118,9 @@ export default function AdminApplication() {
|
||||
</Container>
|
||||
<Routes>
|
||||
<Route
|
||||
path="/auth-clients/create"
|
||||
path="/oauth-clients/create"
|
||||
element={
|
||||
<AdminApplicationCreateAuthClient
|
||||
<AdminApplicationCreateOAuthClient
|
||||
application={app}
|
||||
onClose={goToAuthClientsPage}
|
||||
appKey={appKey}
|
||||
@@ -128,9 +128,9 @@ export default function AdminApplication() {
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/auth-clients/:clientId"
|
||||
path="/oauth-clients/:clientId"
|
||||
element={
|
||||
<AdminApplicationUpdateAuthClient
|
||||
<AdminApplicationUpdateOAuthClient
|
||||
application={app}
|
||||
onClose={goToAuthClientsPage}
|
||||
/>
|
||||
|
||||
@@ -30,7 +30,7 @@ import AppIcon from 'components/AppIcon';
|
||||
import Container from 'components/Container';
|
||||
import PageTitle from 'components/PageTitle';
|
||||
import useApp from 'hooks/useApp';
|
||||
import useAppAuthClients from 'hooks/useAppAuthClients';
|
||||
import useOAuthClients from 'hooks/useOAuthClients';
|
||||
import Can from 'components/Can';
|
||||
import { AppPropType } from 'propTypes/propTypes';
|
||||
|
||||
@@ -63,7 +63,7 @@ export default function Application() {
|
||||
const flowsPathMatch = useMatch({ path: URLS.APP_FLOWS_PATTERN, end: false });
|
||||
const { appKey } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const { data: appAuthClients } = useAppAuthClients(appKey);
|
||||
const { data: appOAuthClients } = useOAuthClients(appKey);
|
||||
|
||||
const { data, loading } = useApp(appKey);
|
||||
const app = data?.data || {};
|
||||
@@ -86,14 +86,14 @@ export default function Application() {
|
||||
appConfig?.data?.disabled === true,
|
||||
};
|
||||
|
||||
const addConnectionWithAuthClient = {
|
||||
label: formatMessage('app.addConnectionWithAuthClient'),
|
||||
key: 'addConnectionWithAuthClient',
|
||||
const addConnectionWithOAuthClient = {
|
||||
label: formatMessage('app.addConnectionWithOAuthClient'),
|
||||
key: 'addConnectionWithOAuthClient',
|
||||
'data-test': 'add-connection-with-auth-client-button',
|
||||
to: URLS.APP_ADD_CONNECTION(appKey, true),
|
||||
disabled:
|
||||
!currentUserAbility.can('create', 'Connection') ||
|
||||
appAuthClients?.data?.length === 0 ||
|
||||
appOAuthClients?.data?.length === 0 ||
|
||||
appConfig?.data?.disabled === true,
|
||||
};
|
||||
|
||||
@@ -102,18 +102,18 @@ export default function Application() {
|
||||
return [addCustomConnection];
|
||||
}
|
||||
|
||||
// means only auth clients are allowed for connection creation
|
||||
// means only OAuth clients are allowed for connection creation
|
||||
if (appConfig?.data?.useOnlyPredefinedAuthClients === true) {
|
||||
return [addConnectionWithAuthClient];
|
||||
return [addConnectionWithOAuthClient];
|
||||
}
|
||||
|
||||
// means there is no app auth client. so we don't show the `addConnectionWithAuthClient`
|
||||
if (appAuthClients?.data?.length === 0) {
|
||||
// means there is no OAuth client. so we don't show the `addConnectionWithOAuthClient`
|
||||
if (appOAuthClients?.data?.length === 0) {
|
||||
return [addCustomConnection];
|
||||
}
|
||||
|
||||
return [addCustomConnection, addConnectionWithAuthClient];
|
||||
}, [appKey, appConfig, appAuthClients, currentUserAbility, formatMessage]);
|
||||
return [addCustomConnection, addConnectionWithOAuthClient];
|
||||
}, [appKey, appConfig, appOAuthClients, currentUserAbility, formatMessage]);
|
||||
|
||||
if (loading) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user