@workos-inc/widgets 1.17.3 → 1.18.0-next.1788904392369

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1358,8 +1358,8 @@ function DisconnectAccountDialog({
1358
1358
  ] })
1359
1359
  ] }) });
1360
1360
  }
1361
- const PipesLoading = ({ count, ...domProps }) => {
1362
- return /* @__PURE__ */ jsx(CardList.Root, { ...getWidgetRootDomProps("loading", domProps), children: Array.from({ length: count }).map((_, index) => /* @__PURE__ */ jsx(CardList.Item, { children: /* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", align: "center", gap: "2", children: [
1361
+ function PipesSkeletonItems({ count }) {
1362
+ return Array.from({ length: count }).map((_, index) => /* @__PURE__ */ jsx(CardList.Item, { children: /* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", align: "center", gap: "2", children: [
1363
1363
  /* @__PURE__ */ jsxs(Flex, { gap: "4", align: "center", children: [
1364
1364
  /* @__PURE__ */ jsx(Skeleton, { children: /* @__PURE__ */ jsx(IconPanel, { children: /* @__PURE__ */ jsx(ProviderIcon, { provider: "google", size: "2" }) }) }),
1365
1365
  /* @__PURE__ */ jsx(Skeleton, { children: /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: /* @__PURE__ */ jsx(
@@ -1379,16 +1379,409 @@ const PipesLoading = ({ count, ...domProps }) => {
1379
1379
  description: "Placeholder button text for loading state"
1380
1380
  }
1381
1381
  ) }) })
1382
- ] }) }, index)) });
1382
+ ] }) }, index));
1383
+ }
1384
+ const PipesLoading = ({ count, ...domProps }) => {
1385
+ return /* @__PURE__ */ jsx(CardList.Root, { ...getWidgetRootDomProps("loading", domProps), children: /* @__PURE__ */ jsx(PipesSkeletonItems, { count }) });
1383
1386
  };
