Unverified Commit 1dd87609 authored by Diksha Thakur's avatar Diksha Thakur Committed by GitHub

fix: Align and format column stats (new PR) (#723)

* Allign and format column stats
Signed-off-by: 's avatardikshathakur3119 <dikshathakur3119@gmail.com>

* Update common version and other minor changes
Signed-off-by: 's avatardikshathakur3119 <dikshathakur3119@gmail.com>

* Update mock data include chart_name
Signed-off-by: 's avatardikshathakur3119 <dikshathakur3119@gmail.com>

* fix lint
Signed-off-by: 's avatardikshathakur3119 <dikshathakur3119@gmail.com>
parent 8cd70af9
...@@ -128,6 +128,7 @@ $resource-title-color: $indigo60; ...@@ -128,6 +128,7 @@ $resource-title-color: $indigo60;
// Spacing // Spacing
$spacer-size: 8px; $spacer-size: 8px;
$spacer-half: $spacer-size/2;
$spacer-1: $spacer-size; $spacer-1: $spacer-size;
$spacer-2: $spacer-size * 2; $spacer-2: $spacer-size * 2;
$spacer-3: $spacer-size * 3; $spacer-3: $spacer-size * 3;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import * as React from 'react'; import * as React from 'react';
import { TableColumnStats } from 'interfaces/index'; import { TableColumnStats } from 'interfaces/index';
import { formatNumber } from 'utils/numberUtils';
import { getStatsInfoText } from '../utils'; import { getStatsInfoText } from '../utils';
import { COLUMN_STATS_TITLE } from '../constants'; import { COLUMN_STATS_TITLE } from '../constants';
...@@ -23,10 +24,12 @@ const ColumnStatRow: React.FC<ColumnStatRowProps> = ({ ...@@ -23,10 +24,12 @@ const ColumnStatRow: React.FC<ColumnStatRowProps> = ({
stat_type, stat_type,
stat_val, stat_val,
}: ColumnStatRowProps) => { }: ColumnStatRowProps) => {
const numberVal = +stat_val;
return ( return (
<div className="column-stat-row"> <div className="column-stat-row">
<div className="stat-name body-3">{stat_type.toUpperCase()}</div> <div className="stat-name body-3">{stat_type.toUpperCase()}</div>
<div className="stat-value">{stat_val}</div> <div className="stat-value">{formatNumber(numberVal)}</div>
</div> </div>
); );
}; };
......
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
.stat-value { .stat-value {
flex: 100px 1 1; flex: 100px 1 1;
padding-right: 4px; padding-right: $spacer-half;
text-align: right;
font-style: $font-family-monospace-code;
} }
} }
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
font-weight: normal; font-weight: normal;
} }
.actionable-badge { .actionable-badge {
&:hover { &:hover {
cursor: pointer; cursor: pointer;
...@@ -52,30 +51,36 @@ ...@@ -52,30 +51,36 @@
.badge-overlay-neutral, .badge-overlay-neutral,
.badge-overlay-positive, .badge-overlay-positive,
.badge-overlay-primary { .badge-overlay-primary {
&:hover, &:hover,
&:focus { &:focus {
background-color: rgba($color: $badge-overlay, background-color: rgba(
$alpha: $badge-opacity-light); $color: $badge-overlay,
$alpha: $badge-opacity-light
);
} }
&:active { &:active {
background-color: rgba($color: $badge-overlay, background-color: rgba(
$alpha: $badge-pressed-light); $color: $badge-overlay,
$alpha: $badge-pressed-light
);
} }
} }
.badge-overlay-warning { .badge-overlay-warning {
&:hover, &:hover,
&:focus { &:focus {
background-color: rgba($color: $badge-overlay, background-color: rgba(
$alpha: $badge-opacity-dark); $color: $badge-overlay,
$alpha: $badge-opacity-dark
);
} }
&:active { &:active {
background-color: rgba($color: $badge-overlay, background-color: rgba(
$alpha: $badge-pressed-dark); $color: $badge-overlay,
$alpha: $badge-pressed-dark
);
} }
} }
} }
...@@ -27,7 +27,8 @@ $row-bottom-border-color: $gray10; ...@@ -27,7 +27,8 @@ $row-bottom-border-color: $gray10;
background-color: $table-header-background-color; background-color: $table-header-background-color;
color: $text-secondary; color: $text-secondary;
border-bottom: $table-header-border-width solid $table-header-bottom-border-color; border-bottom: $table-header-border-width solid
$table-header-bottom-border-color;
} }
.ams-table-heading-cell { .ams-table-heading-cell {
...@@ -107,7 +108,6 @@ $row-bottom-border-color: $gray10; ...@@ -107,7 +108,6 @@ $row-bottom-border-color: $gray10;
&:last-child { &:last-child {
padding-right: $spacer-3; padding-right: $spacer-3;
} }
} }
.ams-table-expanding-button { .ams-table-expanding-button {
......
...@@ -33,6 +33,7 @@ const configDefault: AppConfig = { ...@@ -33,6 +33,7 @@ const configDefault: AppConfig = {
enabled: false, enabled: false,
}, },
logoPath: null, logoPath: null,
numberFormat: null,
mailClientFeatures: { mailClientFeatures: {
feedbackEnabled: false, feedbackEnabled: false,
notificationsEnabled: false, notificationsEnabled: false,
......
...@@ -17,6 +17,7 @@ export interface AppConfig { ...@@ -17,6 +17,7 @@ export interface AppConfig {
userIdLabel?: string /* Temporary configuration due to lacking string customization/translation support */; userIdLabel?: string /* Temporary configuration due to lacking string customization/translation support */;
issueTracking: IssueTrackingConfig; issueTracking: IssueTrackingConfig;
logoPath: string | null; logoPath: string | null;
numberFormat: NumberFormatConfig | null;
mailClientFeatures: MailClientFeaturesConfig; mailClientFeatures: MailClientFeaturesConfig;
announcements: AnnoucementsFeaturesConfig; announcements: AnnoucementsFeaturesConfig;
navLinks: Array<LinkConfig>; navLinks: Array<LinkConfig>;
...@@ -36,6 +37,7 @@ export interface AppConfigCustom { ...@@ -36,6 +37,7 @@ export interface AppConfigCustom {
userIdLabel?: string /* Temporary configuration due to lacking string customization/translation support */; userIdLabel?: string /* Temporary configuration due to lacking string customization/translation support */;
issueTracking?: IssueTrackingConfig; issueTracking?: IssueTrackingConfig;
logoPath?: string; logoPath?: string;
numberFormat?: NumberFormatConfig | null;
mailClientFeatures?: MailClientFeaturesConfig; mailClientFeatures?: MailClientFeaturesConfig;
announcements?: AnnoucementsFeaturesConfig; announcements?: AnnoucementsFeaturesConfig;
navLinks?: Array<LinkConfig>; navLinks?: Array<LinkConfig>;
...@@ -305,3 +307,23 @@ interface EditableTextConfig { ...@@ -305,3 +307,23 @@ interface EditableTextConfig {
interface IssueTrackingConfig { interface IssueTrackingConfig {
enabled: boolean; enabled: boolean;
} }
export enum NumberStyle {
DECIMAL = 'decimal',
CURRENCY = 'currency',
PERCENT = 'percent',
UNIT = 'unit',
}
export interface NumberStyleConfig {
style: NumberStyle;
config: string;
}
/**
* NumberFormatConfig - configurations for formatting different type of numbers like currency, percentage,number system
* this allows users to display numbers in desired format
*/
export interface NumberFormatConfig {
numberSystem: string | null;
[NumberStyle.DECIMAL]?: NumberStyleConfig;
}
...@@ -257,3 +257,12 @@ export function getDescriptionSourceIconPath(sourceId: string): string { ...@@ -257,3 +257,12 @@ export function getDescriptionSourceIconPath(sourceId: string): string {
return ''; return '';
} }
/**
* Returns the desired number format in which we want to format any number
* Used for formatting column stats
* If a configuration does not exist, None is returned
*/
export function getNumberFormat() {
return AppConfig.numberFormat;
}
...@@ -299,3 +299,11 @@ describe('generateExploreUrl', () => { ...@@ -299,3 +299,11 @@ describe('generateExploreUrl', () => {
); );
}); });
}); });
describe('numberFormat', () => {
it('returns number format defined in config', () => {
const actual = ConfigUtils.getNumberFormat();
const expected = AppConfig.numberFormat;
expect(actual).toBe(expected);
});
});
import { getNumberFormat } from 'config/config-utils';
export function formatNumber(value) {
const numberformat = getNumberFormat();
if (numberformat == null) {
return Intl.NumberFormat().format(value);
}
const numbersystem = numberformat.numberSystem || null;
if (numbersystem) {
return Intl.NumberFormat(numbersystem).format(value);
}
return Intl.NumberFormat().format(value);
}
...@@ -70,7 +70,7 @@ responses==0.12.0 ...@@ -70,7 +70,7 @@ responses==0.12.0
# A common package that holds the models deifnition and schemas that are used # A common package that holds the models deifnition and schemas that are used
# accross different amundsen repositories. # accross different amundsen repositories.
amundsen-common>=0.3.6,<1.0 amundsen-common==0.5.6,<1.0
# Library for rest endpoints with Flask # Library for rest endpoints with Flask
# Upstream url: https://github.com/flask-restful/flask-restful # Upstream url: https://github.com/flask-restful/flask-restful
......
...@@ -373,6 +373,7 @@ class SearchDashboard(unittest.TestCase): ...@@ -373,6 +373,7 @@ class SearchDashboard(unittest.TestCase):
} }
self.expected_parsed_results = [ self.expected_parsed_results = [
{ {
'chart_names': [],
'cluster': 'cluster', 'cluster': 'cluster',
'description': 'I am a dashboard', 'description': 'I am a dashboard',
'group_name': 'Amundsen Team', 'group_name': 'Amundsen Team',
...@@ -386,6 +387,7 @@ class SearchDashboard(unittest.TestCase): ...@@ -386,6 +387,7 @@ class SearchDashboard(unittest.TestCase):
'url': 'product/name' 'url': 'product/name'
}, },
{ {
'chart_names': [],
'cluster': 'cluster', 'cluster': 'cluster',
'description': 'I am a second dashboard', 'description': 'I am a second dashboard',
'group_name': 'Amundsen Team', 'group_name': 'Amundsen Team',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment