From f0dc718a67a7c82bcbc39682819dedca2c6c0cf4 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 18 Dec 2024 12:37:45 +0300 Subject: [PATCH] POC/Provisioning: Use cards layout to show more status info (#98155) --- .betterer.results | 40 ++++--- .../provisioning/repository_controller.go | 4 +- .../provisioning/testdata/github-example.yaml | 1 - .../provisioning/DeleteRepositoryButton.tsx | 11 +- .../provisioning/RepositoryListPage.tsx | 110 +++++++++++++----- 5 files changed, 110 insertions(+), 56 deletions(-) diff --git a/.betterer.results b/.betterer.results index 147b121ab9f..59316c4a97e 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5330,8 +5330,7 @@ exports[`better eslint`] = { [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "42"] ], "public/app/features/provisioning/DeleteRepositoryButton.tsx:5381": [ - [0, 0, 0, "No untranslated strings. Wrap text with ", "0"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "1"] + [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"] ], "public/app/features/provisioning/EditRepositoryPage.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"], @@ -5360,8 +5359,11 @@ exports[`better eslint`] = { [0, 0, 0, "No untranslated strings. Wrap text with ", "0"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "1"], [0, 0, 0, "No untranslated strings. Wrap text with ", "2"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "3"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "4"] + [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "3"], + [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "4"], + [0, 0, 0, "No untranslated strings. Wrap text with ", "5"], + [0, 0, 0, "No untranslated strings. Wrap text with ", "6"], + [0, 0, 0, "No untranslated strings. Wrap text with ", "7"] ], "public/app/features/provisioning/RepositorySelect.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"] @@ -5372,26 +5374,30 @@ exports[`better eslint`] = { [0, 0, 0, "No untranslated strings. Wrap text with ", "2"], [0, 0, 0, "No untranslated strings. Wrap text with ", "3"], [0, 0, 0, "No untranslated strings. Wrap text with ", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "8"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "9"], + [0, 0, 0, "No untranslated strings. Wrap text with ", "5"], + [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "6"], + [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "7"], + [0, 0, 0, "No untranslated strings. Wrap text with ", "8"], + [0, 0, 0, "No untranslated strings. Wrap text with ", "9"], [0, 0, 0, "No untranslated strings. Wrap text with ", "10"], [0, 0, 0, "No untranslated strings. Wrap text with ", "11"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "12"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "13"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "14"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "15"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "16"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "17"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "18"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "19"] + [0, 0, 0, "No untranslated strings. Wrap text with ", "12"], + [0, 0, 0, "No untranslated strings. Wrap text with ", "13"] ], "public/app/features/provisioning/SyncRepository.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "1"] ], + "public/app/features/provisioning/api/endpoints.ts:5381": [ + [0, 0, 0, "Unexpected any. Specify a different type.", "0"], + [0, 0, 0, "Unexpected any. Specify a different type.", "1"], + [0, 0, 0, "Unexpected any. Specify a different type.", "2"], + [0, 0, 0, "Unexpected any. Specify a different type.", "3"], + [0, 0, 0, "Unexpected any. Specify a different type.", "4"], + [0, 0, 0, "Unexpected any. Specify a different type.", "5"], + [0, 0, 0, "Unexpected any. Specify a different type.", "6"], + [0, 0, 0, "Unexpected any. Specify a different type.", "7"] + ], "public/app/features/provisioning/api/index.ts:5381": [ [0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"] ], diff --git a/pkg/registry/apis/provisioning/repository_controller.go b/pkg/registry/apis/provisioning/repository_controller.go index 42048b5091a..7c0e08045f4 100644 --- a/pkg/registry/apis/provisioning/repository_controller.go +++ b/pkg/registry/apis/provisioning/repository_controller.go @@ -232,12 +232,12 @@ func (rc *RepositoryController) sync(key string) error { if cachedRepo.Status.Initialized { status, err = repo.OnUpdate(ctx, logger) if err != nil { - return fmt.Errorf("on create repository: %w", err) + rc.logger.Error("OnUpdate", "error", err) } } else { status, err = repo.OnCreate(ctx, logger) if err != nil { - return fmt.Errorf("on create repository: %w", err) + rc.logger.Error("OnCreate", "error", err) } } diff --git a/pkg/tests/apis/provisioning/testdata/github-example.yaml b/pkg/tests/apis/provisioning/testdata/github-example.yaml index 4f0732c2294..9fa9dadbc74 100644 --- a/pkg/tests/apis/provisioning/testdata/github-example.yaml +++ b/pkg/tests/apis/provisioning/testdata/github-example.yaml @@ -19,4 +19,3 @@ spec: generateDashboardPreviews: true pullRequestLinter: true token: "github_pat_dummy" - webhookSecret: "dummyWebhookSecret" diff --git a/public/app/features/provisioning/DeleteRepositoryButton.tsx b/public/app/features/provisioning/DeleteRepositoryButton.tsx index a1724d00814..8faf0ea7b19 100644 --- a/public/app/features/provisioning/DeleteRepositoryButton.tsx +++ b/public/app/features/provisioning/DeleteRepositoryButton.tsx @@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react'; import { AppEvents } from '@grafana/data'; import { getAppEvents } from '@grafana/runtime'; -import { Button, ConfirmModal } from '@grafana/ui'; +import { Button, ConfirmModal, IconButton } from '@grafana/ui'; import { useDeleteRepositoryMutation } from './api'; @@ -26,14 +26,13 @@ export function DeleteRepositoryButton({ name }: { name: string }) { return ( <> - + /> { const name = item.metadata?.name ?? ''; - const healthy = Boolean(item.status?.health.healthy) + const healthy = Boolean(item.status?.health.healthy); + let icon: IconName = 'database'; // based on type + let meta: ReactNode[] = [ + // TODO... add counts? and sync info + ]; + switch (item.spec?.type) { + case 'github': + icon = 'github'; + const spec = item.spec.github; + let url = `https://github.com/${spec?.owner}/${spec?.repository}/`; + if (spec?.branch) { + url += `tree/` + spec?.branch; + } + meta.push({url}); + break; + + case 'local': + meta.push(item.spec.local?.path); + break; + } return ( - - - - {item.spec?.title} - - {item.spec?.type} - - - {healthy ? <> - - Edit + + + + + {item.spec?.title} + + {item.spec?.description} + + {item.status ? ( + <> + {!healthy && ( + ( +
+ {v} +
+
+
+ ))} + >
+ )} + + ) : ( +
+ +
+ )} +
+ {meta} + + + Manage + + {item.spec?.folder && ( + + View - - - : <> - - <> - {item.status?.health.message && item.status.health.message.map(v =>
{v}

)} -
- - Edit - - -
- -
- } -
+ )} + {healthy && } + + + {/* + */} + +
); })