cccs-RyanK commented on code in PR #20876: URL: https://github.com/apache/superset/pull/20876#discussion_r1047399076
########## superset-frontend/src/views/CRUD/tags/TagList.tsx: ########## @@ -0,0 +1,332 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { t } from '@superset-ui/core'; +import React, { useMemo, useCallback } from 'react'; +import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { + createFetchRelated, + createErrorHandler, + Actions, +} from 'src/views/CRUD/utils'; +import { useListViewResource } from 'src/views/CRUD/hooks'; +import ConfirmStatusChange from 'src/components/ConfirmStatusChange'; +import SubMenu, { SubMenuProps } from 'src/views/components/SubMenu'; +import ListView, { + ListViewProps, + Filters, + FilterOperator, +} from 'src/components/ListView'; +import { dangerouslyGetItemDoNotUse } from 'src/utils/localStorageHelpers'; +import withToasts from 'src/components/MessageToasts/withToasts'; +import Icons from 'src/components/Icons'; +import { Tooltip } from 'src/components/Tooltip'; +import FacePile from 'src/components/FacePile'; +import { Link } from 'react-router-dom'; +import { deleteTags } from 'src/tags'; +import { Tag as AntdTag } from 'antd'; +import { Tag } from '../types'; +import TagCard from './TagCard'; + +const PAGE_SIZE = 25; + +interface TagListProps { + addDangerToast: (msg: string) => void; + addSuccessToast: (msg: string) => void; + user: { + userId: string | number; + firstName: string; + lastName: string; + }; +} + +function TagList(props: TagListProps) { + const { + addDangerToast, + addSuccessToast, + user: { userId }, + } = props; + + const { + state: { + loading, + resourceCount: tagCount, + resourceCollection: tags, + bulkSelectEnabled, + }, + hasPerm, + fetchData, + toggleBulkSelect, + refreshData, + } = useListViewResource<Tag>('tag', t('tag'), addDangerToast); + + // TODO: Fix usage of localStorage keying on the user id + const userKey = dangerouslyGetItemDoNotUse(userId?.toString(), null); + + const canDelete = hasPerm('can_write'); + + const initialSort = [{ id: 'changed_on_delta_humanized', desc: true }]; + + function handleTagsDelete( + tags: Tag[], + callback: (text: string) => void, + error: (text: string) => void, + ) { + // TODO what permissions need to be checked here? + deleteTags(tags, callback, error); + refreshData(); + } + + const columns = useMemo( + () => [ + { + Cell: ({ + row: { + original: { name: tagName }, + }, + }: any) => ( Review Comment: The `any` typing on the Cells in the tables are consistent with the other CRUD views (ex: ChartList, DashboardList). Along with the typing on ListViewProps. I can update the typing to be more specific if you think that is best -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org