@integry/sdk 4.7.39 → 4.7.41
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/dist/esm/index.csm.js +1 -1
- package/dist/umd/index.umd.js +1 -1
- package/package.json +6 -1
- package/.eslintignore +0 -1
- package/.vscode/launch.json +0 -17
- package/CHANGELOG_INTERNAL.md +0 -134
- package/README_INTERNAL.md +0 -176
- package/THIRD_PARTY_LICENSES +0 -525
- package/generateTests.js +0 -80
- package/jest.config.cjs +0 -10
- package/src/components/AddTagButton/index.ts +0 -23
- package/src/components/BasicSelect/index.ts +0 -123
- package/src/components/BasicSelect/styles.module.scss +0 -44
- package/src/components/Button/index.ts +0 -97
- package/src/components/Button/styles.module.scss +0 -152
- package/src/components/CheckboxGroup/Checkbox.ts +0 -104
- package/src/components/CheckboxGroup/index.ts +0 -190
- package/src/components/CheckboxGroup/styles.module.scss +0 -63
- package/src/components/CollapsedMenu/index.ts +0 -104
- package/src/components/CollapsedMenu/styles.module.scss +0 -46
- package/src/components/ConfigureFieldWrapper/index.ts +0 -85
- package/src/components/ConfigureFieldWrapper/styles.module.scss +0 -57
- package/src/components/EditableText/index.ts +0 -121
- package/src/components/EditableText/styles.module.scss +0 -38
- package/src/components/EditableTextArea/index.ts +0 -143
- package/src/components/EditableTextArea/styles.module.scss +0 -91
- package/src/components/ErrorMessage/index.ts +0 -16
- package/src/components/ErrorMessage/styles.module.scss +0 -19
- package/src/components/ErrorPage/index.ts +0 -42
- package/src/components/ErrorPage/styles.module.scss +0 -26
- package/src/components/Footer/index.ts +0 -41
- package/src/components/Footer/styles.module.scss +0 -40
- package/src/components/HTMLContent/index.tsx +0 -205
- package/src/components/HTMLContent/styles.module.scss +0 -3
- package/src/components/InfoBox/index.ts +0 -48
- package/src/components/InfoBox/styles.module.scss +0 -21
- package/src/components/Input/BaseInput/index.ts +0 -170
- package/src/components/Input/BaseInput/styles.module.scss +0 -95
- package/src/components/Input/DateInput/index.ts +0 -103
- package/src/components/Input/DateInput/styles.module.scss +0 -50
- package/src/components/Input/Input/index.ts +0 -225
- package/src/components/Input/Input/styles.module.scss +0 -16
- package/src/components/Input/PasswordInput/index.ts +0 -164
- package/src/components/Input/PasswordInput/styles.module.scss +0 -37
- package/src/components/Input/index.ts +0 -7
- package/src/components/Label/index.ts +0 -61
- package/src/components/Label/styles.module.scss +0 -41
- package/src/components/LargeLoader/index.ts +0 -25
- package/src/components/LargeLoader/styles.module.scss +0 -16
- package/src/components/Listbox/ListBoxItem.ts +0 -57
- package/src/components/Listbox/index.ts +0 -488
- package/src/components/Listbox/styles.module.scss +0 -197
- package/src/components/Loader/index.ts +0 -25
- package/src/components/Loader/styles.module.scss +0 -16
- package/src/components/MediaGallery/MediaGalleryModal.ts +0 -82
- package/src/components/MediaGallery/MediaSlider.ts +0 -76
- package/src/components/MediaGallery/index.ts +0 -92
- package/src/components/MediaGallery/styles.module.scss +0 -156
- package/src/components/MediaUpload/index.ts +0 -233
- package/src/components/MediaUpload/styles.module.scss +0 -118
- package/src/components/Modal/index.ts +0 -87
- package/src/components/Modal/styles.module.scss +0 -441
- package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +0 -59
- package/src/components/MultipurposeField/Dropdown/index.tsx +0 -1202
- package/src/components/MultipurposeField/Dropdown/styles.module.scss +0 -215
- package/src/components/MultipurposeField/TagMenu/index.ts +0 -536
- package/src/components/MultipurposeField/TagMenu/styles.module.scss +0 -175
- package/src/components/MultipurposeField/TagOptions/index.tsx +0 -83
- package/src/components/MultipurposeField/TagOptions/styles.module.scss +0 -95
- package/src/components/MultipurposeField/index.tsx +0 -944
- package/src/components/MultipurposeField/styles.module.scss +0 -77
- package/src/components/NewModal/index.ts +0 -69
- package/src/components/NewModal/styles.module.scss +0 -70
- package/src/components/OverflowTooltip/index.tsx +0 -59
- package/src/components/PopUp/ConfirmationPopUp/index.ts +0 -58
- package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +0 -49
- package/src/components/PopUp/SuccessPopUp/index.ts +0 -62
- package/src/components/PopUp/SuccessPopUp/styles.module.scss +0 -38
- package/src/components/RadioGroup/Radio.ts +0 -128
- package/src/components/RadioGroup/index.ts +0 -169
- package/src/components/RadioGroup/styles.module.scss +0 -81
- package/src/components/Search/index.ts +0 -69
- package/src/components/Search/styles.module.scss +0 -149
- package/src/components/TabBar/Tab.ts +0 -33
- package/src/components/TabBar/index.ts +0 -64
- package/src/components/TabBar/styles.module.scss +0 -43
- package/src/components/Tag/index.ts +0 -29
- package/src/components/Tag/styles.module.scss +0 -57
- package/src/components/TagsMenu/index.ts +0 -1697
- package/src/components/TagsMenu/styles.module.scss +0 -350
- package/src/components/TestComponent/index.ts +0 -71
- package/src/components/TestComponent/styles.module.scss +0 -152
- package/src/components/TextArea/index.ts +0 -172
- package/src/components/TextArea/styles.module.scss +0 -72
- package/src/components/TextContent/index.tsx +0 -128
- package/src/components/TextContent/styles.module.scss +0 -6
- package/src/components/ThreeDotLoader/index.ts +0 -39
- package/src/components/ThreeDotLoader/styles.module.scss +0 -41
- package/src/components/TimeInput/index.ts +0 -129
- package/src/components/TimeInput/styles.module.scss +0 -16
- package/src/components/Toggle/index.ts +0 -34
- package/src/components/Toggle/styles.module.scss +0 -56
- package/src/components/Toggle-v2/index.ts +0 -40
- package/src/components/Toggle-v2/styles.module.scss +0 -86
- package/src/components/Tooltip/index.ts +0 -271
- package/src/components/Tooltip/styles.module.scss +0 -105
- package/src/components/form/FunctionField/index.ts +0 -816
- package/src/components/form/FunctionField/styles.module.scss +0 -478
- package/src/components/form/ObjectField/__snapshots__/index.ts.test.tsx.snap +0 -3
- package/src/components/form/ObjectField/index.ts +0 -593
- package/src/components/form/ObjectField/index.ts.test.tsx +0 -213
- package/src/components/form/ObjectField/styles.module.scss +0 -103
- package/src/components/form/index.ts +0 -4
- package/src/contexts/AppContext.ts +0 -12
- package/src/declaration.d.ts +0 -7
- package/src/extensions/HMAC.ts +0 -25
- package/src/extensions/IntegryAPIError.ts +0 -19
- package/src/features/common/AccountDropdown/index.ts +0 -291
- package/src/features/common/AccountDropdown/styles.module.scss +0 -19
- package/src/features/common/ActionForm/index.ts +0 -2602
- package/src/features/common/ActionForm/styles.module.scss +0 -35
- package/src/features/common/AppCard/index.ts +0 -207
- package/src/features/common/AppCard/styles.module.scss +0 -117
- package/src/features/common/AppCardCompact/index.ts +0 -189
- package/src/features/common/AppCardCompact/styles.module.scss +0 -141
- package/src/features/common/AuthSelector/index.ts +0 -537
- package/src/features/common/AuthSelector/styles.module.scss +0 -161
- package/src/features/common/AuthSelectorCompact/index.ts +0 -706
- package/src/features/common/AuthSelectorCompact/styles.module.scss +0 -219
- package/src/features/common/AuthSelectorDropdown/index.ts +0 -704
- package/src/features/common/AuthSelectorDropdown/styles.module.scss +0 -361
- package/src/features/common/AuthSelectorV2/index.ts +0 -336
- package/src/features/common/AuthSelectorV2/styles.module.scss +0 -235
- package/src/features/common/DynamicField/index.ts +0 -402
- package/src/features/common/DynamicField/styles.module.scss +0 -266
- package/src/features/common/DynamicTypedField/index.ts +0 -504
- package/src/features/common/DynamicTypedField/styles.module.scss +0 -135
- package/src/features/common/FunctionForm/index.ts +0 -1095
- package/src/features/common/FunctionForm/styles.module.scss +0 -225
- package/src/features/common/MappingUI/index.ts +0 -649
- package/src/features/common/MappingUI/styles.module.scss +0 -121
- package/src/features/common/MarketplaceAppCard/index.ts +0 -279
- package/src/features/common/MarketplaceAppCard/styles.module.scss +0 -231
- package/src/features/common/MarketplaceAppCardCompact/index.ts +0 -283
- package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +0 -255
- package/src/features/common/NewMappingUI/index.ts +0 -515
- package/src/features/common/NewMappingUI/styles.module.scss +0 -113
- package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +0 -67
- package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +0 -23
- package/src/features/common/RequestAppWidget/index.ts +0 -48
- package/src/features/common/RequestAppWidget/request-app-form.ts +0 -89
- package/src/features/common/RequestAppWidget/styles.module.scss +0 -43
- package/src/features/common/SectionField/index.ts +0 -272
- package/src/features/common/SectionField/styles.module.scss +0 -67
- package/src/features/common/Step/index.ts +0 -827
- package/src/features/common/Step/styles.module.scss +0 -12
- package/src/features/common/StepNavigation/CollapsedSteps.ts +0 -131
- package/src/features/common/StepNavigation/NavItem.ts +0 -111
- package/src/features/common/StepNavigation/index.ts +0 -261
- package/src/features/common/StepNavigation/styles.module.scss +0 -117
- package/src/features/common/Steps/index.ts +0 -1140
- package/src/features/common/Steps/styles.module.scss +0 -314
- package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +0 -404
- package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +0 -367
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.test.tsx +0 -58
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +0 -208
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.test.tsx +0 -49
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +0 -421
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +0 -577
- package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +0 -83
- package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +0 -233
- package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +0 -45
- package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +0 -1085
- package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +0 -465
- package/src/features/containers/AppFlowContainer/Authentication/index.ts +0 -610
- package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +0 -468
- package/src/features/containers/AppFlowContainer/index.ts +0 -114
- package/src/features/containers/AppPageContainer/AppPage/index.tsx +0 -262
- package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +0 -120
- package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +0 -165
- package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +0 -81
- package/src/features/containers/AppPageContainer/index.tsx +0 -93
- package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
- package/src/features/containers/AppsForFlows/index.ts +0 -161
- package/src/features/containers/AppsForFlows/styles.module.scss +0 -280
- package/src/features/containers/AppsForFlowsCompact/index.ts +0 -161
- package/src/features/containers/AppsForFlowsCompact/styles.module.scss +0 -279
- package/src/features/containers/AuthSetupContainer/AppSelection.ts +0 -73
- package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +0 -67
- package/src/features/containers/AuthSetupContainer/Footer.ts +0 -32
- package/src/features/containers/AuthSetupContainer/Header.ts +0 -39
- package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +0 -27
- package/src/features/containers/AuthSetupContainer/index.ts +0 -349
- package/src/features/containers/AuthSetupContainer/styles.module.scss +0 -229
- package/src/features/containers/FlowSetupContainer/index.ts +0 -391
- package/src/features/containers/FlowSetupContainer/styles.module.scss +0 -18
- package/src/features/containers/MarkeplaceApps/index.ts +0 -583
- package/src/features/containers/MarkeplaceApps/styles.module.scss +0 -558
- package/src/features/containers/MarketplaceAppsCompact/index.ts +0 -585
- package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +0 -563
- package/src/features/containers/MarketplaceAppsContainer/index.ts +0 -91
- package/src/features/containers/MarketplaceContainer/AppCard/index.ts +0 -91
- package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +0 -66
- package/src/features/containers/MarketplaceContainer/AppListing/index.ts +0 -34
- package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +0 -10
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +0 -132
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +0 -117
- package/src/features/containers/MarketplaceContainer/index.ts +0 -242
- package/src/features/containers/MarketplaceContainer/styles.module.scss +0 -84
- package/src/features/containers/SDKContainer/index.ts +0 -817
- package/src/features/containers/SDKContainer/styles.module.scss +0 -266
- package/src/features/containers/SDKDebugContainer/index.ts +0 -137
- package/src/features/containers/SDKDebugContainer/styles.module.scss +0 -37
- package/src/features/containers/SDKFailedContainer/index.ts +0 -117
- package/src/features/containers/SDKFailedContainer/styles.module.scss +0 -57
- package/src/features/integrations/IntegrationRow/Icons.ts +0 -77
- package/src/features/integrations/IntegrationRow/index.ts +0 -129
- package/src/features/integrations/IntegrationRow/styles.module.scss +0 -62
- package/src/features/integrations/IntegrationsHeader/index.ts +0 -34
- package/src/features/integrations/IntegrationsHeader/styles.module.scss +0 -47
- package/src/features/integrations/IntegrationsList/index.ts +0 -252
- package/src/features/integrations/IntegrationsList/styles.module.scss +0 -67
- package/src/features/templates/Template/index.ts +0 -295
- package/src/features/templates/Template/styles.module.scss +0 -226
- package/src/features/templates/TemplatesView/index.ts +0 -368
- package/src/features/templates/TemplatesView/styles.module.scss +0 -71
- package/src/features/templates/TemplatesViewCompact/index.ts +0 -364
- package/src/features/templates/TemplatesViewCompact/styles.module.scss +0 -141
- package/src/hooks/useAutosizeTextArea.ts +0 -22
- package/src/hooks/useCustomRef.ts +0 -13
- package/src/hooks/useDebounce.ts +0 -17
- package/src/hooks/useElementResize.ts +0 -40
- package/src/hooks/useEventListener.ts +0 -42
- package/src/hooks/useHover.ts +0 -40
- package/src/hooks/useOnClickOutside.ts +0 -32
- package/src/index.ts +0 -2244
- package/src/index.umd.ts +0 -13
- package/src/interfaces/index.ts +0 -938
- package/src/modules/api/index.ts +0 -1325
- package/src/modules/api/responseHandler.ts +0 -38
- package/src/modules/event-emitter/index.ts +0 -72
- package/src/modules/event-emitter/runners/abstract.ts +0 -21
- package/src/modules/event-emitter/runners/default.ts +0 -11
- package/src/modules/event-emitter/runners/ntimes.ts +0 -28
- package/src/modules/event-emitter/types.ts +0 -34
- package/src/store/actionFunctions.ts +0 -1578
- package/src/store/index.ts +0 -17
- package/src/store/initialState.ts +0 -58
- package/src/types/index.ts +0 -320
- package/src/types/preact-compat.d.ts +0 -4
- package/src/types/store.ts +0 -366
- package/src/types/utils.ts +0 -19
- package/src/utils/ActivityOutputUtils.ts +0 -176
- package/src/utils/common.ts +0 -20
- package/src/utils/copyToClipboard.ts +0 -24
- package/src/utils/datetime.ts +0 -101
- package/src/utils/getUrlParam.ts +0 -11
- package/src/utils/isAuthMessage.ts +0 -16
- package/src/utils/isBrowser.ts +0 -1
- package/src/utils/jsonEncodeDecode.ts +0 -15
- package/src/utils/objectUtils.ts +0 -117
- package/src/utils/popup.ts +0 -30
- package/src/utils/searchJson.ts +0 -51
- package/src/utils/stepUtils.ts +0 -45
- package/src/utils/truncate.ts +0 -6
- package/test/setup.ts +0 -1
- package/vitest.config.ts +0 -16
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// ```bash
|
|
2
|
-
// npm install vitest @testing-library/preact @testing-library/user-event --save-dev
|
|
3
|
-
// ```
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
6
|
-
import { render, fireEvent, screen } from '@testing-library/preact';
|
|
7
|
-
import userEvent from '@testing-library/user-event';
|
|
8
|
-
import '@testing-library/jest-dom/vitest';
|
|
9
|
-
import { ObjectField } from './index';
|
|
10
|
-
|
|
11
|
-
// Mock components and styles if necessary
|
|
12
|
-
vi.mock('@/components/Input', () => ({ Input: () => <div>Input</div> }));
|
|
13
|
-
vi.mock('@/components/TextArea', () => ({
|
|
14
|
-
TextArea: () => <div>TextArea</div>,
|
|
15
|
-
}));
|
|
16
|
-
vi.mock('@/components/CheckboxGroup', () => ({
|
|
17
|
-
CheckboxGroup: () => <div>CheckboxGroup</div>,
|
|
18
|
-
}));
|
|
19
|
-
vi.mock('@/components/ConfigureFieldWrapper', () => ({
|
|
20
|
-
default: ({ children }: { children: React.ReactNode }) => (
|
|
21
|
-
<div>{children}</div>
|
|
22
|
-
),
|
|
23
|
-
}));
|
|
24
|
-
vi.mock('@/components/MultipurposeField/Dropdown', () => ({
|
|
25
|
-
ListBox: () => <div>ListBox</div>,
|
|
26
|
-
}));
|
|
27
|
-
vi.mock('@/components/MultipurposeField', () => ({
|
|
28
|
-
MultipurposeField: () => <div>MultipurposeField</div>,
|
|
29
|
-
}));
|
|
30
|
-
vi.mock('./styles.module.scss', () => ({
|
|
31
|
-
objectContainer: 'objectContainer',
|
|
32
|
-
objectFieldWrap: 'objectFieldWrap',
|
|
33
|
-
label: 'label',
|
|
34
|
-
subLabel: 'subLabel',
|
|
35
|
-
removeButton: 'removeButton',
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
|
-
describe('ObjectField Component', () => {
|
|
39
|
-
const mockOnChange = vi.fn();
|
|
40
|
-
const mockOnChangeInFlow = vi.fn();
|
|
41
|
-
const mockApiHandler = vi.fn();
|
|
42
|
-
|
|
43
|
-
const baseProps = {
|
|
44
|
-
field: {
|
|
45
|
-
title: 'Test Field',
|
|
46
|
-
description: 'Test Description',
|
|
47
|
-
template_fields: [],
|
|
48
|
-
type: 'TEXTFIELD',
|
|
49
|
-
properties: {},
|
|
50
|
-
},
|
|
51
|
-
functionArguments: {},
|
|
52
|
-
connectedAccount: 'test-account',
|
|
53
|
-
appName: 'Test App',
|
|
54
|
-
onChange: mockOnChange,
|
|
55
|
-
onChangeInFlow: mockOnChangeInFlow,
|
|
56
|
-
apiHandler: mockApiHandler,
|
|
57
|
-
activityOutputData: {},
|
|
58
|
-
activityOutputDataRaw: {},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
it('renders without crashing', () => {
|
|
62
|
-
const { container } = render(<ObjectField {...baseProps} />);
|
|
63
|
-
expect(container).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('calls onChange when input changes', async () => {
|
|
67
|
-
const user = userEvent.setup();
|
|
68
|
-
render(<ObjectField {...baseProps} />);
|
|
69
|
-
const input = screen.getByRole('textbox');
|
|
70
|
-
await user.type(input, 'New Value');
|
|
71
|
-
expect(mockOnChange).toHaveBeenCalled();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('conditionally renders add more button based on isArray prop', () => {
|
|
75
|
-
const { rerender } = render(<ObjectField {...baseProps} isArray={true} />);
|
|
76
|
-
expect(screen.queryByText('+ Add another Test Field')).toBeInTheDocument();
|
|
77
|
-
|
|
78
|
-
rerender(<ObjectField {...baseProps} isArray={false} />);
|
|
79
|
-
expect(
|
|
80
|
-
screen.queryByText('+ Add another Test Field'),
|
|
81
|
-
).not.toBeInTheDocument();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('handles array of objects and adds more on button click', async () => {
|
|
85
|
-
const user = userEvent.setup();
|
|
86
|
-
render(<ObjectField {...baseProps} isArray={true} />);
|
|
87
|
-
await user.click(screen.getByText('+ Add another Test Field'));
|
|
88
|
-
expect(screen.getAllByText('Test Field').length).toBe(2);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('removes an item from the list when delete is clicked', async () => {
|
|
92
|
-
const user = userEvent.setup();
|
|
93
|
-
render(
|
|
94
|
-
<ObjectField {...baseProps} isArray={true} objectValue={[{}, {}]} />,
|
|
95
|
-
);
|
|
96
|
-
expect(screen.getAllByText('Test Field').length).toBe(2);
|
|
97
|
-
await user.click(screen.getAllByRole('button')[0]); // Assuming the delete button is the first button
|
|
98
|
-
expect(screen.getAllByText('Test Field').length).toBe(1);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('validates props and throws if required props are missing', () => {
|
|
102
|
-
const consoleError = vi.spyOn(console, 'error');
|
|
103
|
-
consoleError.mockImplementation(() => {});
|
|
104
|
-
|
|
105
|
-
expect(() => render(<ObjectField />)).toThrow();
|
|
106
|
-
expect(consoleError).toHaveBeenCalled();
|
|
107
|
-
|
|
108
|
-
consoleError.mockRestore();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('renders with minimal props', () => {
|
|
112
|
-
const { container } = render(
|
|
113
|
-
<ObjectField field={{}} onChange={vi.fn()} apiHandler={vi.fn()} />,
|
|
114
|
-
);
|
|
115
|
-
expect(container).toMatchSnapshot();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('handles add more fields', async () => {
|
|
119
|
-
const onChange = vi.fn();
|
|
120
|
-
render(
|
|
121
|
-
<ObjectField
|
|
122
|
-
field={{ title: 'Test Field', isArray: true }}
|
|
123
|
-
onChange={onChange}
|
|
124
|
-
apiHandler={vi.fn()}
|
|
125
|
-
/>,
|
|
126
|
-
);
|
|
127
|
-
const addButton = screen.getByText('+ Add another Test Field');
|
|
128
|
-
await fireEvent.click(addButton);
|
|
129
|
-
expect(screen.getAllByText('Test Field').length).toBe(2);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('handles field changes', async () => {
|
|
133
|
-
const onChange = vi.fn();
|
|
134
|
-
const field = {
|
|
135
|
-
title: 'Number Field',
|
|
136
|
-
isArray: true,
|
|
137
|
-
properties: {
|
|
138
|
-
numberField: {
|
|
139
|
-
meta: {
|
|
140
|
-
title: 'Number',
|
|
141
|
-
ui: { ui_field: { type: 'TEXTFIELD' } },
|
|
142
|
-
is_required: true,
|
|
143
|
-
},
|
|
144
|
-
type: 'number',
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
render(
|
|
149
|
-
<ObjectField field={field} onChange={onChange} apiHandler={vi.fn()} />,
|
|
150
|
-
);
|
|
151
|
-
const input = screen.getByTitle('Number');
|
|
152
|
-
await fireEvent.change(input, { target: { value: '123' } });
|
|
153
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
154
|
-
expect.anything(),
|
|
155
|
-
'123',
|
|
156
|
-
expect.anything(),
|
|
157
|
-
true,
|
|
158
|
-
expect.anything(),
|
|
159
|
-
expect.anything(),
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('renders a textarea when no fields are provided', () => {
|
|
164
|
-
const field = { type: 'TEXTAREA' };
|
|
165
|
-
const { container } = render(
|
|
166
|
-
<ObjectField field={field} onChange={vi.fn()} apiHandler={vi.fn()} />,
|
|
167
|
-
);
|
|
168
|
-
expect(container.querySelector('textarea')).not.toBeNull();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('renders nested fields correctly', () => {
|
|
172
|
-
const field = {
|
|
173
|
-
properties: {
|
|
174
|
-
nestedField: {
|
|
175
|
-
meta: {
|
|
176
|
-
title: 'Nested Field',
|
|
177
|
-
ui: { ui_field: { type: 'CHECKBOX' } },
|
|
178
|
-
is_required: false,
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
render(
|
|
184
|
-
<ObjectField field={field} onChange={vi.fn()} apiHandler={vi.fn()} />,
|
|
185
|
-
);
|
|
186
|
-
expect(screen.getByText('CheckboxGroup')).toBeInTheDocument();
|
|
187
|
-
});
|
|
188
|
-
it('handles empty array as objectValue gracefully', () => {
|
|
189
|
-
render(
|
|
190
|
-
<ObjectField
|
|
191
|
-
field={{}}
|
|
192
|
-
onChange={vi.fn()}
|
|
193
|
-
apiHandler={vi.fn()}
|
|
194
|
-
objectValue={[]}
|
|
195
|
-
/>,
|
|
196
|
-
);
|
|
197
|
-
expect(screen.getByText('+ Add another')).toBeInTheDocument();
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('handles null objectValue without crashing', () => {
|
|
201
|
-
render(
|
|
202
|
-
<ObjectField
|
|
203
|
-
field={{}}
|
|
204
|
-
onChange={vi.fn()}
|
|
205
|
-
apiHandler={vi.fn()}
|
|
206
|
-
objectValue={null}
|
|
207
|
-
/>,
|
|
208
|
-
);
|
|
209
|
-
expect(screen.queryByText('TextArea')).toBeNull(); // Assuming TextArea is not rendered by default
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// Additional tests can be added here to cover more complex interactions and edge cases
|
|
213
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
.inputGroupWrapper {
|
|
2
|
-
fieldset {
|
|
3
|
-
padding: 0;
|
|
4
|
-
margin: 0;
|
|
5
|
-
border: none;
|
|
6
|
-
margin-bottom: 24px;
|
|
7
|
-
}
|
|
8
|
-
.readonlyHint {
|
|
9
|
-
width: 100%;
|
|
10
|
-
height: -webkit-fill-available;
|
|
11
|
-
z-index: 99;
|
|
12
|
-
position: absolute;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
.objectContainer {
|
|
16
|
-
margin-bottom: 20px;
|
|
17
|
-
.objectFieldWrap {
|
|
18
|
-
border-top: 1px solid #e2e0db;
|
|
19
|
-
padding-top: 20px;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
legend {
|
|
23
|
-
font-size: 12px;
|
|
24
|
-
padding-left: 0; /* Remove padding on the left */
|
|
25
|
-
margin-left: 0; /* Remove margin on the left */
|
|
26
|
-
border-left: none; /* Remove the default left border */
|
|
27
|
-
width: auto;
|
|
28
|
-
}
|
|
29
|
-
hr {
|
|
30
|
-
border: none;
|
|
31
|
-
height: 1px;
|
|
32
|
-
background-color: #e2e0db;
|
|
33
|
-
}
|
|
34
|
-
a {
|
|
35
|
-
color: #007bff;
|
|
36
|
-
text-decoration: none;
|
|
37
|
-
font-size: 12px;
|
|
38
|
-
&:hover {
|
|
39
|
-
text-decoration: underline;
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
.label {
|
|
44
|
-
margin-bottom: 15px;
|
|
45
|
-
.subLabel {
|
|
46
|
-
display: block;
|
|
47
|
-
margin-bottom: 0;
|
|
48
|
-
|
|
49
|
-
> div:first-child {
|
|
50
|
-
color: #000;
|
|
51
|
-
font-family: Inter;
|
|
52
|
-
font-size: 12px;
|
|
53
|
-
font-style: normal;
|
|
54
|
-
font-weight: 400;
|
|
55
|
-
line-height: normal;
|
|
56
|
-
margin-bottom: 3px;
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-direction: row;
|
|
59
|
-
align-items: center;
|
|
60
|
-
|
|
61
|
-
.tagSpan {
|
|
62
|
-
margin-left: 10px;
|
|
63
|
-
}
|
|
64
|
-
.refreshIcon {
|
|
65
|
-
margin-left: 8px;
|
|
66
|
-
cursor: pointer;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
> div:nth-child(2) {
|
|
70
|
-
color: var(--black-and-grey-draft-and-tooltip-desc, #999);
|
|
71
|
-
font-family: Inter;
|
|
72
|
-
font-size: 12px;
|
|
73
|
-
font-style: normal;
|
|
74
|
-
font-weight: 400;
|
|
75
|
-
line-height: normal;
|
|
76
|
-
margin-bottom: 8px;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
.required {
|
|
80
|
-
color: #333;
|
|
81
|
-
font-size: 16px;
|
|
82
|
-
margin-left: 2px;
|
|
83
|
-
}
|
|
84
|
-
.removeButton {
|
|
85
|
-
background: none;
|
|
86
|
-
border: none;
|
|
87
|
-
color: #999999; /* Red color */
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
font-size: 18px; /* Size of the delete icon */
|
|
90
|
-
padding: 0;
|
|
91
|
-
display: flex;
|
|
92
|
-
justify-content: center;
|
|
93
|
-
align-items: center;
|
|
94
|
-
margin-right: 10px;
|
|
95
|
-
margin-left: auto;
|
|
96
|
-
margin-right: 0px;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.removeButton:hover {
|
|
100
|
-
color: #999999; /* Darker red on hover */
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-cycle
|
|
2
|
-
import { IntegryAPI } from '@/modules/api';
|
|
3
|
-
import { EventEmitter } from '@/modules/event-emitter';
|
|
4
|
-
import { IntegrySDKEvents } from '@/types';
|
|
5
|
-
import { createContext } from 'preact';
|
|
6
|
-
|
|
7
|
-
export default createContext<{
|
|
8
|
-
apiHandler: IntegryAPI;
|
|
9
|
-
eventEmitter: EventEmitter<IntegrySDKEvents>;
|
|
10
|
-
isPreviewMode: boolean;
|
|
11
|
-
isReadOnly?: boolean;
|
|
12
|
-
} | null>(null);
|
package/src/declaration.d.ts
DELETED
package/src/extensions/HMAC.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param key Key to sign hash
|
|
4
|
-
* @param message Message to hash
|
|
5
|
-
* @returns {string}
|
|
6
|
-
*/
|
|
7
|
-
export async function HMAC(message: string, key: string): Promise<string> {
|
|
8
|
-
const g = (str: string) =>
|
|
9
|
-
new Uint8Array(
|
|
10
|
-
[...unescape(encodeURIComponent(str))].map((c) => c.charCodeAt(0)),
|
|
11
|
-
);
|
|
12
|
-
const k = g(key);
|
|
13
|
-
const m = g(message);
|
|
14
|
-
const c = await crypto.subtle.importKey(
|
|
15
|
-
'raw',
|
|
16
|
-
k,
|
|
17
|
-
{ name: 'HMAC', hash: 'SHA-256' },
|
|
18
|
-
true,
|
|
19
|
-
['sign'],
|
|
20
|
-
);
|
|
21
|
-
const s = await crypto.subtle.sign('HMAC', c, m);
|
|
22
|
-
return [...new Uint8Array(s)]
|
|
23
|
-
.map((b) => b.toString(16).padStart(2, '0'))
|
|
24
|
-
.join('');
|
|
25
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { UnfetchResponse } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extend default Error class
|
|
5
|
-
*/
|
|
6
|
-
class IntegryAPIError extends Error {
|
|
7
|
-
statusCode: number | undefined;
|
|
8
|
-
|
|
9
|
-
response: UnfetchResponse | undefined;
|
|
10
|
-
|
|
11
|
-
constructor(errorMessage: string, response?: UnfetchResponse) {
|
|
12
|
-
super(errorMessage);
|
|
13
|
-
this.name = this.constructor.name;
|
|
14
|
-
this.statusCode = response?.status;
|
|
15
|
-
this.response = response;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { IntegryAPIError };
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-use-before-define */
|
|
2
|
-
import { html } from 'htm/preact';
|
|
3
|
-
import { StoreType } from '@/types/store';
|
|
4
|
-
import { useEffect, useContext, useState, useRef } from 'preact/hooks';
|
|
5
|
-
import AppContext from '@/contexts/AppContext';
|
|
6
|
-
import { openPopupWindow } from '@/utils/popup';
|
|
7
|
-
import { LargeLoader } from '@/components/LargeLoader';
|
|
8
|
-
import { Button } from '@/components/Button';
|
|
9
|
-
import { Select } from '@/components/BasicSelect';
|
|
10
|
-
import { Loader } from '@/components/Loader';
|
|
11
|
-
import isBrowser from '@/utils/isBrowser';
|
|
12
|
-
import { AuthData, isAuthMessage } from '@/utils/isAuthMessage';
|
|
13
|
-
import { MarketplaceAppAuthorizationType } from '@/interfaces';
|
|
14
|
-
import { Authorization } from '@/types';
|
|
15
|
-
import { Hint } from '@/components/Tooltip';
|
|
16
|
-
import styles from './styles.module.scss';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
interface AccountDropdownProps extends StoreType {
|
|
20
|
-
authorizationType: MarketplaceAppAuthorizationType;
|
|
21
|
-
isIUAccount?: boolean;
|
|
22
|
-
showConnectButton?: boolean;
|
|
23
|
-
onAuthorizationSelected?: (authObj: Authorization | null, authorizationId: number) => void;
|
|
24
|
-
onAuthorizationDeleted?: (authObj: Authorization | null, authorizationId: number) => void;
|
|
25
|
-
triggerAddAccount?: boolean;
|
|
26
|
-
showError?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const AccountDropdown = (props: AccountDropdownProps) => {
|
|
30
|
-
const context = useContext(AppContext);
|
|
31
|
-
const {
|
|
32
|
-
authorizationType,
|
|
33
|
-
onAuthorizationSelected,
|
|
34
|
-
onAuthorizationDeleted,
|
|
35
|
-
isIUAccount = false,
|
|
36
|
-
showConnectButton = false,
|
|
37
|
-
triggerAddAccount,
|
|
38
|
-
showError = false,
|
|
39
|
-
} = props;
|
|
40
|
-
const [loading, setLoading] = useState<boolean>(false);
|
|
41
|
-
const [selectedAuthorization, setSelectedAuthorization] = useState<Authorization | null>(null);
|
|
42
|
-
const [verifyingAuthorization, setVerifyingAuthorization] = useState<boolean>(false);
|
|
43
|
-
const authorizationTypeRef = useRef<MarketplaceAppAuthorizationType | null>(null);
|
|
44
|
-
const verificationFailedErrorRef = useRef('');
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (isBrowser())
|
|
48
|
-
window.addEventListener('message', onAuthResponseReceived);
|
|
49
|
-
return () => {
|
|
50
|
-
if (isBrowser())
|
|
51
|
-
window.removeEventListener('message', onAuthResponseReceived);
|
|
52
|
-
}
|
|
53
|
-
}, [])
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (authorizationType) {
|
|
57
|
-
authorizationTypeRef.current = authorizationType;
|
|
58
|
-
}
|
|
59
|
-
if (authorizationType && authorizationType.default_authorization) {
|
|
60
|
-
setSelectedAuthorization(getAuthorizationById(authorizationType.default_authorization))
|
|
61
|
-
}
|
|
62
|
-
}, [authorizationType])
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (triggerAddAccount) {
|
|
66
|
-
handleClickConnectBtn();
|
|
67
|
-
}
|
|
68
|
-
}, [triggerAddAccount])
|
|
69
|
-
|
|
70
|
-
const openAuthWindow = (authorizationTypeId: number) => {
|
|
71
|
-
const url = context?.apiHandler.getAuthUrl(
|
|
72
|
-
authorizationTypeId,
|
|
73
|
-
) || '';
|
|
74
|
-
openPopupWindow(url, 'Auth Window', window, 800, 600);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const getAuthorizationById = (authorizationId: number): Authorization | null => {
|
|
78
|
-
let authorizationTypeObj = null;
|
|
79
|
-
if (authorizationType) {
|
|
80
|
-
authorizationTypeObj = authorizationType;
|
|
81
|
-
} else if (authorizationTypeRef.current) {
|
|
82
|
-
authorizationTypeObj = authorizationTypeRef.current;
|
|
83
|
-
}
|
|
84
|
-
if (authorizationTypeObj) {
|
|
85
|
-
return authorizationTypeObj.authorizations.find((authObj) => authObj.id === authorizationId) || null;
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const saveDefaultAuthorization = (authorizationId: number): void => {
|
|
91
|
-
let authorizationTypeId = null;
|
|
92
|
-
if (authorizationType && authorizationType.id) {
|
|
93
|
-
authorizationTypeId = authorizationType.id;
|
|
94
|
-
} else if (authorizationTypeRef.current && authorizationTypeRef.current.id) {
|
|
95
|
-
authorizationTypeId = authorizationTypeRef.current.id;
|
|
96
|
-
}
|
|
97
|
-
if (authorizationTypeId) {
|
|
98
|
-
setVerifyingAuthorization(true);
|
|
99
|
-
context?.apiHandler
|
|
100
|
-
.setDefaultAuthorization({ authorizationId, authorizationTypeId })
|
|
101
|
-
.then((data) => {
|
|
102
|
-
// eslint-disable-next-line no-empty
|
|
103
|
-
if (data && data.id) {
|
|
104
|
-
setVerifyingAuthorization(false);
|
|
105
|
-
const selectedAuthObj = getAuthorizationById(authorizationId);
|
|
106
|
-
if (selectedAuthObj) {
|
|
107
|
-
setSelectedAuthorization(selectedAuthObj);
|
|
108
|
-
}
|
|
109
|
-
if (onAuthorizationSelected) {
|
|
110
|
-
onAuthorizationSelected(selectedAuthObj, authorizationId);
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
setVerifyingAuthorization(false);
|
|
114
|
-
console.error('Failed to save selected authorization');
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const verifyAuthorization = (authorizationId: number): void => {
|
|
121
|
-
verificationFailedErrorRef.current = '';
|
|
122
|
-
setVerifyingAuthorization(true);
|
|
123
|
-
context?.apiHandler
|
|
124
|
-
.verifyOAuthWithError(authorizationId)
|
|
125
|
-
.then((data) => {
|
|
126
|
-
if (data) {
|
|
127
|
-
if (data.is_valid) {
|
|
128
|
-
saveDefaultAuthorization(authorizationId);
|
|
129
|
-
} else {
|
|
130
|
-
verificationFailedErrorRef.current = `${data.error_message}`;
|
|
131
|
-
setVerifyingAuthorization(false);
|
|
132
|
-
// show error message
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
setVerifyingAuthorization(false);
|
|
136
|
-
console.error('Failed to verify authorization');
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const deleteAuth = (authorizationId: number) => {
|
|
142
|
-
setVerifyingAuthorization(true);
|
|
143
|
-
context?.apiHandler
|
|
144
|
-
.deleteAuth(authorizationId)
|
|
145
|
-
.then((res) => {
|
|
146
|
-
if (res?.status === 200) {
|
|
147
|
-
const filteredAuthorizations = authorizationType.authorizations.filter((authObj) => authObj.id !== authorizationId) || [];
|
|
148
|
-
if (filteredAuthorizations?.length > 0) {
|
|
149
|
-
saveDefaultAuthorization(filteredAuthorizations[0].id)
|
|
150
|
-
} else {
|
|
151
|
-
setVerifyingAuthorization(false);
|
|
152
|
-
const deletedAuthObj = getAuthorizationById(authorizationId);
|
|
153
|
-
if (onAuthorizationDeleted) {
|
|
154
|
-
onAuthorizationDeleted(deletedAuthObj, authorizationId);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
setVerifyingAuthorization(false);
|
|
159
|
-
console.error('Failed to disconnect app');
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const onAuthResponseReceived = (messageEvent: MessageEvent<AuthData>) => {
|
|
165
|
-
if (isAuthMessage(messageEvent) && messageEvent.data.activity_name) {
|
|
166
|
-
if (!messageEvent.data.already_exists) {
|
|
167
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
168
|
-
const newAuthorization = {
|
|
169
|
-
id: Number(messageEvent.data.authorization_id),
|
|
170
|
-
authorization_type: messageEvent.data.activity_name,
|
|
171
|
-
user_identity: messageEvent.data.user_identity,
|
|
172
|
-
} as Authorization;
|
|
173
|
-
console.info(messageEvent.data);
|
|
174
|
-
saveDefaultAuthorization(Number(messageEvent.data.authorization_id));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const addAccount = (authorizationTypeId: number): void => {
|
|
180
|
-
openAuthWindow(authorizationTypeId);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const switchAccount = (authorizationId: number): void => {
|
|
184
|
-
verifyAuthorization(authorizationId);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const getAccountOptions = (): { label: string; key: string }[] => {
|
|
188
|
-
let accountOptions = [];
|
|
189
|
-
if (authorizationType && authorizationType.authorizations.length > 0) {
|
|
190
|
-
accountOptions = authorizationType.authorizations.map((authObj) => (
|
|
191
|
-
{ label: authObj.user_identity, key: `${authObj.id}` }
|
|
192
|
-
))
|
|
193
|
-
if (isIUAccount) {
|
|
194
|
-
accountOptions.push({ label: 'Add an account', key: 'ADD_ACCOUNT' })
|
|
195
|
-
} else {
|
|
196
|
-
accountOptions.push({ label: 'Disconnect account', key: 'DISCONNECT_ACCOUNT' })
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
accountOptions = [{ label: 'Add an account', key: 'ADD_ACCOUNT' }]
|
|
200
|
-
}
|
|
201
|
-
return accountOptions;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const handleAccountSelection = (index: number): void => {
|
|
205
|
-
const tempAccountOptions = getAccountOptions();
|
|
206
|
-
if (index >= 0 && tempAccountOptions.length > 0 && index < tempAccountOptions.length) {
|
|
207
|
-
if (tempAccountOptions[index].key === 'ADD_ACCOUNT') {
|
|
208
|
-
if (authorizationType && authorizationType.id) {
|
|
209
|
-
addAccount(authorizationType.id);
|
|
210
|
-
}
|
|
211
|
-
} else if (tempAccountOptions[index].key === 'DISCONNECT_ACCOUNT') {
|
|
212
|
-
if (selectedAuthorization && selectedAuthorization.id) {
|
|
213
|
-
deleteAuth(selectedAuthorization.id);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
switchAccount(Number(tempAccountOptions[index].key));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const shouldShowConnectButton = (): boolean => {
|
|
223
|
-
if (showConnectButton && authorizationType && authorizationType.authorizations.length === 0) {
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
return false;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const handleClickConnectBtn = (): void => {
|
|
230
|
-
if (authorizationType && authorizationType.id) {
|
|
231
|
-
addAccount(authorizationType.id);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
return html`${loading ? html`<div class="${styles.appPageLoader}"><${LargeLoader} /></div>` :
|
|
236
|
-
html`
|
|
237
|
-
${html `
|
|
238
|
-
<${Hint} dismissOnClick=${false} position="bottom-right" deltaY=${0}>
|
|
239
|
-
<div class="${styles.accountDropdownWrap}">
|
|
240
|
-
${shouldShowConnectButton() ? html`
|
|
241
|
-
<${Button} label="Connect account"
|
|
242
|
-
width="136px"
|
|
243
|
-
height="40px"
|
|
244
|
-
className="integry-secondary-btn"
|
|
245
|
-
onClick=${handleClickConnectBtn} />
|
|
246
|
-
`
|
|
247
|
-
: html`
|
|
248
|
-
<div class="${styles.accountDropdown}">
|
|
249
|
-
<${Select}
|
|
250
|
-
ariaLabel="None"
|
|
251
|
-
placeholder="None"
|
|
252
|
-
options=${getAccountOptions()}
|
|
253
|
-
value=${selectedAuthorization ? `${selectedAuthorization.id}` : undefined}
|
|
254
|
-
onChange=${handleAccountSelection}
|
|
255
|
-
><//>
|
|
256
|
-
</div>
|
|
257
|
-
`}
|
|
258
|
-
${verifyingAuthorization && html`
|
|
259
|
-
<div class="${styles.verifyingLoader}">
|
|
260
|
-
<${Loader} />
|
|
261
|
-
</div>
|
|
262
|
-
`}
|
|
263
|
-
${showError && verificationFailedErrorRef.current && html`
|
|
264
|
-
<span class="${styles.spanHint}" data-hint=${verificationFailedErrorRef.current || ''} />
|
|
265
|
-
<svg width="16" height="20" viewBox="0 0 16 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
266
|
-
<rect y="0.5" width="16" height="16" rx="8" fill="#E26154"/>
|
|
267
|
-
<g filter="url(#filter0_d_398_2637)">
|
|
268
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.30152 6.44613C7.25819 5.97754 7.66442 5.52344 8.12171 5.52344C8.61526 5.52344 9.00706 5.9775 8.97049 6.44613L8.68756 9.94401C8.66602 10.2565 8.39017 10.5022 8.07803 10.4798C7.80247 10.4574 7.59183 10.2193 7.57737 9.94401L7.30152 6.44613ZM7.29834 12.1526C7.29834 11.729 7.6707 11.3842 8.13026 11.3842C8.60094 11.3842 8.97328 11.729 8.97286 12.1526V12.3004C8.97286 12.724 8.58982 13.0588 8.13026 13.0588C7.67026 13.0588 7.29834 12.724 7.29834 12.3004V12.1526Z" fill="white"/>
|
|
269
|
-
</g>
|
|
270
|
-
<defs>
|
|
271
|
-
<filter id="filter0_d_398_2637" x="3.29834" y="5.52344" width="9.67432" height="15.5352" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
272
|
-
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
273
|
-
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
|
274
|
-
<feOffset dy="4"/>
|
|
275
|
-
<feGaussianBlur stdDeviation="2"/>
|
|
276
|
-
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
277
|
-
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_398_2637"/>
|
|
278
|
-
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_398_2637" result="shape"/>
|
|
279
|
-
</filter>
|
|
280
|
-
</defs>
|
|
281
|
-
</svg>
|
|
282
|
-
`
|
|
283
|
-
}
|
|
284
|
-
</div>
|
|
285
|
-
<//>
|
|
286
|
-
`}
|
|
287
|
-
`}`
|
|
288
|
-
;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
export default AccountDropdown;
|