1384
- const Pipes = ({ integrations, ...domProps }) => {
1385
- return /* @__PURE__ */ jsx(CardList.Root, { ...getWidgetRootDomProps("resolved", domProps), children: integrations.map((integration) => /* @__PURE__ */ jsx(CardList.Item, { children: /* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", align: "center", gap: "2", children: [
1387
+ function PipesItems({ integrations }) {
1388
+ return integrations.map((integration) => /* @__PURE__ */ jsx(CardList.Item, { children: /* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", align: "center", gap: "2", children: [
1386
1389
  /* @__PURE__ */ jsxs(Flex, { gap: "4", align: "center", children: [
1387
1390
  /* @__PURE__ */ jsx(IconPanel, { color: "panel", children: /* @__PURE__ */ jsx(DataIntegrationIcon, { integration, size: "2" }) }),
1388
1391
  /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: integration.name })
1389
1392
  ] }),
1390
1393
  /* @__PURE__ */ jsx(ProviderStatus, { integration })
1391
- ] }) }, integration.id)) });
1394
+ ] }) }, integration.id));
1395
+ }
1396
+ function PipesEmptyItem({ isFiltered }) {
1397
+ return /* @__PURE__ */ jsx(CardList.Item, { children: /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", children: isFiltered ? /* @__PURE__ */ jsx(
1398
+ Translation,
1399
+ {
1400
+ defaultMessage: "No integrations to show.",
1401
+ id: "cAs7JC",
1402
+ description: "Empty state shown when the host's filter leaves no integrations to list"
1403
+ }
1404
+ ) : /* @__PURE__ */ jsx(
1405
+ Translation,
1406
+ {
1407
+ defaultMessage: "No integrations are available yet.",
1408
+ id: "oK0Rjh",
1409
+ description: "Empty state shown when no integrations are enabled at all"
1410
+ }
1411
+ ) }) });
1412
+ }
1413
+ const Pipes = ({
1414
+ integrations,
1415
+ hasUnfilteredIntegrations,
1416
+ ...domProps
1417
+ }) => {
1418
+ return /* @__PURE__ */ jsx(CardList.Root, { ...getWidgetRootDomProps("resolved", domProps), children: integrations.length > 0 ? /* @__PURE__ */ jsx(PipesItems, { integrations }) : /* @__PURE__ */ jsx(PipesEmptyItem, { isFiltered: hasUnfilteredIntegrations ?? false }) });
1419
+ };
1420
+ function SharedConnectionStatus({
1421
+ connection
1422
+ }) {
1423
+ const isAvailable = connection.connected_accounts.some(
1424
+ (account) => account.availability === "available"
1425
+ );
1426
+ return isAvailable ? /* @__PURE__ */ jsx(Status, { state: "success", children: /* @__PURE__ */ jsx(
1427
+ Translation,
1428
+ {
1429
+ defaultMessage: "Available",
1430
+ id: "_jQjSu",
1431
+ description: "Status text for a shared connection the member can use"
1432
+ }
1433
+ ) }) : /* @__PURE__ */ jsx(Status, { state: "warning", children: /* @__PURE__ */ jsx(
1434
+ Translation,
1435
+ {
1436
+ defaultMessage: "Needs admin attention",
1437
+ id: "K5YoFj",
1438
+ description: "Status text for a shared connection an administrator must repair"
1439
+ }
1440
+ ) });
1441
+ }
1442
+ function SectionedItem({
1443
+ icon,
1444
+ name,
1445
+ status,
1446
+ description,
1447
+ actions
1448
+ }) {
1449
+ return /* @__PURE__ */ jsx(CardList.Item, { children: /* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", align: "center", gap: "4", children: [
1450
+ /* @__PURE__ */ jsxs(Flex, { gap: "4", align: "center", children: [
1451
+ /* @__PURE__ */ jsx(IconPanel, { color: "panel", children: icon }),
1452
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "1", children: [
1453
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", wrap: "wrap", children: [
1454
+ /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: name }),
1455
+ status
1456
+ ] }),
1457
+ description && /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", children: description })
1458
+ ] })
1459
+ ] }),
1460
+ actions
1461
+ ] }) });
1462
+ }
1463
+ function SharedConnectionItem({
1464
+ connection
1465
+ }) {
1466
+ return /* @__PURE__ */ jsx(
1467
+ SectionedItem,
1468
+ {
1469
+ icon: /* @__PURE__ */ jsx(
1470
+ DataIntegrationIcon,
1471
+ {
1472
+ integration: {
1473
+ integrationType: connection.slug,
1474
+ iconSlug: connection.iconSlug,
1475
+ iconUrl: connection.iconUrl,
1476
+ iconDarkUrl: connection.iconDarkUrl
1477
+ },
1478
+ size: "2"
1479
+ }
1480
+ ),
1481
+ name: connection.name,
1482
+ status: /* @__PURE__ */ jsx(SharedConnectionStatus, { connection }),
1483
+ description: connection.description
1484
+ }
1485
+ );
1486
+ }
1487
+ function MemberConnectionStatus({
1488
+ integration
1489
+ }) {
1490
+ const installation = integration.installation;
1491
+ if (!installation) {
1492
+ return null;
1493
+ }
1494
+ if (installation.state === "connected") {
1495
+ return /* @__PURE__ */ jsx(Status, { state: "success", children: installation.auth_method === "api_key" ? /* @__PURE__ */ jsx(
1496
+ Translation,
1497
+ {
1498
+ defaultMessage: "Connected via API key",
1499
+ id: "jQLTNe",
1500
+ description: "Status text for a connection established with an API key"
1501
+ }
1502
+ ) : installation.auth_method === "client_credentials" ? /* @__PURE__ */ jsx(
1503
+ Translation,
1504
+ {
1505
+ defaultMessage: "Connected via client credentials",
1506
+ id: "hQKIrx",
1507
+ description: "Status text for a connection established with client credentials"
1508
+ }
1509
+ ) : /* @__PURE__ */ jsx(
1510
+ Translation,
1511
+ {
1512
+ defaultMessage: "Connected via OAuth",
1513
+ id: "pJcK_M",
1514
+ description: "Status text for a connection established with OAuth"
1515
+ }
1516
+ ) });
1517
+ }
1518
+ return /* @__PURE__ */ jsx(Status, { state: "warning", children: installation.auth_method === "api_key" ? /* @__PURE__ */ jsx(
1519
+ Translation,
1520
+ {
1521
+ defaultMessage: "Update your API key",
1522
+ id: "-YLPTk",
1523
+ description: "Status text for a connection whose API key stopped working"
1524
+ }
1525
+ ) : /* @__PURE__ */ jsx(
1526
+ Translation,
1527
+ {
1528
+ defaultMessage: "Requires reauthorization",
1529
+ id: "dqczQS",
1530
+ description: "Status text for integration needing reauthorization"
1531
+ }
1532
+ ) });
1533
+ }
1534
+ function MemberConnectionActions({
1535
+ integration
1536
+ }) {
1537
+ const [disconnectOpen, setDisconnectOpen] = useState(false);
1538
+ const [apiKeyOpen, setApiKeyOpen] = useState(false);
1539
+ const [clientCredentialsOpen, setClientCredentialsOpen] = useState(false);
1540
+ const [reauthConfigOpen, setReauthConfigOpen] = useState(false);
1541
+ const authorizeEventHandler = useOpenDataIntegrationAuthorizeUrl(integration);
1542
+ const translate = useTranslation();
1543
+ const pipeActionsTitle = translate({
1544
+ defaultMessage: "Pipe actions",
1545
+ id: "1uF9ve",
1546
+ description: "Title for pipe actions dropdown button"
1547
+ });
1548
+ const unpinnedFields = getUnpinnedInstallationFields(integration);
1549
+ if (!integration.installation) {
1550
+ const authMethods = integration.authMethods ?? [];
1551
+ const methods = CONNECT_AUTH_METHODS.filter(
1552
+ (method) => authMethods.includes(method)
1553
+ );
1554
+ return methods.length > 1 ? /* @__PURE__ */ jsx(MultiMethodConnectButton, { integration, methods }) : methods.length === 1 && methods[0] === "api_key" ? /* @__PURE__ */ jsx(ApiKeyConnectButton, { integration }) : methods.length === 1 && methods[0] === "client_credentials" ? /* @__PURE__ */ jsx(ClientCredentialsConnectButton, { integration }) : /* @__PURE__ */ jsx(ConnectIntegrationButton, { integration });
1555
+ }
1556
+ const connected = integration.installation.state === "connected";
1557
+ const isApiKeyInstallation = integration.installation.auth_method === "api_key";
1558
+ const isClientCredentialsInstallation = integration.installation.auth_method === "client_credentials";
1559
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1560
+ /* @__PURE__ */ jsx(
1561
+ DisconnectAccountDialog,
1562
+ {
1563
+ integrationName: integration.name,
1564
+ installationId: integration.installation.id,
1565
+ open: disconnectOpen,
1566
+ onOpenChange: setDisconnectOpen
1567
+ }
1568
+ ),
1569
+ apiKeyOpen && /* @__PURE__ */ jsx(
1570
+ ApiKeyDialog,
1571
+ {
1572
+ integration,
1573
+ open: apiKeyOpen,
1574
+ onOpenChange: setApiKeyOpen
1575
+ }
1576
+ ),
1577
+ clientCredentialsOpen && /* @__PURE__ */ jsx(
1578
+ ClientCredentialsDialog,
1579
+ {
1580
+ integration,
1581
+ fields: unpinnedFields,
1582
+ open: clientCredentialsOpen,
1583
+ onOpenChange: setClientCredentialsOpen
1584
+ }
1585
+ ),
1586
+ unpinnedFields.length > 0 && !isClientCredentialsInstallation && /* @__PURE__ */ jsx(
1587
+ ConnectDialog,
1588
+ {
1589
+ integration,
1590
+ fields: unpinnedFields,
1591
+ open: reauthConfigOpen,
1592
+ onOpenChange: setReauthConfigOpen
1593
+ }
1594
+ ),
1595
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "4", children: [
1596
+ !connected && (isApiKeyInstallation ? /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => setApiKeyOpen(true), children: /* @__PURE__ */ jsx(
1597
+ Translation,
1598
+ {
1599
+ defaultMessage: "Update key",
1600
+ id: "MP-aOE",
1601
+ description: "Button to replace the API key of a connection that stopped working"
1602
+ }
1603
+ ) }) : isClientCredentialsInstallation ? /* @__PURE__ */ jsx(
1604
+ Button,
1605
+ {
1606
+ variant: "secondary",
1607
+ onClick: () => setClientCredentialsOpen(true),
1608
+ children: /* @__PURE__ */ jsx(
1609
+ Translation,
1610
+ {
1611
+ defaultMessage: "Update credentials",
1612
+ id: "1inB3Y",
1613
+ description: "Button to update the client credentials of a connection that stopped working"
1614
+ }
1615
+ )
1616
+ }
1617
+ ) : /* @__PURE__ */ jsx(
1618
+ Button,
1619
+ {
1620
+ variant: "secondary",
1621
+ onClick: async () => {
1622
+ if (unpinnedFields.length > 0) {
1623
+ setReauthConfigOpen(true);
1624
+ return;
1625
+ }
1626
+ try {
1627
+ await authorizeEventHandler();
1628
+ } catch {
1629
+ }
1630
+ },
1631
+ children: /* @__PURE__ */ jsx(
1632
+ Translation,
1633
+ {
1634
+ defaultMessage: "Reauthorize",
1635
+ id: "3IbiTG",
1636
+ description: "Button to reauthorize a connection that stopped working"
1637
+ }
1638
+ )
1639
+ }
1640
+ )),
1641
+ /* @__PURE__ */ jsxs(DropdownMenu.Root, { children: [
1642
+ /* @__PURE__ */ jsx(DropdownMenu.Trigger, { children: /* @__PURE__ */ jsx(IconButton, { title: pipeActionsTitle, children: /* @__PURE__ */ jsx(DotsHorizontalIcon, {}) }) }),
1643
+ /* @__PURE__ */ jsxs(DropdownMenu.Content, { align: "end", children: [
1644
+ connected && isApiKeyInstallation && /* @__PURE__ */ jsx(DropdownMenu.Item, { onClick: () => setApiKeyOpen(true), children: /* @__PURE__ */ jsx(
1645
+ Translation,
1646
+ {
1647
+ defaultMessage: "Rotate API key",
1648
+ id: "GML+c8",
1649
+ description: "Menu option to rotate the API key"
1650
+ }
1651
+ ) }),
1652
+ connected && isClientCredentialsInstallation && /* @__PURE__ */ jsx(DropdownMenu.Item, { onClick: () => setClientCredentialsOpen(true), children: /* @__PURE__ */ jsx(
1653
+ Translation,
1654
+ {
1655
+ defaultMessage: "Update client credentials",
1656
+ id: "daHKWE",
1657
+ description: "Menu option to update stored client credentials"
1658
+ }
1659
+ ) }),
1660
+ /* @__PURE__ */ jsx(
1661
+ DropdownMenu.Item,
1662
+ {
1663
+ variant: "destructive",
1664
+ onClick: () => setDisconnectOpen(true),
1665
+ children: /* @__PURE__ */ jsx(
1666
+ Translation,
1667
+ {
1668
+ defaultMessage: "Disconnect account",
1669
+ id: "esZQrd",
1670
+ description: "Menu option to disconnect an account"
1671
+ }
1672
+ )
1673
+ }
1674
+ )
1675
+ ] })
1676
+ ] })
1677
+ ] })
1678
+ ] });
1679
+ }
1680
+ function MemberConnectionItems({
1681
+ integrations
1682
+ }) {
1683
+ return integrations.map((integration) => /* @__PURE__ */ jsx(
1684
+ SectionedItem,
1685
+ {
1686
+ icon: /* @__PURE__ */ jsx(DataIntegrationIcon, { integration, size: "2" }),
1687
+ name: integration.name,
1688
+ status: /* @__PURE__ */ jsx(MemberConnectionStatus, { integration }),
1689
+ description: integration.description,
1690
+ actions: /* @__PURE__ */ jsx(MemberConnectionActions, { integration })
1691
+ },
1692
+ integration.id
1693
+ ));
1694
+ }
1695
+ function PipesSection({
1696
+ title,
1697
+ description,
1698
+ children
1699
+ }) {
1700
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "3", children: [
1701
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "1", children: [
1702
+ /* @__PURE__ */ jsx(Text, { size: "3", weight: "bold", children: title }),
1703
+ /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", children: description })
1704
+ ] }),
1705
+ children
1706
+ ] });
1707
+ }
1708
+ const PipesSections = ({
1709
+ integrations,
1710
+ hasUnfilteredIntegrations,
1711
+ sharedConnections,
1712
+ hasUnfilteredSharedConnections,
1713
+ isSharedLoading,
1714
+ organizationName,
1715
+ ...domProps
1716
+ }) => {
1717
+ return /* @__PURE__ */ jsxs(
1718
+ Flex,
1719
+ {
1720
+ direction: "column",
1721
+ gap: "5",
1722
+ ...getWidgetRootDomProps("resolved", domProps),
1723
+ children: [
1724
+ (isSharedLoading || sharedConnections.length > 0 || hasUnfilteredSharedConnections) && /* @__PURE__ */ jsx(
1725
+ PipesSection,
1726
+ {
1727
+ title: /* @__PURE__ */ jsx(
1728
+ Translation,
1729
+ {
1730
+ defaultMessage: "Shared connections",
1731
+ id: "Fcd-bK",
1732
+ description: "Heading for the section listing connections the organization owns"
1733
+ }
1734
+ ),
1735
+ description: organizationName ? /* @__PURE__ */ jsx(
1736
+ Translation,
1737
+ {
1738
+ defaultMessage: "Accounts {organizationName} owns and shares with everyone.",
1739
+ id: "7U8P0v",
1740
+ description: "Description of the shared connections section, naming the organization",
1741
+ values: { organizationName }
1742
+ }
1743
+ ) : /* @__PURE__ */ jsx(
1744
+ Translation,
1745
+ {
1746
+ defaultMessage: "Accounts your organization owns and shares with everyone.",
1747
+ id: "72FEZi",
1748
+ description: "Description of the shared connections section when the organization name is unknown"
1749
+ }
1750
+ ),
1751
+ children: /* @__PURE__ */ jsx(CardList.Root, { children: isSharedLoading ? /* @__PURE__ */ jsx(PipesSkeletonItems, { count: 2 }) : sharedConnections.length > 0 ? sharedConnections.map((connection) => /* @__PURE__ */ jsx(
1752
+ SharedConnectionItem,
1753
+ {
1754
+ connection
1755
+ },
1756
+ connection.id
1757
+ )) : /* @__PURE__ */ jsx(PipesEmptyItem, { isFiltered: true }) })
1758
+ }
1759
+ ),
1760
+ /* @__PURE__ */ jsx(
1761
+ PipesSection,
1762
+ {
1763
+ title: /* @__PURE__ */ jsx(
1764
+ Translation,
1765
+ {
1766
+ defaultMessage: "Your connections",
1767
+ id: "-VDI3G",
1768
+ description: "Heading for the section listing the member's own connections"
1769
+ }
1770
+ ),
1771
+ description: /* @__PURE__ */ jsx(
1772
+ Translation,
1773
+ {
1774
+ defaultMessage: "Connect your account to access these connections.",
1775
+ id: "ObXqUu",
1776
+ description: "Description of the personal connections section"
1777
+ }
1778
+ ),
1779
+ children: /* @__PURE__ */ jsx(CardList.Root, { children: integrations.length > 0 ? /* @__PURE__ */ jsx(MemberConnectionItems, { integrations }) : /* @__PURE__ */ jsx(PipesEmptyItem, { isFiltered: hasUnfilteredIntegrations ?? false }) })
1780
+ }
1781
+ )
1782
+ ]
1783
+ }
1784
+ );
1392
1785
  };
1393
1786
  const PipesError = ({ error, ...domProps }) => {
1394
1787
  return /* @__PURE__ */ jsx(Card, { size: "2", ...getWidgetRootDomProps("error", domProps), children: /* @__PURE__ */ jsx(GenericError, { error }) });
@@ -1404,6 +1797,7 @@ function getWidgetRootDomProps(state, domProps) {
1404
1797
  export {
1405
1798
  Pipes,
1406
1799
  PipesError,
1407
- PipesLoading
1800
+ PipesLoading,
1801
+ PipesSections
1408
1802
  };
1409
1803
  //# sourceMappingURL=pipes.js.map