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

feat: accept new badges (#669)

* general badges change
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* added temporary table to use in FE in order to accomodate to different types of badges
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* accepts both badges
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

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

* added more TODOs and @s
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

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

* added license comment
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

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

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

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

* moved mapping of stylee
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>

* removed export
Signed-off-by: 's avatarAllison Suarez Miranda <asuarezmiranda@lyft.com>
parent ad5521d5
......@@ -7,8 +7,9 @@ from typing import Any, Dict, List
from amundsen_common.models.dashboard import DashboardSummary, DashboardSummarySchema
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.api.utils.temporary_table import Table, TableSchema
from amundsen_application.config import MatchRuleObject
from flask import current_app as app
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
......@@ -5,25 +5,46 @@ import * as React from 'react';
import ClickableBadge from 'components/common/Badges';
import { getBadgeConfig } from 'config/config-utils';
import { BadgeStyle } from 'config/config-types';
import { Badge } from 'interfaces/Tags';
export interface BadgeListProps {
badges: Badge[];
badges: any[]; // TODO replace with new badges later @allisonsuarez
}
/*
* 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) => {
return (
<span className="badge-list">
{badges.map((badge, index) => {
const badgeConfig = getBadgeConfig(badge.tag_name);
return (
<ClickableBadge
text={badgeConfig.displayName}
labelStyle={badgeConfig.style}
key={`badge-${index}`}
/>
);
if (badge.tag_name) {
const badgeConfig = getBadgeConfig(badge.tag_name);
return (
<ClickableBadge
text={badgeConfig.displayName}
labelStyle={badgeConfig.style}
key={`badge-${index}`}
/>
);
}
if (badge.badge_name) {
return (
<ClickableBadge
text={badge.badge_name}
labelStyle={mapBadgeStyle(badge.badge_type)}
key={`badge-${index}`}
/>
);
}
})}
</span>
);
......
import { PeopleUser } from './User';
import { Badge } from './Tags';
export enum ResourceType {
table = 'table',
......@@ -40,7 +39,7 @@ export interface TableResource extends Resource {
name: string;
schema: string;
schema_description?: string;
badges?: Badge[];
badges?: any[]; // TODO replace with new badges later @allisonsuarez
}
export interface UserResource extends Resource, PeopleUser {
......
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