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
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
12 changes: 12 additions & 0 deletions packages/cards/src/actions/submit/sign-in.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 SignInActionOptions = SubmitActionOptions & { data: MSTeamsData<ISignInData> };

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

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

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

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

/**
* @deprecated This class is deprecated. Please use {@link SigninSubmitActionData} instead. This will be removed in a future version of the SDK.
*/
export class SignInData implements ISignInData {
type: 'signin';

Expand Down
Loading
Loading