diff --git a/packages/core/src/api/api.ts b/packages/core/src/api/api.ts index abaa28cbbf..cafd0af126 100644 --- a/packages/core/src/api/api.ts +++ b/packages/core/src/api/api.ts @@ -16,7 +16,6 @@ import ApiRef, { ApiRefConfig } from './apis/ApiRef'; import AppBuilder from './app/AppBuilder'; -import WidgetViewBuilder from './widgetView/WidgetViewBuilder'; import BackstagePlugin, { PluginConfig } from './plugin/Plugin'; export function createApp() { @@ -27,10 +26,6 @@ export function createApiRef(config: ApiRefConfig) { return new ApiRef(config); } -export function createWidgetView() { - return new WidgetViewBuilder(); -} - export function createPlugin(config: PluginConfig): BackstagePlugin { return new BackstagePlugin(config); } diff --git a/packages/core/src/api/plugin/Plugin.tsx b/packages/core/src/api/plugin/Plugin.tsx index 47f8331e10..a8b694ae8d 100644 --- a/packages/core/src/api/plugin/Plugin.tsx +++ b/packages/core/src/api/plugin/Plugin.tsx @@ -22,7 +22,6 @@ import { FeatureFlagName, } from './types'; import { validateBrowserCompat, validateFlagName } from 'api/app/FeatureFlags'; -import { Widget } from 'api/widgetView/types'; export type PluginConfig = { id: string; @@ -31,7 +30,6 @@ export type PluginConfig = { export type PluginHooks = { router: RouterHooks; - widgets: WidgetHooks; featureFlags: FeatureFlagsHooks; }; @@ -49,10 +47,6 @@ export type RouterHooks = { ): void; }; -export type WidgetHooks = { - add(widget: Widget): void; -}; - export type FeatureFlagsHooks = { register(name: FeatureFlagName): void; }; @@ -88,11 +82,6 @@ export default class Plugin { outputs.push({ type: 'redirect-route', path, target, options }); }, }, - widgets: { - add(widget: Widget) { - outputs.push({ type: 'widget', widget }); - }, - }, featureFlags: { register(name) { validateBrowserCompat(); diff --git a/packages/core/src/api/plugin/types.ts b/packages/core/src/api/plugin/types.ts index 3192dfd095..c4ac426e5c 100644 --- a/packages/core/src/api/plugin/types.ts +++ b/packages/core/src/api/plugin/types.ts @@ -15,7 +15,6 @@ */ import { ComponentType } from 'react'; -import { Widget } from 'api/widgetView/types'; export type RouteOptions = { // Whether the route path must match exactly, defaults to true. @@ -38,11 +37,6 @@ export type RedirectRouteOutput = { options?: RouteOptions; }; -export type WidgetOutput = { - type: 'widget'; - widget: Widget; -}; - export type FeatureFlagName = string; export type FeatureFlagOutput = { @@ -53,5 +47,4 @@ export type FeatureFlagOutput = { export type PluginOutput = | RouteOutput | RedirectRouteOutput - | WidgetOutput | FeatureFlagOutput; diff --git a/packages/core/src/api/widgetView/WidgetViewBuilder.tsx b/packages/core/src/api/widgetView/WidgetViewBuilder.tsx deleted file mode 100644 index 0bf873df86..0000000000 --- a/packages/core/src/api/widgetView/WidgetViewBuilder.tsx +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React, { ComponentType } from 'react'; -import { AppComponentBuilder } from 'api/app/types'; -import { Widget } from './types'; -import BackstagePlugin from 'api/plugin/Plugin'; -import DefaultWidgetView from 'components/DefaultWidgetView'; - -type WidgetViewRegistration = - | { - type: 'component'; - widget: Widget; - } - | { - type: 'plugin'; - plugin: BackstagePlugin; - }; - -export default class WidgetViewBuilder extends AppComponentBuilder { - private readonly registrations = new Array(); - private output?: ComponentType; - - add(widget: Widget): WidgetViewBuilder { - this.registrations.push({ type: 'component', widget }); - return this; - } - - register(plugin: BackstagePlugin): WidgetViewBuilder { - this.registrations.push({ type: 'plugin', plugin }); - return this; - } - - build(): ComponentType { - if (this.output) { - return this.output; - } - - const widgets = new Array(); - - for (const reg of this.registrations) { - switch (reg.type) { - case 'component': - widgets.push(reg.widget); - break; - case 'plugin': - { - let added = false; - for (const output of reg.plugin.output()) { - if (output.type === 'widget') { - widgets.push(output.widget); - added = true; - } - } - if (!added) { - throw new Error( - `Plugin ${reg.plugin} was registered as widget provider, but did not provide any widgets`, - ); - } - } - break; - default: - throw new Error(`Unknown WidgetViewBuilder registration`); - } - } - - this.output = () => ; - return this.output; - } -} diff --git a/packages/core/src/api/widgetView/types.ts b/packages/core/src/api/widgetView/types.ts deleted file mode 100644 index 9e066225ab..0000000000 --- a/packages/core/src/api/widgetView/types.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ComponentType } from 'react'; - -export type Widget = { - size: 4 | 6 | 8 | 12; - component: ComponentType; -}; - -export type WidgetViewProps = { - widgets: Widget[]; -}; diff --git a/packages/core/src/components/DefaultWidgetView/DefaultWidgetView.tsx b/packages/core/src/components/DefaultWidgetView/DefaultWidgetView.tsx deleted file mode 100644 index 990ecb0e92..0000000000 --- a/packages/core/src/components/DefaultWidgetView/DefaultWidgetView.tsx +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React, { FC } from 'react'; -import { Grid, Paper, makeStyles, Theme } from '@material-ui/core'; -import { WidgetViewProps } from 'api/widgetView/types'; - -const useStyles = makeStyles(theme => ({ - root: { - padding: theme.spacing(2), - }, - widgetWrapper: { - padding: theme.spacing(2), - }, -})); - -const WidgetViewComponent: FC = ({ widgets }) => { - const classes = useStyles(); - - return ( -
- - {widgets.map(({ size, component: WidgetComponent }, index) => ( - - - - - - ))} - -
- ); -}; - -export default WidgetViewComponent; diff --git a/packages/core/src/components/DefaultWidgetView/index.ts b/packages/core/src/components/DefaultWidgetView/index.ts deleted file mode 100644 index b4aaece4cb..0000000000 --- a/packages/core/src/components/DefaultWidgetView/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { default } from './DefaultWidgetView'; diff --git a/packages/core/src/layout/InfoCard/InfoCard.tsx b/packages/core/src/layout/InfoCard/InfoCard.tsx index d645b25aaa..fe2bbfa1ce 100644 --- a/packages/core/src/layout/InfoCard/InfoCard.tsx +++ b/packages/core/src/layout/InfoCard/InfoCard.tsx @@ -52,9 +52,6 @@ const VARIANT_STYLES = { display: 'flex', flexDirection: 'column', }, - widget: { - height: 430, - }, fullHeight: { height: '100%', }, @@ -79,11 +76,6 @@ const VARIANT_STYLES = { }, }, cardContent: { - widget: { - overflowY: 'auto', - height: 332, - width: '100%', - }, fullHeight: { height: 'calc(100% - 50px)', },