Unverified Commit 3770023d authored by Allison Suarez Miranda's avatar Allison Suarez Miranda Committed by GitHub

fix: remove style from badges model (#683)

* removing temp badge change
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* changed badgelist logic
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* badge changes
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* fixing badges

* removed use of tem table
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* deleted temporary table
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* lint fixes
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* updated metadata foxture badge
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* updated betterer
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>
parent 6af0e138
...@@ -7,9 +7,8 @@ from typing import Any, Dict, List ...@@ -7,9 +7,8 @@ from typing import Any, Dict, List
from amundsen_common.models.dashboard import DashboardSummary, DashboardSummarySchema from amundsen_common.models.dashboard import DashboardSummary, DashboardSummarySchema
from amundsen_common.models.popular_table import PopularTable, PopularTableSchema from amundsen_common.models.popular_table import PopularTable, PopularTableSchema
# from amundsen_common.models.table import Table, TableSchema from amundsen_common.models.table import Table, TableSchema
from amundsen_application.models.user import load_user, dump_user from amundsen_application.models.user import load_user, dump_user
from amundsen_application.api.utils.temporary_table import Table, TableSchema
from amundsen_application.config import MatchRuleObject from amundsen_application.config import MatchRuleObject
from flask import current_app as app from flask import current_app as app
import re import re
......
# Copyright Contributors to the Amundsen project.
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# TODO remove after new badges in metadata and search @allisonsuarez
from typing import List, Optional
import attr
from amundsen_common.models.user import User
from marshmallow_annotations.ext.attrs import AttrsSchema
@attr.s(auto_attribs=True, kw_only=True)
class Reader:
user: User
read_count: int
class ReaderSchema(AttrsSchema):
class Meta:
target = Reader
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class Tag:
tag_type: Optional[str] = None
tag_name: Optional[str] = None
badge_name: Optional[str] = None
category: Optional[str] = None
badge_type: Optional[str] = None
class TagSchema(AttrsSchema):
class Meta:
target = Tag
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class Watermark:
watermark_type: Optional[str] = None
partition_key: Optional[str] = None
partition_value: Optional[str] = None
create_time: Optional[str] = None
class WatermarkSchema(AttrsSchema):
class Meta:
target = Watermark
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class Statistics:
stat_type: str
stat_val: Optional[str] = None
start_epoch: Optional[int] = None
end_epoch: Optional[int] = None
class StatisticsSchema(AttrsSchema):
class Meta:
target = Statistics
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class Column:
name: str
description: Optional[str] = None
col_type: str
sort_order: int
stats: List[Statistics] = []
class ColumnSchema(AttrsSchema):
class Meta:
target = Column
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class Application:
application_url: Optional[str] = None
description: Optional[str] = None
id: str
name: Optional[str] = None
kind: Optional[str] = None
class ApplicationSchema(AttrsSchema):
class Meta:
target = Application
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class Source:
source_type: str
source: str
class SourceSchema(AttrsSchema):
class Meta:
target = Source
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class ResourceReport:
name: str
url: str
class ResourceReportSchema(AttrsSchema):
class Meta:
target = ResourceReport
register_as_scheme = True
# this is a temporary hack to satisfy mypy. Once https://github.com/python/mypy/issues/6136 is resolved, use
# `attr.converters.default_if_none(default=False)`
def default_if_none(arg: Optional[bool]) -> bool:
return arg or False
@attr.s(auto_attribs=True, kw_only=True)
class ProgrammaticDescription:
source: str
text: str
class ProgrammaticDescriptionSchema(AttrsSchema):
class Meta:
target = ProgrammaticDescription
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class Table:
database: str
cluster: str
schema: str
name: str
tags: List[Tag] = []
badges: Optional[List[Tag]] = []
table_readers: List[Reader] = []
description: Optional[str] = None
columns: List[Column]
owners: List[User] = []
watermarks: List[Watermark] = []
table_writer: Optional[Application] = None
resource_reports: Optional[List[ResourceReport]] = None
last_updated_timestamp: Optional[int] = None
source: Optional[Source] = None
is_view: Optional[bool] = attr.ib(default=None, converter=default_if_none)
programmatic_descriptions: List[ProgrammaticDescription] = []
class TableSchema(AttrsSchema):
class Meta:
target = Table
register_as_scheme = True
@attr.s(auto_attribs=True, kw_only=True)
class TableSummary:
database: str = attr.ib()
cluster: str = attr.ib()
schema: str = attr.ib()
name: str = attr.ib()
description: Optional[str] = attr.ib(default=None)
schema_description: Optional[str] = attr.ib(default=None)
class TableSummarySchema(AttrsSchema):
class Meta:
target = TableSummary
register_as_scheme = True
...@@ -19,8 +19,8 @@ exports[`strict null compilation`] = { ...@@ -19,8 +19,8 @@ exports[`strict null compilation`] = {
[88, 4, 11, "Type \'Element\' is not assignable to type \'null\'.", "3768376622"], [88, 4, 11, "Type \'Element\' is not assignable to type \'null\'.", "3768376622"],
[91, 4, 11, "Type \'Element[]\' is not assignable to type \'null\'.", "3768376622"] [91, 4, 11, "Type \'Element[]\' is not assignable to type \'null\'.", "3768376622"]
], ],
"js/components/common/BadgeList/index.tsx:3472030733": [ "js/components/common/BadgeList/index.spec.tsx:3492368698": [
[32, 14, 4, "Type \'string | undefined\' is not assignable to type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "2087956376"] [48, 55, 16, "Argument of type \'string | undefined\' is not assignable to parameter of type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "340987603"]
], ],
"js/components/common/Bookmark/MyBookmarks/index.tsx:1185364658": [ "js/components/common/Bookmark/MyBookmarks/index.tsx:1185364658": [
[66, 6, 7, "Type \'Element | null\' is not assignable to type \'never\'.\\n Type \'null\' is not assignable to type \'never\'.", "3716929964"], [66, 6, 7, "Type \'Element | null\' is not assignable to type \'never\'.\\n Type \'null\' is not assignable to type \'never\'.", "3716929964"],
...@@ -74,9 +74,9 @@ exports[`strict null compilation`] = { ...@@ -74,9 +74,9 @@ exports[`strict null compilation`] = {
"js/components/common/ResourceListItem/DashboardListItem/index.spec.tsx:53357032": [ "js/components/common/ResourceListItem/DashboardListItem/index.spec.tsx:53357032": [
[163, 14, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"] [163, 14, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"]
], ],
"js/components/common/ResourceListItem/TableListItem/index.spec.tsx:1564573503": [ "js/components/common/ResourceListItem/TableListItem/index.spec.tsx:218296957": [
[161, 14, 18, "Type \'null\' is not assignable to type \'string | undefined\'.", "3750638477"], [161, 14, 18, "Type \'null\' is not assignable to type \'string | undefined\'.", "3750638477"],
[229, 14, 6, "Type \'null\' is not assignable to type \'any[] | undefined\'.", "1502764275"] [229, 14, 6, "Type \'null\' is not assignable to type \'Badge[] | undefined\'.", "1502764275"]
], ],
"js/components/common/ResourceListItem/UserListItem/index.tsx:942740425": [ "js/components/common/ResourceListItem/UserListItem/index.tsx:942740425": [
[29, 21, 49, "Argument of type \'Element\' is not assignable to parameter of type \'never\'.", "2430213531"], [29, 21, 49, "Argument of type \'Element\' is not assignable to parameter of type \'never\'.", "2430213531"],
......
...@@ -7,7 +7,7 @@ import { shallow } from 'enzyme'; ...@@ -7,7 +7,7 @@ import { shallow } from 'enzyme';
import ClickableBadge from 'components/common/Badges'; import ClickableBadge from 'components/common/Badges';
import { BadgeStyle } from 'config/config-types'; import { BadgeStyle } from 'config/config-types';
import * as ConfigUtils from 'config/config-utils'; import * as ConfigUtils from 'config/config-utils';
import { Badge, TagType } from 'interfaces/Tags'; import { Badge } from 'interfaces/Badges';
import BadgeList from '.'; import BadgeList from '.';
describe('BadgeList', () => { describe('BadgeList', () => {
...@@ -22,12 +22,12 @@ describe('BadgeList', () => { ...@@ -22,12 +22,12 @@ describe('BadgeList', () => {
describe('BadgeList function component', () => { describe('BadgeList function component', () => {
const badges: Badge[] = [ const badges: Badge[] = [
{ {
tag_name: 'test_1', badge_name: 'beta',
tag_type: TagType.BADGE, category: 'table_status',
}, },
{ {
tag_name: 'test_3', badge_name: 'Core Concepts',
tag_type: TagType.BADGE, category: 'coco',
}, },
]; ];
...@@ -46,7 +46,7 @@ describe('BadgeList', () => { ...@@ -46,7 +46,7 @@ describe('BadgeList', () => {
badges.forEach((badge, index) => { badges.forEach((badge, index) => {
const clickableBadge = badgeList.childAt(index); const clickableBadge = badgeList.childAt(index);
const clickableBadgeProps = clickableBadge.props(); const clickableBadgeProps = clickableBadge.props();
const badgeConfig = ConfigUtils.getBadgeConfig(badge.tag_name); const badgeConfig = ConfigUtils.getBadgeConfig(badge.badge_name);
expect(clickableBadgeProps.text).toEqual(badgeConfig.displayName); expect(clickableBadgeProps.text).toEqual(badgeConfig.displayName);
expect(clickableBadgeProps.labelStyle).toEqual(badgeConfig.style); expect(clickableBadgeProps.labelStyle).toEqual(badgeConfig.style);
}); });
......
...@@ -5,29 +5,25 @@ import * as React from 'react'; ...@@ -5,29 +5,25 @@ import * as React from 'react';
import ClickableBadge from 'components/common/Badges'; import ClickableBadge from 'components/common/Badges';
import { getBadgeConfig } from 'config/config-utils'; import { getBadgeConfig } from 'config/config-utils';
import { BadgeStyle } from 'config/config-types'; import { Badge } from 'interfaces/Badges';
import { Badge } from 'interfaces/Tags';
export interface BadgeListProps { export interface BadgeListProps {
badges: any[]; // TODO replace with new badges later @allisonsuarez badges: Badge[];
}
/*
* maps badge type to a badge style
*/
function mapBadgeStyle(badgeType: string): BadgeStyle {
if (badgeType === 'negative') return BadgeStyle.DANGER;
if (badgeType === 'positive') return BadgeStyle.SUCCESS;
if (badgeType === 'warning') return BadgeStyle.WARNING;
return BadgeStyle.DEFAULT;
} }
const BadgeList: React.FC<BadgeListProps> = ({ badges }: BadgeListProps) => { const BadgeList: React.FC<BadgeListProps> = ({ badges }: BadgeListProps) => {
return ( return (
<span className="badge-list"> <span className="badge-list">
{badges.map((badge, index) => { {badges.map((badge, index) => {
let badgeConfig;
// search badges with just name
if (badge.tag_name) { if (badge.tag_name) {
const badgeConfig = getBadgeConfig(badge.tag_name); badgeConfig = getBadgeConfig(badge.tag_name);
}
// metadata badges with name and category
else if (badge.badge_name) {
badgeConfig = getBadgeConfig(badge.badge_name);
}
return ( return (
<ClickableBadge <ClickableBadge
text={badgeConfig.displayName} text={badgeConfig.displayName}
...@@ -35,16 +31,6 @@ const BadgeList: React.FC<BadgeListProps> = ({ badges }: BadgeListProps) => { ...@@ -35,16 +31,6 @@ const BadgeList: React.FC<BadgeListProps> = ({ badges }: BadgeListProps) => {
key={`badge-${index}`} key={`badge-${index}`}
/> />
); );
}
if (badge.badge_name) {
return (
<ClickableBadge
text={badge.badge_name}
labelStyle={mapBadgeStyle(badge.badge_type)}
key={`badge-${index}`}
/>
);
}
})} })}
</span> </span>
); );
......
...@@ -39,7 +39,7 @@ describe('TableListItem', () => { ...@@ -39,7 +39,7 @@ describe('TableListItem', () => {
description: 'I am the description', description: 'I am the description',
key: '', key: '',
last_updated_timestamp: 1553829681, last_updated_timestamp: 1553829681,
badges: [{ tag_name: 'badgeName', tag_type: TagType.BADGE }], badges: [{ tag_name: 'badgeName' }],
name: 'tableName', name: 'tableName',
schema: 'tableSchema', schema: 'tableSchema',
schema_description: 'schemaDescription', schema_description: 'schemaDescription',
...@@ -136,7 +136,7 @@ describe('TableListItem', () => { ...@@ -136,7 +136,7 @@ describe('TableListItem', () => {
description: 'I am the description', description: 'I am the description',
key: '', key: '',
last_updated_timestamp: 1553829681, last_updated_timestamp: 1553829681,
badges: [{ tag_name: 'badgeName', tag_type: TagType.BADGE }], badges: [{ tag_name: 'badgeName' }],
name: 'tableName', name: 'tableName',
schema: 'tableSchema', schema: 'tableSchema',
schema_description: '', schema_description: '',
...@@ -156,7 +156,7 @@ describe('TableListItem', () => { ...@@ -156,7 +156,7 @@ describe('TableListItem', () => {
description: 'I am the description', description: 'I am the description',
key: '', key: '',
last_updated_timestamp: 1553829681, last_updated_timestamp: 1553829681,
badges: [{ tag_name: 'badgeName', tag_type: TagType.BADGE }], badges: [{ tag_name: 'badgeName' }],
name: 'tableName', name: 'tableName',
schema: 'tableSchema', schema: 'tableSchema',
schema_description: null, schema_description: null,
......
...@@ -3,13 +3,12 @@ import { ...@@ -3,13 +3,12 @@ import {
DashboardResource, DashboardResource,
ResourceType, ResourceType,
} from '../../interfaces'; } from '../../interfaces';
import { TagType } from '../../interfaces/Tags';
export const tableMetadata: TableMetadata = { export const tableMetadata: TableMetadata = {
badges: [ badges: [
{ {
tag_name: 'ga', badge_name: 'ga',
tag_type: TagType.BADGE, category: 'table_status',
}, },
], ],
cluster: 'gold', cluster: 'gold',
......
// Copyright Contributors to the Amundsen project.
// SPDX-License-Identifier: Apache-2.0
export interface Badge {
badge_name?: string;
category?: string;
tag_name?: string;
}
import { User } from 'interfaces/User'; import { User } from 'interfaces/User';
import { Tag } from 'interfaces/Tags'; import { Tag } from 'interfaces/Tags';
import { Badge } from 'interfaces/Badges';
import { TableReader } from 'interfaces/TableMetadata'; import { TableReader } from 'interfaces/TableMetadata';
import { TableResource, QueryResource } from 'interfaces/Resources'; import { TableResource, QueryResource } from 'interfaces/Resources';
export interface DashboardMetadata { export interface DashboardMetadata {
badges: Tag[]; badges: Badge[];
chart_names: string[]; chart_names: string[];
cluster: string; cluster: string;
created_timestamp: number; created_timestamp: number;
......
import { PeopleUser } from './User'; import { PeopleUser } from './User';
import { Badge } from './Badges';
export enum ResourceType { export enum ResourceType {
table = 'table', table = 'table',
...@@ -26,6 +27,7 @@ export interface DashboardResource extends Resource { ...@@ -26,6 +27,7 @@ export interface DashboardResource extends Resource {
url: string; url: string;
// Bookmark logic is cleaner if all resources can settle on either "key" or "uri" // Bookmark logic is cleaner if all resources can settle on either "key" or "uri"
key?: string; key?: string;
badges?: Badge[];
} }
export interface TableResource extends Resource { export interface TableResource extends Resource {
...@@ -39,7 +41,7 @@ export interface TableResource extends Resource { ...@@ -39,7 +41,7 @@ export interface TableResource extends Resource {
name: string; name: string;
schema: string; schema: string;
schema_description?: string; schema_description?: string;
badges?: any[]; // TODO replace with new badges later @allisonsuarez badges?: Badge[];
} }
export enum SortDirection { export enum SortDirection {
......
import { UpdateMethod } from './Enums'; import { UpdateMethod } from './Enums';
import { User } from './User'; import { User } from './User';
import { Badge } from './Tags'; import { Badge } from './Badges';
interface PartitionData { interface PartitionData {
is_partitioned: boolean; is_partitioned: boolean;
......
...@@ -7,7 +7,6 @@ export interface UpdateTagData { ...@@ -7,7 +7,6 @@ export interface UpdateTagData {
export enum TagType { export enum TagType {
TAG = 'default', TAG = 'default',
BADGE = 'badge',
} }
export interface Tag { export interface Tag {
...@@ -15,8 +14,3 @@ export interface Tag { ...@@ -15,8 +14,3 @@ export interface Tag {
tag_name: string; tag_name: string;
tag_type?: TagType.TAG; tag_type?: TagType.TAG;
} }
export interface Badge {
tag_name: string;
tag_type: TagType.BADGE;
}
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