@evergis/apps 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/dialogs/ResourcePreview/styled.js +2 -1
- package/dist/catalog/dialogs/ResourcePreview/styled.js.map +1 -1
- package/dist/devmode/modules/layer/components/LayerViewSwitch/hooks/useLayerViewSwitch.js +14 -2
- package/dist/devmode/modules/layer/components/LayerViewSwitch/hooks/useLayerViewSwitch.js.map +1 -1
- package/dist/devmode/modules/layer/slices/layerSlice.d.ts +2 -0
- package/dist/devmode/modules/layer/slices/layerSlice.js +3 -1
- package/dist/devmode/modules/layer/slices/layerSlice.js.map +1 -1
- package/dist/devmode/modules/layer/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -36,7 +36,8 @@ const PreviewIconFile = styled.div.withConfig({ displayName: "PreviewIconFile",
|
|
|
36
36
|
width: 3rem;
|
|
37
37
|
height: 3rem;
|
|
38
38
|
margin: auto;
|
|
39
|
-
|
|
39
|
+
/* Кавычки обязательны: svg встраиваются в сборку data URI с пробелами и одинарными кавычками. */
|
|
40
|
+
background: url("${({ $isDirectory, $resourceType }) => ($isDirectory ? img : getResourceTypeIcon($resourceType))}")
|
|
40
41
|
center center no-repeat;
|
|
41
42
|
`;
|
|
42
43
|
const SYM_LINK_SIZES = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styled.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo, useCallback } from 'react';
|
|
1
|
+
import { useMemo, useRef, useCallback, useEffect } from 'react';
|
|
2
2
|
import { EQL_QUERY_TAB } from '../../../../eql/constants.js';
|
|
3
3
|
import '@evergis/api';
|
|
4
4
|
import '../../../../../core/api/devModeApi.js';
|
|
@@ -91,7 +91,10 @@ const useLayerViewSwitch = () => {
|
|
|
91
91
|
const isEql = tab?.type === EQL_QUERY_TAB;
|
|
92
92
|
const layerName = useMemo(() => (tab ? layerNameOf(tab) : undefined), [tab]);
|
|
93
93
|
const hasEqlModule = useMemo(() => Boolean(registry.getTabType(EQL_QUERY_TAB)), [registry]);
|
|
94
|
+
const openedEqlRef = useRef(false);
|
|
94
95
|
const canShowEql = useDevModeSelector(state => isEql || Boolean(layerSlice.selectors.selectTab(state, tabId)?.isQuery));
|
|
96
|
+
// Режим вкладки слоя: `eql` — query-слой открывается запросом EQL; `json` — выбран переключателем.
|
|
97
|
+
const isEqlMode = useDevModeSelector(state => layerSlice.selectors.selectTab(state, tabId)?.view === "eql");
|
|
95
98
|
const isDirty = useDevModeSelector(state => isEql ? Boolean(selectEqlTab(state, tabId)?.changed) : isLayerDirty(state, tabId));
|
|
96
99
|
const switchView = useCallback(async (type) => {
|
|
97
100
|
if (!tab || !layerName || tab.type === type) {
|
|
@@ -100,11 +103,20 @@ const useLayerViewSwitch = () => {
|
|
|
100
103
|
if (isDirty && !(await confirmDiscard(env))) {
|
|
101
104
|
return;
|
|
102
105
|
}
|
|
103
|
-
|
|
106
|
+
// JSON из переключателя — режим `json`: вкладка не уходит обратно в EQL.
|
|
107
|
+
const init = type === EQL_QUERY_TAB ? { origin: { kind: "layer", layerName } } : { view: "json" };
|
|
104
108
|
await replaceTab(tab.id, { type, ref: layerRefOf(layerName), title: tab.title, init });
|
|
105
109
|
}, [env, isDirty, layerName, replaceTab, tab]);
|
|
106
110
|
const showEql = useCallback(() => switchView(EQL_QUERY_TAB), [switchView]);
|
|
107
111
|
const showJson = useCallback(() => switchView(LAYER_SERVICE_TAB), [switchView]);
|
|
112
|
+
// Query-слой в режиме `eql` открывается запросом EQL: тип слоя известен только после загрузки описания.
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (isEql || !isEqlMode || !canShowEql || !hasEqlModule || openedEqlRef.current) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
openedEqlRef.current = true;
|
|
118
|
+
void showEql();
|
|
119
|
+
}, [canShowEql, hasEqlModule, isEql, isEqlMode, showEql]);
|
|
108
120
|
return { isEql, canShowEql, hasEqlModule, showEql, showJson };
|
|
109
121
|
};
|
|
110
122
|
|
package/dist/devmode/modules/layer/components/LayerViewSwitch/hooks/useLayerViewSwitch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayerViewSwitch.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLayerViewSwitch.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -12,6 +12,7 @@ export declare const layerSlice: {
|
|
|
12
12
|
text?: string | undefined;
|
|
13
13
|
savedText?: string | undefined;
|
|
14
14
|
isQuery: boolean;
|
|
15
|
+
view: import("../types").LayerView;
|
|
15
16
|
}, { payload: { text, isQuery } }: TabPayloadAction<{
|
|
16
17
|
text: string;
|
|
17
18
|
isQuery: boolean;
|
|
@@ -20,6 +21,7 @@ export declare const layerSlice: {
|
|
|
20
21
|
text?: string | undefined;
|
|
21
22
|
savedText?: string | undefined;
|
|
22
23
|
isQuery: boolean;
|
|
24
|
+
view: import("../types").LayerView;
|
|
23
25
|
}, { payload: { text } }: TabPayloadAction<{
|
|
24
26
|
text: string;
|
|
25
27
|
}>) => void;
|
|
@@ -16,7 +16,9 @@ import { LAYER_SLICE, LAYER_SERVICE_TAB } from '../constants.js';
|
|
|
16
16
|
const layerSlice = createTabStateSlice({
|
|
17
17
|
name: LAYER_SLICE,
|
|
18
18
|
tabTypes: [LAYER_SERVICE_TAB],
|
|
19
|
-
createState: () => ({ isQuery: false }),
|
|
19
|
+
createState: (init) => ({ isQuery: false, view: init?.view ?? "eql" }),
|
|
20
|
+
// Таб слоя в сессии — это JSON: запрос EQL восстанавливается своим табом модуля `eql`.
|
|
21
|
+
restore: () => ({ isQuery: false, view: "json" }),
|
|
20
22
|
reducers: {
|
|
21
23
|
layerLoaded: (tab, { payload: { text, isQuery } }) => {
|
|
22
24
|
tab.text = text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layerSlice.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layerSlice.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -5,12 +5,20 @@ export interface LayerModuleOptions {
|
|
|
5
5
|
/** Переключение на запрос EQL у query-слоя — модулем `eql` (по умолчанию да). */
|
|
6
6
|
eqlView?: boolean;
|
|
7
7
|
}
|
|
8
|
+
/** Вид вкладки слоя: запрос EQL (таб модуля `eql`) либо JSON описания (таб модуля `layer`). */
|
|
9
|
+
export type LayerView = "eql" | "json";
|
|
10
|
+
/** Начальные данные таба слоя: `view: "json"` — JSON описания, выбранный переключателем вида. */
|
|
11
|
+
export interface LayerTabInit {
|
|
12
|
+
view?: LayerView;
|
|
13
|
+
}
|
|
8
14
|
export interface LayerTabState {
|
|
9
15
|
/** JSON описания слоя; undefined — ещё не загружен. */
|
|
10
16
|
text?: string;
|
|
11
17
|
savedText?: string;
|
|
12
18
|
/** Слой с запросом EQL: есть вид «EQL». */
|
|
13
19
|
isQuery: boolean;
|
|
20
|
+
/** Режим вкладки: query-слой в режиме `eql` переключатель вида открывает запросом EQL. */
|
|
21
|
+
view: LayerView;
|
|
14
22
|
}
|
|
15
23
|
export interface LayerSavedPayload {
|
|
16
24
|
tabId: string;
|
package/package.json
CHANGED