-
Notifications
You must be signed in to change notification settings - Fork 843
Social: Update share status modal to use Dataviews component #39230
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
Merged
manzoorwanijk
merged 11 commits into
trunk
from
update/social-share-status-modal-to-use-dataviews
Sep 6, 2024
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6d85fac
Add @wordpress/dataviews as a dependency
manzoorwanijk 1ea7f08
Create and use the dataview component
manzoorwanijk e63e6cf
Do some makeup
manzoorwanijk 9ac2fe0
Render and clean up
manzoorwanijk eb73df1
Add changelog
manzoorwanijk 066684f
Copy paste clean up from previous PR
manzoorwanijk 03762fb
Pass data from parent to avoid duplication
manzoorwanijk 1aba079
Merge branch 'trunk' into update/social-share-status-modal-to-use-dat…
manzoorwanijk 830355b
Use only the styles from dataviews for now
manzoorwanijk 21fcc9a
Restore link styles
manzoorwanijk 331b18c
Add a comment about the color
manzoorwanijk 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...packages/publicize-components/changelog/update-social-share-status-modal-to-use-dataviews
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: added | ||
|
|
||
| Updated share status modal to use dataviews |
This file contains hidden or 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
43 changes: 0 additions & 43 deletions
43
projects/js-packages/publicize-components/src/components/share-status/share-info.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
99 changes: 99 additions & 0 deletions
99
projects/js-packages/publicize-components/src/components/share-status/shares-dataview.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { DataViews } from '@wordpress/dataviews'; | ||
| import { getDate, humanTimeDiff } from '@wordpress/date'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { PostShareStatus, ShareStatusItem } from '../../social-store/types'; | ||
| import ConnectionIcon from '../connection-icon'; | ||
| import { ShareStatusAction } from './share-status-action'; | ||
| import { ShareStatusLabel } from './share-status-label'; | ||
| import styles from './styles.module.scss'; | ||
|
|
||
| const getItemId = ( item: ShareStatusItem ) => { | ||
| return `${ item.external_id || item.connection_id }:${ item.timestamp }`; | ||
| }; | ||
|
|
||
| const noop = () => {}; | ||
|
|
||
| type SharesDataViewProps = { | ||
| postShareStatus: PostShareStatus; | ||
| }; | ||
|
|
||
| /** | ||
| * The component for the shares data view. | ||
| * | ||
| * @param {SharesDataViewProps} props - The component props. | ||
| * | ||
| * @return {import('react').ReactNode} - The shares data view component. | ||
| */ | ||
| export function SharesDataView( { postShareStatus }: SharesDataViewProps ) { | ||
| return ( | ||
| <div className={ styles[ 'dataview-wrapper' ] }> | ||
| <DataViews | ||
| isLoading={ postShareStatus.loading } | ||
| getItemId={ getItemId } | ||
| fields={ [ | ||
| { | ||
| id: 'connection', | ||
| label: __( 'Connection', 'jetpack' ), | ||
| render: ( { item } ) => ( | ||
| <div className={ styles[ 'connection-name' ] }> | ||
| <ConnectionIcon | ||
| serviceName={ item.service } | ||
| label={ item.external_name } | ||
| profilePicture={ item.profile_picture } | ||
| /> | ||
| <div className={ styles[ 'share-item-name-wrapper' ] }> | ||
| <div className={ styles[ 'share-item-name' ] }>{ item.external_name }</div> | ||
| </div> | ||
| </div> | ||
| ), | ||
| enableSorting: false, | ||
| enableHiding: false, | ||
| }, | ||
| { | ||
| id: 'timestamp', | ||
| label: __( 'Time', 'jetpack' ), | ||
| render: ( { item } ) => { | ||
| return humanTimeDiff( | ||
| // @ts-expect-error - humanTimeDiff is incorrectly typed, first argument can be a timestamp | ||
| item.timestamp * 1000, | ||
| getDate( null ) | ||
| ); | ||
| }, | ||
| enableSorting: false, | ||
| enableHiding: false, | ||
| }, | ||
| { | ||
| id: 'status', | ||
| label: __( 'Status', 'jetpack' ), | ||
| render: ( { item } ) => ( | ||
| <ShareStatusLabel status={ item.status } message={ item.message } /> | ||
| ), | ||
| enableSorting: false, | ||
| enableHiding: false, | ||
| }, | ||
| { | ||
| id: 'actions', | ||
| label: __( 'Actions', 'jetpack' ), | ||
| render: ( { item } ) => ( | ||
| <ShareStatusAction | ||
| connectionId={ item.connection_id } | ||
| status={ item.status } | ||
| shareLink={ 'success' === item.status ? item.message : '' } | ||
| /> | ||
| ), | ||
| enableSorting: false, | ||
| enableHiding: false, | ||
| }, | ||
| ] } | ||
| data={ postShareStatus.shares } | ||
| view={ { type: 'table' } } | ||
| defaultLayouts={ { table: {} } } | ||
| onChangeView={ noop } | ||
| paginationInfo={ { | ||
| totalItems: postShareStatus.shares.length, | ||
| totalPages: 1, | ||
| } } | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or 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
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.
I think it would be better to call this
Shared ator something similarThere 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.
Then the continuation of the sentence doesn't read nice "Shared at 2 minutes ago", where as, "Time" can be read as its own clause.
Uh oh!
There was an error while loading. Please reload this page.
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.
To me, time feels too vague, also I looked up on the designs it's 'Published at' on the admin page, maybe that's where I got the idea from :D I think Shared at still makes more sense than published at. Either way we should use the same term here and there in the future, even if that's time
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.
But what about the case of failure? We can't say "Shared at".
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.
That's a point we have to make on the admin page designs too, but let's leave time now then