Skip to content

Add shortcutRelay capability to support host shortcut in Apps #2868

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
55 changes: 55 additions & 0 deletions apps/teams-test-app/src/components/ShortcutRelayAPIs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { shortcutRelay } from '@microsoft/teams-js';
import React from 'react';

import { ApiWithoutInput } from './utils';
import { ModuleWrapper } from './utils/ModuleWrapper';

const CheckShortcutRelayCapability = (): React.ReactElement =>
ApiWithoutInput({
name: 'shortcutRelay_checkShortcutRelayCapability',
title: 'Check Shortcut Relay Capability',
onClick: async () => `ShortcutRelay ${shortcutRelay.isSupported() ? 'is' : 'is not'} supported`,
});

const EnableShortcutRelayCapability = (): React.ReactElement =>
ApiWithoutInput({
name: 'shortcutRelay_enableShortcutRelayCapability',
title: 'Enable Shortcut Relay Capability',
onClick: async () => {
await shortcutRelay.enableShortcutRelayCapability();
return 'called';
},
});

const SetOverridableShortcutHandler = (): React.ReactElement =>
ApiWithoutInput({
name: 'shortcutRelay_setOverridableShortcutHandler',
title: 'Set Overridable Shortcut Handler',
onClick: async () => {
shortcutRelay.setOverridableShortcutHandler(() => true);
return 'called';
},
});

const ResetIsShortcutRelayCapabilityEnabled = (): React.ReactElement =>
ApiWithoutInput({
name: 'shortcutRelay_resetIsShortcutRelayCapabilityEnabled',
title: 'Reset Shortcut Relay Capability',
onClick: async () => {
shortcutRelay.resetIsShortcutRelayCapabilityEnabled();
return 'called';
},
});

const ShortcutRelayAPIs = (): React.ReactElement => (
<>
<ModuleWrapper title="ShortcutRelay">
<CheckShortcutRelayCapability />
<EnableShortcutRelayCapability />
<SetOverridableShortcutHandler />
<ResetIsShortcutRelayCapabilityEnabled />
</ModuleWrapper>
</>
);

export default ShortcutRelayAPIs;
2 changes: 2 additions & 0 deletions apps/teams-test-app/src/pages/TestApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import RemoteCameraAPIs from '../components/RemoteCameraAPIs';
import SearchAPIs from '../components/SearchAPIs';
import SecondaryBrowserAPIs from '../components/SecondaryBrowserAPIs';
import SharingAPIs from '../components/SharingAPIs';
import ShortcutRelayAPIs from '../components/ShortcutRelayAPIs';
import StageViewAPIs from '../components/StageViewAPIs';
import StageViewSelfAPIs from '../components/StageViewSelfAPIs';
import StoreAPIs from '../components/StoreApis';
Expand Down Expand Up @@ -157,6 +158,7 @@ export const TestApp: React.FC = () => {
{ name: 'SearchAPIs', component: <SearchAPIs /> },
{ name: 'SecondaryBrowserAPIs', component: <SecondaryBrowserAPIs /> },
{ name: 'SharingAPIs', component: <SharingAPIs /> },
{ name: 'ShortcutRelayAPIs', component: <ShortcutRelayAPIs /> },
{ name: 'WebStorageAPIs', component: <WebStorageAPIs /> },
{ name: 'StageViewAPIs', component: <StageViewAPIs /> },
{ name: 'StageViewSelfAPIs', component: <StageViewSelfAPIs /> },
Expand Down
3 changes: 3 additions & 0 deletions packages/teams-js/src/internal/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ export const enum ApiName {
Settings_SetValidityState = 'settings.setValidityState',
Sharing_History_GetContent = 'sharing.history.getContent',
Sharing_ShareWebContent = 'sharing.shareWebContent',
ShortcutRelay_GetHostShortcuts = 'shortcutRelay.getHostShortcuts',
ShortcutRelay_ForwardShortcutEvent = 'shortcutRelay.forwardShortcutEvent',
ShortcutRelay_HostShortcutChanged = 'shortcutRelay.hostShortcutChanged',
StageView_Open = 'stageView.open',
StageView_Self_Close = 'stageView.self.close',
Store_OpenFullStore = 'store.openFullStore',
Expand Down
1 change: 1 addition & 0 deletions packages/teams-js/src/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ export * as liveShare from './liveShareHost';
export { LiveShareHost } from './liveShareHost';
export * as marketplace from './marketplace';
export { ISerializable } from './serializable.interface';
export * as shortcutRelay from './shortcutRelay';
1 change: 1 addition & 0 deletions packages/teams-js/src/public/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ interface IRuntimeV4 extends IBaseRuntime {
readonly sharing?: {
readonly history?: {};
};
readonly shortcutRelay?: {};
readonly stageView?: {
readonly self?: {};
};
Expand Down
Loading
Loading