diff --git a/catalog-rest-service/src/main/resources/ui/src/AppState.ts b/catalog-rest-service/src/main/resources/ui/src/AppState.ts index d98bc37f51d..d5f5d82894c 100644 --- a/catalog-rest-service/src/main/resources/ui/src/AppState.ts +++ b/catalog-rest-service/src/main/resources/ui/src/AppState.ts @@ -17,14 +17,8 @@ import { makeAutoObservable } from 'mobx'; import { ClientAuth, NewUser } from 'Models'; -import { - EntityReference as UserTeams, - User, -} from './generated/entity/teams/user'; - -type UserTeam = { - displayName?: string; -} & UserTeams; +import { User } from './generated/entity/teams/user'; +import { UserTeam } from './interface/team.interface'; class AppState { users: Array = []; diff --git a/catalog-rest-service/src/main/resources/ui/src/interface/team.interface.ts b/catalog-rest-service/src/main/resources/ui/src/interface/team.interface.ts new file mode 100644 index 00000000000..cf3b94eab0c --- /dev/null +++ b/catalog-rest-service/src/main/resources/ui/src/interface/team.interface.ts @@ -0,0 +1,5 @@ +import { EntityReference as UserTeams } from '../generated/entity/teams/user'; + +export interface UserTeam extends UserTeams { + displayName?: string; +} diff --git a/catalog-rest-service/src/main/resources/ui/src/interface/types.d.ts b/catalog-rest-service/src/main/resources/ui/src/interface/types.d.ts index c5f9d2ed2ae..97ad455214a 100644 --- a/catalog-rest-service/src/main/resources/ui/src/interface/types.d.ts +++ b/catalog-rest-service/src/main/resources/ui/src/interface/types.d.ts @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - declare module 'Models' { import { TagLabel } from '../generated/type/tagLabel'; @@ -295,6 +294,7 @@ declare module 'Models' { users: Array; owns: Array; }; + export type ServiceCollection = { name: string; value: string; diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/tags/Form.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/tags/Form.tsx index debb62e67c2..1fb42983d0e 100644 --- a/catalog-rest-service/src/main/resources/ui/src/pages/tags/Form.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/pages/tags/Form.tsx @@ -24,17 +24,24 @@ import React, { useState, } from 'react'; import MarkdownWithPreview from '../../components/common/editor/MarkdownWithPreview'; -import { TagsCategory } from './tagsTypes'; +import { CreateTagCategory } from '../../generated/api/tags/createTagCategory'; + +type CustomTagCategory = { + categoryType: string; + description: CreateTagCategory['description']; + name: CreateTagCategory['name']; +}; + type FormProp = { - saveData: (value: {}) => void; - initialData: TagsCategory; + saveData: (value: CreateTagCategory) => void; + initialData: CustomTagCategory; }; type EditorContentRef = { getEditorContent: () => string; }; const Form: React.FC = forwardRef( ({ saveData, initialData }, ref): JSX.Element => { - const [data, setData] = useState({ + const [data, setData] = useState({ name: initialData.name, description: initialData.description, categoryType: initialData.categoryType, @@ -60,7 +67,7 @@ const Form: React.FC = forwardRef( useEffect(() => { saveData({ - ...data, + ...(data as CreateTagCategory), }); }, [data]); @@ -75,8 +82,8 @@ const Form: React.FC = forwardRef( { - const [categories, setCategoreis] = useState>([]); - const [currentCategory, setCurrentCategory] = useState(); + const [categories, setCategoreis] = useState>([]); + const [currentCategory, setCurrentCategory] = useState(); const [isEditCategory, setIsEditCategory] = useState(false); const [isAddingCategory, setIsAddingCategory] = useState(false); const [isEditTag, setIsEditTag] = useState(false); const [isAddingTag, setIsAddingTag] = useState(false); - const [editTag, setEditTag] = useState(); + const [editTag, setEditTag] = useState(); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); @@ -95,7 +100,7 @@ const TagsPage = () => { } }; - const createCategory = (data: TagsCategory) => { + const createCategory = (data: CreateTagCategory) => { createTagCategory(data).then((res: AxiosResponse) => { if (res.data) { fetchCategories(); @@ -117,7 +122,7 @@ const TagsPage = () => { setIsEditCategory(false); }; - const createPrimaryTag = (data: TagsCategory) => { + const createPrimaryTag = (data: TagCategory) => { createTag(currentCategory?.name, { name: data.name, description: data.description, @@ -189,7 +194,7 @@ const TagsPage = () => { {categories && - categories.map((category: TagsCategory) => ( + categories.map((category: TagCategory) => (
{ - {currentCategory?.children?.map( - (tag: Tag, index: number) => { + {(currentCategory?.children as TagClass[])?.map( + (tag: TagClass, index: number) => { return ( { {tag.usageCount} @@ -388,11 +393,11 @@ const TagsPage = () => { editable={ editTag?.name === tag.name && !isEditTag } - selectedTags={tag.associatedTags.map( - (tag) => ({ + selectedTags={ + tag.associatedTags?.map((tag) => ({ tagFQN: tag, - }) - )} + })) || [] + } tagList={ getTaglist(categories) as Array } @@ -402,7 +407,7 @@ const TagsPage = () => { onSelectionChange={(tags) => { handleTagSelection(tags); }}> - {tag.associatedTags.length ? ( + {tag.associatedTags?.length ? (
diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/teams/AddUsersModal.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/teams/AddUsersModal.tsx index eedd6f135c3..517b6461da1 100644 --- a/catalog-rest-service/src/main/resources/ui/src/pages/teams/AddUsersModal.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/pages/teams/AddUsersModal.tsx @@ -1,13 +1,9 @@ import React, { useState } from 'react'; import { Button } from '../../components/buttons/Button/Button'; import Searchbar from '../../components/common/searchbar/Searchbar'; -import { EntityReference as UserTeams } from '../../generated/entity/teams/user'; +import { UserTeam } from '../../interface/team.interface'; import UserCard from './UserCard'; -type UserTeam = { - displayName?: string; -} & UserTeams; - type Props = { header: string; list: Array; diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/teams/index.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/teams/index.tsx index 3b8724b2d04..a321ea26510 100644 --- a/catalog-rest-service/src/main/resources/ui/src/pages/teams/index.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/pages/teams/index.tsx @@ -40,20 +40,14 @@ import { TITLE_FOR_NON_ADMIN_ACTION, } from '../../constants/constants'; import { Team } from '../../generated/entity/teams/team'; -import { - EntityReference as UserTeams, - User, -} from '../../generated/entity/teams/user'; +import { User } from '../../generated/entity/teams/user'; +import { UserTeam } from '../../interface/team.interface'; import { getCountBadge } from '../../utils/CommonUtils'; import SVGIcons from '../../utils/SvgUtils'; import AddUsersModal from './AddUsersModal'; import Form from './Form'; import UserCard from './UserCard'; -type UserTeam = { - displayName?: string; -} & UserTeams; - const TeamsPage = () => { const [teams, setTeams] = useState>([]); const [currentTeam, setCurrentTeam] = useState(); diff --git a/catalog-rest-service/src/main/resources/ui/src/utils/CommonUtils.tsx b/catalog-rest-service/src/main/resources/ui/src/utils/CommonUtils.tsx index a8fb6c9f620..18354ba4c76 100644 --- a/catalog-rest-service/src/main/resources/ui/src/utils/CommonUtils.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/utils/CommonUtils.tsx @@ -7,13 +7,9 @@ import { LOCALSTORAGE_RECENTLY_VIEWED, TITLE_FOR_NON_OWNER_ACTION, } from '../constants/constants'; -import { EntityReference as UserTeams } from '../generated/entity/teams/user'; +import { UserTeam } from '../interface/team.interface'; import { countBackground } from './styleconstant'; -type UserTeam = { - displayName?: string; -} & UserTeams; - export const arraySorterByKey = ( key: string, sortDescending = false diff --git a/catalog-rest-service/src/main/resources/ui/src/utils/TagsUtils.ts b/catalog-rest-service/src/main/resources/ui/src/utils/TagsUtils.ts index fbeb92f1229..dd7bfa868eb 100644 --- a/catalog-rest-service/src/main/resources/ui/src/utils/TagsUtils.ts +++ b/catalog-rest-service/src/main/resources/ui/src/utils/TagsUtils.ts @@ -2,13 +2,13 @@ import { AxiosError, AxiosPromise, AxiosResponse } from 'axios'; import { flatten } from 'lodash'; import { ColumnTags, TableColumn } from 'Models'; import { getCategory, getTags } from '../axiosAPIs/tagAPI'; -import { TagsCategory } from '../pages/tags/tagsTypes'; +import { TagCategory, TagClass } from '../generated/entity/tags/tagCategory'; export const getTagCategories = async (fields?: Array | string) => { try { - let listOfCategories: Array = []; + let listOfCategories: Array = []; const categories = await getTags(fields); - const categoryList = categories.data.data.map((category: TagsCategory) => { + const categoryList = categories.data.data.map((category: TagCategory) => { return { name: category.name, description: category.description, @@ -16,7 +16,7 @@ export const getTagCategories = async (fields?: Array | string) => { }); if (categoryList.length) { let promiseArr: Array = []; - promiseArr = categoryList.map((category: TagsCategory) => { + promiseArr = categoryList.map((category: TagCategory) => { return getCategory(category.name, fields); }); @@ -40,13 +40,13 @@ export const getTagCategories = async (fields?: Array | string) => { } }; -export const getTaglist = (categories: Array): Array => { - const children = categories.map((category: TagsCategory) => { +export const getTaglist = (categories: Array): Array => { + const children = categories.map((category: TagCategory) => { return category.children || []; }); const allChildren = flatten(children); - const tagList = allChildren?.map((tag) => { - return tag?.fullyQualifiedName; + const tagList = (allChildren as unknown as TagClass[])?.map((tag) => { + return tag?.fullyQualifiedName || ''; }); return tagList;