Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 15 additions & 25 deletions examples/dialogs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
AdaptiveCard,
IAdaptiveCard,
SubmitAction,
TaskFetchAction,
TaskFetchData,
SubmitActionData,
TaskFetchSubmitActionData,
TextInput,
} from '@microsoft/teams.cards';
import { ConsoleLogger } from '@microsoft/teams.common';
Expand All @@ -27,6 +27,15 @@ if (!process.env['BOT_ENDPOINT']) {
);
}

function createTaskFetchSubmitAction(title: string, openDialogType: string): SubmitAction {
const data = new SubmitActionData({ msteams: new TaskFetchSubmitActionData() });
data.opendialogtype = openDialogType;
const action = new SubmitAction();
action.title = title;
action.data = data;
return action;
Comment on lines +31 to +36
Copy link
Collaborator

@heyitsaamir heyitsaamir Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh, this is just really confusing. (not saying it's your fault -- but just to read this, is really really confusing.). I preferred it with this whole "msteams" stuff was abstracted away.
Right now, this is what I see:

  1. There is a "SubmitAction"
  2. Of that submit action, it has a data. This data is a SubmitActionData
  3. This SubmitActionData has some property called "TaskFetchSubmitActionData" which is on a confusing property called "msteams".
  4. And it also has a property called "openDialogType".

I preferred it with TaskFetchSubmitActionData was would abstract most of this stuff away.... What do you think? We (I, if you don't want to), can push for a better devex here if there's some validation that this sort of sucks lol. To me it does, because all this msteams crap means nothing.

}

const app = new App({
logger,
plugins: [new DevtoolsPlugin()],
Expand All @@ -45,29 +54,10 @@ app.on('message', async ({ send }) => {
size: 'Large',
weight: 'Bolder',
}).withActions(
// raw action
{
type: 'Action.Submit',
title: 'Simple form test',
data: {
msteams: {
type: 'task/fetch',
},
opendialogtype: 'simple_form',
},
},
// Special type of action to open a dialog
new TaskFetchAction({})
.withTitle('Webpage Dialog')
// This data will be passed back in an event so we can
// handle what to show in the dialog
.withValue(new TaskFetchData({ opendialogtype: 'webpage_dialog' })),
new TaskFetchAction({})
.withTitle('Multi-step Form')
.withValue(new TaskFetchData({ opendialogtype: 'multi_step_form' })),
new TaskFetchAction({})
.withTitle('Mixed Example')
.withValue(new TaskFetchData({ opendialogtype: 'mixed_example' }))
createTaskFetchSubmitAction('Simple form test', 'simple_form'),
createTaskFetchSubmitAction('Webpage Dialog', 'webpage_dialog'),
createTaskFetchSubmitAction('Multi-step Form', 'multi_step_form'),
createTaskFetchSubmitAction('Mixed Example', 'mixed_example')
);

// Send the card as an attachment
Expand Down
32 changes: 21 additions & 11 deletions packages/cards/src/actions/submit/collab-stage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { CollabStageAction, CollabStageData, CollabStageValueData } from './collab-stage';
import { CollabStageInvokeDataValue, InvokeSubmitActionData, SubmitActionData } from '../../core';

import { CollabStageAction } from './collab-stage';

describe('Actions.Submit.CollabStage', () => {
it('should build', () => {
const action = new CollabStageAction().withData(new CollabStageData()).withValue({
const action = new CollabStageAction().withData(
new InvokeSubmitActionData(undefined)
).withValue({
name: 'test',
entityId: 'test',
contentUrl: 'http://localhost/tabs/test',
});

expect(action.data.msteams.value?.tabInfo).toEqual({
const msteams = action.data.msteams as InvokeSubmitActionData;
const value = msteams.value as CollabStageInvokeDataValue;
expect(value.tabInfo).toEqual({
name: 'test',
entityId: 'test',
contentUrl: 'http://localhost/tabs/test',
Expand All @@ -17,18 +23,22 @@ describe('Actions.Submit.CollabStage', () => {

it('should build from interface', () => {
const action = CollabStageAction.from({
data: {
msteams: new CollabStageData(
new CollabStageValueData({
name: 'test',
entityId: 'test',
contentUrl: 'http://localhost/tabs/test',
data: new SubmitActionData({
msteams: new InvokeSubmitActionData(
new CollabStageInvokeDataValue({
tabInfo: {
name: 'test',
entityId: 'test',
contentUrl: 'http://localhost/tabs/test',
},
})
),
},
}),
});

expect(action.data.msteams.value?.tabInfo).toEqual({
const msteams = action.data.msteams as InvokeSubmitActionData;
const value = msteams.value as CollabStageInvokeDataValue;
expect(value.tabInfo).toEqual({
name: 'test',
entityId: 'test',
contentUrl: 'http://localhost/tabs/test',
Expand Down
114 changes: 32 additions & 82 deletions packages/cards/src/actions/submit/collab-stage.ts
Original file line number Diff line number Diff line change
@@ -1,117 +1,67 @@
import { ITabInfo } from '../../common';

import { ISubmitAction, SubmitAction, SubmitActionOptions } from '../../core';

import { MSTeamsData } from './ms-teams-data';
import {
CollabStageInvokeDataValue,
ICollabStageInvokeDataValue,
IInvokeSubmitActionData,
InvokeSubmitActionData,
ISubmitAction,
ISubmitActionData,
ITabInfo,
SubmitAction,
SubmitActionData,
SubmitActionOptions,
} from '../../core';

export type CollabStageActionOptions = SubmitActionOptions & {
data: MSTeamsData<ICollabStageData>;
data: ISubmitActionData;
};

/**
* Adaptive Card action response type for the {@link CollabStageAction} function.
*/
export interface ICollabStageAction extends ISubmitAction {
/**
* Initial data that input fields will be combined with. These are essentially hidden properties.
* Initial data that input fields will be combined with. These are essentially 'hidden' properties.
*/
data: MSTeamsData<ICollabStageData>;
data: ISubmitActionData;
}

/**
* Adaptive Card action that opens a collab stage popout window.
*/
export class CollabStageAction extends SubmitAction implements ICollabStageAction {
/**
* Initial data that input fields will be combined with. These are essentially hidden properties.
* Initial data that input fields will be combined with. These are essentially 'hidden' properties.
*/
data: MSTeamsData<ICollabStageData>;
data: ISubmitActionData;

constructor(tab?: ITabInfo, options: SubmitActionOptions = {}) {
super(options);
Object.assign(this, options);
this.data = {
msteams: {
type: 'invoke',
value: tab
? {
type: 'tab/tabInfoAction',
tabInfo: tab,
}
this.data = new SubmitActionData({
msteams: new InvokeSubmitActionData(
tab
? new CollabStageInvokeDataValue({ tabInfo: tab })
: undefined,
},
};
),
});
}

static from(options: CollabStageActionOptions) {
return new CollabStageAction(options.data.msteams.value?.tabInfo, options);
const msteams = options.data.msteams as IInvokeSubmitActionData | undefined;
const value = msteams?.value as ICollabStageInvokeDataValue | undefined;
return new CollabStageAction(value?.tabInfo, options);
}

withData(value: ICollabStageData) {
super.withData({ msteams: value });
withData(value: IInvokeSubmitActionData) {
super.withData(new SubmitActionData({ msteams: value }));
return this;
}

withValue(value: ITabInfo) {
this.data.msteams.value = new CollabStageValueData(value);
const msteams = this.data.msteams as IInvokeSubmitActionData | undefined;
if (msteams) {
msteams.value = new CollabStageInvokeDataValue({ tabInfo: value });
}
return this;
}
}

/**
* Contains the Adaptive Card action data in {@link CollabStageAction}.
*/
export interface ICollabStageData {
type: 'invoke';

/**
* Set the value to send with the invoke
*/
value?: ICollabStageValueData;
}

/**
* Contains the Adaptive Card action data in {@link CollabStageAction}.
*/
export class CollabStageData implements ICollabStageData {
type: 'invoke';

/**
* Set the value to send with the invoke
*/
value?: ICollabStageValueData;

constructor(value?: ICollabStageValueData) {
this.type = 'invoke';
this.value = value;
}
}

/**
* Contains the Adaptive Card action value data in {@link CollabStageActionData}.
*/
export interface ICollabStageValueData {
type: 'tab/tabInfoAction';

/**
* Information about the iFrame content, rendered in the collab stage popout window.
*/
tabInfo: ITabInfo;
}

/**
* Contains the Adaptive Card action value data in {@link CollabStageActionData}.
*/
export class CollabStageValueData implements ICollabStageValueData {
type: 'tab/tabInfoAction';

/**
* Information about the iFrame content, rendered in the collab stage popout window.
*/
tabInfo: ITabInfo;

constructor(tab: ITabInfo) {
this.type = 'tab/tabInfoAction';
this.tabInfo = tab;
}
}
12 changes: 12 additions & 0 deletions packages/cards/src/actions/submit/im-back.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import { MSTeamsData } from './ms-teams-data';

export type IMBackActionOptions = SubmitActionOptions & { data: MSTeamsData<IIMBackData> };

/**
* @deprecated This type is deprecated. Please use {@link IImBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export interface IIMBackAction extends ISubmitAction {
/**
* Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.
*/
data: MSTeamsData<IIMBackData>;
}

/**
* @deprecated This class is deprecated. Please use {@link ImBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export class IMBackAction extends SubmitAction implements IIMBackAction {
/**
* Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.
Expand Down Expand Up @@ -38,6 +44,9 @@ export class IMBackAction extends SubmitAction implements IIMBackAction {
}
}

/**
* @deprecated This type is deprecated. Please use {@link IImBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export interface IIMBackData {
type: 'imBack';

Expand All @@ -47,6 +56,9 @@ export interface IIMBackData {
value: string;
}

/**
* @deprecated This class is deprecated. Please use {@link ImBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export class IMBackData implements IIMBackData {
type: 'imBack';

Expand Down
12 changes: 12 additions & 0 deletions packages/cards/src/actions/submit/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import { MSTeamsData } from './ms-teams-data';

export type InvokeActionOptions = SubmitActionOptions & { data: MSTeamsData<IInvokeData> };

/**
* @deprecated This type is deprecated. Please use {@link IInvokeSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export interface IInvokeAction extends ISubmitAction {
/**
* Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.
*/
data: MSTeamsData<IInvokeData>;
}

/**
* @deprecated This class is deprecated. Please use {@link InvokeSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export class InvokeAction extends SubmitAction implements IInvokeAction {
/**
* Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.
Expand Down Expand Up @@ -38,6 +44,9 @@ export class InvokeAction extends SubmitAction implements IInvokeAction {
}
}

/**
* @deprecated This type is deprecated. Please use {@link IInvokeSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export interface IInvokeData {
type: 'invoke';

Expand All @@ -47,6 +56,9 @@ export interface IInvokeData {
value?: any;
}

/**
* @deprecated This class is deprecated. Please use {@link InvokeSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export class InvokeData implements IInvokeData {
type: 'invoke';

Expand Down
12 changes: 12 additions & 0 deletions packages/cards/src/actions/submit/message-back.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ export type MessageBackActionOptions = SubmitActionOptions & {
data: MSTeamsData<IMessageBackData>;
};

/**
* @deprecated This type is deprecated. Please use {@link IMessageBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export interface IMessageBackAction extends ISubmitAction {
/**
* Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.
*/
data: MSTeamsData<IMessageBackData>;
}

/**
* @deprecated This class is deprecated. Please use {@link MessageBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export class MessageBackAction extends SubmitAction implements IMessageBackAction {
/**
* Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.
Expand All @@ -37,6 +43,9 @@ export class MessageBackAction extends SubmitAction implements IMessageBackActio
}
}

/**
* @deprecated This type is deprecated. Please use {@link IMessageBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export interface IMessageBackData {
type: 'messageBack';

Expand All @@ -58,6 +67,9 @@ export interface IMessageBackData {
value: string;
}

/**
* @deprecated This class is deprecated. Please use {@link MessageBackSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export class MessageBackData implements IMessageBackData {
type: 'messageBack';

Expand Down
Loading
Loading