Skip to content

Commit

Permalink
fix(console): do not show unsaved alert after delete connector (#1496)
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun authored Jul 8, 2022
1 parent 58558e5 commit 61a6b1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -116,7 +117,7 @@ const ConnectorContent = ({ connectorData, onConnectorUpdated }: Props) => {
/>
</div>
</div>
<UnsavedChangesAlertModal hasUnsavedChanges={hasUnsavedChanges} />
<UnsavedChangesAlertModal hasUnsavedChanges={!isDeleted && hasUnsavedChanges} />
</>
);
};
Expand Down
3 changes: 3 additions & 0 deletions packages/console/src/pages/ConnectorDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -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 });
Expand Down Expand Up @@ -169,6 +171,7 @@ const ConnectorDetails = () => {
</TabNavItem>
</TabNav>
<ConnectorContent
isDeleted={isDeleted}
connectorData={data}
onConnectorUpdated={(connector) => {
void mutate(connector);
Expand Down

0 comments on commit 61a6b1a

Please sign in to comment.