apply core-imports codemod to all packages and plugins

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-06-17 17:56:24 +02:00
parent 9b9a8f3925
commit d453c05dc3
541 changed files with 1549 additions and 1321 deletions
+5 -1
View File
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ConfigApi, createApiRef, DiscoveryApi } from '@backstage/core';
import { AuthenticationError, ResponseError } from '@backstage/errors';
import {
AlertSource,
@@ -34,6 +33,11 @@ import {
EventRequest,
} from './types';
import { DateTime as dt } from 'luxon';
import {
ConfigApi,
createApiRef,
DiscoveryApi,
} from '@backstage/core-plugin-api';
export const ilertApiRef = createApiRef<ILertApi>({
id: 'plugin.ilert.service',
+1 -1
View File
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DiscoveryApi } from '@backstage/core';
import {
AlertSource,
Incident,
@@ -26,6 +25,7 @@ import {
IncidentAction,
OnCall,
} from '../types';
import { DiscoveryApi } from '@backstage/core-plugin-api';
export type TableState = {
page: number;
@@ -14,13 +14,15 @@
* limitations under the License.
*/
import React from 'react';
import { useApi, Link } from '@backstage/core';
import Grid from '@material-ui/core/Grid';
import { AlertSource } from '../../types';
import { ilertApiRef } from '../../api';
import { makeStyles } from '@material-ui/core/styles';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { useApi } from '@backstage/core-plugin-api';
import { Link } from '@backstage/core-components';
const useStyles = makeStyles({
root: {
display: 'flex',
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import React from 'react';
import { EmptyState } from '@backstage/core';
import { Button } from '@material-ui/core';
import { EmptyState } from '@backstage/core-components';
export const MissingAuthorizationHeaderError = () => (
<EmptyState
@@ -14,11 +14,13 @@
* limitations under the License.
*/
import React from 'react';
import { useApi, Link } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import { EscalationPolicy } from '../../types';
import { ilertApiRef } from '../../api';
import { useApi } from '@backstage/core-plugin-api';
import { Link } from '@backstage/core-components';
const useStyles = makeStyles({
link: {
lineHeight: '22px',
@@ -16,7 +16,6 @@
import React from 'react';
import { Entity } from '@backstage/catalog-model';
import { AuthenticationError } from '@backstage/errors';
import { ResponseErrorPanel } from '@backstage/core';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import CardHeader from '@material-ui/core/CardHeader';
@@ -34,6 +33,7 @@ import { ILertCardHeaderStatus } from './ILertCardHeaderStatus';
import { ILertCardMaintenanceModal } from './ILertCardMaintenanceModal';
import { ILertCardEmptyState } from './ILertCardEmptyState';
import { ILertCardOnCall } from './ILertCardOnCall';
import { ResponseErrorPanel } from '@backstage/core-components';
export const isPluginApplicableToEntity = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[ILERT_INTEGRATION_KEY_ANNOTATION]);
@@ -14,12 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import {
HeaderIconLinkRow,
IconLinkVerticalProps,
useApi,
alertApiRef,
} from '@backstage/core';
import Alert from '@material-ui/lab/Alert';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
@@ -36,6 +30,12 @@ import Typography from '@material-ui/core/Typography';
import { ilertApiRef } from '../../api';
import { AlertSource, UptimeMonitor } from '../../types';
import {
HeaderIconLinkRow,
IconLinkVerticalProps,
} from '@backstage/core-components';
import { useApi, alertApiRef } from '@backstage/core-plugin-api';
export const ILertCardActionsHeader = ({
alertSource,
setAlertSource,
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { CodeSnippet } from '@backstage/core';
import { BackstageTheme } from '@backstage/theme';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
@@ -24,6 +23,7 @@ import Divider from '@material-ui/core/Divider';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import React from 'react';
import { CodeSnippet } from '@backstage/core-components';
const ENTITY_YAML = `apiVersion: backstage.io/v1alpha1
kind: Component
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import { alertApiRef, useApi } from '@backstage/core';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
@@ -25,6 +24,7 @@ import MenuItem from '@material-ui/core/MenuItem';
import TextField from '@material-ui/core/TextField';
import { ilertApiRef } from '../../api';
import { AlertSource } from '../../types';
import { alertApiRef, useApi } from '@backstage/core-plugin-api';
export const ILertCardMaintenanceModal = ({
alertSource,
@@ -24,9 +24,9 @@ import ReplayIcon from '@material-ui/icons/Replay';
import { makeStyles } from '@material-ui/core/styles';
import { AlertSource } from '../../types';
import { useAlertSourceOnCalls } from '../../hooks/useAlertSourceOnCalls';
import { Progress } from '@backstage/core';
import { ILertCardOnCallEmptyState } from './ILertCardOnCallEmptyState';
import { ILertCardOnCallItem } from './ILertCardOnCallItem';
import { Progress } from '@backstage/core-components';
const useStyles = makeStyles(theme => ({
repeatText: {
@@ -27,9 +27,9 @@ import EmailIcon from '@material-ui/icons/Email';
import PhoneIcon from '@material-ui/icons/Phone';
import { makeStyles } from '@material-ui/core/styles';
import { OnCall } from '../../types';
import { useApi } from '@backstage/core';
import { ilertApiRef } from '../../api';
import { DateTime as dt } from 'luxon';
import { useApi } from '@backstage/core-plugin-api';
const useStyles = makeStyles({
listItemPrimary: {
@@ -14,16 +14,16 @@
* limitations under the License.
*/
import React from 'react';
import { IncidentsPage } from '../IncidentsPage';
import { UptimeMonitorsPage } from '../UptimeMonitorsPage';
import { OnCallSchedulesPage } from '../OnCallSchedulesPage';
import {
Page,
Header,
HeaderTabs,
HeaderLabel,
Content,
} from '@backstage/core';
import { IncidentsPage } from '../IncidentsPage';
import { UptimeMonitorsPage } from '../UptimeMonitorsPage';
import { OnCallSchedulesPage } from '../OnCallSchedulesPage';
} from '@backstage/core-components';
export const ILertPage = () => {
const [selectedTab, setSelectedTab] = React.useState<number>(0);
@@ -14,13 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import {
alertApiRef,
Progress,
useApi,
identityApiRef,
Link,
} from '@backstage/core';
import { IconButton, Menu, MenuItem, Typography } from '@material-ui/core';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import { ilertApiRef } from '../../api';
@@ -28,6 +21,13 @@ import { Incident, IncidentAction } from '../../types';
import { IncidentAssignModal } from './IncidentAssignModal';
import { useIncidentActions } from '../../hooks/useIncidentActions';
import {
alertApiRef,
useApi,
identityApiRef,
} from '@backstage/core-plugin-api';
import { Progress, Link } from '@backstage/core-components';
export const IncidentActionsMenu = ({
incident,
onIncidentChanged,
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import { alertApiRef, useApi } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import Alert from '@material-ui/lab/Alert';
import Button from '@material-ui/core/Button';
@@ -28,6 +27,7 @@ import { useAssignIncident } from '../../hooks/useAssignIncident';
import { Typography } from '@material-ui/core';
import { ilertApiRef } from '../../api';
import { Incident } from '../../types';
import { alertApiRef, useApi } from '@backstage/core-plugin-api';
const useStyles = makeStyles(() => ({
container: {
@@ -14,11 +14,13 @@
* limitations under the License.
*/
import React from 'react';
import { useApi, Link } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import { Incident } from '../../types';
import { ilertApiRef } from '../../api';
import { useApi } from '@backstage/core-plugin-api';
import { Link } from '@backstage/core-components';
const useStyles = makeStyles({
link: {
lineHeight: '22px',
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import { alertApiRef, identityApiRef, useApi } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import Alert from '@material-ui/lab/Alert';
import Button from '@material-ui/core/Button';
@@ -29,6 +28,11 @@ import { Typography } from '@material-ui/core';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { ilertApiRef } from '../../api';
import { AlertSource } from '../../types';
import {
alertApiRef,
identityApiRef,
useApi,
} from '@backstage/core-plugin-api';
const useStyles = makeStyles(() => ({
container: {
@@ -14,10 +14,10 @@
* limitations under the License.
*/
import React from 'react';
import { StatusError, StatusOK } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import Tooltip from '@material-ui/core/Tooltip';
import { ACCEPTED, Incident, PENDING, RESOLVED } from '../../types';
import { StatusError, StatusOK } from '@backstage/core-components';
const useStyles = makeStyles({
denseListIcon: {
@@ -14,12 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import {
Content,
ContentHeader,
SupportButton,
ResponseErrorPanel,
} from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import Button from '@material-ui/core/Button';
import AddIcon from '@material-ui/icons/Add';
@@ -27,6 +21,12 @@ import { IncidentsTable } from './IncidentsTable';
import { MissingAuthorizationHeaderError } from '../Errors';
import { useIncidents } from '../../hooks/useIncidents';
import { IncidentNewModal } from '../Incident/IncidentNewModal';
import {
Content,
ContentHeader,
SupportButton,
ResponseErrorPanel,
} from '@backstage/core-components';
export const IncidentsPage = () => {
const [
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import { Table, TableColumn, useApi } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import { ilertApiRef, TableState } from '../../api';
import { Incident, IncidentStatus } from '../../types';
@@ -27,6 +26,9 @@ import humanizeDuration from 'humanize-duration';
import { IncidentActionsMenu } from '../Incident/IncidentActionsMenu';
import { IncidentLink } from '../Incident/IncidentLink';
import { Table, TableColumn } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
const useStyles = makeStyles(theme => ({
empty: {
padding: theme.spacing(2),
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import { useApi, ItemCardGrid, Progress, Link } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
@@ -24,6 +23,9 @@ import { Schedule } from '../../types';
import { ilertApiRef } from '../../api';
import { OnCallShiftItem } from './OnCallShiftItem';
import { useApi } from '@backstage/core-plugin-api';
import { ItemCardGrid, Progress, Link } from '@backstage/core-components';
const useStyles = makeStyles(() => ({
card: {
margin: 16,
@@ -14,16 +14,16 @@
* limitations under the License.
*/
import React from 'react';
import { AuthenticationError } from '@backstage/errors';
import { OnCallSchedulesGrid } from './OnCallSchedulesGrid';
import { MissingAuthorizationHeaderError } from '../Errors';
import { useOnCallSchedules } from '../../hooks/useOnCallSchedules';
import {
Content,
ContentHeader,
SupportButton,
ResponseErrorPanel,
} from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { OnCallSchedulesGrid } from './OnCallSchedulesGrid';
import { MissingAuthorizationHeaderError } from '../Errors';
import { useOnCallSchedules } from '../../hooks/useOnCallSchedules';
} from '@backstage/core-components';
export const OnCallSchedulesPage = () => {
const [
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import React from 'react';
import { alertApiRef, useApi } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
@@ -29,6 +28,7 @@ import { useShiftOverride } from '../../hooks/useShiftOverride';
import { Shift } from '../../types';
import { DateTimePicker, MuiPickersUtilsProvider } from '@material-ui/pickers';
import LuxonUtils from '@date-io/luxon';
import { alertApiRef, useApi } from '@backstage/core-plugin-api';
const useStyles = makeStyles(() => ({
container: {
@@ -14,13 +14,15 @@
* limitations under the License.
*/
import React from 'react';
import { alertApiRef, useApi, Link } from '@backstage/core';
import { IconButton, Menu, MenuItem, Typography } from '@material-ui/core';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import { ilertApiRef } from '../../api';
import { UptimeMonitor } from '../../types';
import { alertApiRef, useApi } from '@backstage/core-plugin-api';
import { Link } from '@backstage/core-components';
export const UptimeMonitorActionsMenu = ({
uptimeMonitor,
onUptimeMonitorChanged,
@@ -14,11 +14,13 @@
* limitations under the License.
*/
import React from 'react';
import { useApi, Link } from '@backstage/core';
import { makeStyles } from '@material-ui/core/styles';
import { UptimeMonitor } from '../../types';
import { ilertApiRef } from '../../api';
import { useApi } from '@backstage/core-plugin-api';
import { Link } from '@backstage/core-components';
const useStyles = makeStyles({
link: {
lineHeight: '22px',
@@ -14,16 +14,16 @@
* limitations under the License.
*/
import React from 'react';
import { AuthenticationError } from '@backstage/errors';
import { UptimeMonitorsTable } from './UptimeMonitorsTable';
import { MissingAuthorizationHeaderError } from '../Errors';
import { useUptimeMonitors } from '../../hooks/useUptimeMonitors';
import {
Content,
ContentHeader,
SupportButton,
ResponseErrorPanel,
} from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { UptimeMonitorsTable } from './UptimeMonitorsTable';
import { MissingAuthorizationHeaderError } from '../Errors';
import { useUptimeMonitors } from '../../hooks/useUptimeMonitors';
} from '@backstage/core-components';
export const UptimeMonitorsPage = () => {
const [
@@ -15,7 +15,6 @@
*/
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Table, TableColumn } from '@backstage/core';
import { TableState } from '../../api';
import { UptimeMonitor } from '../../types';
import { StatusChip } from './StatusChip';
@@ -26,6 +25,7 @@ import { EscalationPolicyLink } from '../EscalationPolicy/EscalationPolicyLink';
import { UptimeMonitorCheckType } from './UptimeMonitorCheckType';
import { UptimeMonitorActionsMenu } from '../UptimeMonitor/UptimeMonitorActionsMenu';
import { UptimeMonitorLink } from '../UptimeMonitor/UptimeMonitorLink';
import { Table, TableColumn } from '@backstage/core-components';
const useStyles = makeStyles(theme => ({
empty: {
+1 -1
View File
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { AlertSource, UptimeMonitor } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useAlertSource = (integrationKey: string) => {
const ilertApi = useApi(ilertApiRef);
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { AlertSource, OnCall } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useAlertSourceOnCalls = (alertSource?: AlertSource | null) => {
const ilertApi = useApi(ilertApiRef);
+1 -1
View File
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { Incident, IncidentResponder } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useAssignIncident = (incident: Incident | null, open: boolean) => {
const ilertApi = useApi(ilertApiRef);
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { Incident, IncidentAction } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useIncidentActions = (
incident: Incident | null,
+1 -1
View File
@@ -15,7 +15,6 @@
*/
import React from 'react';
import { GetIncidentsOpts, ilertApiRef, TableState } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import {
@@ -25,6 +24,7 @@ import {
IncidentStatus,
AlertSource,
} from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useIncidents = (
paging: boolean,
+1 -1
View File
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { AlertSource } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useNewIncident = (
open: boolean,
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { Schedule } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useOnCallSchedules = () => {
const ilertApi = useApi(ilertApiRef);
+1 -1
View File
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { User, Shift } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useShiftOverride = (s: Shift, isModalOpened: boolean) => {
const ilertApi = useApi(ilertApiRef);
+1 -1
View File
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { ilertApiRef, TableState } from '../api';
import { useApi, errorApiRef } from '@backstage/core';
import { AuthenticationError } from '@backstage/errors';
import { useAsyncRetry } from 'react-use';
import { UptimeMonitor } from '../types';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const useUptimeMonitors = () => {
const ilertApi = useApi(ilertApiRef);
+1 -1
View File
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { IconComponent } from '@backstage/core';
import ILertIconComponent from './assets/ilert.icon.svg';
import { IconComponent } from '@backstage/core-plugin-api';
export {
ilertPlugin,
+3 -3
View File
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ILertClient, ilertApiRef } from './api';
import { iLertRouteRef } from './route-refs';
import {
configApiRef,
createApiFactory,
@@ -21,9 +23,7 @@ import {
identityApiRef,
createRoutableExtension,
createComponentExtension,
} from '@backstage/core';
import { ILertClient, ilertApiRef } from './api';
import { iLertRouteRef } from './route-refs';
} from '@backstage/core-plugin-api';
export const ilertPlugin = createPlugin({
id: 'ilert',
+1 -1
View File
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { createRouteRef } from '@backstage/core';
import ILertIcon from './assets/ilert.icon.svg';
import { createRouteRef } from '@backstage/core-plugin-api';
export const iLertRouteRef = createRouteRef({
icon: ILertIcon,