@orangelogic/orange-dam-content-browser-sdk 2.1.53 → 2.1.54
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/.env +1 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +82 -0
- package/.releaserc +17 -0
- package/.travis.yml +20 -0
- package/CBSDKdemo.html +315 -0
- package/GitVersion.yml +18 -0
- package/azure-pipeline.yaml +93 -0
- package/clientlib.config.js +36 -0
- package/config/env.js +105 -0
- package/config/getHttpsConfig.js +67 -0
- package/config/jest/babelTransform.js +30 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +41 -0
- package/config/modules.js +135 -0
- package/config/paths.js +79 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +10 -0
- package/config/webpack.config.js +762 -0
- package/config/webpackDevServer.config.js +128 -0
- package/config-overrides.js +8 -0
- package/gab_extension/GAB.html +85 -0
- package/gab_extension/GoogleChrome/manifest.json +28 -0
- package/gab_extension/GoogleChrome/src/assets/icon48.png +0 -0
- package/gab_extension/GoogleChrome/src/background/index.js +6 -0
- package/gab_extension/GoogleChrome/src/scripts/index.js +347 -0
- package/gab_extension/MozillaFirefox/manifest.json +20 -0
- package/gab_extension/MozillaFirefox/src/assets/icon.png +0 -0
- package/gab_extension/MozillaFirefox/src/background/index.js +5 -0
- package/gab_extension/MozillaFirefox/src/scripts/index.js +347 -0
- package/gab_extension/README.md +11 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.pbxproj +927 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcuserdata/oldevmac01.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/xcuserdata/oldevmac01.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +63 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/Contents.json +6 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +20 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Base.lproj/Main.html +23 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Icon.png +0 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Script.js +24 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Style.css +61 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/ViewController.swift +81 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (Extension)/SafariWebExtensionHandler.swift +26 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/AppDelegate.swift +24 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/Main.storyboard +38 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Info.plist +27 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/SceneDelegate.swift +18 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (Extension)/Info.plist +13 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/AppDelegate.swift +21 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Base.lproj/Main.storyboard +125 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Info.plist +8 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Orange DAM Asset Browser Extension.entitlements +12 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Info.plist +13 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Orange DAM Asset Browser Extension.entitlements +10 -0
- package/package.json +8 -49
- package/public/index.html +92 -0
- package/scripts/build.js +218 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +53 -0
- package/src/App.tsx +98 -0
- package/src/AppContext.ts +18 -0
- package/src/GlobalConfigContext.ts +46 -0
- package/src/components/ArrayClamp/ArrayClamp.styled.ts +42 -0
- package/src/components/ArrayClamp/ArrayClamp.tsx +167 -0
- package/src/components/ArrayClamp/index.ts +1 -0
- package/src/components/Browser/Browser.styled.ts +82 -0
- package/src/components/Browser/Browser.tsx +284 -0
- package/src/components/Browser/BrowserItem.tsx +98 -0
- package/src/components/ControlBar/ControlBar.constants.tsx +66 -0
- package/src/components/ControlBar/ControlBar.styled.ts +82 -0
- package/src/components/ControlBar/ControlBar.tsx +528 -0
- package/src/components/ControlBar/Facet/Facet.tsx +113 -0
- package/src/components/ControlBar/Facet/index.ts +1 -0
- package/src/components/FormatDialog/CropPreviewer/CropPreviewer.tsx +224 -0
- package/{build/components/FormatDialog/CropPreviewer/index.d.ts → src/components/FormatDialog/CropPreviewer/index.ts} +1 -1
- package/src/components/FormatDialog/CustomRendition/CustomRendition.constants.ts +24 -0
- package/src/components/FormatDialog/CustomRendition/CustomRendition.styled.ts +57 -0
- package/src/components/FormatDialog/CustomRendition/CustomRendition.tsx +178 -0
- package/src/components/FormatDialog/CustomRendition/index.ts +1 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Crop.tsx +249 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Extension.tsx +54 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Format.tsx +86 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Resize.tsx +176 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Rotate.tsx +101 -0
- package/{build/components/FormatDialog/CustomRendition/transformations/index.d.ts → src/components/FormatDialog/CustomRendition/transformations/index.ts} +1 -3
- package/src/components/FormatDialog/FormatDialog.styled.ts +137 -0
- package/src/components/FormatDialog/FormatDialog.tsx +1533 -0
- package/src/components/FormatDialog/Previewer/Previewer.styled.ts +31 -0
- package/src/components/FormatDialog/Previewer/Previewer.tsx +143 -0
- package/src/components/FormatDialog/Previewer/index.ts +1 -0
- package/src/components/FormatDialog/ProxyMenu/ProxyMenu.styled.ts +88 -0
- package/src/components/FormatDialog/ProxyMenu/ProxyMenu.tsx +74 -0
- package/src/components/FormatDialog/ProxyMenu/index.ts +1 -0
- package/src/components/FormatDialog/TrackingParameters/TrackingParameters.tsx +59 -0
- package/src/components/FormatDialog/TrackingParameters/index.ts +1 -0
- package/src/components/FormatDialog/index.ts +1 -0
- package/src/components/Header/Header.styled.ts +51 -0
- package/src/components/Header/Header.tsx +118 -0
- package/src/components/Loader/Loader.tsx +37 -0
- package/src/components/Loader/index.ts +1 -0
- package/src/components/NoResult/NoResult.tsx +37 -0
- package/src/components/NoResult/index.tsx +1 -0
- package/src/components/Result/AssetCard/AssetCard.styled.ts +120 -0
- package/src/components/Result/AssetCard/AssetCard.tsx +192 -0
- package/src/components/Result/AssetCard/AssetCardWrapper.styled.ts +35 -0
- package/src/components/Result/AssetCard/AssetCardWrapper.tsx +165 -0
- package/src/components/Result/AssetCard/index.ts +1 -0
- package/src/components/Result/AssetPreview/AssetPreview.styled.ts +108 -0
- package/src/components/Result/AssetPreview/AssetPreview.tsx +78 -0
- package/src/components/Result/AssetPreview/ImagePreview/ImagePreview.tsx +42 -0
- package/src/components/Result/AssetPreview/ImagePreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.ts +23 -0
- package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.tsx +28 -0
- package/src/components/Result/AssetPreview/OtherPreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/VideoPreview/VideoPreview.tsx +132 -0
- package/src/components/Result/AssetPreview/VideoPreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/index.ts +1 -0
- package/src/consts/asset.ts +16 -0
- package/src/consts/data.ts +17 -0
- package/src/index.tsx +305 -0
- package/src/page/Authenticate/Authenticate.tsx +232 -0
- package/src/page/Authenticate/ConnectingBackground.tsx +44 -0
- package/src/page/Authenticate/index.tsx +94 -0
- package/src/page/Home/Home.styled.ts +46 -0
- package/src/page/Home/Home.tsx +941 -0
- package/src/react-web-component.d.ts +4617 -0
- package/src/store/assets/assets.api.ts +167 -0
- package/src/store/assets/assets.service.ts +223 -0
- package/src/store/assets/assets.slice.ts +104 -0
- package/src/store/auth/auth.service.ts +71 -0
- package/src/store/auth/auth.slice.ts +295 -0
- package/src/store/index.ts +27 -0
- package/src/store/search/search.api.ts +319 -0
- package/src/store/search/search.slice.ts +28 -0
- package/src/store/user/user.api.ts +29 -0
- package/src/styles.css +42 -0
- package/src/types/assets.ts +71 -0
- package/src/types/auth.ts +42 -0
- package/src/types/common.ts +11 -0
- package/src/types/download.ts +8 -0
- package/src/types/navigation.ts +3 -0
- package/src/types/search.ts +116 -0
- package/{build/types/storage.d.ts → src/types/storage.ts} +1 -1
- package/src/types/user.ts +6 -0
- package/src/utils/api.ts +186 -0
- package/src/utils/array.ts +25 -0
- package/src/utils/constants.ts +12 -0
- package/src/utils/fetch.ts +116 -0
- package/src/utils/getRequestUrl.ts +15 -0
- package/src/utils/hooks.ts +36 -0
- package/src/utils/icon.ts +22 -0
- package/src/utils/image.ts +157 -0
- package/src/utils/number.ts +11 -0
- package/src/utils/rotate.ts +23 -0
- package/src/utils/storage.ts +184 -0
- package/src/utils/string.ts +24 -0
- package/src/view/AssetsPicker.tsx +24 -0
- package/src/web-component.d.ts +8151 -0
- package/tsconfig.eslint.json +10 -0
- package/tsconfig.json +37 -0
- package/build/ApiService.d.ts +0 -15
- package/build/App.d.ts +0 -62
- package/build/AppContext.d.ts +0 -18
- package/build/GlobalConfigContext.d.ts +0 -32
- package/build/OrangeDAMContentBrowserSDK.min.css +0 -2
- package/build/OrangeDAMContentBrowserSDK.min.css.map +0 -1
- package/build/OrangeDAMContentBrowserSDK.min.js +0 -11468
- package/build/OrangeDAMContentBrowserSDK.min.js.map +0 -1
- package/build/asset-manifest.json +0 -13
- package/build/components/ArrayClamp/ArrayClamp.d.ts +0 -10
- package/build/components/ArrayClamp/ArrayClamp.styled.d.ts +0 -1
- package/build/components/ArrayClamp/index.d.ts +0 -1
- package/build/components/Browser/Browser.constants.d.ts +0 -3
- package/build/components/Browser/Browser.d.ts +0 -21
- package/build/components/Browser/Browser.styled.d.ts +0 -2
- package/build/components/Browser/BrowserItem.d.ts +0 -13
- package/build/components/Browser/LoadMoreButton.d.ts +0 -9
- package/build/components/ControlBar/ControlBar.constants.d.ts +0 -10
- package/build/components/ControlBar/ControlBar.d.ts +0 -23
- package/build/components/ControlBar/ControlBar.styled.d.ts +0 -1
- package/build/components/ControlBar/Facet/Facet.d.ts +0 -14
- package/build/components/ControlBar/Facet/index.d.ts +0 -1
- package/build/components/FormatDialog/CropPreviewer/CropPreviewer.d.ts +0 -41
- package/build/components/FormatDialog/CustomRendition/CustomRendition.constants.d.ts +0 -5
- package/build/components/FormatDialog/CustomRendition/CustomRendition.d.ts +0 -56
- package/build/components/FormatDialog/CustomRendition/CustomRendition.styled.d.ts +0 -1
- package/build/components/FormatDialog/CustomRendition/index.d.ts +0 -1
- package/build/components/FormatDialog/CustomRendition/transformations/Crop.d.ts +0 -26
- package/build/components/FormatDialog/CustomRendition/transformations/Extension.d.ts +0 -11
- package/build/components/FormatDialog/CustomRendition/transformations/Format.d.ts +0 -10
- package/build/components/FormatDialog/CustomRendition/transformations/Metadata.d.ts +0 -7
- package/build/components/FormatDialog/CustomRendition/transformations/Quality.d.ts +0 -7
- package/build/components/FormatDialog/CustomRendition/transformations/Resize.d.ts +0 -18
- package/build/components/FormatDialog/CustomRendition/transformations/Rotate.d.ts +0 -8
- package/build/components/FormatDialog/FormatDialog.d.ts +0 -49
- package/build/components/FormatDialog/FormatDialog.styled.d.ts +0 -3
- package/build/components/FormatDialog/Previewer/Previewer.d.ts +0 -17
- package/build/components/FormatDialog/Previewer/Previewer.styled.d.ts +0 -1
- package/build/components/FormatDialog/Previewer/index.d.ts +0 -1
- package/build/components/FormatDialog/ProxyMenu/ProxyMenu.d.ts +0 -20
- package/build/components/FormatDialog/ProxyMenu/ProxyMenu.styled.d.ts +0 -2
- package/build/components/FormatDialog/ProxyMenu/index.d.ts +0 -1
- package/build/components/FormatDialog/TrackingParameters/TrackingParameters.d.ts +0 -13
- package/build/components/FormatDialog/TrackingParameters/index.d.ts +0 -1
- package/build/components/FormatDialog/VersionHistory/VersionHistory.d.ts +0 -6
- package/build/components/FormatDialog/VersionHistory/VersionHistory.styled.d.ts +0 -1
- package/build/components/FormatDialog/VersionHistory/index.d.ts +0 -1
- package/build/components/FormatDialog/index.d.ts +0 -1
- package/build/components/Header/Header.d.ts +0 -15
- package/build/components/Header/Header.styled.d.ts +0 -5
- package/build/components/Loader/Loader.d.ts +0 -7
- package/build/components/Loader/index.d.ts +0 -1
- package/build/components/NoResult/NoResult.d.ts +0 -7
- package/build/components/NoResult/index.d.ts +0 -1
- package/build/components/Result/AssetCard/AssetCard.d.ts +0 -15
- package/build/components/Result/AssetCard/AssetCard.styled.d.ts +0 -2
- package/build/components/Result/AssetCard/AssetCardWrapper.d.ts +0 -18
- package/build/components/Result/AssetCard/AssetCardWrapper.styled.d.ts +0 -1
- package/build/components/Result/AssetCard/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/AssetPreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/AssetPreview.styled.d.ts +0 -1
- package/build/components/Result/AssetPreview/ImagePreview/ImagePreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/ImagePreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.d.ts +0 -9
- package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.d.ts +0 -1
- package/build/components/Result/AssetPreview/OtherPreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/VideoPreview/VideoPreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/VideoPreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/index.d.ts +0 -1
- package/build/consts/asset.d.ts +0 -14
- package/build/consts/auth.d.ts +0 -4
- package/build/consts/data.d.ts +0 -21
- package/build/index.d.ts +0 -225
- package/build/index.html +0 -1
- package/build/page/Authenticate/Authenticate.d.ts +0 -2
- package/build/page/Authenticate/ConnectingBackground.d.ts +0 -8
- package/build/page/Authenticate/index.d.ts +0 -2
- package/build/page/Home/Home.d.ts +0 -6
- package/build/page/Home/Home.styled.d.ts +0 -2
- package/build/setupTests.d.ts +0 -1
- package/build/store/assets/assets.api.d.ts +0 -66
- package/build/store/assets/assets.service.d.ts +0 -23
- package/build/store/assets/assets.slice.d.ts +0 -65
- package/build/store/auth/auth.service.d.ts +0 -10
- package/build/store/auth/auth.slice.d.ts +0 -76
- package/build/store/index.d.ts +0 -368
- package/build/store/search/search.api.d.ts +0 -39
- package/build/store/search/search.slice.d.ts +0 -12
- package/build/store/user/user.api.d.ts +0 -5
- package/build/types/assets.d.ts +0 -68
- package/build/types/auth.d.ts +0 -35
- package/build/types/common.d.ts +0 -11
- package/build/types/download.d.ts +0 -8
- package/build/types/navigation.d.ts +0 -3
- package/build/types/search.d.ts +0 -148
- package/build/types/user.d.ts +0 -7
- package/build/utils/api.d.ts +0 -27
- package/build/utils/array.d.ts +0 -13
- package/build/utils/constants.d.ts +0 -11
- package/build/utils/function.d.ts +0 -1
- package/build/utils/getRequestUrl.d.ts +0 -1
- package/build/utils/hooks.d.ts +0 -1
- package/build/utils/icon.d.ts +0 -3
- package/build/utils/image.d.ts +0 -24
- package/build/utils/number.d.ts +0 -4
- package/build/utils/rotate.d.ts +0 -4
- package/build/utils/storage.d.ts +0 -23
- package/build/utils/string.d.ts +0 -12
- package/build/view/AssetsPicker.d.ts +0 -6
- /package/{build → public}/favicon.ico +0 -0
- /package/{build → public}/logo192.png +0 -0
- /package/{build → public}/logo512.png +0 -0
- /package/{build → public}/manifest.json +0 -0
- /package/{build → public}/robots.txt +0 -0
- /package/{build/components/Browser/index.d.ts → src/components/Browser/index.ts} +0 -0
- /package/{build/components/ControlBar/index.d.ts → src/components/ControlBar/index.ts} +0 -0
- /package/{build/components/Header/index.d.ts → src/components/Header/index.ts} +0 -0
- /package/{build/page/Home/index.d.ts → src/page/Home/index.ts} +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { FormEventHandler, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
3
|
+
|
|
4
|
+
import { GlobalConfigContext } from '@/GlobalConfigContext';
|
|
5
|
+
import { AppDispatch } from '@/store';
|
|
6
|
+
import { authErrorSelector, oAuth, setUseSession, siteUrlSelector } from '@/store/auth/auth.slice';
|
|
7
|
+
import { checkCorrectSiteUrl } from '@/utils/api';
|
|
8
|
+
import { LOGIN_GRAPHICS_TOP_COLOR_BASE64 } from '@/utils/constants';
|
|
9
|
+
import { useDebounceState } from '@/utils/hooks';
|
|
10
|
+
import { CxChangeEvent, CxInput } from '@/web-component';
|
|
11
|
+
|
|
12
|
+
const AuthenticatePage = () => {
|
|
13
|
+
const dispatch = useDispatch<AppDispatch>();
|
|
14
|
+
const siteUrl = useSelector(siteUrlSelector);
|
|
15
|
+
const authError = useSelector(authErrorSelector);
|
|
16
|
+
const { pluginInfo, useSession } = useContext(GlobalConfigContext);
|
|
17
|
+
const [isDefined, setIsDefined] = useState(false);
|
|
18
|
+
const [url, setUrl] = useState(siteUrl);
|
|
19
|
+
const [urlError, setUrlError] = useState<string | null>(null);
|
|
20
|
+
const [checkingSite, setCheckingSite] = useDebounceState(false, 1000); // debounce to avoid flashing when check site connect too fast
|
|
21
|
+
const [showUseSessionInput, setShowUseSessionInput] = useState(false);
|
|
22
|
+
const [session, setSession] = useState(useSession);
|
|
23
|
+
const oAuthForm = useRef<HTMLFormElement>(null);
|
|
24
|
+
const siteInputRef = useRef<CxInput>(null);
|
|
25
|
+
const sessionInputRef = useRef<CxInput>(null);
|
|
26
|
+
const hiddenBoxRef = useRef<HTMLButtonElement>(null);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
Promise.all([customElements.whenDefined('cx-input')]).then(() => {
|
|
30
|
+
setIsDefined(true);
|
|
31
|
+
});
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const input = siteInputRef.current;
|
|
36
|
+
if (!input || !isDefined) return;
|
|
37
|
+
const onInput = (e: CxChangeEvent) => {
|
|
38
|
+
setUrl((e.target as HTMLInputElement).value);
|
|
39
|
+
setUrlError(null);
|
|
40
|
+
};
|
|
41
|
+
input.addEventListener('cx-input', onInput);
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
input.removeEventListener('cx-input', onInput);
|
|
45
|
+
};
|
|
46
|
+
}, [isDefined]);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const input = sessionInputRef.current;
|
|
50
|
+
if (!input || !isDefined) return;
|
|
51
|
+
const onInput = (e: CxChangeEvent) => {
|
|
52
|
+
setSession((e.target as HTMLInputElement).value);
|
|
53
|
+
};
|
|
54
|
+
input.addEventListener('cx-input', onInput);
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
input.removeEventListener('cx-input', onInput);
|
|
58
|
+
};
|
|
59
|
+
}, [dispatch, isDefined, showUseSessionInput]);
|
|
60
|
+
|
|
61
|
+
const onSubmit: FormEventHandler<HTMLFormElement> = useCallback((e) => {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
setCheckingSite(true, true);
|
|
64
|
+
const urlWithProtocol = url.indexOf('://') === -1 ? `https://${url}` : url;
|
|
65
|
+
checkCorrectSiteUrl(urlWithProtocol)
|
|
66
|
+
.then(() => {
|
|
67
|
+
dispatch(oAuth({ siteUrl: urlWithProtocol }));
|
|
68
|
+
if (session) {
|
|
69
|
+
dispatch(setUseSession(session));
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
.catch(() => {
|
|
73
|
+
const errorMessage = 'The site is currently not available. Please verify your Site URL and check your Internet connection.';
|
|
74
|
+
setUrlError(errorMessage);
|
|
75
|
+
},
|
|
76
|
+
)
|
|
77
|
+
.finally(() => setCheckingSite(false));
|
|
78
|
+
}, [dispatch, session, setCheckingSite, url]);
|
|
79
|
+
|
|
80
|
+
const cancelConnect = useCallback(() => {
|
|
81
|
+
setCheckingSite(false, true);
|
|
82
|
+
setUrlError(null);
|
|
83
|
+
}, [setCheckingSite]);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
// If the user clicks the hidden box 5 times in 2 second, show the session input
|
|
87
|
+
if (showUseSessionInput) return;
|
|
88
|
+
let clickCount = 0;
|
|
89
|
+
let clickTimeout: NodeJS.Timeout | null = null;
|
|
90
|
+
|
|
91
|
+
const handleClick = () => {
|
|
92
|
+
clickCount++;
|
|
93
|
+
if (clickCount === 5) {
|
|
94
|
+
setShowUseSessionInput(true);
|
|
95
|
+
if (clickTimeout) clearTimeout(clickTimeout);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (clickTimeout) clearTimeout(clickTimeout);
|
|
99
|
+
clickTimeout = setTimeout(() => {
|
|
100
|
+
clickCount = 0;
|
|
101
|
+
}, 2000);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const hiddenBox = hiddenBoxRef.current;
|
|
105
|
+
if (hiddenBox) {
|
|
106
|
+
hiddenBox.addEventListener('click', handleClick);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return () => {
|
|
110
|
+
if (hiddenBox) {
|
|
111
|
+
hiddenBox.removeEventListener('click', handleClick);
|
|
112
|
+
}
|
|
113
|
+
if (clickTimeout) clearTimeout(clickTimeout);
|
|
114
|
+
};
|
|
115
|
+
}, [showUseSessionInput]);
|
|
116
|
+
|
|
117
|
+
let buttonText = 'Connect';
|
|
118
|
+
if (checkingSite) {
|
|
119
|
+
buttonText = 'Connecting...';
|
|
120
|
+
} else if (urlError) {
|
|
121
|
+
buttonText = 'Retry';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div
|
|
126
|
+
style={{
|
|
127
|
+
background: `url(${LOGIN_GRAPHICS_TOP_COLOR_BASE64})`,
|
|
128
|
+
backgroundPositionX: 'center',
|
|
129
|
+
backgroundPositionY: 'top',
|
|
130
|
+
backgroundRepeat: 'no-repeat',
|
|
131
|
+
backgroundSize: 'contain',
|
|
132
|
+
display: 'flex',
|
|
133
|
+
inset: 0,
|
|
134
|
+
padding: 'var(--cx-spacing-x-small)',
|
|
135
|
+
position: 'absolute',
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
<form
|
|
139
|
+
onSubmit={onSubmit}
|
|
140
|
+
ref={oAuthForm}
|
|
141
|
+
style={{
|
|
142
|
+
display: 'flex',
|
|
143
|
+
height: '100%',
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
justifyContent: 'center',
|
|
146
|
+
textAlign: 'center',
|
|
147
|
+
width: '100%',
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<cx-space direction="vertical" spacing="medium" align-items="center">
|
|
151
|
+
{pluginInfo.pluginName && (
|
|
152
|
+
<cx-typography variant="h2">
|
|
153
|
+
Welcome to the {pluginInfo.pluginName}
|
|
154
|
+
</cx-typography>
|
|
155
|
+
)}
|
|
156
|
+
{pluginInfo.publicApplicationName && (
|
|
157
|
+
<cx-typography variant="h4">
|
|
158
|
+
for {pluginInfo.publicApplicationName}
|
|
159
|
+
</cx-typography>
|
|
160
|
+
)}
|
|
161
|
+
{authError && (
|
|
162
|
+
<cx-alert open variant="danger">
|
|
163
|
+
<cx-icon slot="icon" name="error"></cx-icon>
|
|
164
|
+
{authError}
|
|
165
|
+
</cx-alert>
|
|
166
|
+
)}
|
|
167
|
+
<cx-input
|
|
168
|
+
ref={siteInputRef}
|
|
169
|
+
label="Site URL"
|
|
170
|
+
placeholder="Enter your site URL"
|
|
171
|
+
value={url}
|
|
172
|
+
help-text={urlError ?? undefined}
|
|
173
|
+
style={{
|
|
174
|
+
width: '100%',
|
|
175
|
+
}}
|
|
176
|
+
></cx-input>
|
|
177
|
+
{
|
|
178
|
+
showUseSessionInput && (
|
|
179
|
+
<cx-input
|
|
180
|
+
ref={sessionInputRef}
|
|
181
|
+
label="Session ID"
|
|
182
|
+
placeholder="Enter your session ID"
|
|
183
|
+
value={useSession}
|
|
184
|
+
style={{
|
|
185
|
+
width: '100%',
|
|
186
|
+
}}
|
|
187
|
+
></cx-input>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
<cx-space
|
|
191
|
+
justify-content="flex-end"
|
|
192
|
+
style={{
|
|
193
|
+
width: '100%',
|
|
194
|
+
}}
|
|
195
|
+
>
|
|
196
|
+
<cx-space spacing="small" wrap="nowrap">
|
|
197
|
+
{checkingSite && (
|
|
198
|
+
<cx-button variant="default" onClick={cancelConnect}>
|
|
199
|
+
Cancel
|
|
200
|
+
</cx-button>
|
|
201
|
+
)}
|
|
202
|
+
<cx-button
|
|
203
|
+
disabled={url === '' || checkingSite}
|
|
204
|
+
variant="primary"
|
|
205
|
+
type="submit"
|
|
206
|
+
style={{
|
|
207
|
+
width: '100%',
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
{buttonText}
|
|
211
|
+
</cx-button>
|
|
212
|
+
</cx-space>
|
|
213
|
+
</cx-space>
|
|
214
|
+
</cx-space>
|
|
215
|
+
</form>
|
|
216
|
+
<button
|
|
217
|
+
ref={hiddenBoxRef}
|
|
218
|
+
tabIndex={-1}
|
|
219
|
+
style={{
|
|
220
|
+
position: 'absolute',
|
|
221
|
+
left: 0,
|
|
222
|
+
bottom: 0,
|
|
223
|
+
opacity: 0,
|
|
224
|
+
width: '32px',
|
|
225
|
+
height: '32px',
|
|
226
|
+
}}
|
|
227
|
+
></button>
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export default AuthenticatePage;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { CSSProperties, FC } from 'react';
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
footer?: React.ReactNode;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const ConnectingBackground: FC<Props> = ({ children, footer, onCancel }) => {
|
|
10
|
+
return (
|
|
11
|
+
<cx-space
|
|
12
|
+
direction="vertical"
|
|
13
|
+
spacing="large"
|
|
14
|
+
align-items="center"
|
|
15
|
+
justify-content="center"
|
|
16
|
+
style={{
|
|
17
|
+
height: '100%',
|
|
18
|
+
overflowY: 'auto',
|
|
19
|
+
padding: 'var(--cx-spacing-2x-large)',
|
|
20
|
+
textAlign: 'center',
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
|
|
25
|
+
<cx-space direction="vertical" align-items="center">
|
|
26
|
+
<cx-spinner
|
|
27
|
+
style={{
|
|
28
|
+
'--track-width': '0.2rem',
|
|
29
|
+
fontSize: 'var(--cx-font-size-3x-large)',
|
|
30
|
+
} as CSSProperties}
|
|
31
|
+
></cx-spinner>
|
|
32
|
+
<cx-typography variant="body3">
|
|
33
|
+
Waiting to connect
|
|
34
|
+
</cx-typography>
|
|
35
|
+
<cx-button onClick={onCancel}>
|
|
36
|
+
Cancel
|
|
37
|
+
</cx-button>
|
|
38
|
+
</cx-space>
|
|
39
|
+
{footer}
|
|
40
|
+
</cx-space>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default ConnectingBackground;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { FC, useCallback, useContext, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { GlobalConfigContext } from '@/GlobalConfigContext';
|
|
4
|
+
import { useAppDispatch, useAppSelector } from '@/store';
|
|
5
|
+
import {
|
|
6
|
+
appAuthUrlSelector, authStateSelector, cancelAuth, setUseSession, siteUrlSelector,
|
|
7
|
+
USE_SESSION,
|
|
8
|
+
} from '@/store/auth/auth.slice';
|
|
9
|
+
|
|
10
|
+
import AuthenticatePage from './Authenticate';
|
|
11
|
+
import ConnectingBackground from './ConnectingBackground';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
onCancel: () => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const RestoreSession: FC<Props> = ({ onCancel }) => {
|
|
18
|
+
const dispatch = useAppDispatch();
|
|
19
|
+
const localStorageSession = localStorage.getItem(USE_SESSION);
|
|
20
|
+
|
|
21
|
+
if (localStorageSession) {
|
|
22
|
+
dispatch(setUseSession(localStorageSession));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ConnectingBackground onCancel={onCancel}>
|
|
27
|
+
<cx-typography variant="h3">
|
|
28
|
+
Trying to restore your previous session
|
|
29
|
+
</cx-typography>
|
|
30
|
+
</ConnectingBackground>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const RequestLogin: FC<Props> = ({ onCancel }) => {
|
|
35
|
+
const siteUrl = useAppSelector(siteUrlSelector);
|
|
36
|
+
return (
|
|
37
|
+
<ConnectingBackground onCancel={onCancel}>
|
|
38
|
+
<cx-typography variant="h3">
|
|
39
|
+
Requesting login url from {siteUrl}
|
|
40
|
+
</cx-typography>
|
|
41
|
+
</ConnectingBackground>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const WaitForAuthorize: FC<Props> = ({ onCancel }) => {
|
|
46
|
+
const appAuthUrl = useAppSelector(appAuthUrlSelector);
|
|
47
|
+
const { pluginInfo } = useContext(GlobalConfigContext);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ConnectingBackground
|
|
51
|
+
footer={
|
|
52
|
+
<>
|
|
53
|
+
<cx-typography variant="body2">
|
|
54
|
+
I was not redirected automatically?
|
|
55
|
+
</cx-typography>
|
|
56
|
+
|
|
57
|
+
<a href={appAuthUrl} target="_blank" rel="noopener noreferrer">{appAuthUrl}</a>
|
|
58
|
+
</>
|
|
59
|
+
}
|
|
60
|
+
onCancel={onCancel}
|
|
61
|
+
>
|
|
62
|
+
<cx-typography variant="h3">
|
|
63
|
+
Please authorize the {pluginInfo.pluginName} plugin
|
|
64
|
+
</cx-typography>
|
|
65
|
+
<cx-typography variant="body2">
|
|
66
|
+
You will be automatically redirected to authorize {pluginInfo.pluginName} {pluginInfo.publicApplicationName ? `in ${pluginInfo.publicApplicationName}` : ''}
|
|
67
|
+
</cx-typography>
|
|
68
|
+
</ConnectingBackground>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const Authenticate = () => {
|
|
73
|
+
const dispatch = useAppDispatch();
|
|
74
|
+
const authState = useAppSelector(authStateSelector);
|
|
75
|
+
|
|
76
|
+
const onCancel = useCallback(() => {
|
|
77
|
+
dispatch(cancelAuth());
|
|
78
|
+
}, [dispatch]);
|
|
79
|
+
|
|
80
|
+
return useMemo(() => {
|
|
81
|
+
switch (authState) {
|
|
82
|
+
case 'unauthenticated':
|
|
83
|
+
return <AuthenticatePage />;
|
|
84
|
+
case 'restoreSession':
|
|
85
|
+
return <RestoreSession onCancel={onCancel} />;
|
|
86
|
+
case 'requestLogin':
|
|
87
|
+
return <RequestLogin onCancel={onCancel} />;
|
|
88
|
+
case 'waitForAuthorise':
|
|
89
|
+
return <WaitForAuthorize onCancel={onCancel} />;
|
|
90
|
+
}
|
|
91
|
+
}, [authState, onCancel]);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default Authenticate;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.div`
|
|
4
|
+
background-color: var(--cx-color-neutral-0);
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
position: relative;
|
|
12
|
+
transition: opacity ease-in 0.2s;
|
|
13
|
+
|
|
14
|
+
.icon--large {
|
|
15
|
+
font-size: var(--cx-input-font-size-large);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.search-input{
|
|
19
|
+
&::part(input) {
|
|
20
|
+
padding-right: var(--cx-spacing-x-small);
|
|
21
|
+
padding-left: var(--cx-spacing-x-small);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
cx-line-clamp {
|
|
26
|
+
line-height: var(--cx-line-height-small);
|
|
27
|
+
&::part(content) {
|
|
28
|
+
line-height: var(--cx-line-height-small);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.format-loader {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 50%;
|
|
35
|
+
left: 50%;
|
|
36
|
+
transform: translate(-50%, -50%);
|
|
37
|
+
background-color: var(--cx-color-neutral-0);
|
|
38
|
+
padding: var(--cx-spacing-x-small);
|
|
39
|
+
border-radius: var(--cx-border-radius-small);
|
|
40
|
+
|
|
41
|
+
cx-spinner{
|
|
42
|
+
--track-width: 0.2rem;
|
|
43
|
+
font-size: var(--cx-font-size-3x-large);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|