@stack-spot/portal-network 0.53.2 → 0.54.0

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.
@@ -1,5 +1,6 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import {
2
+ import
3
+ {
3
4
  createApplication,
4
5
  createCidr,
5
6
  createDeployment,
@@ -20,7 +21,6 @@ import {
20
21
  listCidr,
21
22
  listDeployments,
22
23
  listDnsZone,
23
- listFolder,
24
24
  listFoundations,
25
25
  listRepositories,
26
26
  listRuntimes,
@@ -101,10 +101,6 @@ class CloudPlatformClient extends ReactQueryNetworkClient {
101
101
  * Get a foundation by id
102
102
  */
103
103
  foundation = this.query(removeAuthorizationParam(getFoundation))
104
- /**
105
- * Get list of foundations folders or folder by id
106
- */
107
- listFolder = this.query(removeAuthorizationParam(listFolder))
108
104
  /**
109
105
  * Get list of foundations folders or folder by id
110
106
  */
@@ -12,7 +12,7 @@ import {
12
12
  getStudiosToCreateButton, getStudioTabs, getUnusedStackVersions, getWorkflow, getWorkflowByStudioSlug, getWorkflowDoc,
13
13
  listActions, listActions1,
14
14
  listActionsByFilters1, listConnectionInterfaceTypes, listLinksByStackVersion, listPlugins, listPluginVersionByIdsController,
15
- listReasons, listStacksByFilters, listStarters, listWorkflowVersion,
15
+ listReasons, listStacks, listStacksByFilters, listStarters, listWorkflowVersion,
16
16
  listWorkspaces, patchStarterV2, removeActionFromPlugin, stackModalViewSummary,
17
17
  stackVersionUsageSummary, updateStudio, updateStudioTabs,
18
18
  } from '../api/content'
@@ -303,6 +303,10 @@ class ContentClient extends ReactQueryNetworkClient {
303
303
  * Gets a stack from a stack version id
304
304
  */
305
305
  getStackByVersionId = this.query(getStackVersionById)
306
+ /**
307
+ * View all stacks by account
308
+ */
309
+ getAllStacks = this.query(listStacks)
306
310
  }
307
311
 
308
312
  export const contentClient = new ContentClient()
@@ -0,0 +1,24 @@
1
+ import { HttpError } from '@oazapfts/runtime'
2
+ import { defaults, downloadAccountData } from '../api/insights'
3
+ import apis from '../apis.json'
4
+ import { DefaultAPIError } from '../error/DefaultAPIError'
5
+ import { baseDictionary } from '../error/dictionary/base'
6
+ import { StackspotAPIError } from '../error/StackspotAPIError'
7
+ import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
8
+
9
+ class InsightsClient extends ReactQueryNetworkClient {
10
+
11
+ constructor() {
12
+ super(apis.insights.url, defaults)
13
+ }
14
+
15
+ protected buildStackSpotError(error: HttpError): StackspotAPIError {
16
+ return new DefaultAPIError(error.data, error.status, baseDictionary, error.headers)
17
+ }
18
+ /**
19
+ * Download account Data
20
+ */
21
+ downloadAccountData = this.query(downloadAccountData)
22
+ }
23
+
24
+ export const insightsClient = new InsightsClient()
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export { cloudPlatformClient } from './client/cloud-platform'
7
7
  export { cloudServicesClient } from './client/cloud-services'
8
8
  export { contentClient } from './client/content'
9
9
  export { eventBusClient } from './client/event-bus'
10
+ export { insightsClient } from './client/insights'
10
11
  export { notificationClient } from './client/notification'
11
12
  export { runtimeManagerClient } from './client/runtime-manager'
12
13
  export { secretsClient } from './client/secrets'
@@ -24,4 +25,5 @@ export { NetworkClient } from './network/NetworkClient'
24
25
  export { queryClient } from './network/react-query-client'
25
26
  export { OperationResult, OperationVariables, UseQueryObjectOptions } from './network/types'
26
27
  export { StreamedJson } from './utils/StreamedJson'
28
+ export { useCanViewOrg } from './utils/use-can-view-org'
27
29
  export { useExtendedList } from './utils/use-extended-list'
@@ -0,0 +1,30 @@
1
+ import { accountClient } from '../client/account'
2
+ import { contentClient } from '../client/content'
3
+ import { insightsClient } from '../client/insights'
4
+ import { workspaceClient } from '../client/workspace'
5
+
6
+ export const useCanViewOrg = ({ accountSlug }: { accountSlug: string }) => {
7
+ const [canCreateEnvironments] = workspaceClient.createEnvironment.useAllowed()
8
+ const [canViewWorkflows] = workspaceClient.accountWorkflows.useAllowed()
9
+ const [canViewVariables] = workspaceClient.accountVariables.useAllowed()
10
+ const [canCreateScm] = accountClient.createSCMCredential.useAllowed()
11
+ const [canViewPartner] = accountClient.partners.useAllowed()
12
+ const [canViewAllByAccount] = contentClient.getAllStacks.useAllowed()
13
+ const canViewEdp = canCreateEnvironments || canViewWorkflows || canViewVariables || canCreateScm || canViewPartner || canViewAllByAccount
14
+
15
+ const [canViewSSO] = accountClient.allSSO.useAllowed()
16
+ const [canDownloadEventHistory] = insightsClient.downloadAccountData.useAllowed({ accountSlug })
17
+ const [canViewServiceCredential] = accountClient.allServiceCredentials.useAllowed()
18
+
19
+ const canViewIdentitySecurity = canViewSSO || canDownloadEventHistory || canViewServiceCredential
20
+
21
+ const [canViewMembers] = accountClient.allMembers.useAllowed()
22
+ const [canViewRoles] = accountClient.allRoles.useAllowed()
23
+ const [canViewGroups] = accountClient.allGroups.useAllowed()
24
+
25
+ const canViewAccessManagement = canViewMembers || canViewRoles || canViewGroups
26
+
27
+ const canViewGeneralSettings = canViewIdentitySecurity || canViewAccessManagement
28
+
29
+ return canViewGeneralSettings || canViewEdp
30
+ }