procon_bypass_man-web 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/.node-version +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/bin/pbm_web +5 -0
- data/lib/procon_bypass_man/web/configuration.rb +40 -0
- data/lib/procon_bypass_man/web/db.rb +4 -4
- data/lib/procon_bypass_man/web/migration/002_insert_default_settings_rows.sql +3 -0
- data/lib/procon_bypass_man/web/models/setting.rb +1 -1
- data/lib/procon_bypass_man/web/public/bundle.js +1 -1
- data/lib/procon_bypass_man/web/server.rb +12 -2
- data/lib/procon_bypass_man/web/setting_parser/layer.rb +72 -0
- data/lib/procon_bypass_man/web/setting_parser/top_level_layer.rb +109 -0
- data/lib/procon_bypass_man/web/setting_parser.rb +4 -152
- data/lib/procon_bypass_man/web/storage.rb +4 -4
- data/lib/procon_bypass_man/web/version.rb +1 -1
- data/lib/procon_bypass_man/web.rb +14 -4
- data/src/components/button_setting.tsx +17 -34
- data/src/components/buttons_modal.tsx +15 -25
- data/src/components/macro_settings.tsx +6 -12
- data/src/hooks/useModal.ts +37 -0
- data/src/pages/buttons_setting_page.tsx +8 -18
- metadata +8 -2
@@ -0,0 +1,37 @@
|
|
1
|
+
import React, { useState, useReducer } from "react";
|
2
|
+
import { Button, buttons } from "../types/button";
|
3
|
+
import { ModalProps } from "../components/buttons_modal";
|
4
|
+
|
5
|
+
export type ModalSetting = {
|
6
|
+
toggleModal: any;
|
7
|
+
setCallbackOnSubmit: any;
|
8
|
+
setCallbackOnClose: any;
|
9
|
+
setTitle: any;
|
10
|
+
setPrefillButtons: any;
|
11
|
+
}
|
12
|
+
|
13
|
+
type openModalParams = {
|
14
|
+
title: string,
|
15
|
+
prefill: any,
|
16
|
+
callbackOnSubmit: any,
|
17
|
+
};
|
18
|
+
|
19
|
+
export const useModal = () => {
|
20
|
+
const [visible, toggleModal] = useReducer(((m: boolean) => { return !m; }), false);
|
21
|
+
const [callbackOnSubmit, setCallbackOnSubmit] = useState(undefined as any)
|
22
|
+
const [callbackOnClose, setCallbackOnClose] = useState(undefined as any)
|
23
|
+
const [title, setTitle] = useState("")
|
24
|
+
const [prefill, setPrefillButtons] = useState<Array<Button>>([])
|
25
|
+
|
26
|
+
const openModal = ({ title, prefill, callbackOnSubmit }: openModalParams): void => {
|
27
|
+
toggleModal();
|
28
|
+
setTitle(title)
|
29
|
+
setPrefillButtons(prefill);
|
30
|
+
setCallbackOnSubmit(() => callbackOnSubmit);
|
31
|
+
setCallbackOnClose(() => toggleModal);
|
32
|
+
}
|
33
|
+
const modalProps: ModalProps = { visible, callbackOnSubmit, callbackOnClose, title, prefill };
|
34
|
+
const modalSetting: ModalSetting ={ toggleModal, setCallbackOnSubmit, setCallbackOnClose, setTitle, setPrefillButtons };
|
35
|
+
|
36
|
+
return [modalProps, openModal] as const;
|
37
|
+
}
|
@@ -13,6 +13,8 @@ import { ButtonsSettingContext, } from "./../contexts/buttons_setting";
|
|
13
13
|
import { ButtonsSettingConverter } from "./../lib/buttons_setting_converter";
|
14
14
|
import { disableFlipType, alwaysFlipType, flipIfPressedSelfType, flipIfPressedSomeButtonsType, ignoreButtonsInFlipingType, remapType, closeMenuType, applyMacroType, installMacroType, installModeType, applyModeType } from "../reducers/layer_reducer";
|
15
15
|
import { ButtonsModal } from "../components/buttons_modal";
|
16
|
+
import { useModal, ModalSetting } from "../hooks/useModal";
|
17
|
+
import { ModalProps } from "../components/buttons_modal";
|
16
18
|
import { InstallableMacros } from "../components/installable_macros";
|
17
19
|
import { InstallableModes } from "../components/installable_modes";
|
18
20
|
import _ from 'lodash';
|
@@ -31,6 +33,7 @@ export const ButtonsSettingPage = () => {
|
|
31
33
|
const layerRefs = layerKeys.map((l) => ({} as LayerRef));
|
32
34
|
const [initializedSetting, setInitializedSetting] = useState({} as ButtonsSettingType)
|
33
35
|
const [infoMessage, setInfoMessage] = useState(undefined as undefined | string)
|
36
|
+
const [modalProps, openModal] = useModal();
|
34
37
|
|
35
38
|
const switchLayer = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
36
39
|
if (event.target instanceof HTMLElement) {
|
@@ -218,22 +221,12 @@ export const ButtonsSettingPage = () => {
|
|
218
221
|
return "inactive"
|
219
222
|
};
|
220
223
|
}
|
224
|
+
|
221
225
|
const handlePrefixKeysField = () => {
|
222
|
-
|
223
|
-
setModalTitle("キープレフィックスの変更")
|
224
|
-
setModalPrefillButtons(prefixKeys);
|
225
|
-
setModalCallbackOnSubmit(() => setPrefixKeys);
|
226
|
-
setModalCloseCallback(() => toggleModal);
|
226
|
+
openModal({ title: "キープレフィックスの変更", prefill: prefixKeys, callbackOnSubmit: setPrefixKeys });
|
227
227
|
}
|
228
228
|
|
229
|
-
|
230
|
-
const [isOpenModal, toggleModal] = useReducer(((m) => { return !m; }), false);
|
231
|
-
const [modalCallbackOnSubmit, setModalCallbackOnSubmit] = useState(undefined as any)
|
232
|
-
const [modalCloseCallback, setModalCloseCallback] = useState(undefined as any)
|
233
|
-
const [modalTitle, setModalTitle] = useState("")
|
234
|
-
const [modalPrefillButtons, setModalPrefillButtons] = useState<Array<Button>>([])
|
235
|
-
|
236
|
-
if(!loaded) { return null; };
|
229
|
+
if(!loaded) { return <div>{infoMessage}</div> };
|
237
230
|
|
238
231
|
return(
|
239
232
|
<>
|
@@ -244,19 +237,16 @@ export const ButtonsSettingPage = () => {
|
|
244
237
|
<a href="#" onClick={exportSetting}>エクスポートする</a>
|
245
238
|
</div>
|
246
239
|
|
247
|
-
<h3>インストール可能なマクロ</h3>
|
248
|
-
{<InstallableMacros />}
|
249
|
-
|
250
240
|
<h3>インストール可能なモード</h3>
|
251
241
|
{<InstallableModes />}
|
252
242
|
|
253
243
|
<h3>インストール可能なマクロ</h3>
|
254
|
-
{
|
244
|
+
{<InstallableMacros />}
|
255
245
|
|
256
246
|
<h3>設定中のプレフィックスキー</h3>
|
257
247
|
<div css={css`position: relative; margin-bottom: 20px;`}>
|
258
248
|
<input type="text" value={prefixKeys.join(", ")} readOnly={true} onClick={handlePrefixKeysField} />
|
259
|
-
{
|
249
|
+
{<ButtonsModal {...modalProps as ModalProps} />}
|
260
250
|
</div>
|
261
251
|
</div>
|
262
252
|
<div css={css`display: table-cell`}>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procon_bypass_man-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- ".babelrc"
|
63
63
|
- ".circleci/config.yml"
|
64
64
|
- ".gitignore"
|
65
|
+
- ".node-version"
|
65
66
|
- ".rspec"
|
66
67
|
- ".rubocop.yml"
|
67
68
|
- CHANGELOG.md
|
@@ -76,8 +77,10 @@ files:
|
|
76
77
|
- bin/setup
|
77
78
|
- jest.config.ts
|
78
79
|
- lib/procon_bypass_man/web.rb
|
80
|
+
- lib/procon_bypass_man/web/configuration.rb
|
79
81
|
- lib/procon_bypass_man/web/db.rb
|
80
82
|
- lib/procon_bypass_man/web/migration/001_create_settings_table.sql
|
83
|
+
- lib/procon_bypass_man/web/migration/002_insert_default_settings_rows.sql
|
81
84
|
- lib/procon_bypass_man/web/models/base_model.rb
|
82
85
|
- lib/procon_bypass_man/web/models/setting.rb
|
83
86
|
- lib/procon_bypass_man/web/public/bundle.js
|
@@ -85,6 +88,8 @@ files:
|
|
85
88
|
- lib/procon_bypass_man/web/public/index.html
|
86
89
|
- lib/procon_bypass_man/web/server.rb
|
87
90
|
- lib/procon_bypass_man/web/setting_parser.rb
|
91
|
+
- lib/procon_bypass_man/web/setting_parser/layer.rb
|
92
|
+
- lib/procon_bypass_man/web/setting_parser/top_level_layer.rb
|
88
93
|
- lib/procon_bypass_man/web/storage.rb
|
89
94
|
- lib/procon_bypass_man/web/version.rb
|
90
95
|
- package.json
|
@@ -98,6 +103,7 @@ files:
|
|
98
103
|
- src/components/macro_settings.tsx
|
99
104
|
- src/components/mode_settings.tsx
|
100
105
|
- src/contexts/buttons_setting.ts
|
106
|
+
- src/hooks/useModal.ts
|
101
107
|
- src/index.html
|
102
108
|
- src/lib/button_state.test.ts
|
103
109
|
- src/lib/button_state.ts
|