Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add delete button for publish targets #6557

Merged
merged 12 commits into from
Mar 25, 2021
Merged
33 changes: 32 additions & 1 deletion Composer/packages/client/src/pages/botProject/PublishTargets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// Licensed under the MIT License.

/** @jsx jsx */
import React, { Fragment, useState, useEffect } from 'react';
import React, { Fragment, useState, useEffect, useCallback } from 'react';
import { jsx, css } from '@emotion/core';
import { useRecoilValue } from 'recoil';
import { PublishTarget } from '@bfc/shared';
import formatMessage from 'format-message';
import { ActionButton } from 'office-ui-fabric-react/lib/Button';
import { FontWeights } from 'office-ui-fabric-react/lib/Styling';
import { SharedColors } from '@uifabric/fluent-theme';
import { OpenConfirmModal } from '@bfc/ui-shared';

import { dispatcherState, settingsState, publishTypesState } from '../../recoilModel';
import { CollapsableWrapper } from '../../components/CollapsableWrapper';
Expand Down Expand Up @@ -83,6 +84,26 @@ export const PublishTargets: React.FC<PublishTargetsProps> = (props) => {
}
}, [scrollToSectionId]);

const onDeletePublishTarget = useCallback(
async (publishTarget: PublishTarget) => {
if (publishTargets) {
GeoffCoxMSFT marked this conversation as resolved.
Show resolved Hide resolved
const targetName = publishTarget.name;
const confirmed = await OpenConfirmModal(
formatMessage('Delete?'),
formatMessage(
'Are you sure you want to remove {targetName}? This will remove only the profile and will not delete provisioned resources.',
{ targetName }
)
);
if (confirmed) {
const newPublishTargets = publishTargets.filter((t) => t.name !== targetName);
setPublishTargets(newPublishTargets, projectId);
}
}
},
[projectId, publishTargets]
);

return (
<Fragment>
<CollapsableWrapper title={formatMessage('Publish profiles')} titleStyle={title}>
Expand All @@ -103,6 +124,7 @@ export const PublishTargets: React.FC<PublishTargetsProps> = (props) => {
</div>
<div css={tableRowItem(columnSizes[2])}>
<ActionButton
data-testid={'editPublishProfile'}
styles={editPublishProfile}
onClick={() => {
setCurrent({ item: p, index: index });
Expand All @@ -116,6 +138,15 @@ export const PublishTargets: React.FC<PublishTargetsProps> = (props) => {
{formatMessage('Edit')}
</ActionButton>
</div>
<div css={tableRowItem(columnSizes[2])}>
<ActionButton
data-testid={'deletePublishProfile'}
styles={editPublishProfile}
onClick={() => onDeletePublishTarget(p)}
GeoffCoxMSFT marked this conversation as resolved.
Show resolved Hide resolved
>
{formatMessage('Delete')}
</ActionButton>
</div>
</div>
);
})}
Expand Down
6 changes: 6 additions & 0 deletions Composer/packages/server/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@
"are_you_sure_you_want_to_remove_propertyname_8a793e4f": {
"message": "Are you sure you want to remove \"{ propertyName }\"?"
},
"are_you_sure_you_want_to_remove_targetname_this_wi_b3ddce54": {
"message": "Are you sure you want to remove { targetName }? This will remove only the profile and will not delete provisioned resources."
},
"are_you_sure_you_want_to_remove_this_property_5bfb9cb5": {
"message": "Are you sure you want to remove this property?"
},
Expand Down Expand Up @@ -962,6 +965,9 @@
"delete_bot_73586104": {
"message": "Delete Bot"
},
"delete_fd07d6ad": {
"message": "Delete?"
},
"delete_form_dialog_schema_c8e28229": {
"message": "Delete form dialog schema?"
},
Expand Down