@finos/legend-application-query 8.1.2 → 9.0.0

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.
Files changed (125) hide show
  1. package/lib/application/LegendQuery.d.ts.map +1 -1
  2. package/lib/application/LegendQuery.js +7 -9
  3. package/lib/application/LegendQuery.js.map +1 -1
  4. package/lib/application/LegendQueryApplicationConfig.d.ts +4 -0
  5. package/lib/application/LegendQueryApplicationConfig.d.ts.map +1 -1
  6. package/lib/application/LegendQueryApplicationConfig.js +4 -0
  7. package/lib/application/LegendQueryApplicationConfig.js.map +1 -1
  8. package/lib/components/{QuerySetupStoreProvider.d.ts → CloneQueryServiceSetup.d.ts} +2 -7
  9. package/lib/components/CloneQueryServiceSetup.d.ts.map +1 -0
  10. package/lib/components/CloneQueryServiceSetup.js +137 -0
  11. package/lib/components/CloneQueryServiceSetup.js.map +1 -0
  12. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts +24 -0
  13. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -0
  14. package/lib/components/Core_LegendQueryApplicationPlugin.js +144 -0
  15. package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -0
  16. package/lib/components/CreateMappingQuerySetup.d.ts +18 -0
  17. package/lib/components/CreateMappingQuerySetup.d.ts.map +1 -0
  18. package/lib/components/CreateMappingQuerySetup.js +160 -0
  19. package/lib/components/CreateMappingQuerySetup.js.map +1 -0
  20. package/lib/components/EditExistingQuerySetup.d.ts +18 -0
  21. package/lib/components/EditExistingQuerySetup.d.ts.map +1 -0
  22. package/lib/components/EditExistingQuerySetup.js +107 -0
  23. package/lib/components/EditExistingQuerySetup.js.map +1 -0
  24. package/lib/components/LegendQueryApplication.d.ts.map +1 -1
  25. package/lib/components/LegendQueryApplication.js +4 -2
  26. package/lib/components/LegendQueryApplication.js.map +1 -1
  27. package/lib/components/LoadProjectServiceQuerySetup.d.ts +18 -0
  28. package/lib/components/LoadProjectServiceQuerySetup.d.ts.map +1 -0
  29. package/lib/components/LoadProjectServiceQuerySetup.js +63 -0
  30. package/lib/components/LoadProjectServiceQuerySetup.js.map +1 -0
  31. package/lib/components/QueryEditor.d.ts.map +1 -1
  32. package/lib/components/QueryEditor.js +31 -33
  33. package/lib/components/QueryEditor.js.map +1 -1
  34. package/lib/components/QueryProductionizerSetup.d.ts +18 -0
  35. package/lib/components/QueryProductionizerSetup.d.ts.map +1 -0
  36. package/lib/components/QueryProductionizerSetup.js +85 -0
  37. package/lib/components/QueryProductionizerSetup.js.map +1 -0
  38. package/lib/components/QuerySetup.d.ts +20 -5
  39. package/lib/components/QuerySetup.d.ts.map +1 -1
  40. package/lib/components/QuerySetup.js +69 -473
  41. package/lib/components/QuerySetup.js.map +1 -1
  42. package/lib/components/UpdateExistingServiceQuerySetup.d.ts +18 -0
  43. package/lib/components/UpdateExistingServiceQuerySetup.d.ts.map +1 -0
  44. package/lib/components/UpdateExistingServiceQuerySetup.js +69 -0
  45. package/lib/components/UpdateExistingServiceQuerySetup.js.map +1 -0
  46. package/lib/index.css +2 -2
  47. package/lib/index.css.map +1 -1
  48. package/lib/index.d.ts +2 -3
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +2 -3
  51. package/lib/index.js.map +1 -1
  52. package/lib/package.json +5 -8
  53. package/lib/stores/CloneServiceQuerySetupStore.d.ts +41 -0
  54. package/lib/stores/CloneServiceQuerySetupStore.d.ts.map +1 -0
  55. package/lib/stores/CloneServiceQuerySetupStore.js +98 -0
  56. package/lib/stores/CloneServiceQuerySetupStore.js.map +1 -0
  57. package/lib/stores/CreateMappingQuerySetupStore.d.ts +40 -0
  58. package/lib/stores/CreateMappingQuerySetupStore.d.ts.map +1 -0
  59. package/lib/stores/CreateMappingQuerySetupStore.js +97 -0
  60. package/lib/stores/CreateMappingQuerySetupStore.js.map +1 -0
  61. package/lib/stores/EditExistingQuerySetupStore.d.ts +33 -0
  62. package/lib/stores/EditExistingQuerySetupStore.d.ts.map +1 -0
  63. package/lib/stores/EditExistingQuerySetupStore.js +85 -0
  64. package/lib/stores/EditExistingQuerySetupStore.js.map +1 -0
  65. package/lib/stores/LegendQueryApplicationPlugin.d.ts +21 -16
  66. package/lib/stores/LegendQueryApplicationPlugin.d.ts.map +1 -1
  67. package/lib/stores/LegendQueryApplicationPlugin.js +4 -0
  68. package/lib/stores/LegendQueryApplicationPlugin.js.map +1 -1
  69. package/lib/stores/LegendQueryRouter.d.ts +28 -1
  70. package/lib/stores/LegendQueryRouter.d.ts.map +1 -1
  71. package/lib/stores/LegendQueryRouter.js +33 -3
  72. package/lib/stores/LegendQueryRouter.js.map +1 -1
  73. package/lib/stores/LoadProjectServiceQuerySetupStore.d.ts +27 -0
  74. package/lib/stores/LoadProjectServiceQuerySetupStore.d.ts.map +1 -0
  75. package/lib/stores/LoadProjectServiceQuerySetupStore.js +61 -0
  76. package/lib/stores/LoadProjectServiceQuerySetupStore.js.map +1 -0
  77. package/lib/stores/QueryEditorStore.d.ts +6 -2
  78. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  79. package/lib/stores/QueryEditorStore.js +35 -17
  80. package/lib/stores/QueryEditorStore.js.map +1 -1
  81. package/lib/stores/QueryEditorStoreTestUtils.d.ts.map +1 -1
  82. package/lib/stores/QueryEditorStoreTestUtils.js +3 -0
  83. package/lib/stores/QueryEditorStoreTestUtils.js.map +1 -1
  84. package/lib/stores/QueryProductionizerSetupStore.d.ts +32 -0
  85. package/lib/stores/QueryProductionizerSetupStore.d.ts.map +1 -0
  86. package/lib/stores/QueryProductionizerSetupStore.js +101 -0
  87. package/lib/stores/QueryProductionizerSetupStore.js.map +1 -0
  88. package/lib/stores/QuerySetupStore.d.ts +22 -85
  89. package/lib/stores/QuerySetupStore.d.ts.map +1 -1
  90. package/lib/stores/QuerySetupStore.js +78 -408
  91. package/lib/stores/QuerySetupStore.js.map +1 -1
  92. package/lib/stores/UpdateExistingServiceQuerySetupStore.d.ts +28 -0
  93. package/lib/stores/UpdateExistingServiceQuerySetupStore.d.ts.map +1 -0
  94. package/lib/stores/UpdateExistingServiceQuerySetupStore.js +73 -0
  95. package/lib/stores/UpdateExistingServiceQuerySetupStore.js.map +1 -0
  96. package/package.json +13 -16
  97. package/src/application/LegendQuery.tsx +7 -8
  98. package/src/application/LegendQueryApplicationConfig.ts +14 -0
  99. package/src/components/CloneQueryServiceSetup.tsx +312 -0
  100. package/src/components/Core_LegendQueryApplicationPlugin.tsx +184 -0
  101. package/src/components/CreateMappingQuerySetup.tsx +352 -0
  102. package/src/components/EditExistingQuerySetup.tsx +280 -0
  103. package/src/components/LegendQueryApplication.tsx +14 -2
  104. package/src/components/LoadProjectServiceQuerySetup.tsx +131 -0
  105. package/src/components/QueryEditor.tsx +127 -81
  106. package/src/components/QueryProductionizerSetup.tsx +206 -0
  107. package/src/components/QuerySetup.tsx +285 -1183
  108. package/src/components/UpdateExistingServiceQuerySetup.tsx +153 -0
  109. package/src/index.ts +3 -2
  110. package/src/stores/CloneServiceQuerySetupStore.ts +151 -0
  111. package/src/stores/CreateMappingQuerySetupStore.ts +155 -0
  112. package/src/stores/EditExistingQuerySetupStore.ts +111 -0
  113. package/src/stores/LegendQueryApplicationPlugin.ts +27 -27
  114. package/src/stores/LegendQueryRouter.ts +95 -12
  115. package/src/stores/LoadProjectServiceQuerySetupStore.ts +87 -0
  116. package/src/stores/QueryEditorStore.ts +90 -24
  117. package/src/stores/QueryEditorStoreTestUtils.ts +3 -0
  118. package/src/stores/QueryProductionizerSetupStore.ts +143 -0
  119. package/src/stores/QuerySetupStore.ts +111 -604
  120. package/src/stores/UpdateExistingServiceQuerySetupStore.ts +118 -0
  121. package/tsconfig.json +13 -1
  122. package/lib/components/QuerySetupStoreProvider.d.ts.map +0 -1
  123. package/lib/components/QuerySetupStoreProvider.js +0 -34
  124. package/lib/components/QuerySetupStoreProvider.js.map +0 -1
  125. package/src/components/QuerySetupStoreProvider.tsx +0 -56
