Skip to content

Commit

Permalink
feat(android-setup): replace device metadata with device info (#2875)
Browse files Browse the repository at this point in the history
  • Loading branch information
karanbirsingh authored Jun 15, 2020
1 parent 40bb718 commit b0f474a
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 56 deletions.
4 changes: 2 additions & 2 deletions src/electron/flux/types/android-setup-store-data.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { DeviceMetadata } from 'electron/flux/types/device-metadata';
import { DeviceInfo } from 'electron/platform/android/android-service-configurator';
import { AndroidSetupStepId } from 'electron/platform/android/setup/android-setup-step-id';

export type AndroidSetupStoreData = {
currentStepId: AndroidSetupStepId;

// undefined if no device exists or if no device has been selected
selectedDevice?: DeviceMetadata;
selectedDevice?: DeviceInfo;
};
8 changes: 0 additions & 8 deletions src/electron/flux/types/device-metadata.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Licensed under the MIT License.

import { NamedFC } from 'common/react/named-fc';
import { DeviceMetadata } from 'electron/flux/types/device-metadata';
import { DeviceInfo } from 'electron/platform/android/android-service-configurator';
import { css, Icon } from 'office-ui-fabric-react';
import * as React from 'react';
import * as styles from './device-description.scss';

export interface DeviceDescriptionProps extends DeviceMetadata {
export interface DeviceDescriptionProps extends DeviceInfo {
className?: string;
currentApplication?: string;
}

export const DeviceDescription = NamedFC<DeviceDescriptionProps>('DeviceDescription', props => {
Expand All @@ -20,12 +21,12 @@ export const DeviceDescription = NamedFC<DeviceDescriptionProps>('DeviceDescript
if (props.currentApplication) {
descriptionAndApp = (
<div className={styles.deviceAndCurrentApplication}>
{props.description}
{props.friendlyName}
<div className={styles.currentApplication}>{props.currentApplication}</div>
</div>
);
} else {
descriptionAndApp = props.description;
descriptionAndApp = props.friendlyName;
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { DeviceMetadata } from 'electron/flux/types/device-metadata';
import { DeviceInfo } from 'electron/platform/android/android-service-configurator';
import {
CheckboxVisibility,
DefaultButton,
Expand All @@ -17,7 +17,7 @@ import { DeviceDescription } from './device-description';
import * as styles from './prompt-choose-device-step.scss';

export type PromptChooseDeviceStepState = {
selectedDevice: DeviceMetadata;
selectedDevice: DeviceInfo;
};

export class PromptChooseDeviceStep extends React.Component<
Expand All @@ -33,7 +33,7 @@ export class PromptChooseDeviceStep extends React.Component<
onSelectionChanged: () => {
const details = this.selection.getSelection();
if (details.length > 0) {
this.setState({ selectedDevice: details[0] as DeviceMetadata });
this.setState({ selectedDevice: details[0] as DeviceInfo });
}
},
});
Expand All @@ -51,17 +51,20 @@ export class PromptChooseDeviceStep extends React.Component<
};

// Available devices will be retrieved from store in future feature work
const devices: DeviceMetadata[] = [
const devices: DeviceInfo[] = [
{
description: 'Phone 1',
id: '1',
friendlyName: 'Phone 1',
isEmulator: true,
},
{
description: 'Phone 2',
id: '2',
friendlyName: 'Phone 2',
isEmulator: false,
},
{
description: 'Phone 3',
id: '3',
friendlyName: 'Phone 3',
isEmulator: true,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@ exports[`PromptChooseDeviceStep renders per snapshot 1`] = `
Array [
Object {
"metadata": Object {
"description": "Phone 1",
"friendlyName": "Phone 1",
"id": "1",
"isEmulator": true,
},
},
Object {
"metadata": Object {
"description": "Phone 2",
"friendlyName": "Phone 2",
"id": "2",
"isEmulator": false,
},
},
Object {
"metadata": Object {
"description": "Phone 3",
"friendlyName": "Phone 3",
"id": "3",
"isEmulator": true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ exports[`PromptConnectedStartTestingStep renders with device 1`] = `
>
<DeviceDescription
className="deviceDescription"
description="Super-Duper Gadget"
friendlyName="Super-Duper Gadget"
id="1"
isEmulator={false}
/>
<Button
Expand Down Expand Up @@ -63,7 +64,8 @@ exports[`PromptConnectedStartTestingStep renders with emulator 1`] = `
>
<DeviceDescription
className="deviceDescription"
description="Emulator Extraordinaire"
friendlyName="Emulator Extraordinaire"
id="1"
isEmulator={true}
/>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ exports[`PromptGrantPermissionsStep renders with device 1`] = `
</React.Fragment>
<DeviceDescription
className="deviceDescription"
description="Super-Duper Gadget"
friendlyName="Super-Duper Gadget"
id="1"
isEmulator={false}
/>
<CustomizedPrimaryButton
Expand Down Expand Up @@ -68,7 +69,8 @@ exports[`PromptGrantPermissionsStep renders with emulator 1`] = `
</React.Fragment>
<DeviceDescription
className="deviceDescription"
description="Emulator Extraordinaire"
friendlyName="Emulator Extraordinaire"
id="1"
isEmulator={true}
/>
<CustomizedPrimaryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ exports[`PromptInstallFailedStep renders with device 1`] = `
</React.Fragment>
<DeviceDescription
className="deviceDescription"
description="Super-Duper Gadget"
friendlyName="Super-Duper Gadget"
id="1"
isEmulator={false}
/>
<CustomizedPrimaryButton
Expand Down Expand Up @@ -68,7 +69,8 @@ exports[`PromptInstallFailedStep renders with emulator 1`] = `
</React.Fragment>
<DeviceDescription
className="deviceDescription"
description="Emulator Extraordinaire"
friendlyName="Emulator Extraordinaire"
id="1"
isEmulator={true}
/>
<CustomizedPrimaryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ exports[`PromptInstallServiceStep renders with device 1`] = `
</React.Fragment>
<DeviceDescription
className="deviceDescription"
description="Super-Duper Gadget"
friendlyName="Super-Duper Gadget"
id="1"
isEmulator={false}
/>
<CustomizedPrimaryButton
Expand Down Expand Up @@ -54,7 +55,8 @@ exports[`PromptInstallServiceStep renders with emulator 1`] = `
</React.Fragment>
<DeviceDescription
className="deviceDescription"
description="Emulator Extraordinaire"
friendlyName="Emulator Extraordinaire"
id="1"
isEmulator={true}
/>
<CustomizedPrimaryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('DeviceDescription', () => {
it('renders with device', () => {
const props: DeviceDescriptionProps = {
isEmulator: false,
description: 'Super-Duper Gadget',
friendlyName: 'Super-Duper Gadget',
id: '0',
};

const rendered = shallow(<DeviceDescription {...props} />);
Expand All @@ -21,7 +22,8 @@ describe('DeviceDescription', () => {
it('renders with emulator', () => {
const props: DeviceDescriptionProps = {
isEmulator: true,
description: 'Emulator Extraordinaire',
friendlyName: 'Emulator Extraordinaire',
id: '1',
};

const rendered = shallow(<DeviceDescription {...props} />);
Expand All @@ -31,8 +33,9 @@ describe('DeviceDescription', () => {
it('renders with extra classname', () => {
const props: DeviceDescriptionProps = {
isEmulator: true,
description: 'Simple Emulator',
friendlyName: 'Simple Emulator',
className: 'my-class',
id: '2',
};

const rendered = shallow(<DeviceDescription {...props} />);
Expand All @@ -42,8 +45,9 @@ describe('DeviceDescription', () => {
it('renders with currentApplication', () => {
const props: DeviceDescriptionProps = {
isEmulator: false,
description: 'Whizbang tablet',
friendlyName: 'Whizbang tablet',
currentApplication: 'Wildlife Manager',
id: '3',
};

const rendered = shallow(<DeviceDescription {...props} />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { AndroidSetupActionCreator } from 'electron/flux/action-creator/android-setup-action-creator';
import { DeviceMetadata } from 'electron/flux/types/device-metadata';
import { DeviceInfo } from 'electron/platform/android/android-service-configurator';
import { AndroidSetupStepLayout } from 'electron/views/device-connect-view/components/android-setup/android-setup-step-layout';
import { CommonAndroidSetupStepProps } from 'electron/views/device-connect-view/components/android-setup/android-setup-types';
import { PromptConnectedStartTestingStep } from 'electron/views/device-connect-view/components/android-setup/prompt-connected-start-testing-step';
Expand Down Expand Up @@ -29,9 +29,10 @@ describe('PromptConnectedStartTestingStep', () => {
});

it('renders with device', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: false,
description: 'Super-Duper Gadget',
friendlyName: 'Super-Duper Gadget',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand All @@ -41,9 +42,10 @@ describe('PromptConnectedStartTestingStep', () => {
});

it('renders with emulator', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: true,
description: 'Emulator Extraordinaire',
friendlyName: 'Emulator Extraordinaire',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { DeviceMetadata } from 'electron/flux/types/device-metadata';
import { DeviceInfo } from 'electron/platform/android/android-service-configurator';
import { CommonAndroidSetupStepProps } from 'electron/views/device-connect-view/components/android-setup/android-setup-types';
import { PromptGrantPermissionsStep } from 'electron/views/device-connect-view/components/android-setup/prompt-grant-permissions-step';
import { shallow } from 'enzyme';
Expand All @@ -15,9 +15,10 @@ describe('PromptGrantPermissionsStep', () => {
});

it('renders with device', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: false,
description: 'Super-Duper Gadget',
friendlyName: 'Super-Duper Gadget',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand All @@ -27,9 +28,10 @@ describe('PromptGrantPermissionsStep', () => {
});

it('renders with emulator', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: true,
description: 'Emulator Extraordinaire',
friendlyName: 'Emulator Extraordinaire',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { DeviceMetadata } from 'electron/flux/types/device-metadata';
import { DeviceInfo } from 'electron/platform/android/android-service-configurator';
import { CommonAndroidSetupStepProps } from 'electron/views/device-connect-view/components/android-setup/android-setup-types';
import { PromptInstallFailedStep } from 'electron/views/device-connect-view/components/android-setup/prompt-install-failed-step';
import { shallow } from 'enzyme';
Expand All @@ -15,9 +15,10 @@ describe('PromptInstallFailedStep', () => {
});

it('renders with device', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: false,
description: 'Super-Duper Gadget',
friendlyName: 'Super-Duper Gadget',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand All @@ -27,9 +28,10 @@ describe('PromptInstallFailedStep', () => {
});

it('renders with emulator', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: true,
description: 'Emulator Extraordinaire',
friendlyName: 'Emulator Extraordinaire',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { DeviceMetadata } from 'electron/flux/types/device-metadata';
import { DeviceInfo } from 'electron/platform/android/android-service-configurator';
import { CommonAndroidSetupStepProps } from 'electron/views/device-connect-view/components/android-setup/android-setup-types';
import { PromptInstallServiceStep } from 'electron/views/device-connect-view/components/android-setup/prompt-install-service-step';
import { shallow } from 'enzyme';
Expand All @@ -15,9 +15,10 @@ describe('PromptInstallServiceStep', () => {
});

it('renders with device', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: false,
description: 'Super-Duper Gadget',
friendlyName: 'Super-Duper Gadget',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand All @@ -27,9 +28,10 @@ describe('PromptInstallServiceStep', () => {
});

it('renders with emulator', () => {
const selectedDevice: DeviceMetadata = {
const selectedDevice: DeviceInfo = {
isEmulator: true,
description: 'Emulator Extraordinaire',
friendlyName: 'Emulator Extraordinaire',
id: '1',
};

props.androidSetupStoreData.selectedDevice = selectedDevice;
Expand Down

0 comments on commit b0f474a

Please sign in to comment.