Skip to content

Commit

Permalink
feat: adapt for sub-api keys [ref Codeinwp/optimole-service#1136]
Browse files Browse the repository at this point in the history
  • Loading branch information
abaicus committed Dec 13, 2024
1 parent 160f394 commit 0266467
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assets/src/dashboard/parts/connected/settings/CloudLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ export default function CloudLibrary( props ) {
} = props;

const storeData = useSelect( select => {
const { isLoading } = select( 'optimole' );
const { isLoading, isSubApiKey } = select( 'optimole' );
return {
isLoading: isLoading()
isLoading: isLoading(),
isSubApiKey: isSubApiKey()
};
}, []);

const { isLoading } = storeData;
const { isLoading, isSubApiKey } = storeData;


const isCloudLibraryEnabled = 'disabled' !== settings[ 'cloud_images' ];
const showSiteSelector = ! isSubApiKey && isCloudLibraryEnabled;
const whitelistedDomains = user_data.whitelist || [];


Expand Down Expand Up @@ -81,7 +83,7 @@ export default function CloudLibrary( props ) {

<hr className="my-8 border-grayish-blue"/>

{isCloudLibraryEnabled && (
{showSiteSelector && (
<BaseControl
label={options_strings.cloud_site_title}
help={options_strings.cloud_site_desc}
Expand Down
3 changes: 3 additions & 0 deletions assets/src/dashboard/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const selectors = {
}

return state.logs;
},
isSubApiKey( state ) {
return state.apiKey && state.apiKey.startsWith( 'optml-s' );
}
};

Expand Down

0 comments on commit 0266467

Please sign in to comment.