@@ -14,493 +14,89 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { ArrowLeftIcon, ArrowRightIcon, BlankPanelContent, clsx, CustomSelectorInput, PanelLoadingIndicator, PlusIcon, RobotIcon, SearchIcon, UserIcon, QuestionCircleIcon, DroidIcon, ManageSearchIcon, ArrowCirceUpIcon, } from '@finos/legend-art';
18
- import { debounce, getNullableFirstElement, isNonNullable, } from '@finos/legend-shared';
19
- import { flowResult } from 'mobx';
20
- import { observer } from 'mobx-react-lite';
21
- import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
22
- import { generateMappingQueryCreatorRoute, generateExistingQueryEditorRoute, generateServiceQueryCreatorRoute, } from '../stores/LegendQueryRouter.js';
23
- import { CreateMappingQuerySetupState, EditExistingQuerySetupState, CloneServiceQuerySetupState, UpdateExistingServiceQuerySetupState, LoadProjectServiceQuerySetupState, QueryProductionizationSetupState, } from '../stores/QuerySetupStore.js';
24
- import { useQuerySetupStore, withQuerySetupStore, } from './QuerySetupStoreProvider.js';
25
- import { LATEST_VERSION_ALIAS, SNAPSHOT_VERSION_ALIAS, } from '@finos/legend-server-depot';
26
- import { compareSemVerVersions } from '@finos/legend-storage';
27
- import { useApplicationStore, buildElementOption, EDITOR_LANGUAGE, TextInputEditor, } from '@finos/legend-application';
28
- import { buildServiceOption, formatServiceOptionLabel, buildQueryOption, } from '@finos/legend-query-builder';
17
+ import { clsx, PanelLoadingIndicator, QuestionCircleIcon, CogIcon, MoreHorizontalIcon, DropdownMenu, PencilIcon, ChevronDownThinIcon, CircleIcon, MenuContent, MenuContentItem, MenuContentItemIcon, MenuContentItemLabel, CheckIcon, MenuContentDivider, } from '@finos/legend-art';
18
+ import { getQueryParameters, guaranteeNonNullable } from '@finos/legend-shared';
19
+ import { observer, useLocalObservable } from 'mobx-react-lite';
20
+ import { createContext, useContext, useEffect } from 'react';
21
+ import { LEGEND_QUERY_SETUP_QUERY_PARAM_TOKEN, } from '../stores/LegendQueryRouter.js';
22
+ import { QuerySetupLandingPageStore, } from '../stores/QuerySetupStore.js';
23
+ import { useApplicationStore } from '@finos/legend-application';
29
24
  import { useLegendQueryApplicationStore } from './LegendQueryBaseStoreProvider.js';
