Skip to content

Commit

Permalink
✨ Add post metadata override section in sidebar (#253)
Browse files Browse the repository at this point in the history
* ✨ Add post metadata override section in sidebar

* 💄 Put metadata override under "Advanced" panel
  • Loading branch information
williamchong authored May 15, 2023
1 parent 553d0cf commit d75487c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion likecoin/assets/js/sidebar/index.asset.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php return array(
'dependencies' => array( 'react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-wordcount' ),
'version' => 'ed3271099c71596f9743',
'version' => 'b67094d4d96b1230990a',
);
2 changes: 1 addition & 1 deletion likecoin/assets/js/sidebar/index.js

Large diffs are not rendered by default.

40 changes: 33 additions & 7 deletions likecoin/js/sidebar/src/pages/LikeCoinPluginSideBar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { PluginSidebar } from '@wordpress/edit-post';
import { useState, useEffect } from 'react';
import { useSelect, useDispatch } from '@wordpress/data';
import { CheckboxControl } from '@wordpress/components';
import {
CheckboxControl, TextControl, Panel, PanelBody, PanelRow,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { count as wordCount } from '@wordpress/wordcount';
import { ISCN_INFO_STORE_NAME } from '../store/iscn-info-store';
Expand All @@ -22,7 +24,11 @@ const { likecoHost, likerlandHost } = window.wpApiSettings;

function LikeCoinPluginSideBar(props) {
const content = useSelect((select) => select('core/editor').getEditedPostAttribute('content'));
const { setISCNLicense } = useDispatch(ISCN_INFO_STORE_NAME);
const {
postISCNInfoData,
postArweaveInfoData,
setISCNLicense,
} = useDispatch(ISCN_INFO_STORE_NAME);
const iscnLicense = useSelect((select) => select(ISCN_INFO_STORE_NAME).getLicense());
const {
isWidgetEnabled: isEnabledButton,
Expand Down Expand Up @@ -138,7 +144,7 @@ function LikeCoinPluginSideBar(props) {
className='blueBackgroundWhiteTextBtn'
onClick={props.handleNFTAction}
>
{ props.NFTClassId ? __('View NFT', 'likecoin') : __('Mint NFT', 'likecoin')}
{props.NFTClassId ? __('View NFT', 'likecoin') : __('Mint NFT', 'likecoin')}
</button>
</div>
</div>
Expand Down Expand Up @@ -187,10 +193,10 @@ function LikeCoinPluginSideBar(props) {
<div className='divOuterHolderMainSidebar'>
<StatusTitle title={__('Widget', 'likecoin')} />
<CheckboxControl
label={__('Enable in-post widget', 'likecoin')}
help={__('Embed widget in this post (Overrides site setting)', 'likecoin')}
checked={!!isEnabledButton}
onChange={handleOnButtonSettingChange}
label={__('Enable in-post widget', 'likecoin')}
help={__('Embed widget in this post (Overrides site setting)', 'likecoin')}
checked={!!isEnabledButton}
onChange={handleOnButtonSettingChange}
/>
</div>
)}
Expand Down Expand Up @@ -252,6 +258,26 @@ function LikeCoinPluginSideBar(props) {
</div>
)}
</div>
<Panel>
<PanelBody title={__('Advanced', 'likecoin')} initialOpen={false}>
<PanelRow>
<TextControl
label={__('Override ISCN ID', 'likecoin')}
value={props.ISCNId}
onChange={(value) => postISCNInfoData({ iscnId: value })}
/>
</PanelRow>
<PanelRow>
<TextControl
label={__('Override Arweave ID', 'likecoin')}
value={props.arweaveId}
onChange={(value) => {
postArweaveInfoData({ arweaveId: value });
}}
/>
</PanelRow>
</PanelBody>
</Panel>
</PluginSidebar>
);
}
Expand Down
2 changes: 1 addition & 1 deletion likecoin/js/sidebar/src/store/iscn-info-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const actions = {
yield {
type: 'UPDATE_ARWEAVE_UPLOAD_AND_IPFS_GLOBAL_STATE',
data: {
arweaveId: res.arweave_id, ipfsHash: res.ipfs_hash,
arweaveId: res.data.arweave_id,
},
};
},
Expand Down

0 comments on commit d75487c

Please sign in to comment.