-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(tags): Update loading + pagination for Tags Page #25473
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ | |
import React, { useEffect, useState } from 'react'; | ||
import { styled, t, css, SupersetTheme } from '@superset-ui/core'; | ||
import { NumberParam, useQueryParam } from 'use-query-params'; | ||
import AllEntitiesTable from 'src/features/allEntities/AllEntitiesTable'; | ||
import AllEntitiesTable, { | ||
TaggedObjects, | ||
} from 'src/features/allEntities/AllEntitiesTable'; | ||
import Button from 'src/components/Button'; | ||
import MetadataBar, { | ||
MetadataType, | ||
|
@@ -28,10 +30,23 @@ import MetadataBar, { | |
LastModified, | ||
} from 'src/components/MetadataBar'; | ||
import { PageHeaderWithActions } from 'src/components/PageHeaderWithActions'; | ||
import { fetchSingleTag } from 'src/features/tags/tags'; | ||
import { Tag } from 'src/views/CRUD/types'; | ||
import TagModal from 'src/features/tags/TagModal'; | ||
import withToasts, { useToasts } from 'src/components/MessageToasts/withToasts'; | ||
import { fetchObjects, fetchSingleTag } from 'src/features/tags/tags'; | ||
import Loading from 'src/components/Loading'; | ||
|
||
interface TaggedObject { | ||
id: number; | ||
type: string; | ||
name: string; | ||
url: string; | ||
changed_on: moment.MomentInput; | ||
created_by: number | undefined; | ||
creator: string; | ||
owners: Owner[]; | ||
tags: Tag[]; | ||
} | ||
|
||
const additionalItemsStyles = (theme: SupersetTheme) => css` | ||
display: flex; | ||
|
@@ -59,6 +74,9 @@ const AllEntitiesContainer = styled.div` | |
.entities { | ||
margin: ${theme.gridUnit * 6}px; 0px; | ||
} | ||
.pagination-container { | ||
background-color: transparent; | ||
} | ||
`} | ||
`; | ||
|
||
|
@@ -88,6 +106,12 @@ function AllEntities() { | |
const [tag, setTag] = useState<Tag | null>(null); | ||
const [showTagModal, setShowTagModal] = useState<boolean>(false); | ||
const { addSuccessToast, addDangerToast } = useToasts(); | ||
const [isLoading, setLoading] = useState<boolean>(false); | ||
const [objects, setObjects] = useState<TaggedObjects>({ | ||
dashboard: [], | ||
chart: [], | ||
query: [], | ||
}); | ||
|
||
const editableTitleProps = { | ||
title: tag?.name || '', | ||
|
@@ -114,21 +138,49 @@ function AllEntities() { | |
}; | ||
const items = [description, owner, lastModified]; | ||
|
||
const fetchTaggedObjects = () => { | ||
setLoading(true); | ||
fetchObjects( | ||
{ tags: tag?.name || '', types: null }, | ||
(data: TaggedObject[]) => { | ||
const objects = { dashboard: [], chart: [], query: [] }; | ||
data.forEach(function (object) { | ||
const object_type = object.type; | ||
objects[object_type].push(object); | ||
}); | ||
setObjects(objects); | ||
setLoading(false); | ||
}, | ||
(error: Response) => { | ||
addDangerToast('Error Fetching Tagged Objects'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you might need to add |
||
setLoading(false); | ||
}, | ||
); | ||
}; | ||
|
||
useEffect(() => { | ||
// fetch single tag met | ||
if (tagId) { | ||
setLoading(true); | ||
fetchSingleTag( | ||
tagId, | ||
(tag: Tag) => { | ||
setTag(tag); | ||
setLoading(false); | ||
}, | ||
(error: Response) => { | ||
addDangerToast(t('Error Fetching Tagged Objects')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
setLoading(false); | ||
}, | ||
); | ||
} | ||
}, [tagId]); | ||
|
||
useEffect(() => { | ||
if (tag) fetchTaggedObjects(); | ||
}, [tag]); | ||
|
||
if (isLoading) return <Loading />; | ||
return ( | ||
<AllEntitiesContainer> | ||
<TagModal | ||
|
@@ -139,7 +191,7 @@ function AllEntities() { | |
editTag={tag} | ||
addSuccessToast={addSuccessToast} | ||
addDangerToast={addDangerToast} | ||
refreshData={() => {}} // todo(hugh): implement refreshData on table reload | ||
refreshData={fetchTaggedObjects} | ||
/> | ||
<AllEntitiesNav> | ||
<PageHeaderWithActions | ||
|
@@ -174,6 +226,7 @@ function AllEntities() { | |
<AllEntitiesTable | ||
search={tag?.name || ''} | ||
setShowTagModal={setShowTagModal} | ||
objects={objects} | ||
/> | ||
</div> | ||
</AllEntitiesContainer> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be 50, like before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
design wants this to be 10 since there are 3 tables on the 1 page