30
- const EditExistingQuerySetup = observer((props) => {
31
- const { querySetupState } = props;
32
- const applicationStore = useApplicationStore();
33
- const setupStore = useQuerySetupStore();
34
- const querySearchRef = useRef(null);
35
- const [searchText, setSearchText] = useState('');
36
- // actions
37
- const back = () => {
38
- setupStore.setSetupState(undefined);
39
- };
40
- const next = () => {
41
- if (querySetupState.currentQuery) {
42
- applicationStore.navigator.goToLocation(generateExistingQueryEditorRoute(querySetupState.currentQuery.id));
43
- }
44
- };
45
- const canProceed = querySetupState.currentQuery;
46
- // query
47
- const queryOptions = querySetupState.queries.map(buildQueryOption);
48
- const selectedQueryOption = querySetupState.currentQuery
49
- ? buildQueryOption(querySetupState.currentQuery)
50
- : null;
51
- const onQueryOptionChange = (option) => {
52
- if (option?.value !== querySetupState.currentQuery) {
53
- querySetupState.setCurrentQuery(option?.value.id);
54
- }
55
- };
56
- const formatQueryOptionLabel = (option) => {
57
- const deleteQuery = (event) => {
58
- event.preventDefault();
59
- event.stopPropagation();
60
- setupStore.graphManagerState.graphManager
61
- .deleteQuery(option.value.id)
62
- .then(() => flowResult(querySetupState.loadQueries('')).catch(applicationStore.alertUnhandledError))
63
- .catch(applicationStore.alertUnhandledError);
64
- };
65
- if (option.value.id === querySetupState.currentQuery?.id) {
66
- return option.label;
67
- }
68
- return (_jsxs("div", { className: "query-setup__existing-query__query-option", children: [_jsx("div", { className: "query-setup__existing-query__query-option__label", title: option.label, children: option.label }), querySetupState.showCurrentUserQueriesOnly && (_jsx("button", { className: "query-setup__existing-query__query-option__action", tabIndex: -1, onClick: deleteQuery, children: "Delete" })), !querySetupState.showCurrentUserQueriesOnly &&
69
- Boolean(option.value.owner) && (_jsx("div", { className: clsx('query-setup__existing-query__query-option__user', {
70
- 'query-setup__existing-query__query-option__user--mine': option.value.isCurrentUserQuery,
71
- }), children: option.value.isCurrentUserQuery ? 'mine' : option.value.owner }))] }));
72
- };
73
- // search text
74
- const debouncedLoadQueries = useMemo(() => debounce((input) => {
75
- flowResult(querySetupState.loadQueries(input)).catch(applicationStore.alertUnhandledError);
76
- }, 500), [applicationStore, querySetupState]);
77
- const onSearchTextChange = (value) => {
78
- if (value !== searchText) {
79
- setSearchText(value);
80
- debouncedLoadQueries.cancel();
81
- debouncedLoadQueries(value);
82
- }
83
- };
84
- // show current user queries only
85
- const toggleShowCurrentUserQueriesOnly = () => {
86
- querySetupState.setShowCurrentUserQueriesOnly(!querySetupState.showCurrentUserQueriesOnly);
87
- debouncedLoadQueries.cancel();
88
- debouncedLoadQueries(searchText);
89
- };
90
- useEffect(() => {
91
- flowResult(querySetupState.loadQueries('')).catch(applicationStore.alertUnhandledError);
92
- }, [querySetupState, applicationStore]);
93
- useEffect(() => {
94
- querySearchRef.current?.focus();
95
- }, []);
96
- return (_jsxs("div", { className: "query-setup__wizard query-setup__existing-query", children: [_jsxs("div", { className: "query-setup__wizard__header query-setup__existing-query__header", children: [_jsx("button", { className: "query-setup__wizard__header__btn", onClick: back, title: "Back to Main Menu", children: _jsx(ArrowLeftIcon, {}) }), _jsx("div", { className: "query-setup__wizard__header__title", children: "Loading an existing query..." }), _jsx("button", { className: clsx('query-setup__wizard__header__btn', {
97
- 'query-setup__wizard__header__btn--ready': canProceed,
98
- }), onClick: next, disabled: !canProceed, title: "Edit query", children: _jsx(ArrowRightIcon, {}) })] }), _jsxs("div", { className: "query-setup__wizard__content", children: [_jsxs("div", { className: "query-setup__wizard__group query-setup__wizard__group--inline", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: _jsx(SearchIcon, {}) }), _jsxs("div", { className: "query-setup__existing-query__input", children: [_jsx(CustomSelectorInput, { ref: querySearchRef, className: "query-setup__wizard__selector", options: queryOptions, isLoading: querySetupState.loadQueriesState.isInProgress, onInputChange: onSearchTextChange, inputValue: searchText, onChange: onQueryOptionChange, value: selectedQueryOption, placeholder: "Search for query by name...", isClearable: true, escapeClearsValue: true, darkMode: true, formatOptionLabel: formatQueryOptionLabel }), _jsx("button", { className: clsx('query-setup__existing-query__btn', {
99
- 'query-setup__existing-query__btn--active': querySetupState.showCurrentUserQueriesOnly,
100
- }), tabIndex: -1, title: `[${querySetupState.showCurrentUserQueriesOnly ? 'on' : 'off'}] Toggle show only queries of current user`, onClick: toggleShowCurrentUserQueriesOnly, children: _jsx(UserIcon, {}) })] })] }), _jsxs("div", { className: "query-setup__existing-query__preview", children: [_jsx(PanelLoadingIndicator, { isLoading: querySetupState.loadQueryState.isInProgress }), querySetupState.currentQuery && (_jsxs(_Fragment, { children: [!querySetupState.currentQueryInfo && (_jsx(BlankPanelContent, { children: `Can't preview query` })), querySetupState.currentQueryInfo && (_jsx(TextInputEditor, { inputValue: querySetupState.currentQueryInfo.content, isReadOnly: true, language: EDITOR_LANGUAGE.PURE, showMiniMap: false, hideGutter: true }))] })), !querySetupState.currentQuery && (_jsx(BlankPanelContent, { children: "No query to preview" }))] })] })] }));
101
- });
102
- const QueryProductionizationSetup = observer((props) => {
103
- const { querySetupState } = props;
104
- const applicationStore = useApplicationStore();
105
- const setupStore = useQuerySetupStore();
106
- const querySearchRef = useRef(null);
107
- const [searchText, setSearchText] = useState('');
108
- // actions
109
- const back = () => {
110
- setupStore.setSetupState(undefined);
111
- };
112
- const next = () => {
113
- if (querySetupState.currentQuery) {
114
- querySetupState
115
- .loadQueryProductionizer()
116
- .catch(applicationStore.alertUnhandledError);
117
- }
118
- };
119
- const canProceed = querySetupState.currentQuery;
120
- // query
121
- const queryOptions = querySetupState.queries.map(buildQueryOption);
122
- const selectedQueryOption = querySetupState.currentQuery
123
- ? buildQueryOption(querySetupState.currentQuery)
124
- : null;
125
- const onQueryOptionChange = (option) => {
126
- if (option?.value !== querySetupState.currentQuery) {
127
- querySetupState.setCurrentQuery(option?.value.id);
128
- }
129
- };
130
- // search text
131
- const debouncedLoadQueries = useMemo(() => debounce((input) => {
132
- flowResult(querySetupState.loadQueries(input)).catch(applicationStore.alertUnhandledError);
133
- }, 500), [applicationStore, querySetupState]);
134
- const onSearchTextChange = (value) => {
135
- if (value !== searchText) {
136
- setSearchText(value);
137
- debouncedLoadQueries.cancel();
138
- debouncedLoadQueries(value);
139
- }
140
- };
141
- useEffect(() => {
142
- flowResult(querySetupState.loadQueries('')).catch(applicationStore.alertUnhandledError);
143
- }, [querySetupState, applicationStore]);
144
- useEffect(() => {
145
- querySearchRef.current?.focus();
146
- }, []);
147
- return (_jsxs("div", { className: "query-setup__wizard query-setup__productionize-query", children: [_jsxs("div", { className: "query-setup__wizard__header query-setup__productionize-query__header", children: [_jsx("button", { className: "query-setup__wizard__header__btn", onClick: back, title: "Back to Main Menu", children: _jsx(ArrowLeftIcon, {}) }), _jsx("div", { className: "query-setup__wizard__header__title", children: "Productionizing an existing query..." }), _jsx("button", { className: clsx('query-setup__wizard__header__btn', {
148
- 'query-setup__wizard__header__btn--ready': canProceed,
149
- }), onClick: next, disabled: !canProceed, title: "Productionize query", children: _jsx(ArrowRightIcon, {}) })] }), _jsxs("div", { className: "query-setup__wizard__content", children: [_jsxs("div", { className: "query-setup__wizard__group query-setup__wizard__group--inline", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: _jsx(SearchIcon, {}) }), _jsx(CustomSelectorInput, { ref: querySearchRef, className: "query-setup__wizard__selector", options: queryOptions, isLoading: querySetupState.loadQueriesState.isInProgress, onInputChange: onSearchTextChange, inputValue: searchText, onChange: onQueryOptionChange, value: selectedQueryOption, placeholder: "Search for query by name...", isClearable: true, escapeClearsValue: true, darkMode: true })] }), _jsxs("div", { className: "query-setup__productionize-query__preview", children: [_jsx(PanelLoadingIndicator, { isLoading: querySetupState.loadQueryState.isInProgress }), querySetupState.currentQuery && (_jsxs(_Fragment, { children: [!querySetupState.currentQueryInfo && (_jsx(BlankPanelContent, { children: `Can't preview query` })), querySetupState.currentQueryInfo && (_jsx(TextInputEditor, { inputValue: querySetupState.currentQueryInfo.content, isReadOnly: true, language: EDITOR_LANGUAGE.PURE, showMiniMap: false, hideGutter: true }))] })), !querySetupState.currentQuery && (_jsx(BlankPanelContent, { children: "No query to preview" }))] })] })] }));
150
- });
151
- export const UpdateExistingServiceQuerySetup = observer((props) => {
152
- const { querySetupState } = props;
153
- const applicationStore = useLegendQueryApplicationStore();
154
- const setupStore = useQuerySetupStore();
155
- const serviceSearchRef = useRef(null);
156
- const [searchText, setSearchText] = useState('');
157
- const back = () => {
158
- setupStore.setSetupState(undefined);
159
- };
160
- const serviceOptions = querySetupState.services.map(buildServiceOption);
161
- const onServiceOptionChange = (option) => {
162
- querySetupState
163
- .loadServiceUpdater(option.value)
164
- .catch(applicationStore.alertUnhandledError);
165
- };
166
- // search text
167
- const debouncedLoadServices = useMemo(() => debounce((input) => {
168
- flowResult(querySetupState.loadServices(input)).catch(applicationStore.alertUnhandledError);
169
- }, 500), [applicationStore, querySetupState]);
170
- const onSearchTextChange = (value) => {
171
- if (value !== searchText) {
172
- setSearchText(value);
173
- debouncedLoadServices.cancel();
174
- debouncedLoadServices(value);
175
- }
176
- };
177
- useEffect(() => {
178
- flowResult(querySetupState.loadServices('')).catch(applicationStore.alertUnhandledError);
179
- }, [querySetupState, applicationStore]);
180
- useEffect(() => {
181
- serviceSearchRef.current?.focus();
182
- }, []);
183
- return (_jsxs("div", { className: "query-setup__wizard query-setup__existing-service-query", children: [_jsxs("div", { className: "query-setup__wizard__header query-setup__existing-service-query__header", children: [_jsx("button", { className: "query-setup__wizard__header__btn", onClick: back, title: "Back to Main Menu", children: _jsx(ArrowLeftIcon, {}) }), _jsx("div", { className: "query-setup__wizard__header__title", children: "Updating an existing service query..." })] }), _jsx("div", { className: "query-setup__wizard__content", children: _jsxs("div", { className: "query-setup__wizard__group query-setup__wizard__group--inline query-setup__existing-service-query__search-bar", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: _jsx(SearchIcon, {}) }), _jsx(CustomSelectorInput, { ref: serviceSearchRef, className: "query-setup__wizard__selector", options: serviceOptions, isLoading: querySetupState.loadServicesState.isInProgress, onInputChange: onSearchTextChange, inputValue: searchText, onChange: onServiceOptionChange, placeholder: "Search for service...", darkMode: true, formatOptionLabel: formatServiceOptionLabel })] }) })] }));
184
- });
185
- const buildProjectOption = (project) => ({
25
+ export const buildProjectOption = (project) => ({
186
26
  label: `${project.groupId}.${project.artifactId}`,
187
27
  value: project,
188
28
  });
189
- const buildVersionOption = (version) => ({
29
+ export const buildVersionOption = (version) => ({
190
30
  label: version,
191
31
  value: version,
192
32
  });
193
- const LoadProjectServiceQuerySetup = observer((props) => {
194
- const { querySetupState } = props;
33
+ const QuerySetupLandingPageStoreContext = createContext(undefined);
34
+ const QuerySetupLandingPageStoreProvider = ({ children }) => {
35
+ const applicationStore = useLegendQueryApplicationStore();
36
+ const store = useLocalObservable(() => new QuerySetupLandingPageStore(applicationStore));
37
+ return (_jsx(QuerySetupLandingPageStoreContext.Provider, { value: store, children: children }));
38
+ };
39
+ export const useQuerySetupLandingPageStore = () => guaranteeNonNullable(useContext(QuerySetupLandingPageStoreContext), `Can't find query setup landing page store in context`);
40
+ export const withQuerySetupLandingPageStore = (WrappedComponent) => function WithQuerySetupLandingPageStore() {
41
+ return (_jsx(QuerySetupLandingPageStoreProvider, { children: _jsx(WrappedComponent, {}) }));
42
+ };
43
+ const QuerySetupAction = observer((props) => {
44
+ const { action } = props;
45
+ const setupStore = useQuerySetupLandingPageStore();
195
46
  const applicationStore = useApplicationStore();
196
- const setupStore = useQuerySetupStore();
197
- const back = () => {
198
- setupStore.setSetupState(undefined);
199
- };
200
- // project
201
- const projectOptions = querySetupState.projects.map(buildProjectOption);
202
- const projectSelectorPlaceholder = querySetupState.loadProjectsState
203
- .isInProgress
204
- ? 'Loading projects'
205
- : querySetupState.loadProjectsState.hasFailed
206
- ? 'Error fetching projects'
207
- : querySetupState.projects.length
208
- ? 'Choose a project'
209
- : 'You have no projects, please create or acquire access for at least one';
210
- const onProjectOptionChange = (option) => {
211
- querySetupState
212
- .loadProjectServiceUpdater(option.value)
213
- .catch(applicationStore.alertUnhandledError);
47
+ const onClick = () => {
48
+ action.action(setupStore).catch(applicationStore.alertUnhandledError);
214
49
  };
215
- useEffect(() => {
216
- flowResult(querySetupState.loadProjects()).catch(applicationStore.alertUnhandledError);
217
- }, [querySetupState, applicationStore]);
218
- return (_jsxs("div", { className: "query-setup__wizard query-setup__existing-service-query", children: [_jsxs("div", { className: "query-setup__wizard__header query-setup__service-query__header", children: [_jsx("button", { className: "query-setup__wizard__header__btn", onClick: back, title: "Back to Main Menu", children: _jsx(ArrowLeftIcon, {}) }), _jsx("div", { className: "query-setup__wizard__header__title", children: "Load service query from a project..." })] }), _jsx("div", { className: "query-setup__wizard__content", children: _jsx("div", { className: "query-setup__wizard__group query-setup__wizard__group--inline query-setup__existing-service-query__search-bar", children: _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: projectOptions, disabled: querySetupState.loadProjectsState.isInProgress ||
219
- !projectOptions.length, isLoading: querySetupState.loadProjectsState.isInProgress, onChange: onProjectOptionChange, placeholder: projectSelectorPlaceholder, darkMode: true }) }) })] }));
50
+ if (!setupStore.showAdvancedActions && action.isAdvanced) {
51
+ return null;
52
+ }
53
+ return (_jsxs("button", { className: clsx('query-setup__landing-page__action', action.className, {
54
+ 'query-setup__landing-page__action--advanced': action.isAdvanced,
55
+ }), tabIndex: -1, onClick: onClick, children: [_jsx("div", { className: "query-setup__landing-page__action__icon", children: action.icon }), _jsx("div", { className: "query-setup__landing-page__action__label", children: action.label })] }));
220
56
  });
221
- const CloneServiceQuerySetup = observer((props) => {
222
- const { querySetupState } = props;
223
- const applicationStore = useApplicationStore();
224
- const setupStore = useQuerySetupStore();
225
- // actions
226
- const back = () => {
227
- setupStore.setSetupState(undefined);
228
- };
229
- const next = () => {
230
- if (querySetupState.currentProject &&
231
- querySetupState.currentVersionId &&
232
- querySetupState.currentServiceExecutionOption) {
233
- applicationStore.navigator.goToLocation(generateServiceQueryCreatorRoute(querySetupState.currentProject.groupId, querySetupState.currentProject.artifactId, querySetupState.currentVersionId, querySetupState.currentServiceExecutionOption.service.path, querySetupState.currentServiceExecutionOption.key));
234
- }
235
- };
236
- const canProceed = querySetupState.currentProject &&
237
- querySetupState.currentVersionId &&
238
- querySetupState.currentServiceExecutionOption;
239
- // project
240
- const projectOptions = querySetupState.projects.map(buildProjectOption);
241
- const selectedProjectOption = querySetupState.currentProject
242
- ? buildProjectOption(querySetupState.currentProject)
243
- : null;
244
- const projectSelectorPlaceholder = querySetupState.loadProjectsState
245
- .isInProgress
246
- ? 'Loading projects'
247
- : querySetupState.loadProjectsState.hasFailed
248
- ? 'Error fetching projects'
249
- : querySetupState.projects.length
250
- ? 'Choose a project'
251
- : 'You have no projects, please create or acquire access for at least one';
252
- const onProjectOptionChange = (option) => {
253
- if (option?.value !== querySetupState.currentProject) {
254
- querySetupState.setCurrentProject(option?.value);
255
- // cascade
256
- querySetupState.setCurrentVersionId(undefined);
257
- querySetupState.setCurrentServiceExecutionOption(undefined);
258
- }
259
- };
260
- // version
261
- const versionOptions = [
262
- LATEST_VERSION_ALIAS,
263
- SNAPSHOT_VERSION_ALIAS,
264
- ...(querySetupState.currentProject?.versions ?? []),
265
- ]
266
- .slice()
267
- .sort((v1, v2) => compareSemVerVersions(v2, v1))
268
- .map(buildVersionOption);
269
- const selectedVersionOption = querySetupState.currentVersionId
270
- ? buildVersionOption(querySetupState.currentVersionId)
271
- : null;
272
- const versionSelectorPlaceholder = !querySetupState.currentProject
273
- ? 'No project selected'
274
- : 'Choose a version';
275
- const onVersionOptionChange = async (option) => {
276
- if (option?.value !== querySetupState.currentVersionId) {
277
- querySetupState.setCurrentVersionId(option?.value);
278
- // cascade
279
- querySetupState.setCurrentServiceExecutionOption(undefined);
280
- if (querySetupState.currentProject &&
281
- querySetupState.currentVersionId) {
282
- await flowResult(querySetupState.loadServiceExecutionOptions(querySetupState.currentProject, querySetupState.currentVersionId)).catch(applicationStore.alertUnhandledError);
283
- }
284
- }
285
- };
286
- // service and key
287
- const serviceExecutionOptions = querySetupState.serviceExecutionOptions.map((option) => ({
288
- label: `${option.service.name}${option.key ? ` [${option.key}]` : ''}`,
289
- value: option,
290
- }));
291
- const selectedServiceExecutionOption = querySetupState.currentServiceExecutionOption
292
- ? {
293
- label: `${querySetupState.currentServiceExecutionOption.service.name}${querySetupState.currentServiceExecutionOption.key
294
- ? ` [${querySetupState.currentServiceExecutionOption.key}]`
295
- : ''}`,
296
- value: querySetupState.currentServiceExecutionOption,
297
- }
298
- : null;
299
- const serviceExecutionSelectorPlaceholder = serviceExecutionOptions.length
300
- ? 'Choose a service'
301
- : 'No service available';
302
- const onServiceExecutionOptionChange = (option) => {
303
- querySetupState.setCurrentServiceExecutionOption(option?.value ?? undefined);
304
- };
305
- useEffect(() => {
306
- flowResult(querySetupState.loadProjects()).catch(applicationStore.alertUnhandledError);
307
- }, [querySetupState, applicationStore]);
308
- return (_jsxs("div", { className: "query-setup__wizard query-setup__service-query", children: [_jsxs("div", { className: "query-setup__wizard__header query-setup__service-query__header", children: [_jsx("button", { className: "query-setup__wizard__header__btn", onClick: back, title: "Back to Main Menu", children: _jsx(ArrowLeftIcon, {}) }), _jsx("div", { className: "query-setup__wizard__header__title", children: "Clone an existing service query..." }), _jsx("button", { className: clsx('query-setup__wizard__header__btn', {
309
- 'query-setup__wizard__header__btn--ready': canProceed,
310
- }), onClick: next, disabled: !canProceed, title: "Create a new query", children: _jsx(ArrowRightIcon, {}) })] }), _jsxs("div", { className: "query-setup__wizard__content", children: [_jsxs("div", { className: "query-setup__service-query__project", children: [_jsxs("div", { className: "query-setup__wizard__group", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: "Project" }), _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: projectOptions, disabled: querySetupState.loadProjectsState.isInProgress ||
311
- !projectOptions.length, isLoading: querySetupState.loadProjectsState.isInProgress, onChange: onProjectOptionChange, value: selectedProjectOption, placeholder: projectSelectorPlaceholder, isClearable: true, escapeClearsValue: true, darkMode: true })] }), _jsxs("div", { className: "query-setup__wizard__group", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: "Version" }), _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: versionOptions, disabled: !querySetupState.currentProject, onChange: onVersionOptionChange, value: selectedVersionOption, placeholder: versionSelectorPlaceholder, isClearable: true, escapeClearsValue: true, darkMode: true })] })] }), _jsxs("div", { className: "query-setup__service-query__graph", children: [(!querySetupState.currentProject ||
312
- !querySetupState.currentVersionId ||
313
- !querySetupState.loadServiceExecutionsState.hasSucceeded) && (_jsxs("div", { className: "query-setup__service-query__graph__loader", children: [_jsx(PanelLoadingIndicator, { isLoading: Boolean(querySetupState.currentProject) &&
314
- Boolean(querySetupState.currentVersionId) &&
315
- !querySetupState.loadServiceExecutionsState.isInProgress }), _jsx(BlankPanelContent, { children: querySetupState.loadServiceExecutionsState.isInProgress
316
- ? `Surveying service executions...`
317
- : querySetupState.loadServiceExecutionsState.hasFailed
318
- ? `Can't load service executions`
319
- : 'Project and version must be specified' })] })), querySetupState.currentProject &&
320
- querySetupState.currentVersionId &&
321
- querySetupState.loadServiceExecutionsState.hasSucceeded && (_jsx(_Fragment, { children: _jsxs("div", { className: "query-setup__wizard__group", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: "Service" }), _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: serviceExecutionOptions, disabled: !serviceExecutionOptions.length, onChange: onServiceExecutionOptionChange, value: selectedServiceExecutionOption, placeholder: serviceExecutionSelectorPlaceholder, isClearable: true, escapeClearsValue: true, darkMode: true })] }) }))] })] })] }));
57
+ const QuerySetupActionGroupConfigMenu = observer(() => {
58
+ const setupStore = useQuerySetupLandingPageStore();
59
+ const toggleShowAdvancedActions = () => setupStore.setShowAdvancedActions(!setupStore.showAdvancedActions);
60
+ const toggleShowAllGroups = () => setupStore.setShowAllGroups(!setupStore.showAllGroups);
61
+ const reset = () => setupStore.resetConfig();
62
+ return (_jsxs(MenuContent, { className: "query-setup__landing-page__config-menu", children: [_jsxs(MenuContentItem, { onClick: toggleShowAdvancedActions, children: [_jsx(MenuContentItemIcon, { children: setupStore.showAdvancedActions ? _jsx(CheckIcon, {}) : null }), _jsx(MenuContentItemLabel, { children: "Show advanced actions" })] }), _jsxs(MenuContentItem, { onClick: toggleShowAllGroups, children: [_jsx(MenuContentItemIcon, { children: setupStore.showAllGroups ? _jsx(CheckIcon, {}) : null }), _jsx(MenuContentItemLabel, { children: "Show all action groups" })] }), _jsx(MenuContentDivider, {}), _jsx(MenuContentItem, { disabled: true, children: "Focus on action group:" }), _jsxs(MenuContentItem, { onClick: () => setupStore.setTagToFocus(undefined), children: [_jsx(MenuContentItemIcon, { children: !setupStore.tagToFocus ? _jsx(CheckIcon, {}) : null }), _jsx(MenuContentItemLabel, { children: "(none)" })] }), setupStore.tags.map((groupKey) => (_jsxs(MenuContentItem, { onClick: () => setupStore.setTagToFocus(groupKey), children: [_jsx(MenuContentItemIcon, { children: setupStore.tagToFocus === groupKey ? _jsx(CheckIcon, {}) : null }), _jsx(MenuContentItemLabel, { children: groupKey })] }, groupKey))), _jsx(MenuContentDivider, {}), _jsx(MenuContentItem, { onClick: reset, disabled: !setupStore.isCustomized, children: "Reset" })] }));
322
63
  });
