-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathutils.tsx
More file actions
59 lines (51 loc) · 1.81 KB
/
Copy pathutils.tsx
File metadata and controls
59 lines (51 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Configuration, PublicClientApplication } from '@azure/msal-browser'
import { Feature } from '@/models/model'
export const getMsalConfig = () => {
// Use runtime environment variables if found in env-config.js, otherwise fallback to
// env settings defined in build time.
// Note: env-config.js is generated on the flying during contain app starts.
const clientId = window.environment?.azureClientId ?? process.env.REACT_APP_AZURE_CLIENT_ID
const tenantId = window.environment?.azureTenantId ?? process.env.REACT_APP_AZURE_TENANT_ID
const authority = `https://login.microsoftonline.com/${tenantId}`
const msalConfig: Configuration = {
auth: {
clientId: clientId,
authority: authority,
redirectUri: window.location.origin
}
}
return new PublicClientApplication(msalConfig)
}
export const enum FeatureType {
AllNodes = 'all_nodes',
Source = 'feathr_source_v1',
Anchor = 'feathr_anchor_v1',
AnchorFeature = 'feathr_anchor_feature_v1',
DerivedFeature = 'feathr_derived_feature_v1'
}
export const isFeature = (featureType: string) => {
return (
featureType === FeatureType.AnchorFeature ||
featureType === FeatureType.DerivedFeature ||
featureType === FeatureType.Source
)
}
export const getFeatureDetailUrl = (project: string, feature: Feature) => {
switch (feature.typeName) {
case FeatureType.Source:
return `/projects/${project}/dataSources/${feature.guid}`
case FeatureType.AnchorFeature:
case FeatureType.DerivedFeature:
return `/projects/${project}/features/${feature.guid}`
default:
return
}
}
export const getJSONMap = (json: any = {}) => {
return Object.keys(json).map((key) => {
return { label: key, key }
})
}
export const isEmpty = (obj: any = {}) => {
return !obj || Object.getOwnPropertyNames(obj).length === 0
}