Skip to content

Commit

Permalink
Merge branch 'sorgh/4327' of https://github.com/hatpick/BotFramework-…
Browse files Browse the repository at this point in the history
…Composer into sorgh/4327
  • Loading branch information
sorgh committed Oct 6, 2020
2 parents c73432e + 70d8fab commit dbf42da
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 7 deletions.
16 changes: 15 additions & 1 deletion Composer/packages/adaptive-form/src/utils/arrayUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import { generateUniqueId } from '@bfc/shared';
import { ChangeHandler } from '@bfc/extension-client';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import isEqual from 'lodash/isEqual';

type ArrayChangeHandler<ItemType> = (items: ArrayItem<ItemType>[]) => void;

Expand Down Expand Up @@ -78,6 +79,19 @@ export function useArrayItems<ItemType = unknown>(
): ArrayItemState<ItemType> {
const [cache, setCache] = useState(generateArrayItems(items));

useEffect(() => {
const newCache = generateArrayItems(items);

if (
!isEqual(
cache.map(({ value }) => value),
newCache.map(({ value }) => value)
)
) {
setCache(newCache);
}
}, [items]);

const handleChange = (newItems: ArrayItem<ItemType>[]) => {
setCache(newItems);
onChange(newItems.map(({ value }) => value));
Expand Down
16 changes: 15 additions & 1 deletion Composer/packages/adaptive-form/src/utils/objectUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import { generateUniqueId } from '@bfc/shared';
import { ChangeHandler } from '@bfc/extension-client';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import isEqual from 'lodash/isEqual';

type ItemType<ValueType = unknown> = { [key: string]: ValueType };
type ObjectChangeHandler<ValueType = unknown> = (items: ObjectItem<ValueType>[]) => void;
Expand Down Expand Up @@ -64,6 +65,19 @@ export function useObjectItems<ValueType = unknown>(
): ObjectItemState<ValueType> {
const [cache, setCache] = useState(generateObjectEntries(items));

useEffect(() => {
const newCache = generateObjectEntries(items);

if (
!isEqual(
newCache.map(({ id, ...rest }) => rest),
cache.map(({ id, ...rest }) => rest)
)
) {
setCache(generateObjectEntries(items));
}
}, [items]);

const handleChange = (items) => {
setCache(items);
onChange(items.reduce((acc, { propertyName, propertyValue }) => ({ ...acc, [propertyName]: propertyValue }), {}));
Expand Down
55 changes: 50 additions & 5 deletions Composer/packages/server/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@
"are_you_sure_you_want_to_stop_current_runtime_and__a5f883b2": {
"message": "Are you sure you want to stop current runtime and replace them?"
},
"are_you_sure_you_want_to_uninstall_these_extension_cf6265e8": {
"message": "Are you sure you want to uninstall these extensions?"
},
"array_643947ee": {
"message": "Array"
},
Expand Down Expand Up @@ -785,6 +788,12 @@
"duplicated_intents_recognized_d3908424": {
"message": "Duplicated intents recognized"
},
"each_page_of_pagesizestring_in_propstring_a7e23b00": {
"message": "Each page of { pageSizeString } in { propString }"
},
"each_value_in_ae285cd9": {
"message": "Each value in"
},
"early_adopters_e8db7999": {
"message": "Early adopters"
},
Expand Down Expand Up @@ -911,6 +920,9 @@
"error_processing_schema_2c707cf3": {
"message": "Error Processing Schema"
},
"event_48c2be6e": {
"message": " (Event)"
},
"event_activity_2067a94b": {
"message": "Event activity"
},
Expand Down Expand Up @@ -965,9 +977,6 @@
"expression_to_evaluate_ce4095b1": {
"message": "Expression to evaluate."
},
"extension_name_e21a5e25": {
"message": "Extension name"
},
"extensions_7250a0bb": {
"message": "Extensions"
},
Expand Down Expand Up @@ -1079,6 +1088,9 @@
"home_351838cd": {
"message": "Home"
},
"host_ef9acfae": {
"message": "Host "
},
"http_request_79847109": {
"message": "HTTP Request"
},
Expand Down Expand Up @@ -1517,12 +1529,18 @@
"no_editor_for_type_8b5593c5": {
"message": "No Editor for { type }"
},
"no_extensions_installed_4b925277": {
"message": "No extensions installed"
},
"no_lu_file_with_name_id_fb21315d": {
"message": "NO LU FILE WITH NAME { id }"
},
"no_lu_or_qna_file_with_name_id_21cfe9dc": {
"message": "NO LU OR QNA FILE WITH NAME { id }"
},
"no_search_results_1ba50423": {
"message": "No search results"
},
"no_name_e082310e": {
"message": "[no name]"
},
Expand Down Expand Up @@ -1904,6 +1922,15 @@
"restart_bot_34e36428": {
"message": "Restart Bot"
},
"result_b1f14e91": {
"message": " = Result"
},
"result_property_100ef34f": {
"message": " = Result property"
},
"return_value_b386d1b": {
"message": "= Return value"
},
"review_and_generate_63dec712": {
"message": "Review and generate"
},
Expand Down Expand Up @@ -1946,8 +1973,8 @@
"search_280d00bd": {
"message": "Search"
},
"search_for_extensions_a27c4772": {
"message": "Search for extensions"
"search_for_extensions_on_npm_c5ca65d9": {
"message": "Search for extensions on npm"
},
"see_log_4b833bf7": {
"message": "See Log"
Expand Down Expand Up @@ -2150,6 +2177,9 @@
"text_7f4593da": {
"message": "Text"
},
"the_api_messages_endpoint_for_the_skill_f318dc63": {
"message": "The /api/messages endpoint for the skill."
},
"the_callback_url_for_the_skill_host_e20e1012": {
"message": "The callback url for the skill host."
},
Expand Down Expand Up @@ -2177,6 +2207,9 @@
"the_return_type_does_not_match_2ae72548": {
"message": "the return type does not match"
},
"the_root_bot_is_not_a_bot_project_d1495cf6": {
"message": "The root bot is not a bot project"
},
"the_welcome_message_is_triggered_by_the_i_conversa_a3ff58f8": {
"message": "The welcome message is triggered by the <i>ConversationUpdate</i> event. To add a new <i>ConversationUpdate</i> trigger:"
},
Expand Down Expand Up @@ -2276,6 +2309,12 @@
"to_which_language_will_you_be_translating_your_bot_77219d69": {
"message": "To which language will you be translating your bot?"
},
"toggle_extension_e41de2d2": {
"message": "Toggle extension"
},
"token_property_e53a19d9": {
"message": " = Token Property"
},
"toolbar_bafd4228": {
"message": "toolbar"
},
Expand Down Expand Up @@ -2327,6 +2366,9 @@
"undo_is_not_supported_ecd6f9fc": {
"message": "Undo is not supported"
},
"uninstall_8730233": {
"message": "Uninstall"
},
"unknown_intent_44b962ba": {
"message": "Unknown intent"
},
Expand Down Expand Up @@ -2420,6 +2462,9 @@
"view_kb_c382e495": {
"message": "View KB"
},
"view_on_npm_2051324d": {
"message": "View on npm"
},
"vishwac_sena_45910bf0": {
"message": "Vishwac Sena"
},
Expand Down

0 comments on commit dbf42da

Please sign in to comment.