Provision Bulk Action: Add pull request button (#109622)

* Provision Bulk Action: pull request link
* Add view branch and compare branch button
This commit is contained in:
Yunwen Zheng
2025-08-14 20:27:06 +02:00
committed by GitHub
parent 4954438cb5
commit 6305d6daed
4 changed files with 52 additions and 5 deletions
@@ -132,12 +132,17 @@ export const provisioningAPIv0alpha1 = generatedAPI.enhanceEndpoints({
},
},
createRepositoryJobs: {
onQueryStarted: async (_, { queryFulfilled, dispatch }) => {
onQueryStarted: async ({ jobSpec }, { queryFulfilled, dispatch }) => {
try {
const showMsg = jobSpec.action === 'pull' || jobSpec.action === 'migrate';
await queryFulfilled;
dispatch(
notifyApp(createSuccessNotification(t('provisioning.sync-repository.success-pull-started', 'Pull started')))
);
if (showMsg) {
dispatch(
notifyApp(
createSuccessNotification(t('provisioning.sync-repository.success-pull-started', 'Pull started'))
)
);
}
} catch (e) {
if (e instanceof Error) {
dispatch(
@@ -4,6 +4,7 @@ import { Trans, t } from '@grafana/i18n';
import { ControlledCollapse, Spinner, Stack, Text } from '@grafana/ui';
import { Job } from 'app/api/clients/provisioning/v0alpha1';
import { PullRequestButtons } from '../Repository/PullRequestButtons';
import { RepositoryLink } from '../Repository/RepositoryLink';
import ProgressBar from '../Shared/ProgressBar';
import { StepStatusInfo } from '../Wizard/types';
@@ -26,6 +27,7 @@ export function JobContent({ jobType, job, isFinishedJob = false, onStatusChange
const { state, message, progress, summary, errors } = job.status;
const repoName = job.metadata?.labels?.['provisioning.grafana.app/repository'];
const pullRequestURL = job.status?.url?.newPullRequestURL;
// Update step status based on job state
useEffect(() => {
@@ -95,7 +97,13 @@ export function JobContent({ jobType, job, isFinishedJob = false, onStatusChange
</Stack>
)}
{state === 'success' ? (
<RepositoryLink name={repoName} jobType={jobType} />
<Stack direction="row" gap={1}>
{pullRequestURL ? (
<PullRequestButtons urls={job.status?.url} jobType={jobType} />
) : (
<RepositoryLink name={repoName} jobType={jobType} />
)}
</Stack>
) : (
<ControlledCollapse label={t('provisioning.job-status.label-view-details', 'View details')} isOpen={false}>
<pre>{JSON.stringify(job, null, 2)}</pre>
@@ -0,0 +1,31 @@
import { Trans } from '@grafana/i18n';
import { LinkButton } from '@grafana/ui';
import { RepositoryUrLs } from 'app/api/clients/provisioning/v0alpha1';
interface Props {
jobType?: 'sync' | 'delete' | 'move';
urls?: RepositoryUrLs;
}
export function PullRequestButtons({ urls, jobType }: Props) {
const pullRequestURL = urls?.newPullRequestURL;
const compareURL = urls?.compareURL;
const branchURL = urls?.sourceURL;
if (jobType === 'sync') {
return null;
}
return (
<>
<LinkButton href={branchURL} icon="external-link-alt" variant="secondary" target="_blank">
<Trans i18nKey="provisioning.repository-link.delete-or-move-job.view-branch">View branch</Trans>
</LinkButton>
<LinkButton href={compareURL} icon="external-link-alt" variant="secondary" target="_blank">
<Trans i18nKey="provisioning.repository-link.delete-or-move-job.compare-branch">Compare branch</Trans>
</LinkButton>
<LinkButton href={pullRequestURL} icon="external-link-alt" variant="secondary" target="_blank">
<Trans i18nKey="provisioning.repository-link.delete-or-move-job.open-pull-request">Open pull request</Trans>
</LinkButton>
</>
);
}
+3
View File
@@ -11470,6 +11470,9 @@
},
"repository-link": {
"delete-or-move-job": {
"compare-branch": "Compare branch",
"open-pull-request": "Open pull request",
"view-branch": "View branch",
"view-repository": "View repository"
},
"grafana-repository-synced": "Your resources are now in your external storage and provisioned into your instance. From now on, your instance and the external storage will be synchronized.",