323
- const CreateMappingQuerySetup = observer((props) => {
324
- const { querySetupState } = props;
325
- const applicationStore = useApplicationStore();
326
- const setupStore = useQuerySetupStore();
327
- // actions
328
- const back = () => {
329
- setupStore.setSetupState(undefined);
330
- };
331
- const next = () => {
332
- if (querySetupState.currentProject &&
333
- querySetupState.currentVersionId &&
334
- querySetupState.currentMapping &&
335
- querySetupState.currentRuntime) {
336
- applicationStore.navigator.goToLocation(generateMappingQueryCreatorRoute(querySetupState.currentProject.groupId, querySetupState.currentProject.artifactId, querySetupState.currentVersionId, querySetupState.currentMapping.path, querySetupState.currentRuntime.path));
337
- }
338
- };
339
- const canProceed = querySetupState.currentProject &&
340
- querySetupState.currentVersionId &&
341
- querySetupState.currentMapping &&
342
- querySetupState.currentRuntime;
343
- // project
344
- const projectOptions = querySetupState.projects.map(buildProjectOption);
345
- const selectedProjectOption = querySetupState.currentProject
346
- ? buildProjectOption(querySetupState.currentProject)
347
- : null;
348
- const projectSelectorPlaceholder = querySetupState.loadProjectsState
349
- .isInProgress
350
- ? 'Loading projects'
351
- : querySetupState.loadProjectsState.hasFailed
352
- ? 'Error fetching projects'
353
- : querySetupState.projects.length
354
- ? 'Choose a project'
355
- : 'You have no projects, please create or acquire access for at least one';
356
- const onProjectOptionChange = (option) => {
357
- if (option?.value !== querySetupState.currentProject) {
358
- querySetupState.setCurrentProject(option?.value);
359
- // cascade
360
- querySetupState.setCurrentVersionId(undefined);
361
- querySetupState.setCurrentMapping(undefined);
362
- querySetupState.setCurrentRuntime(undefined);
363
- }
364
- };
365
- // version
366
- const versionOptions = [
367
- LATEST_VERSION_ALIAS,
368
- SNAPSHOT_VERSION_ALIAS,
369
- ...(querySetupState.currentProject?.versions ?? []),
370
- ]
371
- .slice()
372
- .sort((v1, v2) => compareSemVerVersions(v2, v1))
373
- .map(buildVersionOption);
374
- const selectedVersionOption = querySetupState.currentVersionId
375
- ? buildVersionOption(querySetupState.currentVersionId)
376
- : null;
377
- const versionSelectorPlaceholder = !querySetupState.currentProject
378
- ? 'No project selected'
379
- : 'Choose a version';
380
- const onVersionOptionChange = async (option) => {
381
- if (option?.value !== querySetupState.currentVersionId) {
382
- querySetupState.setCurrentVersionId(option?.value);
383
- // cascade
384
- querySetupState.setCurrentMapping(undefined);
385
- querySetupState.setCurrentRuntime(undefined);
386
- if (querySetupState.currentProject &&
387
- querySetupState.currentVersionId) {
388
- await flowResult(querySetupState.surveyMappingRuntimeCompatibility(querySetupState.currentProject, querySetupState.currentVersionId)).catch(applicationStore.alertUnhandledError);
389
- }
390
- }
391
- };
392
- // mapping
393
- const mappingOptions = querySetupState.mappingRuntimeCompatibilitySurveyResult.map((result) => buildElementOption(result.mapping));
394
- const selectedMappingOption = querySetupState.currentMapping
395
- ? {
396
- label: querySetupState.currentMapping.name,
397
- value: querySetupState.currentMapping,
398
- }
399
- : null;
400
- const mappingSelectorPlaceholder = mappingOptions.length
401
- ? 'Choose a mapping'
402
- : 'No mapping available';
403
- const onMappingOptionChange = (option) => {
404
- querySetupState.setCurrentMapping(option?.value);
405
- // cascade
406
- if (querySetupState.currentMapping) {
407
- querySetupState.setCurrentRuntime(getNullableFirstElement(querySetupState.compatibleRuntimes));
408
- }
409
- else {
410
- querySetupState.setCurrentRuntime(undefined);
411
- }
412
- };
413
- // runtime
414
- const runtimeOptions = querySetupState.compatibleRuntimes.map(buildElementOption);
415
- const selectedRuntimeOption = querySetupState.currentRuntime
416
- ? {
417
- label: querySetupState.currentRuntime.name,
418
- value: querySetupState.currentRuntime,
419
- }
420
- : null;
421
- const runtimeSelectorPlaceholder = !querySetupState.currentMapping
422
- ? 'No mapping specified'
423
- : runtimeOptions.length
424
- ? 'Choose a runtime'
425
- : 'No runtime available';
426
- const onRuntimeOptionChange = (option) => {
427
- querySetupState.setCurrentRuntime(option?.value);
428
- };
429
- useEffect(() => {
430
- flowResult(querySetupState.loadProjects()).catch(applicationStore.alertUnhandledError);
431
- }, [querySetupState, applicationStore]);
432
- return (_jsxs("div", { className: "query-setup__wizard query-setup__create-query", children: [_jsxs("div", { className: "query-setup__wizard__header query-setup__create-query__header", children: [_jsx("button", { className: "query-setup__wizard__header__btn", onClick: back, title: "Back to Main Menu", children: _jsx(ArrowLeftIcon, {}) }), _jsx("div", { className: "query-setup__wizard__header__title", children: "Creating a new query..." }), _jsx("button", { className: clsx('query-setup__wizard__header__btn', {
433
- 'query-setup__wizard__header__btn--ready': canProceed,
434
- }), onClick: next, disabled: !canProceed, title: "Create a new query", children: _jsx(ArrowRightIcon, {}) })] }), _jsxs("div", { className: "query-setup__wizard__content", children: [_jsxs("div", { className: "query-setup__create-query__project", children: [_jsxs("div", { className: "query-setup__wizard__group", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: "Project" }), _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: projectOptions, disabled: querySetupState.loadProjectsState.isInProgress ||
435
- !projectOptions.length, isLoading: querySetupState.loadProjectsState.isInProgress, onChange: onProjectOptionChange, value: selectedProjectOption, placeholder: projectSelectorPlaceholder, isClearable: true, escapeClearsValue: true, darkMode: true })] }), _jsxs("div", { className: "query-setup__wizard__group", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: "Version" }), _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: versionOptions, disabled: !querySetupState.currentProject, onChange: onVersionOptionChange, value: selectedVersionOption, placeholder: versionSelectorPlaceholder, isClearable: true, escapeClearsValue: true, darkMode: true })] })] }), _jsxs("div", { className: "query-setup__create-query__graph", children: [(!querySetupState.currentProject ||
436
- !querySetupState.currentVersionId ||
437
- !querySetupState.surveyMappingRuntimeCompatibilityState
438
- .hasSucceeded) && (_jsxs("div", { className: "query-setup__create-query__graph__loader", children: [_jsx(PanelLoadingIndicator, { isLoading: Boolean(querySetupState.currentProject) &&
439
- Boolean(querySetupState.currentVersionId) &&
440
- !querySetupState.surveyMappingRuntimeCompatibilityState
441
- .hasSucceeded }), _jsx(BlankPanelContent, { children: querySetupState.surveyMappingRuntimeCompatibilityState
442
- .isInProgress
443
- ? `Surveying runtime and mapping compatibility...`
444
- : querySetupState.surveyMappingRuntimeCompatibilityState
445
- .hasFailed
446
- ? `Can't load runtime and mapping`
447
- : 'Project and version must be specified' })] })), querySetupState.currentProject &&
448
- querySetupState.currentVersionId &&
449
- querySetupState.surveyMappingRuntimeCompatibilityState
450
- .hasSucceeded && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "query-setup__wizard__group", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: "Mapping" }), _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: mappingOptions, disabled: !mappingOptions.length, onChange: onMappingOptionChange, value: selectedMappingOption, placeholder: mappingSelectorPlaceholder, isClearable: true, escapeClearsValue: true, darkMode: true })] }), _jsxs("div", { className: "query-setup__wizard__group", children: [_jsx("div", { className: "query-setup__wizard__group__title", children: "Runtime" }), _jsx(CustomSelectorInput, { className: "query-setup__wizard__selector", options: runtimeOptions, disabled: !mappingOptions.length ||
451
- !querySetupState.currentMapping, onChange: onRuntimeOptionChange, value: selectedRuntimeOption, placeholder: runtimeSelectorPlaceholder, isClearable: true, escapeClearsValue: true, darkMode: true })] })] }))] })] })] }));
64
+ const QuerySetupActionGroup = observer((props) => {
65
+ const { tag } = props;
66
+ const setupStore = useQuerySetupLandingPageStore();
67
+ const actions = setupStore.actions.filter((action) => action.tag === tag);
68
+ const createActions = actions.filter((action) => action.isCreateAction);
69
+ const editActions = actions.filter((action) => !action.isCreateAction);
70
+ const showAdvancedActions = () => setupStore.setShowAdvancedActions(true);
71
+ return (_jsxs("div", { className: clsx('query-setup__landing-page__action-group', {
72
+ 'query-setup__landing-page__action-group--with-tag': Boolean(tag),
73
+ }), children: [tag && (_jsx("div", { className: "query-setup__landing-page__action-group__tag", children: tag })), _jsx("div", { className: "query-setup__landing-page__action-group__header", children: (!tag || setupStore.tagToFocus === tag) && (_jsxs(DropdownMenu, { className: "query-setup__landing-page__action-group__config", title: "Show settings...", content: _jsx(QuerySetupActionGroupConfigMenu, {}), menuProps: {
74
+ anchorOrigin: { vertical: 'bottom', horizontal: 'left' },
75
+ transformOrigin: { vertical: 'top', horizontal: 'left' },
76
+ }, children: [_jsx(CogIcon, {}), setupStore.isCustomized && (_jsx("div", { className: "query-setup__landing-page__action-group__config__status", children: _jsx(CircleIcon, {}) }))] })) }), _jsxs("div", { className: "query-setup__landing-page__action-group__body", children: [_jsx("div", { className: "query-setup__landing-page__action-group__body__column", children: editActions.map((action) => (_jsx(QuerySetupAction, { action: action }, action.key))) }), _jsx("div", { className: "query-setup__landing-page__action-group__body__column", children: createActions.map((action) => (_jsx(QuerySetupAction, { action: action }, action.key))) })] }), _jsx("div", { className: "query-setup__landing-page__action-group__footer", children: _jsx("div", { className: "query-setup__landing-page__action-group__footer__content", children: !setupStore.showAdvancedActions && (_jsx("button", { className: "query-setup__landing-page__action-group__footer__btn", onClick: showAdvancedActions, tabIndex: -1, title: "Show advanced actions", children: _jsx(MoreHorizontalIcon, {}) })) }) })] }));
452
77
  });
