0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

fix(console): do not show unsaved alert after delete connector (#1496)

This commit is contained in:
Gao Sun 2022-07-08 23:17:15 +08:00 committed by GitHub
parent 58558e5011
commit 61a6b1ab4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -14,11 +14,12 @@ import * as styles from '../index.module.scss';
import SenderTester from './SenderTester';
type Props = {
isDeleted: boolean;
connectorData: ConnectorDTO;
onConnectorUpdated: (connector: ConnectorDTO) => void;
};
const ConnectorContent = ({ connectorData, onConnectorUpdated }: Props) => {
const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Props) => {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const [config, setConfig] = useState<string>();
const [isSubmitting, setIsSubmitting] = useState(false);
@ -116,7 +117,7 @@ const ConnectorContent = ({ connectorData, onConnectorUpdated }: Props) => {
/>
</div>
</div>
<UnsavedChangesAlertModal hasUnsavedChanges={hasUnsavedChanges} />
<UnsavedChangesAlertModal hasUnsavedChanges={!isDeleted && hasUnsavedChanges} />
</>
);
};

View file

@ -35,6 +35,7 @@ import * as styles from './index.module.scss';
const ConnectorDetails = () => {
const { connectorId } = useParams();
const { mutate: mutateGlobal } = useSWRConfig();
const [isDeleted, setIsDeleted] = useState(false);
const [isReadMeOpen, setIsReadMeOpen] = useState(false);
const [isSetupOpen, setIsSetupOpen] = useState(false);
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
@ -60,6 +61,7 @@ const ConnectorDetails = () => {
toast.success(t('connector_details.connector_deleted'));
await mutateGlobal('/api/connectors');
setIsDeleted(true);
if (data?.type === ConnectorType.Social) {
navigate(`/connectors/social`, { replace: true });
@ -169,6 +171,7 @@ const ConnectorDetails = () => {
</TabNavItem>
</TabNav>
<ConnectorContent
isDeleted={isDeleted}
connectorData={data}
onConnectorUpdated={(connector) => {
void mutate(connector);