From f5f99d9a9372851fc941a2f6079586d1adb434bb Mon Sep 17 00:00:00 2001 From: Pierre Beitz Date: Mon, 24 Aug 2020 14:30:27 +0200 Subject: [PATCH] refactor: small cleanup around fullscreenmodal removing components that just add classes, so that we can replace them with their ui-kit pendants some time soon. pulling out some static content (it's easier to reason about components if there can't be a `this` involved). get rid of `.modal-full-screen-header-with-sub-title`, which was aligning the height of the header when installing Frameworks. chose to remove all the complexity around it and live with a headline that's off by 2 pixels to replace it with a ui-kit component in the future. replace PropTypes with TS-typings. --- .../jobs/src/js/components/JobsFormModal.tsx | 4 +- .../js/components/form/GeneralFormSection.tsx | 88 +++++++++---------- .../components/modals/CreateServiceModal.tsx | 9 +- .../modals/ServiceRootGroupModal/Header.tsx | 5 +- .../__snapshots__/typecheck-test.ts.snap | 22 ----- src/js/components/FrameworkConfiguration.tsx | 10 +-- src/js/components/form/FieldTextarea.tsx | 31 +------ .../modals/FullScreenModalHeader.tsx | 24 +---- .../modals/FullScreenModalHeaderActions.tsx | 38 +++----- .../modals/FullScreenModalHeaderSubTitle.tsx | 23 ----- .../modals/FullScreenModalHeaderTitle.tsx | 23 ----- .../components/modal/full-screen/styles.less | 14 +-- 12 files changed, 78 insertions(+), 213 deletions(-) delete mode 100644 src/js/components/modals/FullScreenModalHeaderSubTitle.tsx delete mode 100644 src/js/components/modals/FullScreenModalHeaderTitle.tsx diff --git a/plugins/jobs/src/js/components/JobsFormModal.tsx b/plugins/jobs/src/js/components/JobsFormModal.tsx index 0be83e518b..764fc5b9d4 100644 --- a/plugins/jobs/src/js/components/JobsFormModal.tsx +++ b/plugins/jobs/src/js/components/JobsFormModal.tsx @@ -12,7 +12,6 @@ import isEqual from "lodash/isEqual"; import FullScreenModal from "#SRC/js/components/modals/FullScreenModal"; import FullScreenModalHeader from "#SRC/js/components/modals/FullScreenModalHeader"; import FullScreenModalHeaderActions from "#SRC/js/components/modals/FullScreenModalHeaderActions"; -import FullScreenModalHeaderTitle from "#SRC/js/components/modals/FullScreenModalHeaderTitle"; import DataValidatorUtil from "#SRC/js/utils/DataValidatorUtil"; import ModalHeading from "#SRC/js/components/modals/ModalHeading"; import ToggleButton from "#SRC/js/components/ToggleButton"; @@ -403,7 +402,8 @@ class JobFormModal extends React.Component< actions={this.getSecondaryActions()} type="secondary" /> - {title} + +
{title}
{ - const match = e.path.join("."); - return match === path; - }) +const getFieldError = (path: string, errors: FormError[]) => + errors + .filter((e) => e.path.join(".") === path) .map((e) => e.message) .join(" "); -} -class GeneralFormSection extends React.Component { - constructor(props: Readonly) { - super(props); - } +const idTooltipContent = ( + + Unique identifier for the job consisting of a series of names separated by + dots. Each name must be at least 1 character and may only contain digits + (`0-9`), dashes (`-`), and lowercase letters (`a-z`). The name may not begin + or end with a dash. + +); +const descTooltipContent = A description of this job.; +const cpuTooltipContent = ( + + The number of CPU shares this job needs per instance. This number does not + have to be integer, but can be a fraction. + +); +const gpuTooltipContent = ( + + The number of GPU shares this job needs per instance. Only available with + the UCR runtime. + +); +export default class GeneralFormSection extends React.Component { public getResourceRow() { const { formData, showErrors, errors } = this.props; - const cpuTooltipContent = ( - - The number of CPU shares this job needs per instance. This number does - not have to be integer, but can be a fraction. - - ); - const gpuTooltipContent = ( - - The number of GPU shares this job needs per instance. Only available - with the UCR runtime. - - ); const gpusDisabled = !formData.cmdOnly && formData.container !== "ucr"; const cpusError = getFieldError("run.cpus", errors); @@ -60,7 +62,7 @@ class GeneralFormSection extends React.Component { return ( - + @@ -82,12 +84,12 @@ class GeneralFormSection extends React.Component { type="number" name="job.run.cpus" value={formData.cpus} - autoFocus={showErrors && cpusError} + autoFocus={showErrors && !!cpusError} /> {cpusError} - + @@ -99,12 +101,12 @@ class GeneralFormSection extends React.Component { name="job.run.mem" type="number" value={formData.mem} - autoFocus={showErrors && memError} + autoFocus={showErrors && !!memError} /> {memError} - + @@ -116,12 +118,12 @@ class GeneralFormSection extends React.Component { name="job.run.disk" type="number" value={formData.disk} - autoFocus={showErrors && diskError} + autoFocus={showErrors && !!diskError} /> {diskError} - + @@ -144,7 +146,7 @@ class GeneralFormSection extends React.Component { type="number" disabled={gpusDisabled} value={formData.gpus} - autoFocus={showErrors && gpusError} + autoFocus={showErrors && !!gpusError} /> {gpusError} @@ -185,7 +187,7 @@ class GeneralFormSection extends React.Component { checked={!formData.cmdOnly} name="cmdOnly" type="radio" - value={false} + value={"false"} /> Container Image @@ -194,7 +196,7 @@ class GeneralFormSection extends React.Component { checked={formData.cmdOnly} name="cmdOnly" type="radio" - value={true} + value={"true"} /> Command Only @@ -203,7 +205,7 @@ class GeneralFormSection extends React.Component { @@ -242,7 +244,10 @@ class GeneralFormSection extends React.Component { )} - + @@ -282,15 +287,6 @@ class GeneralFormSection extends React.Component { public render() { const { formData, errors, showErrors, isEdit } = this.props; - const idTooltipContent = ( - - Unique identifier for the job consisting of a series of names separated - by dots. Each name must be at least 1 character and may only contain - digits (`0-9`), dashes (`-`), and lowercase letters (`a-z`). The name - may not begin or end with a dash. - - ); - const descTooltipContent = A description of this job.; const idError = getFieldError("id", errors); return ( @@ -299,7 +295,7 @@ class GeneralFormSection extends React.Component { General - + @@ -362,5 +358,3 @@ class GeneralFormSection extends React.Component { ); } } - -export default GeneralFormSection; diff --git a/plugins/services/src/js/components/modals/CreateServiceModal.tsx b/plugins/services/src/js/components/modals/CreateServiceModal.tsx index a7ca920c62..e58ac5fd7d 100644 --- a/plugins/services/src/js/components/modals/CreateServiceModal.tsx +++ b/plugins/services/src/js/components/modals/CreateServiceModal.tsx @@ -17,7 +17,6 @@ import DataValidatorUtil from "#SRC/js/utils/DataValidatorUtil"; import FullScreenModal from "#SRC/js/components/modals/FullScreenModal"; import FullScreenModalHeader from "#SRC/js/components/modals/FullScreenModalHeader"; import FullScreenModalHeaderActions from "#SRC/js/components/modals/FullScreenModalHeaderActions"; -import FullScreenModalHeaderTitle from "#SRC/js/components/modals/FullScreenModalHeaderTitle"; import ModalHeading from "#SRC/js/components/modals/ModalHeading"; import PodValidators from "#SRC/resources/raml/marathon/v2/types/pod.raml"; import ToggleButton from "#SRC/js/components/ToggleButton"; @@ -554,9 +553,9 @@ class CreateServiceModal extends React.Component { actions={this.getSecondaryActions()} type="secondary" /> - +
Review & Run Service - +
- {title} +
{title}
{ ]} type="secondary" /> - +
{mode === "create" ? ( New Group ) : ( Edit Group )} - +
'. plugins/organization/submodules/service-accounts/components/ServiceAccountDetailPage.tsx: error TS2339: Property 'isRemote' does not exist on type 'ServiceAccount'. plugins/organization/submodules/service-accounts/components/ServiceAccountDetailPage.tsx: error TS2339: Property 'isRemote' does not exist on type 'ServiceAccount'. -plugins/organization/submodules/service-accounts/components/ServiceAccountForm.tsx: error TS2322: type * is not assignable to type *. plugins/organization/submodules/service-accounts/components/ServiceAccountsActionsModal.tsx: error TS2339: Property 'store_listeners' does not exist on type 'ServiceAccountsActionsModal'. plugins/organization/submodules/service-accounts/components/ServiceAccountsActionsModal.tsx: error TS2339: Property 'store_listeners' does not exist on type 'ServiceAccountsActionsModal'. plugins/organization/submodules/service-accounts/components/ServiceAccountsActionsModal.tsx: error TS2556: Expected 0 arguments, but got 1 or more. @@ -1854,13 +1840,11 @@ plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'localErr plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'localErrors' does not exist on type 'Readonly<{}>'. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'textValue' does not exist on type 'Readonly<{}>'. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'localErrors' does not exist on type 'Readonly<{}>'. -plugins/secrets/components/SecretFormModal.tsx: error TS2322: type * is not assignable to type *. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'fileValue' does not exist on type 'Readonly<{}>'. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'localErrors' does not exist on type 'Readonly<{}>'. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'localErrors' does not exist on type 'Readonly<{}>'. plugins/secrets/components/SecretFormModal.tsx: error TS2322: type * is not assignable to type *. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'localErrors' does not exist on type 'Readonly<{}>'. -plugins/secrets/components/SecretFormModal.tsx: error TS2322: type * is not assignable to type *. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'path' does not exist on type 'Readonly<{}>'. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'textValue' does not exist on type 'Readonly<{}>'. plugins/secrets/components/SecretFormModal.tsx: error TS2339: Property 'fileValue' does not exist on type 'Readonly<{}>'. @@ -2424,7 +2408,6 @@ plugins/services/src/js/components/forms/ContainerServiceFormSection.tsx: error plugins/services/src/js/components/forms/ContainerServiceFormSection.tsx: error TS2339: Property 'data' does not exist on type *. plugins/services/src/js/components/forms/ContainerServiceFormSection.tsx: error TS2339: Property 'errors' does not exist on type *. plugins/services/src/js/components/forms/ContainerServiceFormSection.tsx: error TS2339: Property 'path' does not exist on type *. -plugins/services/src/js/components/forms/ContainerServiceFormSection.tsx: error TS2322: type * is not assignable to type *. plugins/services/src/js/components/forms/ContainerServiceFormSection.tsx: error TS2339: Property 'configReducers' does not exist on type *. plugins/services/src/js/components/forms/ContainerServiceFormSection.tsx: error TS2339: Property 'service' does not exist on type *. plugins/services/src/js/components/forms/EnvironmentFormSection.tsx: error TS2339: Property 'onRemoveItem' does not exist on type *. @@ -5547,11 +5530,6 @@ src/js/components/modals/ActionsModal.tsx: error TS2339: Property 'itemType' doe src/js/components/modals/ActionsModal.tsx: error TS2339: Property 'requestErrors' does not exist on type 'Readonly<{}>'. src/js/components/modals/ActionsModal.tsx: error TS2339: Property 'validationError' does not exist on type 'Readonly<{}>'. src/js/components/modals/FullScreenModal.tsx: error TS2322: Type '\\"100%\\"' is not assignable to type 'null'. -src/js/components/modals/FullScreenModalHeaderActions.tsx: error TS2448: Block-scoped variable 'classProps' used before its declaration. -src/js/components/modals/FullScreenModalHeaderActions.tsx: error TS2448: Block-scoped variable 'classProps' used before its declaration. -src/js/components/modals/FullScreenModalHeaderActions.tsx: error TS2339: Property 'actions' does not exist on type *. -src/js/components/modals/FullScreenModalHeaderActions.tsx: error TS2339: Property 'className' does not exist on type *. -src/js/components/modals/FullScreenModalHeaderActions.tsx: error TS2339: Property 'type' does not exist on type *. src/js/components/modals/ImageViewerModal.tsx: error TS2339: Property 'isLoadingImage' does not exist on type 'Readonly<{}>'. src/js/components/modals/ImageViewerModal.tsx: error TS2339: Property 'onClose' does not exist on type *. src/js/components/modals/ImageViewerModal.tsx: error TS2339: Property 'open' does not exist on type *. diff --git a/src/js/components/FrameworkConfiguration.tsx b/src/js/components/FrameworkConfiguration.tsx index f500bc1396..3e53556c65 100644 --- a/src/js/components/FrameworkConfiguration.tsx +++ b/src/js/components/FrameworkConfiguration.tsx @@ -8,8 +8,6 @@ import { InfoBoxInline } from "@dcos/ui-kit"; import FullScreenModal from "#SRC/js/components/modals/FullScreenModal"; import FullScreenModalHeader from "#SRC/js/components/modals/FullScreenModalHeader"; import FullScreenModalHeaderActions from "#SRC/js/components/modals/FullScreenModalHeaderActions"; -import FullScreenModalHeaderTitle from "#SRC/js/components/modals/FullScreenModalHeaderTitle"; -import FullScreenModalHeaderSubTitle from "#SRC/js/components/modals/FullScreenModalHeaderSubTitle"; import ToggleButton from "#SRC/js/components/ToggleButton"; import ModalHeading from "#SRC/js/components/modals/ModalHeading"; import UniversePackage from "#SRC/js/structs/UniversePackage"; @@ -305,15 +303,15 @@ class FrameworkConfiguration extends React.Component { actions={this.getSecondaryActions()} type="secondary" /> - +
- +
{lastUpdated ? LastUpdated.warningIcon(lastUpdated) : null}{" "} {StringUtil.capitalize(packageDetails.getName()) + " " + packageDetails.getVersion()} - - +
+
; -const FieldTextarea = (props) => { - const { className } = props; - const classes = classNames("form-control", className); - - return