453
- const QuerySetupLandingPage = observer(() => {
454
- const setupStore = useQuerySetupStore();
455
- const extraQuerySetupOptions = setupStore.pluginManager
456
- .getApplicationPlugins()
457
- .flatMap((plugin) => plugin.getExtraQuerySetupOptionRendererConfigurations?.() ?? [])
458
- .filter(isNonNullable)
459
- .map((config) => (_jsx(Fragment, { children: config.renderer(setupStore) }, config.key)));
460
- const editQuery = () => setupStore.setSetupState(new EditExistingQuerySetupState(setupStore));
461
- const updateServiceQuery = () => setupStore.setSetupState(new UpdateExistingServiceQuerySetupState(setupStore));
462
- const cloneServiceQuery = () => setupStore.setSetupState(new CloneServiceQuerySetupState(setupStore));
463
- const createMappingQuery = () => setupStore.setSetupState(new CreateMappingQuerySetupState(setupStore));
464
- const loadServiceQueryFromProject = () => setupStore.setSetupState(new LoadProjectServiceQuerySetupState(setupStore));
465
- const productionizeQuery = () => setupStore.setSetupState(new QueryProductionizationSetupState(setupStore));
78
+ export const QuerySetupLandingPage = withQuerySetupLandingPageStore(observer(() => {
79
+ const setupStore = useQuerySetupLandingPageStore();
80
+ const applicationStore = useLegendQueryApplicationStore();
81
+ const params = getQueryParameters(applicationStore.navigator.getCurrentAddress(), true);
82
+ const showAdvancedActions = params[LEGEND_QUERY_SETUP_QUERY_PARAM_TOKEN.SHOW_ADVANCED_ACTIONS];
83
+ const showAllGroups = params[LEGEND_QUERY_SETUP_QUERY_PARAM_TOKEN.SHOW_ALL_GROUPS];
84
+ const tagToFocus = params[LEGEND_QUERY_SETUP_QUERY_PARAM_TOKEN.TAG];
85
+ const goToStudio = () => applicationStore.navigator.visitAddress(applicationStore.config.studioUrl);
86
+ const showAllActionGroup = () => setupStore.setShowAllGroups(true);
87
+ useEffect(() => {
88
+ setupStore.initialize(showAdvancedActions, showAllGroups, tagToFocus);
89
+ }, [setupStore, showAdvancedActions, showAllGroups, tagToFocus]);
90
+ return (_jsx("div", { className: "query-setup", children: _jsx("div", { className: "query-setup__landing-page", children: setupStore.initState.hasCompleted && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "query-setup__landing-page__title", children: ["What do you want to do today", _jsx(QuestionCircleIcon, { className: "query-setup__landing-page__title__question-mark", title: "Choose one of the option below to start" })] }), _jsxs("div", { className: "query-setup__landing-page__actions", children: [setupStore.tagToFocus && (_jsx(QuerySetupActionGroup, { tag: setupStore.tagToFocus })), !setupStore.tagToFocus && (_jsxs(_Fragment, { children: [_jsx(QuerySetupActionGroup, {}), setupStore.showAllGroups && (_jsxs(_Fragment, { children: [setupStore.tags.map((tag) => (_jsx(QuerySetupActionGroup, { tag: tag }, tag))), _jsxs("div", { className: "query-setup__landing-page__action-group query-setup__landing-page__action-group--studio", children: [_jsx("div", { className: "query-setup__landing-page__action-group__tag", children: "Developer Workstation" }), _jsx("div", { className: "query-setup__landing-page__action-group__header" }), _jsx("div", { className: "query-setup__landing-page__action-group__body", children: _jsxs("button", { className: "query-setup__landing-page__action query-setup__landing-page__action--studio", onClick: goToStudio, tabIndex: -1, children: [_jsx("div", { className: "query-setup__landing-page__action__icon", children: _jsx(PencilIcon, {}) }), _jsx("div", { className: "query-setup__landing-page__action__label", children: "Open Legend Studio" })] }) }), _jsx("div", { className: "query-setup__landing-page__action-group__footer" })] })] })), !setupStore.showAllGroups && (_jsx("div", { className: "query-setup__landing-page__footer", children: _jsx("button", { className: "query-setup__landing-page__footer__more-btn", onClick: showAllActionGroup, tabIndex: -1, title: "Show all action groups", children: _jsx(ChevronDownThinIcon, {}) }) }))] }))] })] })) }) }));
91
+ }));
92
+ export const BaseQuerySetupStoreContext = createContext(undefined);
93
+ export const useBaseQuerySetupStore = () => guaranteeNonNullable(useContext(BaseQuerySetupStoreContext), `Can't find base query setup store in context`);
94
+ export const BaseQuerySetup = observer((props) => {
95
+ const { children } = props;
96
+ const setupStore = useBaseQuerySetupStore();
466
97
  useEffect(() => {
467
98
  setupStore.initialize();
468
99
  }, [setupStore]);
469
- return (_jsx(_Fragment, { children: _jsxs("div", { className: "query-setup__landing-page", children: [_jsx(PanelLoadingIndicator, { isLoading: setupStore.initState.isInProgress }), setupStore.initState.hasCompleted && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "query-setup__landing-page__title", children: ["What do you want to do today", _jsx(QuestionCircleIcon, { className: "query-setup__landing-page__title__question-mark", title: "Choose one of the option below to start" })] }), _jsxs("div", { className: "query-setup__landing-page__options", children: [_jsxs("button", { className: "query-setup__landing-page__option query-setup__landing-page__option--existing-query", onClick: editQuery, children: [_jsx("div", { className: "query-setup__landing-page__option__icon", children: _jsx(ManageSearchIcon, { className: "query-setup__landing-page__icon--search" }) }), _jsx("div", { className: "query-setup__landing-page__option__label", children: "Load an existing query" })] }), extraQuerySetupOptions, _jsxs("button", { className: "query-setup__landing-page__option query-setup__landing-page__option--advanced query-setup__landing-page__option--create-query", onClick: createMappingQuery, children: [_jsx("div", { className: "query-setup__landing-page__option__icon", children: _jsx(PlusIcon, {}) }), _jsx("div", { className: "query-setup__landing-page__option__label", children: "Create new query on a mapping" })] }), _jsxs("button", { className: "query-setup__landing-page__option query-setup__landing-page__option--advanced query-setup__landing-page__option--service-query", onClick: cloneServiceQuery, children: [_jsx("div", { className: "query-setup__landing-page__option__icon", children: _jsx(RobotIcon, {}) }), _jsx("div", { className: "query-setup__landing-page__option__label", children: "Clone an existing service query" })] }), _jsxs("button", { className: "query-setup__landing-page__option query-setup__landing-page__option--advanced query-setup__landing-page__option--service-query", onClick: updateServiceQuery, children: [_jsx("div", { className: "query-setup__landing-page__option__icon", children: _jsx(DroidIcon, {}) }), _jsx("div", { className: "query-setup__landing-page__option__label", children: "Update an existing service query" })] }), _jsxs("button", { className: "query-setup__landing-page__option query-setup__landing-page__option--advanced query-setup__landing-page__option--service-query", onClick: loadServiceQueryFromProject, children: [_jsx("div", { className: "query-setup__landing-page__option__icon", children: _jsx(DroidIcon, {}) }), _jsx("div", { className: "query-setup__landing-page__option__label", children: "Load service query from a project" })] }), _jsxs("button", { className: "query-setup__landing-page__option query-setup__landing-page__option--advanced query-setup__landing-page__option--service-query", onClick: productionizeQuery, children: [_jsx("div", { className: "query-setup__landing-page__option__icon", children: _jsx(ArrowCirceUpIcon, {}) }), _jsx("div", { className: "query-setup__landing-page__option__label", children: "Productionize an existing query" })] })] })] }))] }) }));
100
+ return (_jsxs(_Fragment, { children: [_jsx(PanelLoadingIndicator, { isLoading: setupStore.initState.isInProgress }), setupStore.initState.hasCompleted && (_jsx("div", { className: "query-setup", children: children }))] }));
470
101
  });
