Skip to content

Commit

Permalink
Merge pull request #3545 from relative-ci/metrics-table-sort
Browse files Browse the repository at this point in the history
Metrics table sort
  • Loading branch information
vio authored Jul 15, 2023
2 parents 4adfcd1 + 614a76e commit 4783267
Show file tree
Hide file tree
Showing 31 changed files with 406 additions and 411 deletions.
26 changes: 16 additions & 10 deletions packages/ui/src/assets/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 24 additions & 10 deletions packages/ui/src/assets/icons.svg.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-arrow-down"
id="arrow"
xmlns="http://www.w3.org/2000/svg"
>
Expand All @@ -21,22 +20,44 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-arrow-right-circle"
viewBox="0 0 24 24"
id="arrow-right-circle"
xmlns="http://www.w3.org/2000/svg"
>
<circle cx="12" cy="12" r="10" />
<path d="M12 16l4-4-4-4M8 12h8" />
</symbol>
<symbol
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
viewBox="0 0 24 24"
id="chevron-down"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M6 9l6 6 6-6" />
</symbol>
<symbol
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
viewBox="0 0 24 24"
id="chevron-up"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M18 15l-6-6-6 6" />
</symbol>
<symbol
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-clock"
id="clock"
xmlns="http://www.w3.org/2000/svg"
>
Expand All @@ -49,7 +70,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-x-circle"
viewBox="0 0 24 24"
id="close"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -64,7 +84,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-git-commit"
id="commit"
xmlns="http://www.w3.org/2000/svg"
>
Expand All @@ -90,7 +109,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-external-link"
viewBox="0 0 24 24"
id="external-link"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -104,7 +122,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-bar-chart"
id="filter"
xmlns="http://www.w3.org/2000/svg"
>
Expand All @@ -125,7 +142,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-help-circle"
id="help"
xmlns="http://www.w3.org/2000/svg"
>
Expand All @@ -152,7 +168,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-menu"
id="menu"
xmlns="http://www.w3.org/2000/svg"
>
Expand Down Expand Up @@ -183,7 +198,6 @@ export const SvgIcons = (props) => (
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-alert-triangle"
id="warning"
xmlns="http://www.w3.org/2000/svg"
>
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/assets/icons/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/ui/src/assets/icons/chevron-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

11 changes: 2 additions & 9 deletions packages/ui/src/components/bundle-assets/bundle-assets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { FileName } from '../../ui/file-name';
import { HoverCard } from '../../ui/hover-card';
import { Tag } from '../../ui/tag';
import { Filters } from '../../ui/filters';
import { SortDropdown } from '../../ui/sort-dropdown';
import { EmptySet } from '../../ui/empty-set';
import { Toolbar } from '../../ui/toolbar';
import { AssetInfo } from '../asset-info';
Expand Down Expand Up @@ -170,7 +169,6 @@ export const BundleAssets = (props) => {
filters,
entryId,
hasActiveFilters,
sortFields,
sort,
updateSort,
search,
Expand Down Expand Up @@ -221,7 +219,6 @@ export const BundleAssets = (props) => {
className={css.toolbar}
renderActions={({ actionClassName }) => (
<FlexStack space="xxsmall" className={cx(css.dropdown, actionClassName)}>
<SortDropdown fields={sortFields} {...sort} onChange={updateSort} />
<MetricsTableOptions
handleViewAll={resetAllFilters}
handleResetFilters={resetFilters}
Expand Down Expand Up @@ -252,6 +249,8 @@ export const BundleAssets = (props) => {
emptyMessage={emptyMessage}
showHeaderSum
title={metricsTableTitle}
sort={sort}
updateSort={updateSort}
/>
</main>
</section>
Expand Down Expand Up @@ -313,12 +312,6 @@ BundleAssets.propTypes = {
}).isRequired,
entryId: PropTypes.string,
hasActiveFilters: PropTypes.bool,
sortFields: PropTypes.shape({
[PropTypes.string]: PropTypes.shape({
label: PropTypes.string,
defaultDirection: PropTypes.bool,
}),
}).isRequired,
search: PropTypes.string.isRequired,
updateSearch: PropTypes.func.isRequired,
sort: PropTypes.shape({
Expand Down
32 changes: 8 additions & 24 deletions packages/ui/src/components/bundle-assets/bundle-assets.utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ASSET_ENTRY_TYPE, ASSET_FILE_TYPE, ASSET_FILTERS, getFileType } from '@bundle-stats/utils';

import { SORT_BY_NAME, SORT_BY_DELTA, SORT_BY_SIZE } from './bundle-assets.constants';

export const addRowAssetFlags = (row) => {
const { runs } = row;

Expand Down Expand Up @@ -72,25 +70,11 @@ export const getRowFilter = (filters) => (item) => {
return true;
};

export const getCustomSort = (sortId) => (item) => {
if (sortId === SORT_BY_NAME) {
return item.key;
}

if (sortId === SORT_BY_DELTA) {
return item?.runs?.[0]?.delta ? Math.abs(item.runs[0].delta) : 0;
}

if (sortId === SORT_BY_SIZE) {
return item?.runs?.[0]?.value || 0;
}

return [
!item.isNotPredictive,
!item.changed,
!item.isInitial,
!item.isEntry,
!item.isChunk,
item.key,
];
};
export const getCustomSort = (item) => [
!item.isNotPredictive,
!item.changed,
!item.isInitial,
!item.isEntry,
!item.isChunk,
item.key,
];
2 changes: 0 additions & 2 deletions packages/ui/src/components/bundle-assets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useRowsSort } from '../../hooks/rows-sort';
import { useSearchParams } from '../../hooks/search-params';
import { BundleAssets as BundleAssetsComponent } from './bundle-assets';
import { addRowAssetFlags, addRowIsNotPredictive, getRowFilter, getCustomSort } from './bundle-assets.utils';
import { SORT_BY } from './bundle-assets.constants';

export const BundleAssets = (props) => {
const { jobs, filters, search, setState, sortBy, direction, ...restProps } = props;
Expand Down Expand Up @@ -55,7 +54,6 @@ export const BundleAssets = (props) => {

const sortParams = useRowsSort({
rows: filteredRows,
sortFields: SORT_BY,
sortBy,
sortDirection: direction,
getCustomSort,
Expand Down

This file was deleted.

16 changes: 2 additions & 14 deletions packages/ui/src/components/bundle-modules/bundle-modules.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { FlexStack } from '../../layout/flex-stack';
import { EmptySet } from '../../ui/empty-set';
import { FileName } from '../../ui/file-name';
import { Filters } from '../../ui/filters';
import { SortDropdown } from '../../ui/sort-dropdown';
import { Tag } from '../../ui/tag';
import { Toolbar } from '../../ui/toolbar';
import { MetricsTable } from '../metrics-table';
Expand Down Expand Up @@ -125,7 +124,6 @@ export const BundleModules = ({
resetAllFilters,
filters,
entryId,
sortFields,
sort,
updateSort,
search,
Expand Down Expand Up @@ -179,12 +177,6 @@ export const BundleModules = ({
className={css.toolbar}
renderActions={({ actionClassName }) => (
<FlexStack space="xxsmall" className={cx(css.dropdown, actionClassName)}>
<SortDropdown
className={css.tableDropdown}
fields={sortFields}
onChange={updateSort}
{...sort}
/>
<MetricsTableOptions
handleViewAll={resetAllFilters}
handleResetFilters={resetFilters}
Expand Down Expand Up @@ -216,6 +208,8 @@ export const BundleModules = ({
emptyMessage={emptyMessage}
showHeaderSum
title={metricsTableTitle}
sort={sort}
updateSort={updateSort}
/>
</div>
{entryId && (
Expand Down Expand Up @@ -277,12 +271,6 @@ BundleModules.propTypes = {

hasActiveFilters: PropTypes.bool,

sortFields: PropTypes.shape({
[PropTypes.string]: PropTypes.shape({
label: PropTypes.string,
defaultDirection: PropTypes.bool,
}),
}).isRequired,
sort: PropTypes.shape({
sortBy: PropTypes.string,
direction: PropTypes.string,
Expand Down
Loading

0 comments on commit 4783267

Please sign in to comment.