@integry/sdk 4.5.2 → 4.5.4
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.
- package/.vscode/launch.json +2 -2
- package/THIRD_PARTY_LICENSES +0 -37
- package/dist/esm/index.csm.d.ts +12 -2
- package/dist/esm/index.csm.js +7262 -1
- package/dist/umd/index.umd.d.ts +9 -1
- package/dist/umd/index.umd.js +7262 -1
- package/jest.config.cjs +10 -0
- package/package.json +10 -4
- package/src/components/AddTagButton/index.ts +23 -0
- package/src/components/BasicSelect/index.ts +114 -0
- package/src/components/BasicSelect/styles.module.scss +44 -0
- package/src/components/Button/index.ts +94 -0
- package/src/components/Button/styles.module.scss +152 -0
- package/src/components/CheckboxGroup/Checkbox.ts +104 -0
- package/src/components/CheckboxGroup/index.ts +190 -0
- package/src/components/CheckboxGroup/styles.module.scss +63 -0
- package/src/components/CollapsedMenu/index.ts +101 -0
- package/src/components/CollapsedMenu/styles.module.scss +46 -0
- package/src/components/ConfigureFieldWrapper/index.ts +85 -0
- package/src/components/ConfigureFieldWrapper/styles.module.scss +57 -0
- package/src/components/EditableText/index.ts +121 -0
- package/src/components/EditableText/styles.module.scss +38 -0
- package/src/components/EditableTextArea/index.ts +143 -0
- package/src/components/EditableTextArea/styles.module.scss +91 -0
- package/src/components/ErrorMessage/index.ts +16 -0
- package/src/components/ErrorMessage/styles.module.scss +19 -0
- package/src/components/ErrorPage/index.ts +42 -0
- package/src/components/ErrorPage/styles.module.scss +26 -0
- package/src/components/Footer/index.ts +41 -0
- package/src/components/Footer/styles.module.scss +40 -0
- package/src/components/HTMLContent/index.tsx +275 -0
- package/src/components/HTMLContent/styles.module.scss +3 -0
- package/src/components/InfoBox/index.ts +48 -0
- package/src/components/InfoBox/styles.module.scss +21 -0
- package/src/components/Input/BaseInput/index.ts +170 -0
- package/src/components/Input/BaseInput/styles.module.scss +94 -0
- package/src/components/Input/DateInput/index.ts +103 -0
- package/src/components/Input/DateInput/styles.module.scss +50 -0
- package/src/components/Input/Input/index.ts +206 -0
- package/src/components/Input/Input/styles.module.scss +14 -0
- package/src/components/Input/PasswordInput/index.ts +164 -0
- package/src/components/Input/PasswordInput/styles.module.scss +37 -0
- package/src/components/Input/index.ts +7 -0
- package/src/components/Label/index.ts +61 -0
- package/src/components/Label/styles.module.scss +41 -0
- package/src/components/LargeLoader/index.ts +25 -0
- package/src/components/LargeLoader/styles.module.scss +16 -0
- package/src/components/Listbox/ListBoxItem.ts +57 -0
- package/src/components/Listbox/index.ts +479 -0
- package/src/components/Listbox/styles.module.scss +197 -0
- package/src/components/Loader/index.ts +25 -0
- package/src/components/Loader/styles.module.scss +16 -0
- package/src/components/MediaGallery/MediaGalleryModal.ts +82 -0
- package/src/components/MediaGallery/MediaSlider.ts +76 -0
- package/src/components/MediaGallery/index.ts +92 -0
- package/src/components/MediaGallery/styles.module.scss +156 -0
- package/src/components/MediaUpload/index.ts +233 -0
- package/src/components/MediaUpload/styles.module.scss +118 -0
- package/src/components/Modal/index.ts +87 -0
- package/src/components/Modal/styles.module.scss +441 -0
- package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +58 -0
- package/src/components/MultipurposeField/Dropdown/index.tsx +981 -0
- package/src/components/MultipurposeField/Dropdown/styles.module.scss +208 -0
- package/src/components/MultipurposeField/TagMenu/index.ts +384 -0
- package/src/components/MultipurposeField/TagMenu/styles.module.scss +136 -0
- package/src/components/MultipurposeField/TagOptions/index.tsx +83 -0
- package/src/components/MultipurposeField/TagOptions/styles.module.scss +95 -0
- package/src/components/MultipurposeField/index.tsx +687 -0
- package/src/components/MultipurposeField/styles.module.scss +56 -0
- package/src/components/NewModal/index.ts +69 -0
- package/src/components/NewModal/styles.module.scss +70 -0
- package/src/components/OverflowTooltip/index.tsx +59 -0
- package/src/components/PopUp/ConfirmationPopUp/index.ts +58 -0
- package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +49 -0
- package/src/components/PopUp/SuccessPopUp/index.ts +62 -0
- package/src/components/PopUp/SuccessPopUp/styles.module.scss +38 -0
- package/src/components/RadioGroup/Radio.ts +129 -0
- package/src/components/RadioGroup/index.ts +169 -0
- package/src/components/RadioGroup/styles.module.scss +81 -0
- package/src/components/Search/index.ts +69 -0
- package/src/components/Search/styles.module.scss +149 -0
- package/src/components/TabBar/Tab.ts +33 -0
- package/src/components/TabBar/index.ts +64 -0
- package/src/components/TabBar/styles.module.scss +43 -0
- package/src/components/Tag/index.ts +29 -0
- package/src/components/Tag/styles.module.scss +57 -0
- package/src/components/TextArea/index.ts +172 -0
- package/src/components/TextArea/styles.module.scss +70 -0
- package/src/components/TextContent/index.tsx +128 -0
- package/src/components/TextContent/styles.module.scss +6 -0
- package/src/components/ThreeDotLoader/index.ts +39 -0
- package/src/components/ThreeDotLoader/styles.module.scss +41 -0
- package/src/components/TimeInput/index.ts +129 -0
- package/src/components/TimeInput/styles.module.scss +16 -0
- package/src/components/Toggle/index.ts +34 -0
- package/src/components/Toggle/styles.module.scss +56 -0
- package/src/components/Toggle-v2/index.ts +40 -0
- package/src/components/Toggle-v2/styles.module.scss +86 -0
- package/src/components/Tooltip/index.ts +271 -0
- package/src/components/Tooltip/styles.module.scss +105 -0
- package/src/components/form/ObjectField/index.ts +364 -0
- package/src/components/form/ObjectField/styles.module.scss +103 -0
- package/src/components/form/index.ts +3 -0
- package/src/contexts/AppContext.ts +12 -0
- package/src/declaration.d.ts +7 -0
- package/src/extensions/HMAC.ts +25 -0
- package/src/extensions/IntegryAPIError.ts +19 -0
- package/src/features/common/AccountDropdown/index.ts +291 -0
- package/src/features/common/AccountDropdown/styles.module.scss +19 -0
- package/src/features/common/ActionForm/index.ts +1818 -0
- package/src/features/common/ActionForm/styles.module.scss +23 -0
- package/src/features/common/AppCard/index.ts +207 -0
- package/src/features/common/AppCard/styles.module.scss +117 -0
- package/src/features/common/AppCardCompact/index.ts +189 -0
- package/src/features/common/AppCardCompact/styles.module.scss +141 -0
- package/src/features/common/AuthSelector/index.ts +537 -0
- package/src/features/common/AuthSelector/styles.module.scss +161 -0
- package/src/features/common/AuthSelectorCompact/index.ts +706 -0
- package/src/features/common/AuthSelectorCompact/styles.module.scss +219 -0
- package/src/features/common/AuthSelectorDropdown/index.ts +704 -0
- package/src/features/common/AuthSelectorDropdown/styles.module.scss +361 -0
- package/src/features/common/DynamicField/index.ts +229 -0
- package/src/features/common/DynamicField/styles.module.scss +67 -0
- package/src/features/common/DynamicTypedField/index.ts +217 -0
- package/src/features/common/DynamicTypedField/styles.module.scss +67 -0
- package/src/features/common/FunctionForm/index.ts +862 -0
- package/src/features/common/FunctionForm/styles.module.scss +163 -0
- package/src/features/common/MappingUI/index.ts +649 -0
- package/src/features/common/MappingUI/styles.module.scss +121 -0
- package/src/features/common/MarketplaceAppCard/index.ts +279 -0
- package/src/features/common/MarketplaceAppCard/styles.module.scss +231 -0
- package/src/features/common/MarketplaceAppCardCompact/index.ts +283 -0
- package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +255 -0
- package/src/features/common/NewMappingUI/index.ts +515 -0
- package/src/features/common/NewMappingUI/styles.module.scss +113 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +67 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +23 -0
- package/src/features/common/RequestAppWidget/index.ts +48 -0
- package/src/features/common/RequestAppWidget/request-app-form.ts +89 -0
- package/src/features/common/RequestAppWidget/styles.module.scss +43 -0
- package/src/features/common/SectionField/index.ts +272 -0
- package/src/features/common/SectionField/styles.module.scss +67 -0
- package/src/features/common/Step/index.ts +827 -0
- package/src/features/common/Step/styles.module.scss +12 -0
- package/src/features/common/StepNavigation/CollapsedSteps.ts +125 -0
- package/src/features/common/StepNavigation/NavItem.ts +111 -0
- package/src/features/common/StepNavigation/index.ts +257 -0
- package/src/features/common/StepNavigation/styles.module.scss +117 -0
- package/src/features/common/Steps/index.ts +1139 -0
- package/src/features/common/Steps/styles.module.scss +314 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +383 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +367 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +194 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +389 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +577 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +83 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +212 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +45 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +1081 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +452 -0
- package/src/features/containers/AppFlowContainer/Authentication/index.ts +610 -0
- package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +468 -0
- package/src/features/containers/AppFlowContainer/index.ts +114 -0
- package/src/features/containers/AppPageContainer/AppPage/index.tsx +262 -0
- package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +120 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +165 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +81 -0
- package/src/features/containers/AppPageContainer/index.tsx +93 -0
- package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
- package/src/features/containers/AppsForFlows/index.ts +161 -0
- package/src/features/containers/AppsForFlows/styles.module.scss +280 -0
- package/src/features/containers/AppsForFlowsCompact/index.ts +161 -0
- package/src/features/containers/AppsForFlowsCompact/styles.module.scss +279 -0
- package/src/features/containers/AuthSetupContainer/AppSelection.ts +73 -0
- package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +67 -0
- package/src/features/containers/AuthSetupContainer/Footer.ts +32 -0
- package/src/features/containers/AuthSetupContainer/Header.ts +39 -0
- package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +27 -0
- package/src/features/containers/AuthSetupContainer/index.ts +349 -0
- package/src/features/containers/AuthSetupContainer/styles.module.scss +229 -0
- package/src/features/containers/FlowSetupContainer/index.ts +390 -0
- package/src/features/containers/FlowSetupContainer/styles.module.scss +18 -0
- package/src/features/containers/MarkeplaceApps/index.ts +574 -0
- package/src/features/containers/MarkeplaceApps/styles.module.scss +559 -0
- package/src/features/containers/MarketplaceAppsCompact/index.ts +576 -0
- package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +546 -0
- package/src/features/containers/MarketplaceAppsContainer/index.ts +83 -0
- package/src/features/containers/MarketplaceContainer/AppCard/index.ts +91 -0
- package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +66 -0
- package/src/features/containers/MarketplaceContainer/AppListing/index.ts +34 -0
- package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +10 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +132 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +117 -0
- package/src/features/containers/MarketplaceContainer/index.ts +242 -0
- package/src/features/containers/MarketplaceContainer/styles.module.scss +84 -0
- package/src/features/containers/SDKContainer/index.ts +817 -0
- package/src/features/containers/SDKContainer/styles.module.scss +266 -0
- package/src/features/containers/SDKDebugContainer/index.ts +137 -0
- package/src/features/containers/SDKDebugContainer/styles.module.scss +37 -0
- package/src/features/containers/SDKFailedContainer/index.ts +117 -0
- package/src/features/containers/SDKFailedContainer/styles.module.scss +57 -0
- package/src/features/integrations/IntegrationRow/Icons.ts +77 -0
- package/src/features/integrations/IntegrationRow/index.ts +129 -0
- package/src/features/integrations/IntegrationRow/styles.module.scss +62 -0
- package/src/features/integrations/IntegrationsHeader/index.ts +34 -0
- package/src/features/integrations/IntegrationsHeader/styles.module.scss +47 -0
- package/src/features/integrations/IntegrationsList/index.ts +252 -0
- package/src/features/integrations/IntegrationsList/styles.module.scss +67 -0
- package/src/features/templates/Template/index.ts +295 -0
- package/src/features/templates/Template/styles.module.scss +226 -0
- package/src/features/templates/TemplatesView/index.ts +368 -0
- package/src/features/templates/TemplatesView/styles.module.scss +71 -0
- package/src/features/templates/TemplatesViewCompact/index.ts +364 -0
- package/src/features/templates/TemplatesViewCompact/styles.module.scss +141 -0
- package/src/hooks/useAutosizeTextArea.ts +22 -0
- package/src/hooks/useCustomRef.ts +13 -0
- package/src/hooks/useDebounce.ts +17 -0
- package/src/hooks/useElementResize.ts +40 -0
- package/src/hooks/useEventListener.ts +44 -0
- package/src/hooks/useHover.ts +40 -0
- package/src/hooks/useOnClickOutside.ts +32 -0
- package/src/index.ts +2051 -0
- package/src/index.umd.ts +13 -0
- package/src/interfaces/index.ts +924 -0
- package/src/modules/api/index.ts +1315 -0
- package/src/modules/api/responseHandler.ts +38 -0
- package/src/modules/event-emitter/index.ts +72 -0
- package/src/modules/event-emitter/runners/abstract.ts +21 -0
- package/src/modules/event-emitter/runners/default.ts +11 -0
- package/src/modules/event-emitter/runners/ntimes.ts +28 -0
- package/src/modules/event-emitter/types.ts +34 -0
- package/src/store/actionFunctions.ts +1573 -0
- package/src/store/index.ts +17 -0
- package/src/store/initialState.ts +58 -0
- package/src/stories/Button.stories.tsx +83 -0
- package/src/stories/Checkbox/Checkbox.stories.tsx +41 -0
- package/src/stories/Checkbox/CheckboxGroup.stories.tsx +46 -0
- package/src/stories/EditableText.stories.tsx +35 -0
- package/src/stories/Input/BaseInput.stories.tsx +48 -0
- package/src/stories/Input/DateInput.stories.tsx +28 -0
- package/src/stories/Input/Input.stories.tsx +24 -0
- package/src/stories/Input/PasswordInput.stories.tsx +26 -0
- package/src/stories/Introduction.stories.mdx +211 -0
- package/src/stories/Label.stories.tsx +27 -0
- package/src/stories/Listbox.stories.tsx +122 -0
- package/src/stories/Radio/Radio.stories.tsx +39 -0
- package/src/stories/Radio/RadioGroup.stories.tsx +46 -0
- package/src/stories/StepNavigation/NavItem.stories.tsx +31 -0
- package/src/stories/StepNavigation/StepNavigation.stories.tsx +50 -0
- package/src/stories/TabBar.stories.tsx +31 -0
- package/src/stories/TextArea.stories.tsx +23 -0
- package/src/stories/TimeInput.stories.tsx +37 -0
- package/src/stories/Toggle.stories.tsx +33 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/types/index.ts +293 -0
- package/src/types/store.ts +366 -0
- package/src/types/utils.ts +19 -0
- package/src/utils/ActivityOutputUtils.ts +163 -0
- package/src/utils/common.ts +20 -0
- package/src/utils/copyToClipboard.ts +24 -0
- package/src/utils/datetime.ts +101 -0
- package/src/utils/getUrlParam.ts +11 -0
- package/src/utils/isAuthMessage.ts +16 -0
- package/src/utils/isBrowser.ts +1 -0
- package/src/utils/jsonEncodeDecode.ts +15 -0
- package/src/utils/objectUtils.ts +116 -0
- package/src/utils/popup.ts +30 -0
- package/src/utils/searchJson.ts +51 -0
- package/src/utils/stepUtils.ts +45 -0
- package/src/utils/truncate.ts +6 -0
- package/test/setup.ts +1 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
import { html, Component } from 'htm/preact';
|
|
2
|
+
import { connect } from 'unistore/preact';
|
|
3
|
+
|
|
4
|
+
import { Loader } from '@/components/Loader';
|
|
5
|
+
import { IntegryAPI } from '@/modules/api';
|
|
6
|
+
import { Radio } from '@/components/RadioGroup/Radio';
|
|
7
|
+
import { Button, ButtonTypes } from '@/components/Button';
|
|
8
|
+
import { ErrorMessage } from '@/components/ErrorMessage';
|
|
9
|
+
import { Label } from '@/components/Label';
|
|
10
|
+
import { Hint } from '@/components/Tooltip';
|
|
11
|
+
import { Authorization, StoreType } from '@/types/store';
|
|
12
|
+
import { actionFunctions } from '@/store';
|
|
13
|
+
import isBrowser from '@/utils/isBrowser';
|
|
14
|
+
import AppContext from '@/contexts/AppContext';
|
|
15
|
+
|
|
16
|
+
import { openPopupWindow } from '@/utils/popup';
|
|
17
|
+
import { AuthData, isAuthMessage } from '@/utils/isAuthMessage';
|
|
18
|
+
|
|
19
|
+
import styles from './styles.module.scss';
|
|
20
|
+
|
|
21
|
+
interface AuthSelectorPropsType extends StoreType {
|
|
22
|
+
stepId: number;
|
|
23
|
+
apiHandler: IntegryAPI;
|
|
24
|
+
showErrors?: boolean;
|
|
25
|
+
onAuthSelected(
|
|
26
|
+
authId: number | null,
|
|
27
|
+
isVerified: boolean,
|
|
28
|
+
override: boolean,
|
|
29
|
+
): void;
|
|
30
|
+
forcedLoading?: boolean;
|
|
31
|
+
isReadOnly?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface AuthSelectorStateType {
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
fetched: boolean;
|
|
37
|
+
willDeleteAuthWithIndex: number | null;
|
|
38
|
+
gottoNextStepAfterAuth: boolean;
|
|
39
|
+
isSelfApp: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const Confirmation = (props: { callback(shouldDelete: boolean): void }) => {
|
|
43
|
+
const { callback } = props;
|
|
44
|
+
return html`
|
|
45
|
+
<div class=${styles.confirmation}>
|
|
46
|
+
<div class=${styles.confirmationText}>Are you sure?</div>
|
|
47
|
+
<button onclick=${() => callback(false)}>No</button>
|
|
48
|
+
<button onclick=${() => callback(true)}>Yes</button>
|
|
49
|
+
</div>
|
|
50
|
+
`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const Resend = () => html`
|
|
54
|
+
<svg
|
|
55
|
+
class=${styles.resend}
|
|
56
|
+
width="13"
|
|
57
|
+
height="15"
|
|
58
|
+
viewBox="0 0 13 15"
|
|
59
|
+
fill="none"
|
|
60
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
+
>
|
|
62
|
+
<path
|
|
63
|
+
d="M11.8403 5.34L10.1453 6.345C10.5053 6.96 10.7003 7.68 10.7003 8.445C10.7003 10.77 8.81031 12.645 6.50031 12.645C4.19031 12.645 2.30031 10.755 2.30031 8.445C2.30031 6.135 4.19031 4.245 6.50031 4.245V6.15L11.1053 3.27L6.50031 0.375V2.28C3.09531 2.28 0.320312 5.055 0.320312 8.46C0.320313 11.85 3.09531 14.625 6.50031 14.625C9.90531 14.625 12.6803 11.85 12.6803 8.445C12.6803 7.32 12.3653 6.255 11.8403 5.34Z"
|
|
64
|
+
fill="#8D8D8D"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
const STATUS_ICON = {
|
|
70
|
+
connected: html` <svg
|
|
71
|
+
data-hint="Connected"
|
|
72
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
+
width="12"
|
|
74
|
+
height="12"
|
|
75
|
+
viewBox="0 0 12 12"
|
|
76
|
+
fill="none"
|
|
77
|
+
>
|
|
78
|
+
<path
|
|
79
|
+
d="M5.07595 8.71074C4.99537 8.71124 4.91558 8.69526 4.8414 8.66377C4.76723 8.63229 4.70025 8.58597 4.64465 8.52767L2.70076 6.55521C2.64173 6.49997 2.59474 6.43321 2.56257 6.35906C2.5304 6.28491 2.51367 6.20495 2.51367 6.12412C2.51367 6.0433 2.5304 5.96334 2.56257 5.88919C2.59474 5.81503 2.64173 5.74827 2.70076 5.69303C2.75596 5.63496 2.82243 5.58871 2.89607 5.55711C2.96971 5.52551 3.04904 5.50921 3.12918 5.50921C3.20932 5.50921 3.2885 5.52551 3.36214 5.55711C3.43578 5.58871 3.50225 5.63496 3.55745 5.69303L5.02272 7.1812L8.04198 3.50208C8.09133 3.43834 8.15314 3.38537 8.22373 3.34644C8.29433 3.3075 8.37226 3.28343 8.45251 3.27568C8.53277 3.26794 8.61363 3.2767 8.69038 3.30142C8.76712 3.32613 8.83804 3.36627 8.89867 3.41939C8.96243 3.46871 9.0155 3.53057 9.05446 3.60113C9.09341 3.67169 9.11739 3.74947 9.12514 3.82968C9.13289 3.9099 9.12419 3.99084 9.09946 4.06754C9.07474 4.14425 9.03461 4.21509 8.98147 4.2757L5.53682 8.4745C5.48369 8.54182 5.41645 8.59676 5.33992 8.63552C5.2634 8.67427 5.17943 8.69591 5.09369 8.69892L5.07595 8.71074Z"
|
|
80
|
+
fill="#7ED321"
|
|
81
|
+
/>
|
|
82
|
+
<path
|
|
83
|
+
d="M6.00303 12C4.41143 11.9984 2.8854 11.3658 1.75997 10.2409C0.634541 9.11601 0.00156423 7.5908 0 5.99998C0.00156423 4.40916 0.634541 2.88395 1.75997 1.75907C2.8854 0.634194 4.41143 0.00156346 6.00303 0C7.5936 0.00312568 9.11804 0.636454 10.2422 1.76116C11.3663 2.88587 11.9984 4.41018 12 5.99998C11.9984 7.58978 11.3663 9.11413 10.2422 10.2388C9.11804 11.3635 7.5936 11.9969 6.00303 12ZM6.00303 0.885826C4.64648 0.887389 3.34595 1.4267 2.38673 2.38545C1.4275 3.34421 0.887824 4.6441 0.88626 5.99998C0.88626 7.35634 1.42544 8.65715 2.385 9.61624C3.34456 10.5753 4.646 11.1142 6.00303 11.1142C7.35903 11.1126 8.65888 10.5731 9.61717 9.61415C10.5755 8.65523 11.1137 7.35532 11.1137 5.99998C11.1122 4.64512 10.5734 3.34613 9.61543 2.38754C8.65749 1.42896 7.35855 0.888951 6.00303 0.885826Z"
|
|
84
|
+
fill="#7ED321"
|
|
85
|
+
/>
|
|
86
|
+
</svg>`,
|
|
87
|
+
error: html` <svg
|
|
88
|
+
data-hint="${'Could not authorize'}"
|
|
89
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
90
|
+
width="12"
|
|
91
|
+
height="12"
|
|
92
|
+
viewBox="0 0 12 12"
|
|
93
|
+
fill="none"
|
|
94
|
+
>
|
|
95
|
+
<path
|
|
96
|
+
d="M5.99833 0.891429C6.08866 0.891429 6.31281 0.918857 6.43659 1.16571L11.0702 10.3749C11.1839 10.6011 11.0969 10.7966 11.0535 10.8686C11.01 10.9406 10.8828 11.112 10.6319 11.112H1.36474C1.11382 11.112 0.986692 10.944 0.9432 10.8686C0.899708 10.7966 0.812723 10.6011 0.926472 10.3749L5.56006 1.16571C5.68385 0.918857 5.908 0.891429 5.99833 0.891429ZM5.99833 0C5.51991 0 5.0415 0.250286 4.78724 0.754286L0.15365 9.96343C-0.314727 10.8926 0.344346 12 1.36474 12H10.6353C11.6557 12 12.3147 10.8926 11.8464 9.96343L7.20942 0.754286C6.95515 0.250286 6.47674 0 5.99833 0Z"
|
|
97
|
+
fill="#F05C42"
|
|
98
|
+
/>
|
|
99
|
+
<path
|
|
100
|
+
d="M5.99494 8.71924C5.83435 8.71924 5.70053 8.77752 5.59013 8.89067C5.47973 9.00381 5.42285 9.14095 5.42285 9.3021C5.42285 9.48724 5.47973 9.63124 5.59682 9.7341C5.71391 9.83695 5.84774 9.88838 6.00163 9.88838C6.15553 9.88838 6.286 9.83695 6.4031 9.73067C6.51685 9.62781 6.57372 9.48381 6.57372 9.3021C6.57372 9.14095 6.51685 9.00381 6.4031 8.89067C6.29269 8.7741 6.15553 8.71924 5.99494 8.71924Z"
|
|
101
|
+
fill="#F05C42"
|
|
102
|
+
/>
|
|
103
|
+
<path
|
|
104
|
+
d="M5.99923 3.9668C5.68474 3.9668 5.43048 4.23423 5.44386 4.55651L5.54423 7.57708C5.55092 7.8308 5.755 8.03308 6.00257 8.03308C6.25014 8.03308 6.45422 7.8308 6.46091 7.57708L6.55793 4.55651C6.56797 4.23423 6.31371 3.9668 5.99923 3.9668Z"
|
|
105
|
+
fill="#F05C42"
|
|
106
|
+
/>
|
|
107
|
+
</svg>`,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const AuthorizationRow = (props: {
|
|
111
|
+
id: string;
|
|
112
|
+
value: string;
|
|
113
|
+
isChecked?: boolean;
|
|
114
|
+
isLoading: boolean;
|
|
115
|
+
willDelete?: boolean;
|
|
116
|
+
isDeleting?: boolean;
|
|
117
|
+
error?: string;
|
|
118
|
+
status: 'VERIFYING' | 'CONNECTED' | 'ERROR' | 'IDLE' | null;
|
|
119
|
+
handleChange?: (id: string) => void;
|
|
120
|
+
handleReverify?: () => void;
|
|
121
|
+
handleDelete?: (shouldDelete: boolean) => void;
|
|
122
|
+
handleWillDelete?: () => void;
|
|
123
|
+
isReadOnly?: boolean;
|
|
124
|
+
forcedLoading?: boolean;
|
|
125
|
+
}) => {
|
|
126
|
+
const {
|
|
127
|
+
id,
|
|
128
|
+
value,
|
|
129
|
+
isChecked,
|
|
130
|
+
status = 'IDLE',
|
|
131
|
+
isDeleting = false,
|
|
132
|
+
willDelete = false,
|
|
133
|
+
handleChange,
|
|
134
|
+
handleReverify,
|
|
135
|
+
handleDelete = () => null,
|
|
136
|
+
handleWillDelete = () => null,
|
|
137
|
+
error,
|
|
138
|
+
isReadOnly,
|
|
139
|
+
} = props;
|
|
140
|
+
|
|
141
|
+
return html`
|
|
142
|
+
<div
|
|
143
|
+
class="${styles.checkboxRow} ${isChecked
|
|
144
|
+
? styles.isCheckBoxSelected
|
|
145
|
+
: ''}"
|
|
146
|
+
>
|
|
147
|
+
${isReadOnly &&
|
|
148
|
+
html`<span
|
|
149
|
+
class=${styles.readonlyHint}
|
|
150
|
+
data-hint=${isReadOnly ? `Cannot modify user selection` : ''}
|
|
151
|
+
></span>`}
|
|
152
|
+
<div class=${`${styles.radio} ${isReadOnly ? styles.readonly : ''}`}>
|
|
153
|
+
<${Radio}
|
|
154
|
+
id=${id}
|
|
155
|
+
value=${html`
|
|
156
|
+
<div
|
|
157
|
+
style="display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px;"
|
|
158
|
+
>
|
|
159
|
+
<span
|
|
160
|
+
style="font-size: 12px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: normal;"
|
|
161
|
+
>${value}</span
|
|
162
|
+
>
|
|
163
|
+
<div class=${styles.status} style="margin-bottom: -2px;">
|
|
164
|
+
${isReadOnly
|
|
165
|
+
? html`
|
|
166
|
+
${false &&
|
|
167
|
+
isChecked &&
|
|
168
|
+
html`<div>
|
|
169
|
+
<div class=${styles.statusGreen} />
|
|
170
|
+
Connected
|
|
171
|
+
</div>`}
|
|
172
|
+
`
|
|
173
|
+
: html`
|
|
174
|
+
<div
|
|
175
|
+
class="${styles.statusIcon}"
|
|
176
|
+
style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;"
|
|
177
|
+
>
|
|
178
|
+
${false &&
|
|
179
|
+
status === 'VERIFYING' &&
|
|
180
|
+
!isDeleting &&
|
|
181
|
+
html`<div class=${styles.statusOrange} />
|
|
182
|
+
<${Loader} /> `}
|
|
183
|
+
${status === 'VERIFYING' &&
|
|
184
|
+
!isDeleting &&
|
|
185
|
+
html`<${Loader} size="sm" /> `}
|
|
186
|
+
</div>
|
|
187
|
+
<div
|
|
188
|
+
class="${styles.statusIcon}"
|
|
189
|
+
style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;"
|
|
190
|
+
>
|
|
191
|
+
${status === 'CONNECTED' &&
|
|
192
|
+
!error &&
|
|
193
|
+
!isDeleting &&
|
|
194
|
+
false &&
|
|
195
|
+
html`<div class=${styles.statusGreen} />
|
|
196
|
+
Connected`}
|
|
197
|
+
${status === 'CONNECTED' &&
|
|
198
|
+
!error &&
|
|
199
|
+
!isDeleting &&
|
|
200
|
+
STATUS_ICON.connected}
|
|
201
|
+
</div>
|
|
202
|
+
<div
|
|
203
|
+
class="${styles.statusIcon}"
|
|
204
|
+
style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;"
|
|
205
|
+
>
|
|
206
|
+
${status === 'ERROR' &&
|
|
207
|
+
!isDeleting &&
|
|
208
|
+
false &&
|
|
209
|
+
html`<div class=${styles.statusRed} />
|
|
210
|
+
Failed
|
|
211
|
+
${!isReadOnly &&
|
|
212
|
+
html`<div onclick=${handleReverify}>
|
|
213
|
+
<${Resend} />
|
|
214
|
+
</div>`} `}
|
|
215
|
+
${status === 'ERROR' &&
|
|
216
|
+
!isDeleting &&
|
|
217
|
+
false &&
|
|
218
|
+
html`${STATUS_ICON.error}
|
|
219
|
+
${!isReadOnly &&
|
|
220
|
+
html`<div onclick=${handleReverify}>
|
|
221
|
+
<${Resend} />
|
|
222
|
+
</div>`} `}
|
|
223
|
+
</div>
|
|
224
|
+
${isDeleting && html`<${Loader} />`}
|
|
225
|
+
${error &&
|
|
226
|
+
!isDeleting &&
|
|
227
|
+
!(status === 'VERIFYING') &&
|
|
228
|
+
html`<div class=${styles.error}>${error}</div>`}
|
|
229
|
+
`}
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
`}
|
|
233
|
+
isChecked=${isChecked}
|
|
234
|
+
onChange=${handleChange}
|
|
235
|
+
isDisabled=${isReadOnly}
|
|
236
|
+
className="authRadio"
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
<div
|
|
240
|
+
class=${`${styles.statusWrap} ${isReadOnly ? styles.readonly : ''}`}
|
|
241
|
+
></div>
|
|
242
|
+
${willDelete &&
|
|
243
|
+
!isDeleting &&
|
|
244
|
+
html` <${Confirmation} callback=${handleDelete} /> `}
|
|
245
|
+
${!(status === 'VERIFYING' || isDeleting || willDelete) &&
|
|
246
|
+
!isReadOnly &&
|
|
247
|
+
html`
|
|
248
|
+
<div class=${styles.deleteIcon} onclick=${handleWillDelete}>
|
|
249
|
+
<svg
|
|
250
|
+
width="15"
|
|
251
|
+
height="15"
|
|
252
|
+
viewBox="0 0 15 15"
|
|
253
|
+
fill="none"
|
|
254
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
255
|
+
>
|
|
256
|
+
<path d="M1.5 4.1999H13.65" stroke="#F05C42" />
|
|
257
|
+
<path
|
|
258
|
+
d="M11.6254 5.5498V6.2248L10.9504 13.6498H4.20039L3.52539 6.2248V5.5498"
|
|
259
|
+
stroke="#F05C42"
|
|
260
|
+
stroke-linejoin="round"
|
|
261
|
+
/>
|
|
262
|
+
<path
|
|
263
|
+
d="M5.55078 3.525V2.175C5.55078 1.80221 5.85299 1.5 6.22578 1.5H8.92578C9.29857 1.5 9.60078 1.80221 9.60078 2.175V3.525"
|
|
264
|
+
stroke="#F05C42"
|
|
265
|
+
/>
|
|
266
|
+
</svg>
|
|
267
|
+
</div>
|
|
268
|
+
`}
|
|
269
|
+
</div>
|
|
270
|
+
`;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
class AuthSelector extends Component<
|
|
274
|
+
AuthSelectorPropsType,
|
|
275
|
+
AuthSelectorStateType
|
|
276
|
+
> {
|
|
277
|
+
static contextType = AppContext;
|
|
278
|
+
|
|
279
|
+
constructor(props: AuthSelectorPropsType) {
|
|
280
|
+
super(props);
|
|
281
|
+
this.state = {
|
|
282
|
+
isLoading: false,
|
|
283
|
+
fetched: false,
|
|
284
|
+
willDeleteAuthWithIndex: null,
|
|
285
|
+
gottoNextStepAfterAuth: false,
|
|
286
|
+
isSelfApp: false,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
componentDidMount() {
|
|
291
|
+
if (isBrowser())
|
|
292
|
+
window.addEventListener('message', this.onAuthResponseReceived);
|
|
293
|
+
|
|
294
|
+
// in preview mode, auto-verify the auth we pass
|
|
295
|
+
const { stepId, stepMapping, selectedAuthByAppId } = this.props;
|
|
296
|
+
const stepAppId = stepMapping[stepId].step.authorization_type.app.id;
|
|
297
|
+
const selectedAuthIdOfApp = selectedAuthByAppId[stepAppId];
|
|
298
|
+
let auth = stepMapping[stepId].selectedAuthId;
|
|
299
|
+
|
|
300
|
+
if (
|
|
301
|
+
stepMapping[stepId].step.authorization_type.app.id ===
|
|
302
|
+
this.props.genericData.selfAppId
|
|
303
|
+
) {
|
|
304
|
+
this.setState({ isSelfApp: true });
|
|
305
|
+
let openAuthWindow = false;
|
|
306
|
+
if (
|
|
307
|
+
!this.props.genericData.userVariablesValidation &&
|
|
308
|
+
stepMapping[stepId].authorizations.length === 0
|
|
309
|
+
) {
|
|
310
|
+
openAuthWindow = true;
|
|
311
|
+
this.setState({ gottoNextStepAfterAuth: true });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (openAuthWindow) {
|
|
315
|
+
this.openAuthWindow();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (!auth && stepMapping[stepId].authorizations.length > 0) {
|
|
320
|
+
auth =
|
|
321
|
+
selectedAuthIdOfApp ||
|
|
322
|
+
stepMapping[stepId].authorizations[0].authorizationId;
|
|
323
|
+
}
|
|
324
|
+
let authIndex = stepMapping[stepId].authorizations.findIndex(
|
|
325
|
+
(el) => el.authorizationId === auth,
|
|
326
|
+
);
|
|
327
|
+
if (stepMapping[stepId].authorizations.length > 0 && authIndex === -1) {
|
|
328
|
+
authIndex = 0; // if the selected auth is not in the list, we select the first one
|
|
329
|
+
}
|
|
330
|
+
const authStatus = this.getAuthStatus(
|
|
331
|
+
stepMapping[stepId].authorizations[authIndex] || auth,
|
|
332
|
+
);
|
|
333
|
+
// auth is selected but is in idle state
|
|
334
|
+
if (stepMapping[stepId].selectedAuthId && authStatus === 'IDLE') {
|
|
335
|
+
this.verifyAuth(authIndex, true);
|
|
336
|
+
} else if (!stepMapping[stepId].selectedAuthId && authIndex !== -1) {
|
|
337
|
+
this.verifyAuth(authIndex, true); // if not auth is selected in the step. we verify the auth at authIndex
|
|
338
|
+
} else if (auth) {
|
|
339
|
+
this.verifyAuth(0, true);
|
|
340
|
+
}
|
|
341
|
+
const visibleFields = this.props.stepMapping[
|
|
342
|
+
stepId
|
|
343
|
+
].step.template_fields.filter((field: any) => field.is_visible === true);
|
|
344
|
+
|
|
345
|
+
if (stepMapping[stepId].step.activity.type !== 'MAKE_HTTP_CALL') {
|
|
346
|
+
if (
|
|
347
|
+
visibleFields.length !== 0 || // if there are visible fields
|
|
348
|
+
(stepMapping[stepId].step.authorization_type.app.id ===
|
|
349
|
+
this.props.genericData.selfAppId && // or if the selfApp(app whose flow are being listed) is the same as the app of the step
|
|
350
|
+
stepMapping[stepId].authorizations.length > 0) // and there are authorizations of that app
|
|
351
|
+
) {
|
|
352
|
+
if (stepMapping[stepId].authorizations.length) {
|
|
353
|
+
this.props.onAuthSelected(
|
|
354
|
+
// select the first auth automatically and skip the auth selection step
|
|
355
|
+
stepMapping[stepId].authorizations[authIndex].authorizationId,
|
|
356
|
+
true,
|
|
357
|
+
true,
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
if (
|
|
361
|
+
!this.props.genericData.isTestIntegration ||
|
|
362
|
+
(this.props.genericData.isTestIntegration &&
|
|
363
|
+
stepMapping[stepId].step.authorization_type.app.id !==
|
|
364
|
+
this.props.genericData.selfAppId)
|
|
365
|
+
) {
|
|
366
|
+
this.props.gotoNextStep();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
componentDidUpdate(prevProps: AuthSelectorPropsType) {
|
|
373
|
+
const { stepId, stepMapping } = this.props;
|
|
374
|
+
const step = stepMapping[stepId];
|
|
375
|
+
const authId = step.selectedAuthId;
|
|
376
|
+
|
|
377
|
+
const authIndex = stepMapping[stepId].authorizations.findIndex(
|
|
378
|
+
(el) => el.authorizationId === authId,
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
const auth = stepMapping[stepId].authorizations[authIndex];
|
|
382
|
+
|
|
383
|
+
const authStatus = this.getAuthStatus(
|
|
384
|
+
stepMapping[stepId].authorizations[authIndex],
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
// verify auth whenever we select a new one
|
|
388
|
+
// if (authId !== prevProps.stepMapping[stepId].selectedAuthId && authIndex) {
|
|
389
|
+
// console.log('verifying 1');
|
|
390
|
+
|
|
391
|
+
// this.verifyAuth(authIndex);
|
|
392
|
+
// }
|
|
393
|
+
if (
|
|
394
|
+
step.authorizations.length ===
|
|
395
|
+
prevProps.stepMapping[stepId].authorizations.length + 1
|
|
396
|
+
) {
|
|
397
|
+
// auth was added so we verify
|
|
398
|
+
this.verifyAuth(step.authorizations.length - 1);
|
|
399
|
+
}
|
|
400
|
+
// verify auth in edit mode when step changes
|
|
401
|
+
if (
|
|
402
|
+
authStatus === 'IDLE' &&
|
|
403
|
+
!auth.isVerifying &&
|
|
404
|
+
!auth.isVerified &&
|
|
405
|
+
!this.state.isLoading
|
|
406
|
+
) {
|
|
407
|
+
this.verifyAuth(authIndex, true);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
componentWillUnmount() {
|
|
412
|
+
if (isBrowser())
|
|
413
|
+
window.removeEventListener('message', this.onAuthResponseReceived);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
private verifyAuth = (authIndex: number, override?: boolean) => {
|
|
417
|
+
const { stepId } = this.props;
|
|
418
|
+
const auth = this.props.stepMapping[stepId].authorizations[authIndex];
|
|
419
|
+
|
|
420
|
+
if (!auth) return;
|
|
421
|
+
|
|
422
|
+
const isAuthVerifiedInPreviewMode =
|
|
423
|
+
!this.props.genericData.isPreviewMode && auth.isVerified;
|
|
424
|
+
const hideAuhtorizationStatus = !this.props.stepMapping[stepId]
|
|
425
|
+
.isUserinfoRequired;
|
|
426
|
+
|
|
427
|
+
if (isAuthVerifiedInPreviewMode || hideAuhtorizationStatus) {
|
|
428
|
+
this.props.onAuthSelected(auth.authorizationId, true, !!override);
|
|
429
|
+
this.context.eventEmitter.emit('did-select-authorization', {
|
|
430
|
+
authorizationId: Number(auth.authorizationId),
|
|
431
|
+
});
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
this.setState({ isLoading: true });
|
|
436
|
+
this.props.toggleVerifyAuthorizationFlag({
|
|
437
|
+
stepId,
|
|
438
|
+
authId: auth.authorizationId,
|
|
439
|
+
isVerifying: true,
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
this.props.apiHandler
|
|
443
|
+
.verifyOAuth(auth.authorizationId)
|
|
444
|
+
.then((res) => {
|
|
445
|
+
if (res) {
|
|
446
|
+
this.props.onAuthSelected(auth.authorizationId, true, !!override);
|
|
447
|
+
this.context.eventEmitter.emit('did-select-authorization', {
|
|
448
|
+
authorizationId: Number(auth.authorizationId),
|
|
449
|
+
});
|
|
450
|
+
} else {
|
|
451
|
+
this.props.onAuthSelected(auth.authorizationId, false, !!override);
|
|
452
|
+
}
|
|
453
|
+
})
|
|
454
|
+
.catch((err) => console.error(err))
|
|
455
|
+
.finally(() => {
|
|
456
|
+
this.props.toggleVerifyAuthorizationFlag({
|
|
457
|
+
stepId,
|
|
458
|
+
authId: auth.authorizationId,
|
|
459
|
+
isVerifying: false,
|
|
460
|
+
});
|
|
461
|
+
this.setState({ isLoading: false });
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
private willDelete = (authIndex: number) => {
|
|
466
|
+
this.setState({
|
|
467
|
+
willDeleteAuthWithIndex: authIndex,
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
private deleteAuth = (authIndex: number) => {
|
|
472
|
+
const { stepId } = this.props;
|
|
473
|
+
const auth = this.props.stepMapping[stepId].authorizations[authIndex];
|
|
474
|
+
|
|
475
|
+
this.props.toggleDeleteAuthorizationFlag({
|
|
476
|
+
stepId,
|
|
477
|
+
authId: auth.authorizationId,
|
|
478
|
+
isDeleting: true,
|
|
479
|
+
error: '',
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
this.context.eventEmitter.emit('did-begin-remove-authorization', {
|
|
483
|
+
authorizationId: Number(auth.authorizationId),
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
this.props.apiHandler
|
|
487
|
+
.deleteAuth(auth.authorizationId)
|
|
488
|
+
.then((res) => {
|
|
489
|
+
if (res?.status === 200) {
|
|
490
|
+
this.props.removeAuthorization({
|
|
491
|
+
stepId,
|
|
492
|
+
authId: auth.authorizationId,
|
|
493
|
+
});
|
|
494
|
+
this.context.eventEmitter.emit('did-remove-authorization', {
|
|
495
|
+
authorizationId: Number(auth.authorizationId),
|
|
496
|
+
appId: this.props.genericData.app_id || '',
|
|
497
|
+
});
|
|
498
|
+
} else if (res?.status === 405) {
|
|
499
|
+
// we have a deletion error
|
|
500
|
+
this.props.toggleDeleteAuthorizationFlag({
|
|
501
|
+
stepId,
|
|
502
|
+
authId: auth.authorizationId,
|
|
503
|
+
isDeleting: false,
|
|
504
|
+
error: `${res.data}`,
|
|
505
|
+
});
|
|
506
|
+
} else {
|
|
507
|
+
this.props.toggleDeleteAuthorizationFlag({
|
|
508
|
+
stepId,
|
|
509
|
+
authId: auth.authorizationId,
|
|
510
|
+
isDeleting: false,
|
|
511
|
+
error: 'An unexpected error occurred',
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
})
|
|
515
|
+
.catch((err) => {
|
|
516
|
+
console.error(err);
|
|
517
|
+
})
|
|
518
|
+
.finally(() => this.setState({ willDeleteAuthWithIndex: null }));
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
private onAuthResponseReceived = (messageEvent: MessageEvent<AuthData>) => {
|
|
522
|
+
if (isAuthMessage(messageEvent) && messageEvent.data.activity_name) {
|
|
523
|
+
console.info(messageEvent.data);
|
|
524
|
+
if (this.props.stepId) {
|
|
525
|
+
const { stepId } = this.props;
|
|
526
|
+
const authApp = this.props.stepMapping[stepId]?.step?.activity?.app;
|
|
527
|
+
if (!messageEvent.data.already_exists) {
|
|
528
|
+
this.props.addAuthorization({
|
|
529
|
+
stepId: this.props.stepId,
|
|
530
|
+
authData: {
|
|
531
|
+
authorizationId: messageEvent.data.authorization_id,
|
|
532
|
+
userIdentity: messageEvent.data.user_identity,
|
|
533
|
+
disableLink: '',
|
|
534
|
+
authType: '',
|
|
535
|
+
isVerified: false,
|
|
536
|
+
didFetchStatus: false,
|
|
537
|
+
isVerifying: false,
|
|
538
|
+
isDeleting: false,
|
|
539
|
+
error: '',
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
} else {
|
|
543
|
+
this.props.setStepAuthId({
|
|
544
|
+
stepId: this.props.stepId,
|
|
545
|
+
authId: Number(messageEvent.data.authorization_id),
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
this.context.eventEmitter.emit('did-add-authorization', {
|
|
549
|
+
identity: messageEvent.data.user_identity,
|
|
550
|
+
authorizationId: Number(messageEvent.data.authorization_id),
|
|
551
|
+
flowId: this.props.genericData.templateId,
|
|
552
|
+
appId: authApp.id || '',
|
|
553
|
+
appName: authApp?.name,
|
|
554
|
+
appIcon: authApp?.icon_url,
|
|
555
|
+
alreadyExists: messageEvent.data.already_exists,
|
|
556
|
+
externalId: messageEvent.data.external_id,
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
if (this.state.gottoNextStepAfterAuth) {
|
|
560
|
+
this.props.gotoNextStep();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
private getAuthStatus = (auth: Authorization) => {
|
|
567
|
+
const { stepId } = this.props;
|
|
568
|
+
if (!auth) return null;
|
|
569
|
+
let status = 'IDLE';
|
|
570
|
+
const hideAuhtorizationStatus = !this.props.stepMapping[stepId]
|
|
571
|
+
.isUserinfoRequired;
|
|
572
|
+
if (hideAuhtorizationStatus) {
|
|
573
|
+
return status;
|
|
574
|
+
}
|
|
575
|
+
if (auth.isVerified && auth.didFetchStatus) status = 'CONNECTED';
|
|
576
|
+
if (!auth.isVerified && auth.didFetchStatus) status = 'ERROR';
|
|
577
|
+
if (auth.isVerifying) status = 'VERIFYING';
|
|
578
|
+
return status;
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
private getError = () => {
|
|
582
|
+
const { stepId } = this.props;
|
|
583
|
+
const step = this.props.stepMapping[stepId];
|
|
584
|
+
if (!step.authorizations) {
|
|
585
|
+
return `Please add a valid ${
|
|
586
|
+
step.step.authorization_type.app?.name || step.step.activity.app.name
|
|
587
|
+
} account`;
|
|
588
|
+
}
|
|
589
|
+
return `Please select a valid ${
|
|
590
|
+
step.step.authorization_type.app?.name || step.step.activity.app.name
|
|
591
|
+
} account`;
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
public openAuthWindow = () => {
|
|
595
|
+
const { stepMapping, stepId } = this.props;
|
|
596
|
+
const selectedStep = stepMapping[stepId].step;
|
|
597
|
+
if (selectedStep) {
|
|
598
|
+
const url = this.context.apiHandler.getAuthUrl(
|
|
599
|
+
selectedStep.authorization_type.id,
|
|
600
|
+
);
|
|
601
|
+
openPopupWindow(url, 'Auth Window', window, 800, 600);
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
render() {
|
|
606
|
+
const { stepId, showErrors = false, forcedLoading = false } = this.props;
|
|
607
|
+
const step = this.props.stepMapping[stepId];
|
|
608
|
+
const { authorizations } = step;
|
|
609
|
+
const isReadOnly = this.context?.isReadOnly || this.props.isReadOnly;
|
|
610
|
+
if (forcedLoading) {
|
|
611
|
+
return html`
|
|
612
|
+
<div style="margin-top:-74px; display: flex; justify-content: center;">
|
|
613
|
+
<${Loader} />
|
|
614
|
+
</div>
|
|
615
|
+
`;
|
|
616
|
+
}
|
|
617
|
+
return html`
|
|
618
|
+
<div class="${styles.authSelectorWrap} integry-container__auth-selector">
|
|
619
|
+
${false &&
|
|
620
|
+
html` <${Label}
|
|
621
|
+
title="Connect account"
|
|
622
|
+
description=${`Select your ${
|
|
623
|
+
step.step.authorization_type.app?.name ||
|
|
624
|
+
step.step.activity.app.name
|
|
625
|
+
} account`}
|
|
626
|
+
isRequired=${true}
|
|
627
|
+
/>`}
|
|
628
|
+
<div class=${styles.rows} style="margin-bottom: 8px;">
|
|
629
|
+
${authorizations.map(
|
|
630
|
+
(el, index) => html`<${AuthorizationRow}
|
|
631
|
+
id=${el.authorizationId}
|
|
632
|
+
value=${el.userIdentity}
|
|
633
|
+
status=${this.getAuthStatus(el)}
|
|
634
|
+
isChecked=${el.authorizationId === step.selectedAuthId}
|
|
635
|
+
isDeleting=${el.isDeleting}
|
|
636
|
+
willDelete=${this.state.willDeleteAuthWithIndex === index}
|
|
637
|
+
error=${el.error}
|
|
638
|
+
handleChange=${() => this.verifyAuth(index)}
|
|
639
|
+
handleReverify=${() => this.verifyAuth(index)}
|
|
640
|
+
handleDelete=${(shouldDelete: boolean) =>
|
|
641
|
+
shouldDelete
|
|
642
|
+
? this.deleteAuth(index)
|
|
643
|
+
: this.setState({ willDeleteAuthWithIndex: null })}
|
|
644
|
+
handleWillDelete=${() => this.willDelete(index)}
|
|
645
|
+
isReadOnly=${isReadOnly}
|
|
646
|
+
/>`,
|
|
647
|
+
)}
|
|
648
|
+
</div>
|
|
649
|
+
${(!isReadOnly || this.props.genericData.isTestIntegration) &&
|
|
650
|
+
html`
|
|
651
|
+
<div class=${showErrors ? `${styles.error}` : ''}>
|
|
652
|
+
<${Hint}
|
|
653
|
+
dismissOnClick=${false}
|
|
654
|
+
position="bottom-right"
|
|
655
|
+
deltaY=${0}
|
|
656
|
+
>
|
|
657
|
+
${(!this.state.isSelfApp || authorizations.length === 0) &&
|
|
658
|
+
html`<div
|
|
659
|
+
data-hint=${this.props.genericData.isPreviewMode &&
|
|
660
|
+
'New accounts cannot be added in preview mode'}
|
|
661
|
+
class=${styles.addAccountCTA}
|
|
662
|
+
onClick=${() => {
|
|
663
|
+
if (
|
|
664
|
+
!this.props.genericData.isPreviewMode &&
|
|
665
|
+
!(
|
|
666
|
+
this.state.isLoading ||
|
|
667
|
+
this.props.genericData.isPreviewMode
|
|
668
|
+
)
|
|
669
|
+
) {
|
|
670
|
+
this.openAuthWindow();
|
|
671
|
+
}
|
|
672
|
+
}}
|
|
673
|
+
>
|
|
674
|
+
<svg
|
|
675
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
676
|
+
width="16"
|
|
677
|
+
height="16"
|
|
678
|
+
viewBox="0 0 16 16"
|
|
679
|
+
fill="none"
|
|
680
|
+
>
|
|
681
|
+
<path
|
|
682
|
+
d="M7.94453 7.94417V8.44417H8.44453V7.94417H7.94453ZM7.94453 8.44417H8.44453V7.94417H7.94453V8.44417ZM8.44453 8.44417V7.94417H7.94453V8.44417H8.44453ZM8.44453 7.94417H7.94453V8.44417H8.44453V7.94417ZM8.19453 3.64417C8.05646 3.64417 7.94453 3.53224 7.94453 3.39417H8.94453C8.94453 2.97995 8.60874 2.64417 8.19453 2.64417V3.64417ZM8.44453 3.39417C8.44453 3.53224 8.3326 3.64417 8.19453 3.64417V2.64417C7.78032 2.64417 7.44453 2.97995 7.44453 3.39417H8.44453ZM8.44453 7.94417V3.39417H7.44453V7.94417H8.44453ZM3.39453 8.44417H7.94453V7.44417H3.39453V8.44417ZM3.64453 8.19417C3.64453 8.33224 3.5326 8.44417 3.39453 8.44417V7.44417C2.98032 7.44417 2.64453 7.77995 2.64453 8.19417H3.64453ZM3.39453 7.94417C3.5326 7.94417 3.64453 8.05609 3.64453 8.19417H2.64453C2.64453 8.60838 2.98032 8.94417 3.39453 8.94417V7.94417ZM7.94453 7.94417H3.39453V8.94417H7.94453V7.94417ZM8.44453 12.9942V8.44417H7.44453V12.9942H8.44453ZM8.19453 12.7442C8.3326 12.7442 8.44453 12.8561 8.44453 12.9942H7.44453C7.44453 13.4084 7.78032 13.7442 8.19453 13.7442V12.7442ZM7.94453 12.9942C7.94453 12.8561 8.05646 12.7442 8.19453 12.7442V13.7442C8.60874 13.7442 8.94453 13.4084 8.94453 12.9942H7.94453ZM7.94453 8.44417V12.9942H8.94453V8.44417H7.94453ZM12.9945 7.94417H8.44453V8.94417H12.9945V7.94417ZM12.7445 8.19417C12.7445 8.05609 12.8565 7.94417 12.9945 7.94417V8.94417C13.4087 8.94417 13.7445 8.60838 13.7445 8.19417H12.7445ZM12.9945 8.44417C12.8565 8.44417 12.7445 8.33224 12.7445 8.19417H13.7445C13.7445 7.77995 13.4087 7.44417 12.9945 7.44417V8.44417ZM8.44453 8.44417H12.9945V7.44417H8.44453V8.44417ZM7.94453 3.39417V7.94417H8.94453V3.39417H7.94453Z"
|
|
683
|
+
fill="#333333"
|
|
684
|
+
/>
|
|
685
|
+
</svg>
|
|
686
|
+
<!-- <span>${`Add another ${step.step.authorization_type.app.name} account`}</span> -->
|
|
687
|
+
<span>${`Add account`}</span>
|
|
688
|
+
</div>`}
|
|
689
|
+
<//>
|
|
690
|
+
</div>
|
|
691
|
+
${showErrors && html`<${ErrorMessage}>${this.getError()}<//>`}
|
|
692
|
+
`}
|
|
693
|
+
</div>
|
|
694
|
+
`;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
export default connect<
|
|
699
|
+
AuthSelectorPropsType,
|
|
700
|
+
AuthSelectorStateType,
|
|
701
|
+
StoreType,
|
|
702
|
+
unknown
|
|
703
|
+
>(
|
|
704
|
+
['stepMapping', 'genericData', 'selectedAuthByAppId', 'xIntegryConfig'],
|
|
705
|
+
actionFunctions,
|
|
706
|
+
)(AuthSelector);
|