Skip to content

Commit

Permalink
Merge branch 'durnford/fix/lg-attachments' of github.com:microsoft/Bo…
Browse files Browse the repository at this point in the history
…tFramework-Composer into durnford/fix/lg-attachments
  • Loading branch information
tdurnford committed May 3, 2021
2 parents 12e0f82 + 141a1cc commit c525b56
Show file tree
Hide file tree
Showing 8 changed files with 296 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ManageService } from '../ManageService/ManageService';
import { currentProjectIdState } from '../../recoilModel';
import { rootBotProjectIdSelector } from '../../recoilModel/selectors/project';

const QNA_REGIONS = [{ key: 'westus', text: 'westus' }];
const QNA_REGIONS = [{ key: 'westus', text: 'West US' }];
const QNA_TIERS = [
{ key: 'free', text: 'Free' },
{ key: 'paid', text: 'Paid' },
Expand Down
272 changes: 201 additions & 71 deletions Composer/packages/client/src/components/ManageService/ManageService.tsx

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Composer/packages/client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export const Tips = {
export const LUIS_REGIONS: IDropdownOption[] = [
{
key: 'westus',
text: formatMessage('westus'),
text: formatMessage('West US'),
},
{
key: 'westeurope',
text: formatMessage('westeurope'),
text: formatMessage('West Europe'),
},
{
key: 'australiaeast',
text: formatMessage('australiaeast'),
text: formatMessage('Australia East'),
},
];

Expand Down
76 changes: 45 additions & 31 deletions Composer/packages/client/src/pages/botProject/PublishTargets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { OpenConfirmModal } from '@bfc/ui-shared';

import { dispatcherState, settingsState, publishTypesState } from '../../recoilModel';
import { AuthDialog } from '../../components/Auth/AuthDialog';
import { isShowAuthDialog } from '../../utils/auth';
import { useLocation } from '../../utils/hooks';
import { isShowAuthDialog as shouldShowTokenDialog } from '../../utils/auth';

import { PublishProfileDialog } from './create-publish-profile/PublishProfileDialog';
import { tableRow, tableRowItem, tableColumnHeader, columnSizes, actionButton } from './styles';
Expand All @@ -27,6 +28,10 @@ const publishTargetsContainer = css`
flex-direction: column;
`;

const belowTargetsContainer = css`
padding: 0 20px 20px 20px;
`;

const publishTargetsHeader = css`
display: flex;
flex-direction: row;
Expand All @@ -47,7 +52,6 @@ const editPublishProfile = {

type PublishTargetsProps = {
projectId: string;
completePartial?: boolean;
scrollToSectionId?: string;
};

Expand All @@ -57,22 +61,28 @@ export const PublishTargets: React.FC<PublishTargetsProps> = (props) => {
const { getPublishTargetTypes, setPublishTargets } = useRecoilValue(dispatcherState);
const publishTypes = useRecoilValue(publishTypesState(projectId));

const [dialogHidden, setDialogHidden] = useState(true);
const [showAuthDialog, setShowAuthDialog] = useState(false);
const [showPublishDialog, setShowingPublishDialog] = useState(false);
const [showAuthDialog, setShowingAuthDialog] = useState(false);

const publishTargetsRef = React.useRef<HTMLDivElement>(null);
const [current, setCurrent] = useState<{ index: number; item: PublishTarget } | null>(null);

const { location } = useLocation();

useEffect(() => {
if (props.completePartial && publishTargets && publishTargets.length > 0) {
setCurrent({ item: publishTargets[0], index: 0 });
if (isShowAuthDialog(true)) {
setShowAuthDialog(true);
} else {
setDialogHidden(false);
if (location.hash === '#completePublishProfile') {
if (publishTargets && publishTargets.length > 0) {
// clear the hash so that the dialog doesn't open again.
window.location.hash = '';
setCurrent({ item: publishTargets[0], index: 0 });
if (shouldShowTokenDialog(true)) {
setShowingAuthDialog(true);
} else {
setShowingPublishDialog(true);
}
}
}
}, [props.completePartial, publishTargets]);
}, [location, publishTargets]);

useEffect(() => {
if (projectId) {
Expand Down Expand Up @@ -103,6 +113,22 @@ export const PublishTargets: React.FC<PublishTargetsProps> = (props) => {
}
};

const addNewButton = (
<ActionButton
data-testid={'addNewPublishProfile'}
styles={actionButton}
onClick={() => {
if (shouldShowTokenDialog(true)) {
setShowingAuthDialog(true);
} else {
setShowingPublishDialog(true);
}
}}
>
{formatMessage('Add new')}
</ActionButton>
);

return (
<Fragment>
<div ref={publishTargetsRef} css={publishTargetsContainer} id="addNewPublishProfile">
Expand All @@ -126,10 +152,10 @@ export const PublishTargets: React.FC<PublishTargetsProps> = (props) => {
styles={editPublishProfile}
onClick={() => {
setCurrent({ item: p, index: index });
if (isShowAuthDialog(true)) {
setShowAuthDialog(true);
if (shouldShowTokenDialog(true)) {
setShowingAuthDialog(true);
} else {
setDialogHidden(false);
setShowingPublishDialog(true);
}
}}
>
Expand All @@ -148,35 +174,23 @@ export const PublishTargets: React.FC<PublishTargetsProps> = (props) => {
</div>
);
})}
<ActionButton
data-testid={'addNewPublishProfile'}
styles={actionButton}
onClick={() => {
if (isShowAuthDialog(true)) {
setShowAuthDialog(true);
} else {
setDialogHidden(false);
}
}}
>
{formatMessage('Add new')}
</ActionButton>
</div>
<div css={belowTargetsContainer}>{addNewButton}</div>
{showAuthDialog && (
<AuthDialog
needGraph
next={() => {
setDialogHidden(false);
setShowingPublishDialog(true);
}}
onDismiss={() => {
setShowAuthDialog(false);
setShowingAuthDialog(false);
}}
/>
)}
{!dialogHidden ? (
{showPublishDialog ? (
<PublishProfileDialog
closeDialog={() => {
setDialogHidden(true);
setShowingPublishDialog(false);
// reset current
setCurrent(null);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export const RootBotExternalService: React.FC<RootBotExternalServiceProps> = (pr
),
a2: ({ children }) => (
<Link
key="luis-endpoint-key-info"
key="luis-endpoint-key-limits-info"
href={'https://aka.ms/composer-settings-luislimits'}
target="_blank"
>
Expand Down
8 changes: 2 additions & 6 deletions Composer/packages/client/src/pages/publish/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ const Publish: React.FC<RouteComponentProps<{ projectId: string; targetName?: st
const decoded = props.location?.search ? decodeURIComponent(props.location.search) : '';
const { publishTargetName, url } = querystring.parse(decoded);
const [skillManifestUrl, setSkillManifestUrl] = useState('');
const [completionRequired, setCompletionRequired] = useState<boolean>(false);

useEffect(() => {
if (publishTargetName && botStatusList.length > 0 && skillPublishStatus === SKILL_PUBLISH_STATUS.INITIAL) {
Expand Down Expand Up @@ -276,11 +275,8 @@ const Publish: React.FC<RouteComponentProps<{ projectId: string; targetName?: st

// pop out get started if #getstarted is in the URL
useEffect(() => {
if (location.hash === '#addNewPublishProfile') {
if (location.hash === '#addNewPublishProfile' || location.hash === '#completePublishProfile') {
setActiveTab('addNewPublishProfile');
} else if (location.hash === '#completePublishProfile') {
setActiveTab('addNewPublishProfile');
setCompletionRequired(true);
}
}, [location]);

Expand Down Expand Up @@ -510,7 +506,7 @@ const Publish: React.FC<RouteComponentProps<{ projectId: string; targetName?: st
</Stack.Item>
)}
<Stack.Item align="stretch" styles={{ root: { flexGrow: 1, overflow: 'auto', maxHeight: '100%' } }}>
<PublishTargets completePartial={completionRequired} projectId={provisionProject} />
<PublishTargets projectId={provisionProject} />
</Stack.Item>
</Stack>
</PivotItem>
Expand Down
24 changes: 8 additions & 16 deletions Composer/packages/client/src/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,27 +327,19 @@ export function getAccessTokenUrl(options: { clientId: string; redirectUrl: stri
return url;
}

export function isShowAuthDialog(needGraph: boolean): boolean {
export function userShouldProvideTokens(): boolean {
if (isElectron()) {
return false;
} else if (!(authConfig.clientId && authConfig.redirectUrl && authConfig.tenantId)) {
return isTokenExpired(getTokenFromCache('accessToken'))
? true
: needGraph && isTokenExpired(getTokenFromCache('graphToken'))
? true
: false;
} else {
return false;
}
} else return !(authConfig.clientId && authConfig.redirectUrl && authConfig.tenantId);
}

export function userShouldProvideTokens(): boolean {
if (isElectron()) {
return false;
} else if (authConfig.clientId && authConfig.redirectUrl && authConfig.tenantId) {
export function isShowAuthDialog(needGraph: boolean): boolean {
if (userShouldProvideTokens())
return (
(needGraph && isTokenExpired(getTokenFromCache('graphToken'))) || isTokenExpired(getTokenFromCache('accessToken'))
);
else {
return false;
} else {
return true;
}
}

Expand Down
49 changes: 35 additions & 14 deletions Composer/packages/server/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@
"audio_card_8587cf83": {
"message": "Audio card"
},
"australiaeast_f3227a31": {
"message": "australiaeast"
"australia_east_b7af6cc": {
"message": "Australia East"
},
"authentication_error_39e996c5": {
"message": "Authentication Error"
Expand All @@ -431,6 +431,9 @@
"azure_connections_9e63f716": {
"message": "Azure connections"
},
"azure_directory_d9065529": {
"message": "Azure directory"
},
"azure_functions_5e23be5c": {
"message": "Azure Functions"
},
Expand Down Expand Up @@ -632,9 +635,6 @@
"choose_from_existing_e85a88c4": {
"message": "Choose from existing"
},
"choose_from_existing_service_keys_create_a_new_ser_53728093": {
"message": "Choose from existing { service } keys, create a new { service } resource, or generate a request to handoff to your Azure admin. "
},
"choose_how_to_create_your_bot_a97f7b3e": {
"message": "Choose how to create your bot"
},
Expand Down Expand Up @@ -2501,6 +2501,9 @@
"next_steps_fce2208": {
"message": "Next steps"
},
"no_azure_directories_were_found_6dfe6f6f": {
"message": "No Azure Directories were found."
},
"no_editor_for_type_8b5593c5": {
"message": "No Editor for { type }"
},
Expand Down Expand Up @@ -3317,11 +3320,8 @@
"select_runtime_version_to_add_d63d383b": {
"message": "Select runtime version to add"
},
"select_service_keys_6d3f0980": {
"message": "Select { service } keys"
},
"select_subscription_c5678611": {
"message": "Select subscription"
"select_service_key_6ca27e67": {
"message": "Select { service } key"
},
"select_the_language_that_bot_will_be_able_to_under_1f2bcb96": {
"message": "Select the language that bot will be able to understand (User input) and respond to (Bot responses).\n To make this bot available in other languages, click “Add’ to create a copy of the default language, and translate the content into the new language."
Expand All @@ -3335,6 +3335,15 @@
"select_which_tasks_this_skill_can_perform_172b0eae": {
"message": "Select which tasks this skill can perform"
},
"select_your_azure_directory_then_choose_the_subscr_7034a3c0": {
"message": "Select your Azure directory, then choose the subscription where you’d like your new { service } resource."
},
"select_your_azure_directory_then_choose_the_subscr_8c3aa61": {
"message": "Select your Azure directory, then choose the subscription where your existing resource is located and the keys you want to use."
},
"select_your_azure_directory_then_choose_the_subscr_e3d67edf": {
"message": "Select your Azure directory, then choose the subscription where you’d like your new { service } resource. "
},
"selection_field_86d1dc94": {
"message": "selection field"
},
Expand Down Expand Up @@ -3728,6 +3737,12 @@
"there_is_no_thumbnail_view_908fe5cc": {
"message": "There is no thumbnail view"
},
"there_was_a_problem_getting_the_access_token_for_t_69f5a5e2": {
"message": "There was a problem getting the access token for the current Azure directory. { errMessage }"
},
"there_was_a_problem_loading_azure_directories_errm_56e6145d": {
"message": "There was a problem loading Azure directories. { errMessage }"
},
"there_was_an_error_74ed3c58": {
"message": "There was an error"
},
Expand Down Expand Up @@ -3959,6 +3974,9 @@
"unknown_state_23f73afb": {
"message": "Unknown State"
},
"unnamed_4c8565a0": {
"message": "Unnamed"
},
"unread_notifications_indicator_e2ca00d5": {
"message": "Unread notifications Indicator"
},
Expand Down Expand Up @@ -4109,11 +4127,11 @@
"welcome_to_composer_7147714a": {
"message": "Welcome to Composer!"
},
"westeurope_cabf9688": {
"message": "westeurope"
"west_europe_75ac94f4": {
"message": "West Europe"
},
"westus_dc50d800": {
"message": "westus"
"west_us_51d3fdbb": {
"message": "West US"
},
"what_can_the_user_accomplish_through_this_conversa_7ddb03a1": {
"message": "What can the user accomplish through this conversation? For example, BookATable, OrderACoffee etc."
Expand Down Expand Up @@ -4259,6 +4277,9 @@
"your_skill_is_ready_to_be_shared_6376eb3c": {
"message": "Your skill is ready to be shared!"
},
"your_subscription_list_is_empty_please_add_your_su_6b229c26": {
"message": "Your subscription list is empty, please add your subscription, or login with another account."
},
"your_teams_adapter_is_configured_for_your_publishe_e84e9275": {
"message": "Your Teams adapter is configured for your published bot. Copy the manifest, open App Studio in Teams and add the manifest so you can test your bot in Teams"
},
Expand Down

0 comments on commit c525b56

Please sign in to comment.