@orangelogic/orange-dam-content-browser-sdk 1.0.1-test
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/README.md +57 -0
- package/azure-pipeline.yaml +94 -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 +192 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +92 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -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/Browser/index.ts +1 -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/ControlBar/index.ts +1 -0
- package/src/components/FormatDialog/CropPreviewer/CropPreviewer.tsx +224 -0
- package/src/components/FormatDialog/CropPreviewer/index.ts +3 -0
- 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/src/components/FormatDialog/CustomRendition/transformations/index.ts +5 -0
- 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/Header/index.ts +1 -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/page/Home/index.ts +1 -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/src/types/storage.ts +1 -0
- 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
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { PayloadAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { RootState } from '@/store';
|
|
3
|
+
import { resetImportStatus } from '@/store/assets/assets.slice';
|
|
4
|
+
import {
|
|
5
|
+
GetAccessKeyRes,
|
|
6
|
+
GetAccessKeyResponseCode,
|
|
7
|
+
OAuthRes,
|
|
8
|
+
} from '@/types/auth';
|
|
9
|
+
import { getRequestUrl } from '@/utils/getRequestUrl';
|
|
10
|
+
import { deleteData, getData, storeData } from '@/utils/storage';
|
|
11
|
+
import { generateRandomString } from '@/utils/string';
|
|
12
|
+
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
13
|
+
|
|
14
|
+
import { assetsApi } from '../assets/assets.api';
|
|
15
|
+
import { searchApi } from '../search/search.api';
|
|
16
|
+
import { userApi } from '../user/user.api';
|
|
17
|
+
import {
|
|
18
|
+
abortAuthService,
|
|
19
|
+
authAbortController,
|
|
20
|
+
CANCEL_AUTH_MESSAGE,
|
|
21
|
+
getAccessKeyService,
|
|
22
|
+
getAccessTokenService,
|
|
23
|
+
requestAuthorizeService,
|
|
24
|
+
} from './auth.service';
|
|
25
|
+
|
|
26
|
+
export const AUTH_FEATURE_KEY = 'auth';
|
|
27
|
+
export const AUTH_FEATURE_ACCESS_KEY_KEY = `${AUTH_FEATURE_KEY}_access_key_key`;
|
|
28
|
+
export const AUTH_FEATURE_SITE_URL_KEY = `${AUTH_FEATURE_KEY}_site_url_key`;
|
|
29
|
+
export const USE_SESSION = 'useSession';
|
|
30
|
+
|
|
31
|
+
export type AuthState = {
|
|
32
|
+
siteUrl: string;
|
|
33
|
+
userConfigSiteUrl?: string;
|
|
34
|
+
nonce?: string;
|
|
35
|
+
accessToken?: string;
|
|
36
|
+
accessKey?: string;
|
|
37
|
+
oAuthUrl?: string;
|
|
38
|
+
error?: string;
|
|
39
|
+
status: 'authenticated' | 'unauthenticated' | 'restoreSession' | 'requestLogin' | 'waitForAuthorise';
|
|
40
|
+
useSession: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// #region Slice
|
|
44
|
+
const initialState: AuthState = {
|
|
45
|
+
siteUrl: '',
|
|
46
|
+
status: 'unauthenticated',
|
|
47
|
+
useSession: '',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const authSlice = createSlice({
|
|
51
|
+
name: AUTH_FEATURE_KEY,
|
|
52
|
+
initialState,
|
|
53
|
+
reducers: {
|
|
54
|
+
setAccessToken: (state, action: PayloadAction<string | undefined>) => {
|
|
55
|
+
state.accessToken = action.payload;
|
|
56
|
+
},
|
|
57
|
+
updateAuthTokens: (state, action: PayloadAction<Partial<AuthState>>) => {
|
|
58
|
+
state.status = 'authenticated';
|
|
59
|
+
state.accessKey = action.payload.accessKey;
|
|
60
|
+
state.accessToken = action.payload.accessToken;
|
|
61
|
+
},
|
|
62
|
+
setSiteUrl: (state, action: PayloadAction<string>) => {
|
|
63
|
+
state.error = '';
|
|
64
|
+
state.siteUrl = action.payload;
|
|
65
|
+
},
|
|
66
|
+
setUserConfigSiteUrl: (state, action: PayloadAction<string>) => {
|
|
67
|
+
state.userConfigSiteUrl = action.payload;
|
|
68
|
+
},
|
|
69
|
+
generateNonce: (state) => {
|
|
70
|
+
state.nonce = generateRandomString(12);
|
|
71
|
+
},
|
|
72
|
+
logout: (state) => {
|
|
73
|
+
state.status = 'unauthenticated';
|
|
74
|
+
state.error = '';
|
|
75
|
+
state.accessKey = undefined;
|
|
76
|
+
state.accessToken = undefined;
|
|
77
|
+
state.oAuthUrl = undefined;
|
|
78
|
+
state.siteUrl = state.userConfigSiteUrl ?? '';
|
|
79
|
+
state.nonce = undefined;
|
|
80
|
+
state.useSession = '';
|
|
81
|
+
deleteData(AUTH_FEATURE_ACCESS_KEY_KEY);
|
|
82
|
+
deleteData(AUTH_FEATURE_SITE_URL_KEY);
|
|
83
|
+
deleteData(USE_SESSION);
|
|
84
|
+
deleteData('selectedSortOrder');
|
|
85
|
+
deleteData('selectedSortDirection');
|
|
86
|
+
deleteData('selectedView');
|
|
87
|
+
deleteData('newlySelectedFacet');
|
|
88
|
+
deleteData('newFacets');
|
|
89
|
+
deleteData('selectedFilter');
|
|
90
|
+
deleteData('selectedIsSeeThrough');
|
|
91
|
+
deleteData('searchText');
|
|
92
|
+
deleteData('lastLocation');
|
|
93
|
+
},
|
|
94
|
+
setAuthStatus: (state, action: PayloadAction<AuthState['status']>) => {
|
|
95
|
+
state.status = action.payload;
|
|
96
|
+
},
|
|
97
|
+
setUseSession: (state, action: PayloadAction<string>) => {
|
|
98
|
+
state.useSession = action.payload;
|
|
99
|
+
storeData(USE_SESSION, action.payload);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
extraReducers: (builder) => {
|
|
103
|
+
builder
|
|
104
|
+
.addCase(
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
106
|
+
oAuth.fulfilled,
|
|
107
|
+
(state, { payload }) => {
|
|
108
|
+
if (payload) {
|
|
109
|
+
const { accessKey, accessToken, siteUrl } = payload;
|
|
110
|
+
state.accessKey = accessKey;
|
|
111
|
+
state.accessToken = accessToken;
|
|
112
|
+
state.status = 'authenticated';
|
|
113
|
+
state.siteUrl = siteUrl;
|
|
114
|
+
storeData(AUTH_FEATURE_ACCESS_KEY_KEY, accessKey ?? '');
|
|
115
|
+
storeData(AUTH_FEATURE_SITE_URL_KEY, siteUrl);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
)
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
120
|
+
.addCase(oAuth.rejected, (state, action) => {
|
|
121
|
+
state.error = action.payload as string;
|
|
122
|
+
state.status = 'unauthenticated';
|
|
123
|
+
deleteData(AUTH_FEATURE_ACCESS_KEY_KEY);
|
|
124
|
+
})
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
126
|
+
.addCase(oAuth.pending, (state) => {
|
|
127
|
+
state.error = '';
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export default authSlice.reducer;
|
|
133
|
+
export const { logout, setAccessToken, generateNonce, setSiteUrl, setUserConfigSiteUrl, setUseSession } = authSlice.actions;
|
|
134
|
+
// #endregion
|
|
135
|
+
|
|
136
|
+
// #region Selector
|
|
137
|
+
export const authenticatedSelector = (rootState: RootState) =>
|
|
138
|
+
rootState[AUTH_FEATURE_KEY].status == 'authenticated';
|
|
139
|
+
|
|
140
|
+
export const accessTokenSelector = (rootState: RootState) =>
|
|
141
|
+
rootState[AUTH_FEATURE_KEY].accessToken;
|
|
142
|
+
|
|
143
|
+
export const oAuthUrlSelector = (rootState: RootState) =>
|
|
144
|
+
rootState[AUTH_FEATURE_KEY].oAuthUrl;
|
|
145
|
+
|
|
146
|
+
export const siteUrlSelector = (rootState: RootState) =>
|
|
147
|
+
rootState[AUTH_FEATURE_KEY].siteUrl;
|
|
148
|
+
|
|
149
|
+
export const userConfigSiteUrlSelector = (rootState: RootState) =>
|
|
150
|
+
rootState[AUTH_FEATURE_KEY].userConfigSiteUrl;
|
|
151
|
+
|
|
152
|
+
export const authErrorSelector = (rootState: RootState) =>
|
|
153
|
+
rootState[AUTH_FEATURE_KEY].error;
|
|
154
|
+
|
|
155
|
+
export const nonceSelector = (rootState: RootState) =>
|
|
156
|
+
rootState[AUTH_FEATURE_KEY].nonce;
|
|
157
|
+
|
|
158
|
+
export const authStateSelector = (rootState: RootState) =>
|
|
159
|
+
rootState[AUTH_FEATURE_KEY].status;
|
|
160
|
+
|
|
161
|
+
export const useSessionSelector = (rootState: RootState) =>
|
|
162
|
+
rootState[AUTH_FEATURE_KEY].useSession;
|
|
163
|
+
|
|
164
|
+
export const appAuthUrlSelector = (rootState: RootState) => {
|
|
165
|
+
const siteUrl = rootState[AUTH_FEATURE_KEY].siteUrl;
|
|
166
|
+
return siteUrl ? getRequestUrl(siteUrl, `AppAuth?RID=${rootState[AUTH_FEATURE_KEY].nonce}`) : '';
|
|
167
|
+
};
|
|
168
|
+
// #endregion
|
|
169
|
+
|
|
170
|
+
// #region Action
|
|
171
|
+
export const cancelAuth = createAsyncThunk(`${AUTH_FEATURE_KEY}/oauth`, (_, { dispatch, getState }) => {
|
|
172
|
+
if (!authenticatedSelector(getState() as RootState)) {
|
|
173
|
+
abortAuthService();
|
|
174
|
+
dispatch(authSlice.actions.setAuthStatus('unauthenticated'));
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export const oAuth = createAsyncThunk<OAuthRes, { siteUrl: string }>(
|
|
179
|
+
`${AUTH_FEATURE_KEY}/oauth`,
|
|
180
|
+
async ({ siteUrl }, { rejectWithValue, dispatch, getState }) => {
|
|
181
|
+
dispatch(authSlice.actions.setSiteUrl(siteUrl));
|
|
182
|
+
dispatch(authSlice.actions.setAuthStatus('requestLogin'));
|
|
183
|
+
|
|
184
|
+
const execute = async () => {
|
|
185
|
+
dispatch(generateNonce());
|
|
186
|
+
const nonce = nonceSelector(getState() as RootState);
|
|
187
|
+
const resp = await requestAuthorizeService(nonce ?? '');
|
|
188
|
+
if (authAbortController.signal.aborted) {
|
|
189
|
+
throw Error(CANCEL_AUTH_MESSAGE);
|
|
190
|
+
}
|
|
191
|
+
const requestID = resp.requestID;
|
|
192
|
+
const popupUrl = appAuthUrlSelector(getState() as RootState);
|
|
193
|
+
dispatch(authSlice.actions.setAuthStatus('waitForAuthorise'));
|
|
194
|
+
window.open(popupUrl, '_blank');
|
|
195
|
+
const getAccessKeyData = await getAccessKeyService(requestID);
|
|
196
|
+
if (getAccessKeyData.accessKey) {
|
|
197
|
+
const tokenResp = await getAccessTokenService(getAccessKeyData.accessKey);
|
|
198
|
+
if (tokenResp.accessToken) {
|
|
199
|
+
return {
|
|
200
|
+
code: GetAccessKeyResponseCode.Authorized,
|
|
201
|
+
accessKey: getAccessKeyData.accessKey,
|
|
202
|
+
accessToken: tokenResp.accessToken,
|
|
203
|
+
siteUrl,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return getAccessKeyData;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
let getOAuthResult: Awaited<ReturnType<typeof execute>>;
|
|
211
|
+
try {
|
|
212
|
+
getOAuthResult = await execute();
|
|
213
|
+
if (getOAuthResult.code !== GetAccessKeyResponseCode.Authorized) {
|
|
214
|
+
return rejectWithValue((getOAuthResult as GetAccessKeyRes).message);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Login successfully, reset other state
|
|
218
|
+
dispatch(resetImportStatus());
|
|
219
|
+
dispatch(searchApi.util.resetApiState());
|
|
220
|
+
dispatch(assetsApi.util.resetApiState());
|
|
221
|
+
dispatch(userApi.util.resetApiState());
|
|
222
|
+
|
|
223
|
+
return getOAuthResult as OAuthRes;
|
|
224
|
+
} catch (exception) {
|
|
225
|
+
return rejectWithValue((exception as Error).message);
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
export const initAuthInfoFromCache = createAsyncThunk(
|
|
231
|
+
`${AUTH_FEATURE_KEY}/initAuthInfoFromCache`,
|
|
232
|
+
async (_, { dispatch, rejectWithValue, getState }) => {
|
|
233
|
+
dispatch(authSlice.actions.setAuthStatus('restoreSession'));
|
|
234
|
+
|
|
235
|
+
const execute = async () => {
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
237
|
+
let siteUrl = siteUrlSelector(getState() as RootState);
|
|
238
|
+
if (!siteUrl) {
|
|
239
|
+
siteUrl = await getData(AUTH_FEATURE_SITE_URL_KEY) ?? '';
|
|
240
|
+
if (!siteUrl) {
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
242
|
+
siteUrl = userConfigSiteUrlSelector(getState() as RootState) ?? '';
|
|
243
|
+
}
|
|
244
|
+
if (siteUrl) {
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
246
|
+
dispatch(setSiteUrl(siteUrl));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!siteUrl) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const accessKey = await getData(AUTH_FEATURE_ACCESS_KEY_KEY);
|
|
255
|
+
|
|
256
|
+
if (accessKey) {
|
|
257
|
+
const accessToken = (
|
|
258
|
+
await getAccessTokenService(accessKey)
|
|
259
|
+
).accessToken;
|
|
260
|
+
if (accessToken) {
|
|
261
|
+
dispatch(
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
263
|
+
authSlice.actions.updateAuthTokens({
|
|
264
|
+
accessKey,
|
|
265
|
+
accessToken,
|
|
266
|
+
}),
|
|
267
|
+
);
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return false;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
let isSuccess = false;
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
isSuccess = await execute();
|
|
278
|
+
if (!isSuccess) {
|
|
279
|
+
return rejectWithValue('Unable to recover access key');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
dispatch(resetImportStatus());
|
|
283
|
+
dispatch(searchApi.util.resetApiState());
|
|
284
|
+
dispatch(assetsApi.util.resetApiState());
|
|
285
|
+
dispatch(userApi.util.resetApiState());
|
|
286
|
+
} catch (exception) {
|
|
287
|
+
return rejectWithValue((exception as Error).message);
|
|
288
|
+
} finally {
|
|
289
|
+
if (!isSuccess) {
|
|
290
|
+
dispatch(logout());
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
);
|
|
295
|
+
// #endregion
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
2
|
+
import type { TypedUseSelectorHook } from 'react-redux';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
4
|
+
import authReducer, { AUTH_FEATURE_KEY } from './auth/auth.slice';
|
|
5
|
+
import assetsReducer, { ASSETS_FEATURE_KEY } from './assets/assets.slice';
|
|
6
|
+
import { searchApi } from './search/search.api';
|
|
7
|
+
import { assetsApi } from './assets/assets.api';
|
|
8
|
+
import { userApi } from './user/user.api';
|
|
9
|
+
|
|
10
|
+
export const store = configureStore({
|
|
11
|
+
reducer: {
|
|
12
|
+
[AUTH_FEATURE_KEY]: authReducer,
|
|
13
|
+
[ASSETS_FEATURE_KEY]: assetsReducer,
|
|
14
|
+
[searchApi.reducerPath]: searchApi.reducer,
|
|
15
|
+
[userApi.reducerPath]: userApi.reducer,
|
|
16
|
+
[assetsApi.reducerPath]: assetsApi.reducer,
|
|
17
|
+
},
|
|
18
|
+
middleware: (getDefaultMiddleware) =>
|
|
19
|
+
getDefaultMiddleware().concat([searchApi.middleware, userApi.middleware, assetsApi.middleware]),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
23
|
+
|
|
24
|
+
export type AppDispatch = typeof store.dispatch;
|
|
25
|
+
|
|
26
|
+
export const useAppDispatch = () => useDispatch<AppDispatch>();
|
|
27
|
+
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import _mapKeys from 'lodash-es/mapKeys';
|
|
2
|
+
import _camelCase from 'lodash-es/camelCase';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_VIEW_SIZE, ORIGINAL_VIEW_SIZE, FIELD_CORTEX_PATH, FIELD_DOC_TYPE, FIELD_EXTENSION, FIELD_FILE_SIZE,
|
|
6
|
+
FIELD_HAS_BROWSER_CHILDREN,
|
|
7
|
+
FIELD_IDENTIFIER, FIELD_KEYWORDS, FIELD_MAX_HEIGHT, FIELD_MAX_WIDTH, FIELD_SCRUB_URL, FIELD_SUBTYPE, FIELD_TITLE_WITH_FALLBACK, FIELD_ALLOW_ATS_LINK,
|
|
8
|
+
} from '@/consts/data';
|
|
9
|
+
import { Asset, Folder, GetContentRequest, GetContentResponse } from '@/types/search';
|
|
10
|
+
import { AppBaseQuery, GetValueByKeyCaseInsensitive } from '@/utils/api';
|
|
11
|
+
import { isNullOrWhiteSpace } from '@/utils/string';
|
|
12
|
+
import { createApi } from '@reduxjs/toolkit/query/react';
|
|
13
|
+
|
|
14
|
+
const NATURAL_SORT_ORDER_REFERENCE_ID = 'OR4ND000000063615';
|
|
15
|
+
|
|
16
|
+
const resolveFolderExtraFilters = (searchText: string) => {
|
|
17
|
+
if (isNullOrWhiteSpace(searchText)) {
|
|
18
|
+
return 'MediaType:Story OR MediaType:Album';
|
|
19
|
+
}
|
|
20
|
+
return `(MediaType:Story OR MediaType:Album) AND Story_Title:${searchText}`;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const resolveAssetExtraFilters = ({
|
|
24
|
+
extensions,
|
|
25
|
+
searchText,
|
|
26
|
+
statuses,
|
|
27
|
+
visibilityClasses,
|
|
28
|
+
}: {
|
|
29
|
+
extensions: string[];
|
|
30
|
+
searchText: string;
|
|
31
|
+
statuses: string[];
|
|
32
|
+
visibilityClasses: string[];
|
|
33
|
+
}) => {
|
|
34
|
+
let statusQuery = '';
|
|
35
|
+
if (statuses?.length) {
|
|
36
|
+
statusQuery = statuses
|
|
37
|
+
.map(status => `WorkflowStatus:${status}`)
|
|
38
|
+
.join(' OR ');
|
|
39
|
+
if (statuses.length > 1) {
|
|
40
|
+
statusQuery = `(${statusQuery})`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let extensionsQuery = '';
|
|
45
|
+
if (extensions?.length) {
|
|
46
|
+
extensionsQuery = extensions
|
|
47
|
+
.map(extension => `FileExtension:${extension}`)
|
|
48
|
+
.join(' OR ');
|
|
49
|
+
if (extensions.length > 1) {
|
|
50
|
+
extensionsQuery = `(${extensionsQuery})`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let visibilityClassesQuery = '';
|
|
55
|
+
if (visibilityClasses?.length) {
|
|
56
|
+
visibilityClassesQuery = visibilityClasses
|
|
57
|
+
.map(visibilityClass => `Purpose:${visibilityClass}`)
|
|
58
|
+
.join(' OR ');
|
|
59
|
+
if (visibilityClasses.length > 1) {
|
|
60
|
+
visibilityClassesQuery = `(${visibilityClassesQuery})`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const searchTextQuery = isNullOrWhiteSpace(searchText) ? '' : `Text:${searchText}`;
|
|
65
|
+
|
|
66
|
+
const filters = [statusQuery, extensionsQuery, visibilityClassesQuery, searchTextQuery].filter(filter => filter.length > 0);
|
|
67
|
+
|
|
68
|
+
return filters.join(' AND ');
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Define a service using a base URL and expected endpoints
|
|
72
|
+
export const searchApi = createApi({
|
|
73
|
+
reducerPath: 'searchApi',
|
|
74
|
+
baseQuery: AppBaseQuery,
|
|
75
|
+
tagTypes: ['Folders', 'Images', 'ImagesInFolders'],
|
|
76
|
+
endpoints: (builder) => ({
|
|
77
|
+
getFolders: builder.query({
|
|
78
|
+
query: ({
|
|
79
|
+
folder,
|
|
80
|
+
searchText,
|
|
81
|
+
useSession,
|
|
82
|
+
}: {
|
|
83
|
+
folder: Folder;
|
|
84
|
+
searchText: string;
|
|
85
|
+
useSession?: string;
|
|
86
|
+
}) => {
|
|
87
|
+
const params = [
|
|
88
|
+
[
|
|
89
|
+
'extraFilters',
|
|
90
|
+
resolveFolderExtraFilters(searchText),
|
|
91
|
+
],
|
|
92
|
+
['fields', FIELD_CORTEX_PATH],
|
|
93
|
+
['fields', FIELD_DOC_TYPE],
|
|
94
|
+
['fields', FIELD_TITLE_WITH_FALLBACK],
|
|
95
|
+
['fields', FIELD_HAS_BROWSER_CHILDREN],
|
|
96
|
+
['objectRecordID', folder.id],
|
|
97
|
+
['orderBy', NATURAL_SORT_ORDER_REFERENCE_ID],
|
|
98
|
+
['seeThru', !isNullOrWhiteSpace(searchText)],
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
if (useSession) {
|
|
102
|
+
params.push(['UseSession', useSession]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
url: '/webapi/extensibility/integrations/contentBrowserSDK/getcontent_4bw_v1',
|
|
107
|
+
params,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
transformResponse: (
|
|
111
|
+
response: GetContentResponse,
|
|
112
|
+
_meta,
|
|
113
|
+
arg,
|
|
114
|
+
): Folder[] => {
|
|
115
|
+
return (
|
|
116
|
+
response.contentItems
|
|
117
|
+
?.map((item) => {
|
|
118
|
+
return {
|
|
119
|
+
id: item.recordID,
|
|
120
|
+
title:
|
|
121
|
+
GetValueByKeyCaseInsensitive(item.fields, FIELD_TITLE_WITH_FALLBACK) ?? '',
|
|
122
|
+
docType:
|
|
123
|
+
GetValueByKeyCaseInsensitive(item.fields, FIELD_DOC_TYPE) ?? '',
|
|
124
|
+
path: [...arg.folder.path, arg.folder.title],
|
|
125
|
+
fullPath: (
|
|
126
|
+
GetValueByKeyCaseInsensitive(item.fields, FIELD_CORTEX_PATH) ?? ''
|
|
127
|
+
).replace(/^Root\//i, ''),
|
|
128
|
+
parents: [...arg.folder.parents, arg.folder],
|
|
129
|
+
hasChildren: (GetValueByKeyCaseInsensitive(item.fields, FIELD_HAS_BROWSER_CHILDREN) ?? '0') === '1' ? true : false,
|
|
130
|
+
};
|
|
131
|
+
}) ?? []
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
providesTags: (_result, _error, arg) => {
|
|
135
|
+
return [{ type: 'Folders', id: arg.folder.id }];
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
getCollections: builder.query({
|
|
139
|
+
query: ({
|
|
140
|
+
folder,
|
|
141
|
+
useSession,
|
|
142
|
+
}) => {
|
|
143
|
+
const params = [
|
|
144
|
+
['fields', FIELD_CORTEX_PATH],
|
|
145
|
+
['fields', FIELD_DOC_TYPE],
|
|
146
|
+
['fields', FIELD_TITLE_WITH_FALLBACK],
|
|
147
|
+
['seeThru', true],
|
|
148
|
+
['subtypeCriteria', folder],
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
if (useSession) {
|
|
152
|
+
params.push(['UseSession', useSession]);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
url: '/webapi/extensibility/integrations/contentBrowserSDK/getcontent_4bw_v1',
|
|
157
|
+
params,
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
transformResponse: (
|
|
161
|
+
response: GetContentResponse,
|
|
162
|
+
_meta,
|
|
163
|
+
): Folder[] => {
|
|
164
|
+
return (
|
|
165
|
+
response.contentItems
|
|
166
|
+
?.map((item) => ({
|
|
167
|
+
id: item.recordID,
|
|
168
|
+
title:
|
|
169
|
+
GetValueByKeyCaseInsensitive(item.fields, FIELD_TITLE_WITH_FALLBACK) ?? '',
|
|
170
|
+
docType:
|
|
171
|
+
GetValueByKeyCaseInsensitive(item.fields, FIELD_DOC_TYPE) ?? '',
|
|
172
|
+
path: [],
|
|
173
|
+
fullPath: (
|
|
174
|
+
GetValueByKeyCaseInsensitive(item.fields, FIELD_CORTEX_PATH) ?? ''
|
|
175
|
+
).replace(/^Root\//i, ''),
|
|
176
|
+
parents: [],
|
|
177
|
+
hasChildren: false,
|
|
178
|
+
})) ?? []
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
providesTags: (_result, _error, arg) => {
|
|
182
|
+
return [{ type: 'Folders', id: arg.folder.id }];
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
getAssets: builder.query({
|
|
186
|
+
query: ({
|
|
187
|
+
extensions,
|
|
188
|
+
folderID,
|
|
189
|
+
isSeeThrough,
|
|
190
|
+
mediaTypes,
|
|
191
|
+
start,
|
|
192
|
+
pageSize,
|
|
193
|
+
searchText,
|
|
194
|
+
sortOrder,
|
|
195
|
+
statuses,
|
|
196
|
+
visibilityClasses,
|
|
197
|
+
useSession,
|
|
198
|
+
}: GetContentRequest) => {
|
|
199
|
+
const mappedMediaTypes = mediaTypes.map((mediaType) => ['subtypeCriteria', mediaType]);
|
|
200
|
+
const params = [
|
|
201
|
+
['objectRecordID', folderID],
|
|
202
|
+
['fields', FIELD_TITLE_WITH_FALLBACK],
|
|
203
|
+
['fields', DEFAULT_VIEW_SIZE],
|
|
204
|
+
['fields', ORIGINAL_VIEW_SIZE],
|
|
205
|
+
['fields', FIELD_KEYWORDS],
|
|
206
|
+
['fields', FIELD_MAX_WIDTH],
|
|
207
|
+
['fields', FIELD_MAX_HEIGHT],
|
|
208
|
+
['fields', FIELD_FILE_SIZE],
|
|
209
|
+
['fields', FIELD_DOC_TYPE],
|
|
210
|
+
['fields', FIELD_SUBTYPE],
|
|
211
|
+
['fields', FIELD_IDENTIFIER],
|
|
212
|
+
['fields', FIELD_EXTENSION],
|
|
213
|
+
['seeThru', isSeeThrough],
|
|
214
|
+
['start', start],
|
|
215
|
+
['limit', pageSize],
|
|
216
|
+
];
|
|
217
|
+
const extraFilters = resolveAssetExtraFilters({
|
|
218
|
+
extensions,
|
|
219
|
+
searchText,
|
|
220
|
+
statuses,
|
|
221
|
+
visibilityClasses,
|
|
222
|
+
});
|
|
223
|
+
if (extraFilters) {
|
|
224
|
+
params.push(['extraFilters', extraFilters]);
|
|
225
|
+
}
|
|
226
|
+
if (sortOrder) {
|
|
227
|
+
params.push(['orderBy', sortOrder]);
|
|
228
|
+
}
|
|
229
|
+
if (mappedMediaTypes.length) {
|
|
230
|
+
params.push(...mappedMediaTypes);
|
|
231
|
+
}
|
|
232
|
+
if (useSession) {
|
|
233
|
+
params.push(['UseSession', useSession]);
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
url: '/webapi/extensibility/integrations/contentBrowserSDK/getcontent_4bw_v1',
|
|
237
|
+
params,
|
|
238
|
+
};
|
|
239
|
+
},
|
|
240
|
+
transformResponse: (
|
|
241
|
+
response: GetContentResponse,
|
|
242
|
+
): {
|
|
243
|
+
facets: Record<string, Record<string, number>>;
|
|
244
|
+
items: Asset[];
|
|
245
|
+
totalCount: number;
|
|
246
|
+
} => ({
|
|
247
|
+
facets: _mapKeys(response.facets, (_, key) => _camelCase(key)),
|
|
248
|
+
items:
|
|
249
|
+
response.contentItems?.map((item) => {
|
|
250
|
+
let extension = GetValueByKeyCaseInsensitive(item.fields, FIELD_EXTENSION) ?? '';
|
|
251
|
+
if (extension && !extension.startsWith('.')) {
|
|
252
|
+
extension = '.' + extension;
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
docType: GetValueByKeyCaseInsensitive(item.fields, FIELD_DOC_TYPE) ?? '',
|
|
256
|
+
docSubType: GetValueByKeyCaseInsensitive(item.fields, FIELD_SUBTYPE) ?? '',
|
|
257
|
+
extension,
|
|
258
|
+
height: GetValueByKeyCaseInsensitive(item.fields, FIELD_MAX_HEIGHT) ?? '0',
|
|
259
|
+
id: item.recordID,
|
|
260
|
+
identifier: GetValueByKeyCaseInsensitive(item.fields, FIELD_IDENTIFIER) ?? '',
|
|
261
|
+
imageUrl: GetValueByKeyCaseInsensitive(item.fields, DEFAULT_VIEW_SIZE) ?? '',
|
|
262
|
+
originalUrl: GetValueByKeyCaseInsensitive(item.fields, ORIGINAL_VIEW_SIZE) ?? '',
|
|
263
|
+
name: GetValueByKeyCaseInsensitive(item.fields, FIELD_TITLE_WITH_FALLBACK) ?? '',
|
|
264
|
+
scrubUrl: GetValueByKeyCaseInsensitive(item.fields, FIELD_SCRUB_URL) ?? '',
|
|
265
|
+
size: GetValueByKeyCaseInsensitive(item.fields, FIELD_FILE_SIZE) ?? '0 MB',
|
|
266
|
+
tags: GetValueByKeyCaseInsensitive(item.fields, FIELD_KEYWORDS) ?? '',
|
|
267
|
+
width: GetValueByKeyCaseInsensitive(item.fields, FIELD_MAX_WIDTH) ?? '0',
|
|
268
|
+
allowATSLink: GetValueByKeyCaseInsensitive(item.fields, FIELD_ALLOW_ATS_LINK) === 'True',
|
|
269
|
+
} as Asset;
|
|
270
|
+
}) ?? [],
|
|
271
|
+
totalCount: response.totalCount,
|
|
272
|
+
}),
|
|
273
|
+
providesTags: (_result, _error, arg) => {
|
|
274
|
+
return [
|
|
275
|
+
{
|
|
276
|
+
extensions: arg.extensions,
|
|
277
|
+
id: arg.folderID,
|
|
278
|
+
isSeeThrough: arg.isSeeThrough,
|
|
279
|
+
mediaTypes: arg.mediaTypes,
|
|
280
|
+
searchText: arg.searchText,
|
|
281
|
+
sortOrder: arg.sortOrder,
|
|
282
|
+
statuses: arg.statuses,
|
|
283
|
+
type: 'ImagesInFolders',
|
|
284
|
+
},
|
|
285
|
+
'Images',
|
|
286
|
+
];
|
|
287
|
+
},
|
|
288
|
+
merge: (currentCachedData, responseData, request) => {
|
|
289
|
+
if (request.arg.start > 0) {
|
|
290
|
+
currentCachedData.items.push(...responseData.items);
|
|
291
|
+
return currentCachedData;
|
|
292
|
+
} else {
|
|
293
|
+
return responseData;
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
forceRefetch({ currentArg, previousArg }) {
|
|
297
|
+
return currentArg !== previousArg;
|
|
298
|
+
},
|
|
299
|
+
serializeQueryArgs: ({ endpointName, queryArgs }) => {
|
|
300
|
+
return {
|
|
301
|
+
endpointName,
|
|
302
|
+
extensions: queryArgs.extensions,
|
|
303
|
+
id: queryArgs.folderID,
|
|
304
|
+
isSeeThrough: queryArgs.isSeeThrough,
|
|
305
|
+
mediaTypes: queryArgs.mediaTypes,
|
|
306
|
+
searchText: queryArgs.searchText,
|
|
307
|
+
sortOrder: queryArgs.sortOrder,
|
|
308
|
+
statuses: queryArgs.statuses,
|
|
309
|
+
type: 'ImagesInFolders',
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
}),
|
|
313
|
+
}),
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Export hooks for usage in functional components, which are
|
|
317
|
+
// auto-generated based on the defined endpoints
|
|
318
|
+
export const { useGetFoldersQuery, useGetCollectionsQuery, useGetAssetsQuery } =
|
|
319
|
+
searchApi;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Folder } from '@/types/search';
|
|
2
|
+
import { createAsyncThunk } from '@reduxjs/toolkit';
|
|
3
|
+
import { searchApi } from './search.api';
|
|
4
|
+
|
|
5
|
+
export const RootFolder: Folder = Object.freeze({
|
|
6
|
+
id: '',
|
|
7
|
+
title: '',
|
|
8
|
+
docType: 'Story',
|
|
9
|
+
path: [],
|
|
10
|
+
parents: [],
|
|
11
|
+
fullPath: '',
|
|
12
|
+
hasChildren: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// #region Thunk
|
|
16
|
+
export const explorePath = createAsyncThunk(
|
|
17
|
+
'auth/explorePath',
|
|
18
|
+
async (folder: Folder, { dispatch }) => {
|
|
19
|
+
dispatch(
|
|
20
|
+
searchApi.util.invalidateTags([
|
|
21
|
+
{ type: 'ImagesInFolders', id: folder.id },
|
|
22
|
+
]),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return true;
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
// #endregion
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { store } from '@/store';
|
|
2
|
+
import { UserInfo } from '@/types/user';
|
|
3
|
+
import { AppBaseQuery } from '@/utils/api';
|
|
4
|
+
import { createApi } from '@reduxjs/toolkit/query/react';
|
|
5
|
+
|
|
6
|
+
import { AUTH_FEATURE_KEY } from '../auth/auth.slice';
|
|
7
|
+
|
|
8
|
+
// Define a service using a base URL and expected endpoints
|
|
9
|
+
export const userApi = createApi({
|
|
10
|
+
reducerPath: 'userApi',
|
|
11
|
+
baseQuery: AppBaseQuery,
|
|
12
|
+
endpoints: (builder) => ({
|
|
13
|
+
getUserInfo: builder.query({
|
|
14
|
+
query: () => '/webapi/extensibility/integrations/gab/authorization/getuserinfo_4bs_v1',
|
|
15
|
+
transformResponse: (response: UserInfo): UserInfo => {
|
|
16
|
+
const authState = store.getState()[AUTH_FEATURE_KEY];
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
...response,
|
|
20
|
+
avatar: `${authState.siteUrl}/${response.avatar}`,
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Export hooks for usage in functional components, which are
|
|
28
|
+
// auto-generated based on the defined endpoints
|
|
29
|
+
export const { useGetUserInfoQuery } = userApi;
|