Skip to content
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

[RNMobile] Add paused media state handlers to Android bridge code #57476

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
573d7f0
Fix incorrect heading level in Editor curation docs (#57409)
ndiego Dec 28, 2023
970e925
NumberControl: Make increment and decrement buttons keyboard accessib…
afercia Dec 28, 2023
9c8001a
DataViews: update names for `DropdownMenuRadioItemCustom` (#57416)
oandregal Dec 28, 2023
3f6c738
Navigation Block: Use dom.focus for focus control (#57362)
t-hamano Dec 28, 2023
ec2c51d
DataViews: hide actions menu upon selecting a layout (#57418)
oandregal Dec 28, 2023
1f9b753
Server directive processing: Stop processing non-interactive blocks (…
cbravobernal Dec 28, 2023
1c79fd8
Performance: Avoid extra `useMarkPersistent` dispatch calls (#57435)
ntsekouras Dec 28, 2023
36396cc
Font Library: remove "has_font_mime_type" function (#57364)
HrithikDalal Dec 28, 2023
10facf1
Update modal description and button label (#57368)
HrithikDalal Dec 28, 2023
663916f
Update tutorial based on user feedback. (#57403)
ndiego Dec 28, 2023
83e1a2c
Change the slug for the theme.json doc to avoid conflicts (#57410)
ndiego Dec 28, 2023
6f6b083
Migrate 'allowed patterns' e2e tests to Playwright (#57399)
Mamaduka Dec 29, 2023
3591f4d
DataViews: fallback to `(no title)` if there's no rendered title (#57…
oandregal Dec 29, 2023
b85da47
DataViews: make fields dependant on view.type (#57450)
oandregal Dec 29, 2023
af8c530
DataViews: prevent unnecessary re-renders (#57452)
oandregal Dec 29, 2023
2888084
Docs/tutorial: Fix opposite condition for content generation in rende…
atachibana Dec 29, 2023
2dbd8a5
DataViews: prevent unnecessary renders for Pagination (#57454)
oandregal Dec 29, 2023
0d2bf01
Make the Replace featured image button perceivable by assistive techn…
afercia Dec 29, 2023
9431114
DataViews: memoize onSetSelection (#57458)
oandregal Dec 29, 2023
63a6321
Fix Template preview menu item accessibility. (#57456)
afercia Dec 30, 2023
fc36077
Migrate 'preferences' e2e tests to Playwright (#57446)
Mamaduka Dec 30, 2023
a87f24e
Migrate remaining 'publish panel' e2e tests to Playwright (#57432)
Mamaduka Jan 1, 2024
06b5fa5
Core Data: Pass the 'options' argument to data action shortcuts (#57383)
Mamaduka Jan 1, 2024
4eb3b74
Editor: Unify the DocumentTools component (#57214)
youknowriad Jan 1, 2024
18dd101
Avoid using a memoized selector without dependencies (#57257)
youknowriad Jan 1, 2024
1014dc6
Quality: avoid React warning when changing rendering mode (#57413)
t-hamano Jan 1, 2024
31e67ea
Global style revisions: move change summary code and tests to block e…
ramonjd Jan 2, 2024
5831320
Adding padding to entity save panel header (#57471)
ramonjd Jan 2, 2024
3c80f02
use a classname instead of the element in case a strong element is pa…
ramonjd Jan 2, 2024
f70554c
Passed progress values to failed media uploads and add paused media h…
derekblank Jan 2, 2024
2d43054
Migrate 'sidebar' e2e tests to Playwright (#57448)
Mamaduka Jan 2, 2024
0aabb54
Add onMediaFileSavePaused handler
derekblank Jan 2, 2024
f364b68
[RNMobile] Auto-scroll upon block insertion (#57273)
fluiddot Jan 2, 2024
9e0747e
Add individual headings to the elements translations (#57472)
ramonjd Jan 2, 2024
7ebb55c
DataViews: Use in patterns page (#57333)
ntsekouras Jan 2, 2024
1ed7ba2
[Mobile] Unselect blocks using the hardware back button (Android) (#5…
Jan 2, 2024
50a8314
Remove deprecated `behaviors` syntax (#57165)
michalczaplinski Jan 2, 2024
60bf21e
Add `compact` size variant to InputControl-based components (#57398)
mirka Jan 2, 2024
1b2dac7
Block editor: give iframe fallback background color (#57330)
ramonjd Jan 2, 2024
45dc4b1
Background image block support: Add tests for size and repeat output …
andrewserong Jan 2, 2024
78f28c1
Update paused handlers from merge
derekblank Jan 3, 2024
a33a090
Merge branch 'rnmobile/media-upload-progress-connection-subscription'…
derekblank Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DataViews: Use in patterns page (#57333)
* DataViews: Use in patterns page

* add export JSON action

* add rename action

* add delete and reset actions

* remove comments
  • Loading branch information
ntsekouras authored Jan 2, 2024
commit 7ebb55ca27e7bdf6275e73ff75de608158127533
7 changes: 6 additions & 1 deletion packages/edit-site/src/components/page-main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
* Internal dependencies
*/
import PagePatterns from '../page-patterns';
import DataviewsPatterns from '../page-patterns/dataviews-patterns';
import PageTemplateParts from '../page-template-parts';
import PageTemplates from '../page-templates';
import PagePages from '../page-pages';
Expand All @@ -24,7 +25,11 @@ export default function PageMain() {
} else if ( path === '/wp_template_part/all' ) {
return <PageTemplateParts />;
} else if ( path === '/patterns' ) {
return <PagePatterns />;
return window?.__experimentalAdminViews ? (
<DataviewsPatterns />
) : (
<PagePatterns />
);
} else if ( window?.__experimentalAdminViews && path === '/pages' ) {
return <PagePages />;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
/**
* External dependencies
*/
import { paramCase as kebabCase } from 'change-case';

/**
* WordPress dependencies
*/
import { downloadBlob } from '@wordpress/blob';
import { __, sprintf } from '@wordpress/i18n';
import {
Button,
TextControl,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalText as Text,
} from '@wordpress/components';
import { store as coreStore } from '@wordpress/core-data';
import { useDispatch } from '@wordpress/data';
import { useState } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
import { decodeEntities } from '@wordpress/html-entities';
import { store as reusableBlocksStore } from '@wordpress/reusable-blocks';

/**
* Internal dependencies
*/
import { store as editSiteStore } from '../../store';
import { PATTERN_TYPES, TEMPLATE_PART_POST_TYPE } from '../../utils/constants';

export const exportJSONaction = {
id: 'export-pattern',
label: __( 'Export as JSON' ),
isEligible: ( item ) => item.type === PATTERN_TYPES.user,
callback: ( item ) => {
const json = {
__file: item.type,
title: item.title || item.name,
content: item.patternBlock.content.raw,
syncStatus: item.patternBlock.wp_pattern_sync_status,
};
return downloadBlob(
`${ kebabCase( item.title || item.name ) }.json`,
JSON.stringify( json, null, 2 ),
'application/json'
);
},
};

export const renameAction = {
id: 'rename-pattern',
label: __( 'Rename' ),
isEligible: ( item ) => {
const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
const isUserPattern = item.type === PATTERN_TYPES.user;
const isCustomPattern =
isUserPattern || ( isTemplatePart && item.isCustom );
const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;
return isCustomPattern && ! hasThemeFile;
},
RenderModal: ( { item, closeModal } ) => {
const [ title, setTitle ] = useState( () => item.title );
const { editEntityRecord, saveEditedEntityRecord } =
useDispatch( coreStore );
const { createSuccessNotice, createErrorNotice } =
useDispatch( noticesStore );
async function onRename( event ) {
event.preventDefault();
try {
await editEntityRecord( 'postType', item.type, item.id, {
title,
} );
// Update state before saving rerenders the list.
setTitle( '' );
closeModal();
// Persist edited entity.
await saveEditedEntityRecord( 'postType', item.type, item.id, {
throwOnError: true,
} );
createSuccessNotice(
item.type === TEMPLATE_PART_POST_TYPE
? __( 'Template part renamed.' )
: __( 'Pattern renamed.' ),
{ type: 'snackbar' }
);
} catch ( error ) {
const fallbackErrorMessage =
item.type === TEMPLATE_PART_POST_TYPE
? __(
'An error occurred while renaming the template part.'
)
: __( 'An error occurred while renaming the pattern.' );
const errorMessage =
error.message && error.code !== 'unknown_error'
? error.message
: fallbackErrorMessage;
createErrorNotice( errorMessage, { type: 'snackbar' } );
}
}
return (
<form onSubmit={ onRename }>
<VStack spacing="5">
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
required
/>
<HStack justify="right">
<Button
__next40pxDefaultSize
variant="tertiary"
onClick={ () => {
closeModal();
} }
>
{ __( 'Cancel' ) }
</Button>
<Button
__next40pxDefaultSize
variant="primary"
type="submit"
>
{ __( 'Save' ) }
</Button>
</HStack>
</VStack>
</form>
);
},
};

const canDeleteOrReset = ( item ) => {
const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
const isUserPattern = item.type === PATTERN_TYPES.user;
return isUserPattern || ( isTemplatePart && item.isCustom );
};

export const deleteAction = {
id: 'delete-pattern',
label: __( 'Delete' ),
isEligible: ( item ) => {
const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;
return canDeleteOrReset( item ) && ! hasThemeFile;
},
hideModalHeader: true,
RenderModal: ( { item, closeModal } ) => {
const { __experimentalDeleteReusableBlock } =
useDispatch( reusableBlocksStore );
const { createErrorNotice, createSuccessNotice } =
useDispatch( noticesStore );
const { removeTemplate } = useDispatch( editSiteStore );

const deletePattern = async () => {
try {
await __experimentalDeleteReusableBlock( item.id );
createSuccessNotice(
sprintf(
// translators: %s: The pattern's title e.g. 'Call to action'.
__( '"%s" deleted.' ),
item.title
),
{ type: 'snackbar', id: 'edit-site-patterns-success' }
);
} catch ( error ) {
const errorMessage =
error.message && error.code !== 'unknown_error'
? error.message
: __( 'An error occurred while deleting the pattern.' );
createErrorNotice( errorMessage, {
type: 'snackbar',
id: 'edit-site-patterns-error',
} );
}
};
const deleteItem = () =>
item.type === TEMPLATE_PART_POST_TYPE
? removeTemplate( item )
: deletePattern();
return (
<VStack spacing="5">
<Text>
{ sprintf(
// translators: %s: The pattern or template part's title e.g. 'Call to action'.
__( 'Are you sure you want to delete "%s"?' ),
decodeEntities( item.title || item.name )
) }
</Text>
<HStack justify="right">
<Button variant="tertiary" onClick={ closeModal }>
{ __( 'Cancel' ) }
</Button>
<Button variant="primary" onClick={ deleteItem }>
{ __( 'Delete' ) }
</Button>
</HStack>
</VStack>
);
},
};

export const resetAction = {
id: 'reset-action',
label: __( 'Clear customizations' ),
isEligible: ( item ) => {
const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;
return canDeleteOrReset( item ) && hasThemeFile;
},
hideModalHeader: true,
RenderModal: ( { item, closeModal } ) => {
const { removeTemplate } = useDispatch( editSiteStore );
return (
<VStack spacing="5">
<Text>
{ __(
'Are you sure you want to clear these customizations?'
) }
</Text>
<HStack justify="right">
<Button variant="tertiary" onClick={ closeModal }>
{ __( 'Cancel' ) }
</Button>
<Button
variant="primary"
onClick={ () => removeTemplate( item ) }
>
{ __( 'Clear' ) }
</Button>
</HStack>
</VStack>
);
},
};
Loading
Loading