@robosystems/core 0.14.1 → 0.15.1

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.
@@ -9,6 +9,7 @@ import { useGraphContext } from '../../contexts/graph-context';
9
9
  import { useOrg } from '../../contexts/org-context';
10
10
  import { useServiceOfferings } from '../../contexts/service-offerings-context';
11
11
  import { useToast } from '../../hooks/use-toast';
12
+ import { useUser } from '../../hooks/use-user';
12
13
  import { unwrapSdk } from '../../lib/sdk-errors';
13
14
  export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStarted, onBackups, onBilling, onBrowse, onCancel, emptyState, }) {
14
15
  const [userSubscriptions, setUserSubscriptions] = useState([]);
@@ -18,6 +19,7 @@ export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStart
18
19
  const [loadError, setLoadError] = useState(null);
19
20
  const { showError, ToastContainer } = useToast();
20
21
  const { currentOrg } = useOrg();
22
+ const { user } = useUser();
21
23
  const { offerings, isLoading: offeringsLoading } = useServiceOfferings();
22
24
  const { setCurrentGraph } = useGraphContext();
23
25
  const loadData = useCallback(async () => {
@@ -32,7 +34,10 @@ export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStart
32
34
  path: { org_id: currentOrg.id },
33
35
  }));
34
36
  if (subscriptions) {
35
- const repositorySubscriptions = (subscriptions || []).filter((sub) => sub.resource_type === 'repository');
37
+ // An owner or admin is listed every member's seat; the viewer's
38
+ // subscription is only their own (or an org seat with no owner).
39
+ const repositorySubscriptions = (subscriptions || []).filter((sub) => sub.resource_type === 'repository' &&
40
+ (!sub.user_id || sub.user_id === (user === null || user === void 0 ? void 0 : user.id)));
36
41
  setUserSubscriptions(repositorySubscriptions);
37
42
  }
38
43
  else {
@@ -50,7 +55,7 @@ export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStart
50
55
  finally {
51
56
  setLoading(false);
52
57
  }
53
- }, [currentOrg === null || currentOrg === void 0 ? void 0 : currentOrg.id, showError]);
58
+ }, [currentOrg === null || currentOrg === void 0 ? void 0 : currentOrg.id, user === null || user === void 0 ? void 0 : user.id, showError]);
54
59
  useEffect(() => {
55
60
  loadData();
56
61
  }, [loadData]);
@@ -9,6 +9,7 @@ import { useGraphContext } from '../../contexts/graph-context';
9
9
  import { useOrg } from '../../contexts/org-context';
10
10
  import { useServiceOfferings } from '../../contexts/service-offerings-context';
11
11
  import { useToast } from '../../hooks/use-toast';
12
+ import { useUser } from '../../hooks/use-user';
12
13
  import { unwrapSdk } from '../../lib/sdk-errors';
13
14
  import { useRepositorySubscription } from '../../task-monitoring/operationHooks';
14
15
  export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHeader = true, showInfoCard = true, }) {
@@ -22,6 +23,7 @@ export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHead
22
23
  const [planChangeModal, setPlanChangeModal] = useState(null);
23
24
  const { showSuccess, showError, ToastContainer } = useToast();
24
25
  const { currentOrg } = useOrg();
26
+ const { user } = useUser();
25
27
  const { offerings, isLoading: offeringsLoading } = useServiceOfferings();
26
28
  const repositorySubscription = useRepositorySubscription();
27
29
  const { setCurrentGraph, refreshGraphs } = useGraphContext();
@@ -38,7 +40,10 @@ export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHead
38
40
  path: { org_id: currentOrg.id },
39
41
  }));
40
42
  if (subscriptions) {
41
- const repositorySubscriptions = (subscriptions || []).filter((sub) => sub.resource_type === 'repository');
43
+ // An owner or admin is listed every member's seat; the viewer's
44
+ // subscription is only their own (or an org seat with no owner).
45
+ const repositorySubscriptions = (subscriptions || []).filter((sub) => sub.resource_type === 'repository' &&
46
+ (!sub.user_id || sub.user_id === (user === null || user === void 0 ? void 0 : user.id)));
42
47
  setUserSubscriptions(repositorySubscriptions);
43
48
  }
44
49
  else {
@@ -56,7 +61,7 @@ export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHead
56
61
  finally {
57
62
  setLoading(false);
58
63
  }
59
- }, [currentOrg === null || currentOrg === void 0 ? void 0 : currentOrg.id, showError]);
64
+ }, [currentOrg === null || currentOrg === void 0 ? void 0 : currentOrg.id, user === null || user === void 0 ? void 0 : user.id, showError]);
60
65
  useEffect(() => {
61
66
  loadData();
62
67
  }, [loadData]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/core",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "description": "Shared RoboSystems frontend core library (auth, contexts, task monitoring, UI components) for the RoboSystems Next.js apps",
5
5
  "license": "MIT",
6
6
  "private": false,