This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 375
Hailiu/settings ui #1134
Merged
Merged
Hailiu/settings ui #1134
Changes from 22 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
1cf8239
per slot dialog settings with optional obfucate
hailiu2586 ea33bf1
switch to choice group instead of dropdown
hailiu2586 9e95a79
use createPortal to project show-keys toggle
hailiu2586 62fd08b
Merge branch 'master' into hailiu/settings-ui
hailiu2586 13067b8
fix integration test for breadcrumb
hailiu2586 1b55347
use formatMessage for textual content
hailiu2586 9df430b
change text content
hailiu2586 f305d61
hide settings by default
hailiu2586 2b03f41
fix typo
hailiu2586 a833af3
Merge branch 'master' into hailiu/settings-ui
hailiu2586 5f030e6
fix lint and test:coverage
hailiu2586 3ce4433
fix test:coerage
hailiu2586 de09379
fix build
hailiu2586 c060771
Merge branch 'master' into hailiu/settings-ui
hailiu2586 8ed0bd9
udpate copy text
hailiu2586 84dd0c4
Update Composer/packages/client/src/utils/objUtil.ts
hailiu2586 5b9ee8e
fix hosted routes
hailiu2586 7f55036
fix open bot emulator
hailiu2586 5559c59
refactor cross frame state data
hailiu2586 197ebe7
Merge branch 'master' into hailiu/settings-ui
hailiu2586 f4d7231
fix setDialogSettingsSlot
hailiu2586 55d2db0
fix args order'
hailiu2586 1840d7a
add save button to hosted settings edit UI
hailiu2586 9fc9500
clean up obfuscate
hailiu2586 49df0fb
remove code-mirror
hailiu2586 6538362
Merge branch 'master' into hailiu/settings-ui
a-b-r-o-w-n 18c141e
convert to css-in-js
a-b-r-o-w-n 2505026
Merge branch 'master' into hailiu/settings-ui
a-b-r-o-w-n e8c8892
add hosted to ShellData type
a-b-r-o-w-n ac699c5
fix lint issue
hailiu2586 d52d698
add emotion babel plugin for test
a-b-r-o-w-n d8b0942
require jsx pragma
a-b-r-o-w-n 5bcc37e
Merge branch 'master' into hailiu/settings-ui
hailiu2586 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,14 @@ import settingsStorage from '../../utils/dialogSettingStorage'; | |
| import { SensitiveProperties } from '../../constants'; | ||
|
|
||
| import { BASEURL, ActionTypes } from './../../constants/index'; | ||
| import { BotEnvironments } from './../../utils/envUtil'; | ||
|
|
||
| export const setSettings: ActionCreator = async ({ dispatch }, botName: string, settings: DialogSetting) => { | ||
| export const setSettings: ActionCreator = async ( | ||
| { dispatch }, | ||
| botName: string, | ||
| settings: DialogSetting, | ||
| slot?: BotEnvironments | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
these are just strings, not an enum
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ts enum can have string values |
||
| ) => { | ||
| try { | ||
| // set value to store | ||
| dispatch({ | ||
|
|
@@ -22,7 +28,8 @@ export const setSettings: ActionCreator = async ({ dispatch }, botName: string, | |
| settingsStorage.setField(botName, property, propertyValue ? propertyValue : ''); | ||
| } | ||
| // set value to server | ||
| await axios.post(`${BASEURL}/projects/opened/settings`, { settings }); | ||
| const suffix = slot ? `/${slot}` : ''; | ||
| await axios.post(`${BASEURL}/projects/opened/settings${suffix}`, { settings }); | ||
| } catch (err) { | ||
| dispatch({ | ||
| type: ActionTypes.SET_ERROR, | ||
|
|
@@ -33,3 +40,35 @@ export const setSettings: ActionCreator = async ({ dispatch }, botName: string, | |
| }); | ||
| } | ||
| }; | ||
|
|
||
| export const setDialogSettingsSlot = async ({ dispatch }, editing: boolean, slot?: BotEnvironments) => { | ||
| const suffix = slot ? `/${slot}` : ''; | ||
| const query = editing ? '' : '?obfuscate=true'; | ||
| const url = `${BASEURL}/projects/opened/settings${suffix}${query}`; | ||
|
|
||
| try { | ||
| const response = await axios.get(`${BASEURL}/projects/opened/settings${suffix}`); | ||
| const settings = response.data; | ||
| dispatch({ | ||
| type: ActionTypes.SYNC_ENV_SETTING, | ||
| payload: { | ||
| settings, | ||
| }, | ||
| }); | ||
| } catch (err) { | ||
| dispatch({ | ||
| type: ActionTypes.SET_ERROR, | ||
| payload: { | ||
| message: err.response && err.response.data.message ? err.reponse.data.message : err, | ||
| summary: 'DLG SETTINGS ERROR', | ||
| }, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| export const setEditDialogSettings: ActionCreator = async (store, editing: boolean, slot?: BotEnvironments) => { | ||
| if (editing) { | ||
| // fetch the real settings for editing | ||
| await setDialogSettingsSlot(store, editing, slot); | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export const isAbsHosted = () => process.env.COMPOSER_AUTH_PROVIDER === 'abs-h' || process.env.MOCKHOSTED; | ||
| export enum BotEnvironments { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
there is a way to get the 'slot' names from the backend, and the default slot name |
||
| PRODUCTION = 'production', | ||
| INTEGRATION = 'integration', | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * obfuscate object member values to '*****' | ||
| * @param obj | ||
| */ | ||
| export const obfuscate = (obj: Record<string, any> | string | number | boolean) => { | ||
| const OBFUSCATED_VALUE = '*****'; | ||
| if (typeof obj !== 'object') { | ||
|
hailiu2586 marked this conversation as resolved.
Outdated
|
||
| return OBFUSCATED_VALUE; | ||
| } | ||
| if (Array.isArray(obj)) { | ||
| return obj.map(obfuscate); | ||
| } | ||
|
|
||
| return obj ? Object.keys(obj).reduce((prev, k) => ({ ...prev, [k]: obfuscate(obj[k]) }), {}) : OBFUSCATED_VALUE; | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.