mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add the possibility to enable/disable default OAuths (#303)
This commit is contained in:
committed by
GitHub
parent
719f1ad4e9
commit
32d19cbe7c
@@ -15,6 +15,7 @@ interface Props {
|
||||
submitError: string;
|
||||
|
||||
handleToggleEnabledOAuth(id: number, enabled: boolean): void;
|
||||
handleToggleEnabledDefaultOAuth(id: number, enabled: boolean): void;
|
||||
handleDeleteOAuth(id: number): void;
|
||||
|
||||
setPage: React.Dispatch<React.SetStateAction<AuthenticationPages>>;
|
||||
@@ -27,6 +28,7 @@ const AuthenticationIndexPage = ({
|
||||
submitError,
|
||||
|
||||
handleToggleEnabledOAuth,
|
||||
handleToggleEnabledDefaultOAuth,
|
||||
handleDeleteOAuth,
|
||||
|
||||
setPage,
|
||||
@@ -48,6 +50,7 @@ const AuthenticationIndexPage = ({
|
||||
<OAuthProvidersList
|
||||
oAuths={oAuths.items}
|
||||
handleToggleEnabledOAuth={handleToggleEnabledOAuth}
|
||||
handleToggleEnabledDefaultOAuth={handleToggleEnabledDefaultOAuth}
|
||||
handleDeleteOAuth={handleDeleteOAuth}
|
||||
setPage={setPage}
|
||||
setSelectedOAuth={setSelectedOAuth}
|
||||
|
||||
@@ -16,6 +16,7 @@ interface Props {
|
||||
onSubmitOAuth(oAuth: IOAuth, authenticityToken: string): Promise<any>;
|
||||
onUpdateOAuth(id: number, form: ISiteSettingsOAuthForm, authenticityToken: string): Promise<any>;
|
||||
onToggleEnabledOAuth(id: number, isEnabled: boolean, authenticityToken: string): void;
|
||||
onToggleEnabledDefaultOAuth(id: number, isEnabled: boolean, authenticityToken: string): void;
|
||||
onDeleteOAuth(id: number, authenticityToken: string): void;
|
||||
|
||||
isSubmitting: boolean;
|
||||
@@ -32,6 +33,7 @@ const AuthenticationSiteSettingsP = ({
|
||||
onSubmitOAuth,
|
||||
onUpdateOAuth,
|
||||
onToggleEnabledOAuth,
|
||||
onToggleEnabledDefaultOAuth,
|
||||
onDeleteOAuth,
|
||||
isSubmitting,
|
||||
submitError,
|
||||
@@ -58,6 +60,10 @@ const AuthenticationSiteSettingsP = ({
|
||||
onToggleEnabledOAuth(id, enabled, authenticityToken);
|
||||
};
|
||||
|
||||
const handleToggleEnabledDefaultOAuth = (id: number, enabled: boolean) => {
|
||||
onToggleEnabledDefaultOAuth(id, enabled, authenticityToken);
|
||||
};
|
||||
|
||||
const handleDeleteOAuth = (id: number) => {
|
||||
onDeleteOAuth(id, authenticityToken);
|
||||
};
|
||||
@@ -67,6 +73,7 @@ const AuthenticationSiteSettingsP = ({
|
||||
<AuthenticationIndexPage
|
||||
oAuths={oAuths}
|
||||
handleToggleEnabledOAuth={handleToggleEnabledOAuth}
|
||||
handleToggleEnabledDefaultOAuth={handleToggleEnabledDefaultOAuth}
|
||||
handleDeleteOAuth={handleDeleteOAuth}
|
||||
setPage={setPage}
|
||||
setSelectedOAuth={setSelectedOAuth}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { MutedText } from '../../common/CustomTexts';
|
||||
interface Props {
|
||||
oAuth: IOAuth;
|
||||
handleToggleEnabledOAuth(id: number, enabled: boolean): void;
|
||||
handleToggleEnabledDefaultOAuth(id: number, enabled: boolean): void;
|
||||
handleDeleteOAuth(id: number): void;
|
||||
setPage: React.Dispatch<React.SetStateAction<AuthenticationPages>>;
|
||||
setSelectedOAuth: React.Dispatch<React.SetStateAction<number>>;
|
||||
@@ -20,6 +21,7 @@ interface Props {
|
||||
const OAuthProviderItem = ({
|
||||
oAuth,
|
||||
handleToggleEnabledOAuth,
|
||||
handleToggleEnabledDefaultOAuth,
|
||||
handleDeleteOAuth,
|
||||
setPage,
|
||||
setSelectedOAuth,
|
||||
@@ -41,48 +43,59 @@ const OAuthProviderItem = ({
|
||||
/>
|
||||
</div>
|
||||
:
|
||||
<div><MutedText>{I18n.t('site_settings.authentication.default_oauth')}</MutedText></div>
|
||||
<div className="oAuthIsEnabled">
|
||||
<Switch
|
||||
label={I18n.t(`common.${oAuth.isEnabled ? 'enabled' : 'disabled'}`)}
|
||||
onClick={() => handleToggleEnabledDefaultOAuth(oAuth.id, !oAuth.defaultOAuthIsEnabled)}
|
||||
checked={oAuth.defaultOAuthIsEnabled}
|
||||
htmlId={`oAuth${oAuth.name}EnabledSwitch`}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{
|
||||
oAuth.tenantId &&
|
||||
<div className="oAuthActions">
|
||||
<CopyToClipboardButton
|
||||
label={I18n.t('site_settings.authentication.copy_url')}
|
||||
textToCopy={oAuth.callbackUrl}
|
||||
/>
|
||||
|
||||
<ActionLink
|
||||
onClick={() =>
|
||||
window.open(`/o_auths/${oAuth.id}/start?reason=test`, '', 'width=640, height=640')
|
||||
}
|
||||
icon={<TestIcon />}
|
||||
customClass='testAction'
|
||||
>
|
||||
{I18n.t('common.buttons.test')}
|
||||
</ActionLink>
|
||||
|
||||
<ActionLink
|
||||
onClick={() => {
|
||||
setSelectedOAuth(oAuth.id);
|
||||
setPage('edit');
|
||||
}}
|
||||
icon={<EditIcon />}
|
||||
customClass='editAction'
|
||||
>
|
||||
{I18n.t('common.buttons.edit')}
|
||||
</ActionLink>
|
||||
|
||||
<ActionLink
|
||||
onClick={() => confirm(I18n.t('common.confirmation')) && handleDeleteOAuth(oAuth.id)}
|
||||
icon={<DeleteIcon />}
|
||||
customClass='deleteAction'
|
||||
>
|
||||
{I18n.t('common.buttons.delete')}
|
||||
</ActionLink>
|
||||
</div>
|
||||
oAuth.tenantId ?
|
||||
<div className="oAuthActions">
|
||||
<CopyToClipboardButton
|
||||
label={I18n.t('site_settings.authentication.copy_url')}
|
||||
textToCopy={oAuth.callbackUrl}
|
||||
/>
|
||||
|
||||
<ActionLink
|
||||
onClick={() =>
|
||||
window.open(`/o_auths/${oAuth.id}/start?reason=test`, '', 'width=640, height=640')
|
||||
}
|
||||
icon={<TestIcon />}
|
||||
customClass='testAction'
|
||||
>
|
||||
{I18n.t('common.buttons.test')}
|
||||
</ActionLink>
|
||||
|
||||
<ActionLink
|
||||
onClick={() => {
|
||||
setSelectedOAuth(oAuth.id);
|
||||
setPage('edit');
|
||||
}}
|
||||
icon={<EditIcon />}
|
||||
customClass='editAction'
|
||||
>
|
||||
{I18n.t('common.buttons.edit')}
|
||||
</ActionLink>
|
||||
|
||||
<ActionLink
|
||||
onClick={() => confirm(I18n.t('common.confirmation')) && handleDeleteOAuth(oAuth.id)}
|
||||
icon={<DeleteIcon />}
|
||||
customClass='deleteAction'
|
||||
>
|
||||
{I18n.t('common.buttons.delete')}
|
||||
</ActionLink>
|
||||
</div>
|
||||
:
|
||||
<div className="defaultOAuthDiv">
|
||||
<span className="defaultOAuthLabel"><MutedText>{I18n.t('site_settings.authentication.default_oauth')}</MutedText></span>
|
||||
</div>
|
||||
}
|
||||
</li>
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import OAuthProviderItem from './OAuthProviderItem';
|
||||
interface Props {
|
||||
oAuths: Array<IOAuth>;
|
||||
handleToggleEnabledOAuth(id: number, enabled: boolean): void;
|
||||
handleToggleEnabledDefaultOAuth(id: number, enabled: boolean): void;
|
||||
handleDeleteOAuth(id: number): void;
|
||||
setPage: React.Dispatch<React.SetStateAction<AuthenticationPages>>;
|
||||
setSelectedOAuth: React.Dispatch<React.SetStateAction<number>>;
|
||||
@@ -17,6 +18,7 @@ interface Props {
|
||||
const OAuthProvidersList = ({
|
||||
oAuths,
|
||||
handleToggleEnabledOAuth,
|
||||
handleToggleEnabledDefaultOAuth,
|
||||
handleDeleteOAuth,
|
||||
setPage,
|
||||
setSelectedOAuth,
|
||||
@@ -35,6 +37,7 @@ const OAuthProvidersList = ({
|
||||
<OAuthProviderItem
|
||||
oAuth={oAuth}
|
||||
handleToggleEnabledOAuth={handleToggleEnabledOAuth}
|
||||
handleToggleEnabledDefaultOAuth={handleToggleEnabledDefaultOAuth}
|
||||
handleDeleteOAuth={handleDeleteOAuth}
|
||||
setPage={setPage}
|
||||
setSelectedOAuth={setSelectedOAuth}
|
||||
|
||||
Reference in New Issue
Block a user