backstage

Форк
0
/
extensions.tsx 
92 строки · 2.7 Кб
1
/*
2
 * Copyright 2020 The Backstage Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
import { useEntity } from '@backstage/plugin-catalog-react';
18
import React from 'react';
19
import { sentryPlugin, rootRouteRef } from './plugin';
20
import {
21
  createComponentExtension,
22
  createRoutableExtension,
23
} from '@backstage/core-plugin-api';
24
import { Options } from '@material-table/core';
25

26
/** @public */
27
export type SentryPageProps = {
28
  statsFor?: '24h' | '14d' | '';
29
  tableOptions?: Options<never>;
30
};
31

32
/** @public */
33
export const EntitySentryContent = sentryPlugin.provide(
34
  createRoutableExtension({
35
    name: 'EntitySentryContent',
36
    mountPoint: rootRouteRef,
37
    component: () =>
38
      import('./components/SentryIssuesWidget').then(
39
        ({ SentryIssuesWidget }) => {
40
          const SentryPage = (props: SentryPageProps) => {
41
            const { entity } = useEntity();
42
            const defaultOptions: Options<never> = {
43
              padding: 'dense',
44
              paging: true,
45
              search: false,
46
              pageSize: 5,
47
            };
48
            return (
49
              <SentryIssuesWidget
50
                entity={entity}
51
                statsFor={props.statsFor || '24h'}
52
                tableOptions={{ ...defaultOptions, ...props.tableOptions }}
53
              />
54
            );
55
          };
56
          return SentryPage;
57
        },
58
      ),
59
  }),
60
);
61

62
/** @public */
63
export const EntitySentryCard = sentryPlugin.provide(
64
  createComponentExtension({
65
    name: 'EntitySentryCard',
66
    component: {
67
      lazy: () =>
68
        import('./components/SentryIssuesWidget').then(
69
          ({ SentryIssuesWidget }) => {
70
            const SentryCard = (props: SentryPageProps) => {
71
              const { entity } = useEntity();
72
              return (
73
                <SentryIssuesWidget
74
                  entity={entity}
75
                  statsFor={props.statsFor || '24h'}
76
                  tableOptions={
77
                    props.tableOptions || {
78
                      padding: 'dense',
79
                      paging: true,
80
                      search: false,
81
                      pageSize: 5,
82
                    }
83
                  }
84
                />
85
              );
86
            };
87
            return SentryCard;
88
          },
89
        ),
90
    },
91
  }),
92
);
93

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.