471
- export const QuerySetup = withQuerySetupStore(observer(() => {
472
- const setupStore = useQuerySetupStore();
473
- const querySetupState = setupStore.querySetupState;
474
- const renderQuerySetupScreen = (setupState) => {
475
- if (setupState instanceof EditExistingQuerySetupState) {
476
- return _jsx(EditExistingQuerySetup, { querySetupState: setupState });
477
- }
478
- else if (setupState instanceof CreateMappingQuerySetupState) {
479
- return _jsx(CreateMappingQuerySetup, { querySetupState: setupState });
480
- }
481
- else if (setupState instanceof CloneServiceQuerySetupState) {
482
- return _jsx(CloneServiceQuerySetup, { querySetupState: setupState });
483
- }
484
- else if (setupState instanceof UpdateExistingServiceQuerySetupState) {
485
- return _jsx(UpdateExistingServiceQuerySetup, { querySetupState: setupState });
486
- }
487
- else if (setupState instanceof LoadProjectServiceQuerySetupState) {
488
- return _jsx(LoadProjectServiceQuerySetup, { querySetupState: setupState });
489
- }
490
- else if (setupState instanceof QueryProductionizationSetupState) {
491
- return _jsx(QueryProductionizationSetup, { querySetupState: setupState });
492
- }
493
- const extraQuerySetupRenderers = setupStore.pluginManager
494
- .getApplicationPlugins()
495
- .flatMap((plugin) => plugin.getExtraQuerySetupRenderers?.() ?? []);
496
- for (const querySetupRenderer of extraQuerySetupRenderers) {
497
- const elementEditor = querySetupRenderer(setupState);
498
- if (elementEditor) {
499
- return elementEditor;
500
- }
501
- }
502
- return null;
503
- };
504
- return (_jsxs("div", { className: "query-setup", children: [!querySetupState && _jsx(QuerySetupLandingPage, {}), querySetupState && renderQuerySetupScreen(querySetupState)] }));
505
- }));
506
102
  //# sourceMappingURL=QuerySetup.js.map