Skip to content

Commit

Permalink
Social: Change Manage connections button to a link with connections (
Browse files Browse the repository at this point in the history
…#38220)

* Switch `Manage connections` to a link with at least 1 connection

* changelog

* Fixup versions
  • Loading branch information
gmjuhasz authored Jul 8, 2024
1 parent dea21ad commit bcb5e62
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Changed `Manage connections` to a link with at least 1 connection
2 changes: 1 addition & 1 deletion projects/js-packages/publicize-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-publicize-components",
"version": "0.55.2-alpha",
"version": "0.56.0-alpha",
"description": "A library of JS components required by the Publicize editor plugin",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/publicize-components/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import usePublicizeConfig from '../../hooks/use-publicize-config';
import useSocialMediaConnections from '../../hooks/use-social-media-connections';
import PublicizeConnection from '../connection';
import { EnabledConnectionsNotice } from './enabled-connections-notice';
import { SettingsButton } from './settings-button';
import styles from './styles.module.scss';
import { useConnectionState } from './use-connection-state';
Expand Down Expand Up @@ -33,6 +34,7 @@ export const ConnectionsList: React.FC = () => {
);
} ) }
</ul>
<EnabledConnectionsNotice />
{ ! needsUserConnection ? <SettingsButton variant="secondary" /> : null }
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { AdvancedPlanNudge } from './advanced-plan-nudge';
import { AutoConversionNotice } from './auto-conversion-notice';
import { BrokenConnectionsNotice } from './broken-connections-notice';
import { ConnectionsList } from './connections-list';
import { EnabledConnectionsNotice } from './enabled-connections-notice';
import { InstagramNoMediaNotice } from './instagram-no-media-notice';
import { SettingsButton } from './settings-button';
import { ShareCountInfo } from './share-count-info';
Expand Down Expand Up @@ -108,7 +107,6 @@ export default function PublicizeForm() {
<PanelRow>
<ConnectionsList />
</PanelRow>
<EnabledConnectionsNotice />
<ShareCountInfo />
<BrokenConnectionsNotice />
<UnsupportedConnectionsNotice />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ type SettingsButtonProps = {
* @returns {import('react').ReactNode} The button/link component.
*/
export function SettingsButton( { label, variant = 'primary' }: SettingsButtonProps ) {
const { useAdminUiV1 } = useSelect( select => {
const { useAdminUiV1, connections } = useSelect( select => {
return {
useAdminUiV1: select( store ).useAdminUiV1(),
connections: select( store ).getConnections(),
};
}, [] );
const { openConnectionsModal } = useDispatch( store );
const { connectionsAdminUrl } = usePublicizeConfig();

const text = label || __( 'Manage connections', 'jetpack' );
const hasConnections = connections.length > 0;

return useAdminUiV1 ? (
<Button
onClick={ openConnectionsModal }
variant={ variant }
size="small"
variant={ hasConnections ? 'link' : variant }
size={ hasConnections ? 'default' : 'small' }
className={ styles[ 'settings-button' ] }
>
{ text }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

.enabled-connections-notice {
color: var(--jp-gray-50);
margin-bottom: 0.5rem;
}

p.auto-share-title {
Expand Down Expand Up @@ -77,7 +78,7 @@ p.auto-share-title {
}
}

.settings-button {
.settings-button.settings-button {
display: block;
margin-block: 0.5rem;
margin-bottom: 0.5rem;
}

0 comments on commit bcb5e62

Please sign in to comment.