From 994546b24a0e6470b3ac2131b8635b8430bdb446 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 6 Nov 2019 10:44:11 -0800 Subject: [PATCH] Setup of the bug creation screen Summary: This diff sets up the create form for the new support request project. The current screen is very basic. I will be iterating through it in the upcoming diffs. Reviewed By: passy Differential Revision: D18327464 fbshipit-source-id: af01fc10f68a135f32f0ae98551986852019e8aa --- src/MenuBar.tsx | 55 ++++++++++++++++++--------- src/fb-stubs/SupportRequestFormV2.tsx | 17 +++++++++ src/reducers/connections.tsx | 4 +- src/ui/components/MultiLineInput.tsx | 34 +++++++++++++++++ src/ui/index.tsx | 1 + 5 files changed, 92 insertions(+), 19 deletions(-) create mode 100644 src/fb-stubs/SupportRequestFormV2.tsx create mode 100644 src/ui/components/MultiLineInput.tsx diff --git a/src/MenuBar.tsx b/src/MenuBar.tsx index 45a8e39d1..e9dab1d56 100644 --- a/src/MenuBar.tsx +++ b/src/MenuBar.tsx @@ -15,12 +15,15 @@ import { ACTIVE_SHEET_PLUGINS, ACTIVE_SHEET_SETTINGS, } from './reducers/application'; +import {setStaticView} from './reducers/connections'; +import SupportRequestFormV2 from './fb-stubs/SupportRequestFormV2'; import {Store} from './reducers/'; import electron, {MenuItemConstructorOptions} from 'electron'; import {notNull} from './utils/typeUtils'; import constants from './fb-stubs/constants'; import os from 'os'; import path from 'path'; +import GK from './fb-stubs/GK'; export type DefaultKeyboardAction = 'clear' | 'goToBottom' | 'createPaste'; export type TopLevelMenu = 'Edit' | 'View' | 'Window' | 'Help'; @@ -221,28 +224,44 @@ function getTemplate( }, }); } + const fileSubmenu: MenuItemConstructorOptions[] = [ + { + label: 'Preferences', + accelerator: 'Cmd+,', + click: () => store.dispatch(setActiveSheet(ACTIVE_SHEET_SETTINGS)), + }, + { + label: 'Import Flipper File...', + accelerator: 'CommandOrControl+O', + click: function() { + showOpenDialog(store); + }, + }, + { + label: 'Export', + submenu: exportSubmenu, + }, + ]; + if (GK.get('support_requests_v2')) { + const supportRequestSubmenu = [ + { + label: 'Create...', + click: function() { + // Dispatch an action to open the export screen of Support Request form + store.dispatch(setStaticView(SupportRequestFormV2)); + }, + }, + ]; + fileSubmenu.push({ + label: 'Support Requests', + submenu: supportRequestSubmenu, + }); + } const template: MenuItemConstructorOptions[] = [ { label: 'File', - submenu: [ - { - label: 'Preferences', - accelerator: 'Cmd+,', - click: () => store.dispatch(setActiveSheet(ACTIVE_SHEET_SETTINGS)), - }, - { - label: 'Import Flipper File...', - accelerator: 'CommandOrControl+O', - click: function() { - showOpenDialog(store); - }, - }, - { - label: 'Export', - submenu: exportSubmenu, - }, - ], + submenu: fileSubmenu, }, { label: 'Edit', diff --git a/src/fb-stubs/SupportRequestFormV2.tsx b/src/fb-stubs/SupportRequestFormV2.tsx new file mode 100644 index 000000000..ffd2609eb --- /dev/null +++ b/src/fb-stubs/SupportRequestFormV2.tsx @@ -0,0 +1,17 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import React, {Component} from 'react'; +import {Text} from '../ui'; + +export default class extends Component { + render() { + return Build your support request creation form.; + } +} diff --git a/src/reducers/connections.tsx b/src/reducers/connections.tsx index 9f1f8db8f..46c0795ad 100644 --- a/src/reducers/connections.tsx +++ b/src/reducers/connections.tsx @@ -20,11 +20,13 @@ const WelcomeScreen = isHeadless() ? require('../chrome/WelcomeScreenHeadless').default : require('../chrome/WelcomeScreen').default; import SupportRequestForm from '../fb-stubs/SupportRequestFormManager'; +import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2'; export type StaticView = | null | typeof WelcomeScreen - | typeof SupportRequestForm; + | typeof SupportRequestForm + | typeof SupportRequestFormV2; export type FlipperError = { occurrences?: number; diff --git a/src/ui/components/MultiLineInput.tsx b/src/ui/components/MultiLineInput.tsx new file mode 100644 index 000000000..b6a09ce17 --- /dev/null +++ b/src/ui/components/MultiLineInput.tsx @@ -0,0 +1,34 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import styled from 'react-emotion'; +import {colors} from './colors'; + +export const multilineStyle = { + border: `1px solid ${colors.light15}`, + borderRadius: 4, + font: 'inherit', + fontSize: '1em', + height: '28px', + lineHeight: '28px', + marginRight: 5, + + '&:disabled': { + backgroundColor: '#ddd', + borderColor: '#ccc', + cursor: 'not-allowed', + }, +}; + +const MultiLineInput = styled('textarea')({ + ...multilineStyle, + padding: '0 10px', +}); + +export default MultiLineInput; diff --git a/src/ui/index.tsx b/src/ui/index.tsx index 3385c7892..c5daf4551 100644 --- a/src/ui/index.tsx +++ b/src/ui/index.tsx @@ -70,6 +70,7 @@ export {default as TabsContainer} from './components/TabsContainer'; // inputs export {default as Input} from './components/Input'; +export {default as MultiLineInput} from './components/MultiLineInput'; export {default as Textarea} from './components/Textarea'; export {default as Select} from './components/Select'; export {default as Checkbox} from './components/Checkbox';