forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.js
More file actions
206 lines (179 loc) · 4.64 KB
/
ui.js
File metadata and controls
206 lines (179 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
import {
getActiveSearch,
getPaneCollapse,
getQuickOpenEnabled,
getSource,
getFileSearchQuery,
getProjectDirectoryRoot
} from "../selectors";
import { selectSource } from "../actions/sources/select";
import type { ThunkArgs, panelPositionType } from "./types";
import { getEditor } from "../utils/editor";
import { searchContents } from "./file-search";
import type {
ActiveSearchType,
OrientationType,
SelectedPrimaryPaneTabType
} from "../reducers/ui";
export function setContextMenu(type: string, event: any) {
return ({ dispatch }: ThunkArgs) => {
dispatch({ type: "SET_CONTEXT_MENU", contextMenu: { type, event } });
};
}
export function setPrimaryPaneTab(tabName: SelectedPrimaryPaneTabType) {
return { type: "SET_PRIMARY_PANE_TAB", tabName };
}
export function closeActiveSearch() {
return {
type: "TOGGLE_ACTIVE_SEARCH",
value: null
};
}
export function setActiveSearch(activeSearch?: ActiveSearchType) {
return ({ dispatch, getState }: ThunkArgs) => {
const activeSearchState = getActiveSearch(getState());
if (activeSearchState === activeSearch) {
return;
}
if (getQuickOpenEnabled(getState())) {
dispatch({ type: "CLOSE_QUICK_OPEN" });
}
dispatch({
type: "TOGGLE_ACTIVE_SEARCH",
value: activeSearch
});
};
}
export function updateActiveFileSearch() {
return ({ dispatch, getState }: ThunkArgs) => {
const isFileSearchOpen = getActiveSearch(getState()) === "file";
const fileSearchQuery = getFileSearchQuery(getState());
if (isFileSearchOpen && fileSearchQuery) {
const editor = getEditor();
dispatch(searchContents(fileSearchQuery, editor));
}
};
}
export function toggleFrameworkGrouping(toggleValue: boolean) {
return ({ dispatch, getState }: ThunkArgs) => {
dispatch({
type: "TOGGLE_FRAMEWORK_GROUPING",
value: toggleValue
});
};
}
export function showSource(sourceId: string) {
return ({ dispatch, getState }: ThunkArgs) => {
const source = getSource(getState(), sourceId);
if (!source) {
return;
}
if (getPaneCollapse(getState(), "start")) {
dispatch({
type: "TOGGLE_PANE",
position: "start",
paneCollapsed: false
});
}
dispatch(setPrimaryPaneTab("sources"));
dispatch({ type: "SHOW_SOURCE", source: null });
dispatch(selectSource(source.id));
dispatch({ type: "SHOW_SOURCE", source });
};
}
export function togglePaneCollapse(
position: panelPositionType,
paneCollapsed: boolean
) {
return ({ dispatch, getState }: ThunkArgs) => {
const prevPaneCollapse = getPaneCollapse(getState(), position);
if (prevPaneCollapse === paneCollapsed) {
return;
}
dispatch({
type: "TOGGLE_PANE",
position,
paneCollapsed
});
};
}
/**
* @memberof actions/sources
* @static
*/
export function highlightLineRange(location: {
start: number,
end: number,
sourceId: number
}) {
return {
type: "HIGHLIGHT_LINES",
location
};
}
export function flashLineRange(location: {
start: number,
end: number,
sourceId: number
}) {
return ({ dispatch }: ThunkArgs) => {
dispatch(highlightLineRange(location));
setTimeout(() => dispatch(clearHighlightLineRange()), 200);
};
}
/**
* @memberof actions/sources
* @static
*/
export function clearHighlightLineRange() {
return {
type: "CLEAR_HIGHLIGHT_LINES"
};
}
export function openConditionalPanel(line: ?number) {
if (!line) {
return;
}
return {
type: "OPEN_CONDITIONAL_PANEL",
line
};
}
export function closeConditionalPanel() {
return {
type: "CLOSE_CONDITIONAL_PANEL"
};
}
export function clearProjectDirectoryRoot() {
return {
type: "SET_PROJECT_DIRECTORY_ROOT",
url: ""
};
}
export function setProjectDirectoryRoot(newRoot: string) {
return ({ dispatch, getState }: ThunkArgs) => {
const curRoot = getProjectDirectoryRoot(getState());
if (newRoot && curRoot) {
const newRootArr = newRoot.replace(/\/+/g, "/").split("/");
const curRootArr = curRoot
.replace(/^\//, "")
.replace(/\/+/g, "/")
.split("/");
if (newRootArr[0] !== curRootArr[0]) {
newRootArr.splice(0, 2);
newRoot = `${curRoot}/${newRootArr.join("/")}`;
}
}
dispatch({
type: "SET_PROJECT_DIRECTORY_ROOT",
url: newRoot
});
};
}
export function setOrientation(orientation: OrientationType) {
return { type: "SET_ORIENTATION", orientation };
}