Skip to content

Commit

Permalink
Convert the story back to the non-control version
Browse files Browse the repository at this point in the history
We don't have the addon on v16.
  • Loading branch information
gzdunek committed Dec 11, 2024
1 parent 2d8d605 commit 050e973
Showing 1 changed file with 49 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { Meta } from '@storybook/react';
import { wait } from 'shared/utils/wait';

import { MockAppContextProvider } from 'teleterm/ui/fixtures/MockAppContextProvider';
Expand All @@ -34,41 +33,65 @@ import { DocumentAuthorizeWebSession } from './DocumentAuthorizeWebSession';

export default {
title: 'Teleterm/DocumentAuthorizeWebSession',
component: Story,
argTypes: {
isDeviceTrusted: { control: { type: 'boolean' } },
isRequestedUserLoggedIn: { control: { type: 'boolean' } },
},
args: {
isDeviceTrusted: true,
isRequestedUserLoggedIn: true,
};

const doc: types.DocumentAuthorizeWebSession = {
uri: '/docs/e2hyt5',
rootClusterUri: rootClusterUri,
kind: 'doc.authorize_web_session',
title: 'Authorize Web Session',
webSessionRequest: {
redirectUri: '',
token: '',
id: '',
username: 'alice',
},
} satisfies Meta<StoryProps>;
};

interface StoryProps {
isDeviceTrusted: boolean;
isRequestedUserLoggedIn: boolean;
export function DeviceNotTrusted() {
const rootCluster = makeRootCluster();
const appContext = new MockAppContext();
appContext.clustersService.setState(draftState => {
draftState.clusters.set(rootCluster.uri, rootCluster);
});
return (
<MockAppContextProvider appContext={appContext}>
<MockWorkspaceContextProvider rootClusterUri={rootCluster.uri}>
<DocumentAuthorizeWebSession doc={doc} visible={true} />
</MockWorkspaceContextProvider>
</MockAppContextProvider>
);
}

export function Story(props: StoryProps) {
export function RequestedUserNotLoggedIn() {
const rootCluster = makeRootCluster({
loggedInUser: makeLoggedInUser({ isDeviceTrusted: props.isDeviceTrusted }),
loggedInUser: makeLoggedInUser({ isDeviceTrusted: true }),
});
const doc: types.DocumentAuthorizeWebSession = {
uri: '/docs/e2hyt5',
rootClusterUri: rootClusterUri,
kind: 'doc.authorize_web_session',
title: 'Authorize Web Session',
const docForDifferentUser: types.DocumentAuthorizeWebSession = {
...doc,
webSessionRequest: {
redirectUri: '',
token: '',
id: '',
username: props.isRequestedUserLoggedIn
? rootCluster.loggedInUser.name
: 'bob',
...doc.webSessionRequest,
username: 'bob',
},
};
const appContext = new MockAppContext();
appContext.clustersService.setState(draftState => {
draftState.clusters.set(rootCluster.uri, rootCluster);
});

return (
<MockAppContextProvider appContext={appContext}>
<MockWorkspaceContextProvider rootClusterUri={rootCluster.uri}>
<DocumentAuthorizeWebSession doc={docForDifferentUser} visible={true} />
</MockWorkspaceContextProvider>
</MockAppContextProvider>
);
}

export function DeviceTrusted() {
const rootCluster = makeRootCluster({
loggedInUser: makeLoggedInUser({ isDeviceTrusted: true }),
});
const appContext = new MockAppContext();
appContext.clustersService.setState(draftState => {
draftState.clusters.set(rootCluster.uri, rootCluster);
Expand Down

0 comments on commit 050e973

Please sign in to comment.