-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assortment of UI changes for coverage over time for components #2809
Changes from all commits
f560608
573680a
845ba5e
a68a143
10f0ac7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,9 @@ const mockPull = { | |
}, | ||
], | ||
}, | ||
head: { | ||
branchName: 'abc', | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,9 @@ export const query = ` | |
message | ||
} | ||
} | ||
head { | ||
branchName | ||
} | ||
} | ||
} | ||
... on NotFoundError { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom' | |
import { Branch, useBranch, useBranches } from 'services/branches' | ||
import { useLocationParams } from 'services/navigation' | ||
import { useRepoOverview } from 'services/repo' | ||
import A from 'ui/A' | ||
import Icon from 'ui/Icon' | ||
import Select from 'ui/Select' | ||
|
||
|
@@ -21,7 +22,13 @@ const defaultQueryParams = { | |
const getDecodedBranch = (branch?: string) => | ||
!!branch ? decodeURIComponent(branch) : undefined | ||
|
||
const BranchSelector: React.FC = () => { | ||
interface BranchSelectorProps { | ||
isDisabled: boolean | undefined | ||
} | ||
|
||
const BranchSelector: React.FC<BranchSelectorProps> = ({ | ||
isDisabled = false, | ||
}) => { | ||
const { provider, owner, repo, branch } = useParams<URLParams>() | ||
const { params, updateParams } = useLocationParams(defaultQueryParams) | ||
const [branchSearchTerm, setBranchSearchTerm] = useState<string>('') | ||
|
@@ -48,7 +55,10 @@ const BranchSelector: React.FC = () => { | |
}) | ||
|
||
const decodedBranch = getDecodedBranch(branch) | ||
const selectedBranch = decodedBranch ?? overview?.defaultBranch ?? '' | ||
|
||
const selectedBranch = | ||
// @ts-expect-error | ||
decodedBranch || params.branch || overview?.defaultBranch || '' | ||
|
||
const { data: searchBranchValue } = useBranch({ | ||
provider, | ||
|
@@ -70,7 +80,7 @@ const BranchSelector: React.FC = () => { | |
} | ||
|
||
return ( | ||
<div className="md:w-[16rem]"> | ||
<div className="flex flex-col justify-between gap-2 p-4 sm:py-0 md:w-[16rem]"> | ||
<h3 className="flex items-center gap-1 text-sm font-semibold text-ds-gray-octonary"> | ||
<span className="text-ds-gray-quinary"> | ||
<Icon name="branch" size="sm" variant="developer" /> | ||
|
@@ -97,8 +107,24 @@ const BranchSelector: React.FC = () => { | |
} | ||
}} | ||
onSearch={(term: string) => setBranchSearchTerm(term)} | ||
disabled={isDisabled} | ||
/> | ||
</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the "latest commit" section under the branch selector. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
{selection?.head?.commitid && ( | ||
<p className="text-xs"> | ||
<span className="font-bold">Source:</span> latest commit{' '} | ||
<A | ||
to={{ | ||
pageName: 'commit', | ||
options: { commit: selection?.head?.commitid }, | ||
}} | ||
isExternal={false} | ||
hook="components-latest-commit" | ||
> | ||
{selection?.head?.commitid.slice(0, 7)} | ||
</A> | ||
</p> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,8 +60,8 @@ const Header = ({ | |
return ( | ||
<div className="flex flex-col justify-end divide-y divide-solid divide-ds-gray-secondary"> | ||
<div className="grid w-2/3 divide-y divide-solid divide-ds-gray-secondary sm:w-full sm:grid-cols-2 sm:divide-x sm:divide-y-0 md:grid-cols-4"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes padding of the header area. |
||
<BranchSelector /> | ||
<div className="md:w-[16rem]"> | ||
<BranchSelector isDisabled={controlsDisabled} /> | ||
<div className="flex flex-col justify-between gap-2 p-4 sm:py-0"> | ||
<h3 className="text-sm font-semibold text-ds-gray-octonary"> | ||
Configured components | ||
</h3> | ||
|
@@ -73,7 +73,7 @@ const Header = ({ | |
<A to={{ pageName: 'components' }}>Learn more</A> | ||
</p> | ||
</div> | ||
<div className="md:w-[16rem]"> | ||
<div className="flex flex-col gap-2 p-4 sm:py-0"> | ||
<h3 className="text-sm font-semibold text-ds-gray-octonary"> | ||
Historical trend | ||
</h3> | ||
|
@@ -91,7 +91,7 @@ const Header = ({ | |
renderSelected={({ label }: { label: string }) => label} | ||
/> | ||
</div> | ||
<div className="md:w-[16rem]"> | ||
<div className="flex flex-col gap-2 p-4 sm:py-0"> | ||
<h3 className="text-sm font-semibold text-ds-gray-octonary"> | ||
Show by | ||
</h3> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,50 @@ interface ComponentsTableHelper { | |
delete: React.ReactElement | null | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds the table headers (without the actual data) when in the state of either not configured, activate measurements, or is backfilling. Because we want to show the table headers and then the corresponding messages. |
||
export const LoadingTable = () => { | ||
const data = useMemo(() => [], []) | ||
const table = useReactTable({ | ||
data, | ||
columns, | ||
getCoreRowModel: getCoreRowModel(), | ||
}) | ||
|
||
return ( | ||
<div className="tableui"> | ||
<table> | ||
<colgroup> | ||
<col className="@sm/table:w-4/12" /> | ||
<col className="@sm/table:w-3/12" /> | ||
<col className="@sm/table:w-3/12" /> | ||
<col className="@sm/table:w-2/12" /> | ||
<col className="@sm/table:w-3/12" /> | ||
</colgroup> | ||
<thead data-testid="header-row"> | ||
{table.getHeaderGroups().map((headerGroup) => ( | ||
<tr key={headerGroup.id}> | ||
{headerGroup.headers.map((header) => ( | ||
<th key={header.id}> | ||
<div | ||
className={cs('flex flex-row', { | ||
'justify-end': | ||
header.id !== 'name' && header.id !== 'lastUploaded', | ||
})} | ||
> | ||
{flexRender( | ||
header.column.columnDef.header, | ||
header.getContext() | ||
)} | ||
</div> | ||
</th> | ||
))} | ||
</tr> | ||
))} | ||
</thead> | ||
</table> | ||
</div> | ||
) | ||
} | ||
|
||
const columnHelper = createColumnHelper<ComponentsTableHelper>() | ||
|
||
const columns = [ | ||
|
@@ -125,7 +169,7 @@ function createTableData({ | |
/> | ||
), | ||
lastUploaded: ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. align the Last Uploaded column to the left (because the values of this column are strings) |
||
<span className="flex justify-end"> | ||
<span className="flex justify-start"> | ||
{lastUploaded ? formatTimeToNow(lastUploaded) : ''} | ||
</span> | ||
), | ||
|
@@ -135,6 +179,7 @@ function createTableData({ | |
data-testid="delete-component" | ||
onClick={() => setModalInfo({ componentId: name, showModal: true })} | ||
className="text-ds-gray-tertiary hover:text-ds-gray-senary" | ||
aria-label={'delete ' + name} | ||
> | ||
<Icon size="md" name="trash" variant="outline" /> | ||
</button> | ||
|
@@ -199,7 +244,8 @@ const ComponentTable = memo(function Table({ | |
> | ||
<div | ||
className={cs('flex flex-row', { | ||
'justify-end': header.id !== 'name', | ||
'justify-end': | ||
header.id !== 'name' && header.id !== 'lastUploaded', | ||
})} | ||
> | ||
{flexRender( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a link to the repo's component tab with the current PR's branch