Skip to content

Commit

Permalink
enh: notion messaging post update permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Fontanier committed Mar 8, 2024
1 parent 3b6120d commit 6435a64
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion front/pages/w/[wId]/builder/data-sources/[name]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Button,
Cog6ToothIcon,
ContextItem,
Dialog,
DocumentTextIcon,
GithubLogo,
ListCheckIcon,
Expand Down Expand Up @@ -30,6 +31,7 @@ import Nango from "@nangohq/frontend";
import type { InferGetServerSidePropsType } from "next";
import Link from "next/link";
import { useRouter } from "next/router";
import type { ReactNode } from "react";
import { useContext, useEffect, useMemo, useState } from "react";

import ConnectorPermissionsModal from "@app/components/ConnectorPermissionsModal";
Expand Down Expand Up @@ -725,6 +727,7 @@ interface ConnectorUiConfig {
addDataButtonLabel: string | null;
displaySettingsButton: boolean;
guideLink: string | null;
onPostPermissionsUpdate?: () => ReactNode;
}

function getRenderingConfigForConnectorProvider(
Expand Down Expand Up @@ -759,6 +762,12 @@ function getRenderingConfigForConnectorProvider(
addDataButtonLabel: "Add / Remove data, manage permissions",
displaySettingsButton: false,
guideLink: CONNECTOR_CONFIGURATIONS[connectorProvider].guideLink,
onPostPermissionsUpdate: () => (
<span>
We've taken your edits into account. Notion permission edits may
take up to 24 hours to be reflected on your workspace.
</span>
),
};
case "github":
return {
Expand Down Expand Up @@ -940,18 +949,39 @@ function ManagedDataSourceView({
addDataButtonLabel,
displaySettingsButton,
guideLink,
onPostPermissionsUpdate,
} = getRenderingConfigForConnectorProvider(connectorProvider);

const [
postPermissionsUpdateDialogIsOpen,
setPostPermissionsUpdateDialogIsOpen,
] = useState(false);

return (
<>
{onPostPermissionsUpdate && (
<Dialog
isOpen={postPermissionsUpdateDialogIsOpen}
onCancel={() => setPostPermissionsUpdateDialogIsOpen(false)}
onValidate={() => {
setPostPermissionsUpdateDialogIsOpen(false);
}}
title="Permissions updated"
>
{onPostPermissionsUpdate()}
</Dialog>
)}
<DataSourceDetailsModal
dataSource={dataSource}
visible={showDataSourceDetailsModal}
onClose={() => {
setShowDataSourceDetailsModal(false);
}}
onClick={() => {
void handleUpdatePermissions();
void handleUpdatePermissions().then(() => {
onPostPermissionsUpdate &&
setPostPermissionsUpdateDialogIsOpen(true);
});
}}
/>
<ConnectorPermissionsModal
Expand Down

0 comments on commit 6435a64

Please sign in to comment.