+ ))}
+
+ )}
+
+ View in FireHydrant
+
+
+
+
+
+
+
+ Declare an incident
+
+
+
+
+
+
+
+
+
+ View all incidents
+
+
+
+ {showServiceDetails && (
+
+
+
+
+
+
+ View Service Details
+
+
+
+ )}
+
+
+ {showServiceDetails && (
+
+
+
+ )}
+
+ );
+};
diff --git a/plugins/firehydrant/src/components/ServiceDetailsCard/index.ts b/plugins/firehydrant/src/components/ServiceDetailsCard/index.ts
new file mode 100644
index 0000000000..33e68ecf3b
--- /dev/null
+++ b/plugins/firehydrant/src/components/ServiceDetailsCard/index.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 { ServiceDetailsCard } from './ServiceDetailsCard';
diff --git a/plugins/firehydrant/src/components/serviceAnalytics.ts b/plugins/firehydrant/src/components/serviceAnalytics.ts
new file mode 100644
index 0000000000..ba88af86da
--- /dev/null
+++ b/plugins/firehydrant/src/components/serviceAnalytics.ts
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 { useAsyncRetry } from 'react-use';
+import { fireHydrantApiRef } from '../api';
+import { errorApiRef, useApi } from '@backstage/core-plugin-api';
+
+export const useServiceAnalytics = ({
+ serviceId,
+ startDate,
+ endDate,
+}: {
+ serviceId: string;
+ startDate: string;
+ endDate: string;
+}) => {
+ const api = useApi(fireHydrantApiRef);
+ const errorApi = useApi(errorApiRef);
+
+ const { loading, value, error, retry } = useAsyncRetry(async () => {
+ try {
+ return await api.getServiceAnalytics({
+ serviceId: serviceId,
+ startDate: startDate,
+ endDate: endDate,
+ });
+ } catch (e) {
+ errorApi.post(e);
+ return Promise.reject(e);
+ }
+ });
+
+ return {
+ loading,
+ value,
+ error,
+ retry,
+ };
+};
diff --git a/plugins/firehydrant/src/components/serviceDetails.ts b/plugins/firehydrant/src/components/serviceDetails.ts
new file mode 100644
index 0000000000..b8cac2736a
--- /dev/null
+++ b/plugins/firehydrant/src/components/serviceDetails.ts
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 { useAsyncRetry } from 'react-use';
+import { fireHydrantApiRef } from '../api';
+import { errorApiRef, useApi } from '@backstage/core-plugin-api';
+
+export const useServiceDetails = ({ serviceName }: { serviceName: string }) => {
+ const api = useApi(fireHydrantApiRef);
+ const errorApi = useApi(errorApiRef);
+
+ const { loading, value, error, retry } = useAsyncRetry(async () => {
+ try {
+ return await api.getServiceDetails({ serviceName: serviceName });
+ } catch (e) {
+ errorApi.post(e);
+ return Promise.reject(e);
+ }
+ });
+
+ return {
+ loading,
+ value,
+ error,
+ retry,
+ };
+};
diff --git a/plugins/firehydrant/src/components/types.ts b/plugins/firehydrant/src/components/types.ts
new file mode 100644
index 0000000000..e607b2357d
--- /dev/null
+++ b/plugins/firehydrant/src/components/types.ts
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 type Service = {
+ id: string;
+ name: string;
+ description?: string;
+ active_incidents?: string[];
+};
+
+export type Incident = {
+ id: string;
+ active: boolean;
+ description?: string;
+ name: string;
+ incident_url: string;
+};
diff --git a/plugins/firehydrant/src/index.ts b/plugins/firehydrant/src/index.ts
new file mode 100644
index 0000000000..465e42f1ae
--- /dev/null
+++ b/plugins/firehydrant/src/index.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 { firehydrantPlugin, FirehydrantCard } from './plugin';
diff --git a/plugins/firehydrant/src/plugin.test.ts b/plugins/firehydrant/src/plugin.test.ts
new file mode 100644
index 0000000000..ffde182e64
--- /dev/null
+++ b/plugins/firehydrant/src/plugin.test.ts
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 { firehydrantPlugin } from './plugin';
+
+describe('firehydrant', () => {
+ it('should export plugin', () => {
+ expect(firehydrantPlugin).toBeDefined();
+ });
+});
diff --git a/plugins/firehydrant/src/plugin.ts b/plugins/firehydrant/src/plugin.ts
new file mode 100644
index 0000000000..4277c1833f
--- /dev/null
+++ b/plugins/firehydrant/src/plugin.ts
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 { fireHydrantApiRef, FireHydrantAPIClient } from './api';
+import {
+ createApiFactory,
+ createPlugin,
+ discoveryApiRef,
+ createComponentExtension,
+} from '@backstage/core-plugin-api';
+
+import { rootRouteRef } from './routes';
+
+export const firehydrantPlugin = createPlugin({
+ id: 'firehydrant',
+ apis: [
+ createApiFactory({
+ api: fireHydrantApiRef,
+ deps: { discoveryApi: discoveryApiRef },
+ factory: ({ discoveryApi }) => new FireHydrantAPIClient({ discoveryApi }),
+ }),
+ ],
+ routes: {
+ root: rootRouteRef,
+ },
+});
+
+export const FirehydrantCard = firehydrantPlugin.provide(
+ createComponentExtension({
+ component: {
+ lazy: () =>
+ import('./components/ServiceDetailsCard').then(
+ m => m.ServiceDetailsCard,
+ ),
+ },
+ }),
+);
diff --git a/plugins/firehydrant/src/routes.ts b/plugins/firehydrant/src/routes.ts
new file mode 100644
index 0000000000..eb2f8b6375
--- /dev/null
+++ b/plugins/firehydrant/src/routes.ts
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 { createRouteRef } from '@backstage/core-plugin-api';
+
+export const rootRouteRef = createRouteRef({
+ title: 'firehydrant',
+});
diff --git a/plugins/firehydrant/src/setupTests.ts b/plugins/firehydrant/src/setupTests.ts
new file mode 100644
index 0000000000..fc6dbd98f8
--- /dev/null
+++ b/plugins/firehydrant/src/setupTests.ts
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * 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 '@testing-library/jest-dom';
+import 'cross-fetch/polyfill';