SupportBundles: Improve UX (#60964)

implement of easy frontend fixes for bundle list
This commit is contained in:
Jo 2023-01-04 15:11:02 +00:00 committed by GitHub
parent a226903ec6
commit 9633b5c69c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 9 deletions

View File

@ -113,7 +113,7 @@ func (s *store) List() ([]supportbundles.Bundle, error) {
} }
sort.Slice(res, func(i, j int) bool { sort.Slice(res, func(i, j int) bool {
return res[i].CreatedAt < res[j].CreatedAt return res[i].CreatedAt > res[j].CreatedAt
}) })
return res, nil return res, nil

View File

@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { useAsyncFn } from 'react-use'; import { useAsyncFn } from 'react-use';
import { dateTimeFormat } from '@grafana/data'; import { dateTimeFormat } from '@grafana/data';
import { getBackendSrv } from '@grafana/runtime'; import { config, getBackendSrv } from '@grafana/runtime';
import { LinkButton } from '@grafana/ui'; import { LinkButton } from '@grafana/ui';
import { Page } from 'app/core/components/Page/Page'; import { Page } from 'app/core/components/Page/Page';
@ -13,6 +13,12 @@ const subTitle = (
</span> </span>
); );
const newButton = (
<LinkButton icon="plus" href="admin/support-bundles/create" variant="primary">
New Support Bundle
</LinkButton>
);
type SupportBundleState = 'complete' | 'error' | 'timeout' | 'pending'; type SupportBundleState = 'complete' | 'error' | 'timeout' | 'pending';
interface SupportBundle { interface SupportBundle {
@ -34,17 +40,17 @@ function SupportBundles() {
fetchBundles(); fetchBundles();
}, [fetchBundles]); }, [fetchBundles]);
const actions = config.featureToggles.topnav ? newButton : undefined;
return ( return (
<Page navId="support-bundles" subTitle={subTitle}> <Page navId="support-bundles" subTitle={subTitle} actions={actions}>
<Page.Contents isLoading={bundlesState.loading}> <Page.Contents isLoading={bundlesState.loading}>
<LinkButton href="admin/support-bundles/create" variant="primary"> {!config.featureToggles.topnav && newButton}
Create New Support Bundle
</LinkButton>
<table className="filter-table form-inline"> <table className="filter-table form-inline">
<thead> <thead>
<tr> <tr>
<th>Date</th> <th>Created on</th>
<th>Requested by</th> <th>Requested by</th>
<th>Expires</th> <th>Expires</th>
<th style={{ width: '1%' }} /> <th style={{ width: '1%' }} />
@ -57,7 +63,12 @@ function SupportBundles() {
<th>{b.creator}</th> <th>{b.creator}</th>
<th>{dateTimeFormat(b.expiresAt * 1000)}</th> <th>{dateTimeFormat(b.expiresAt * 1000)}</th>
<th> <th>
<LinkButton disabled={b.state !== 'complete'} target={'_self'} href={'/api/support-bundles/' + b.uid}> <LinkButton
fill="outline"
disabled={b.state !== 'complete'}
target={'_self'}
href={'/api/support-bundles/' + b.uid}
>
Download Download
</LinkButton> </LinkButton>
</th> </th>

View File

@ -25,6 +25,12 @@ const createSupportBundle = async (data: SupportBundleCreateRequest) => {
return result; return result;
}; };
const subTitle = (
<span>
Choose the components for the support bundle. The support bundle will be available for 3 days after creation.
</span>
);
export const SupportBundlesCreate = ({}: Props): JSX.Element => { export const SupportBundlesCreate = ({}: Props): JSX.Element => {
const onSubmit = useCallback(async (data) => { const onSubmit = useCallback(async (data) => {
try { try {
@ -57,7 +63,7 @@ export const SupportBundlesCreate = ({}: Props): JSX.Element => {
}, {}); }, {});
return ( return (
<Page navId="support-bundles" pageNav={{ text: 'Create support bundle' }}> <Page navId="support-bundles" pageNav={{ text: 'Create support bundle' }} subTitle={subTitle}>
<Page.Contents> <Page.Contents>
<Page.OldNavOnly> <Page.OldNavOnly>
<h3 className="page-sub-heading">Create support bundle</h3> <h3 className="page-sub-heading">Create support bundle</h3>