PluginProbe ʕ •ᴥ•ʔ
Presto Player / trunk
Presto Player vtrunk
4.3.1 4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / dashboard / pages / settings / general / LicensePage.js
presto-player / src / admin / dashboard / pages / settings / general Last commit date
BrandingPage.js 1 month ago ContributePage.js 1 month ago CustomCssPage.js 1 month ago LicensePage.js 1 month ago MediaHubPage.js 1 month ago PresetsPage.js 1 month ago UninstallPage.js 1 month ago ViewingAnalyticsPage.js 1 month ago
LicensePage.js
150 lines
1 import { __ } from '@wordpress/i18n';
2 import { useState } from 'react';
3 import { Button, Container, Input, Label, Text, toast } from '@bsf/force-ui';
4 import SettingsPageShell from '../shared/SettingsPageShell';
5 import SectionCard from '../shared/SectionCard';
6 import ConfirmDialog from '../shared/ConfirmDialog';
7 import useLicenseSettings from '../../../hooks/useLicenseSettings';
8 import useRegisterActivePage from '../../../hooks/useRegisterActivePage';
9
10 const LicensePage = ( { registerActivePage } ) => {
11 const {
12 isLoading,
13 isActivating,
14 isDeactivating,
15 isActive,
16 licenseKey: savedLicenseKey,
17 activate,
18 deactivate,
19 } = useLicenseSettings();
20
21 const [ licenseKey, setLicenseKey ] = useState( '' );
22 const [ confirmDeactivateOpen, setConfirmDeactivateOpen ] = useState( false );
23
24 useRegisterActivePage( registerActivePage, {
25 isDirty: false,
26 save: null,
27 discard: null,
28 } );
29
30 const handleActivate = async () => {
31 if ( ! licenseKey.trim() ) {
32 toast.error( __( 'Please enter a license key.', 'presto-player' ) );
33 return;
34 }
35 try {
36 const data = await activate( licenseKey.trim() );
37 setLicenseKey( '' );
38 toast.success(
39 data.message || __( 'License activated successfully.', 'presto-player' )
40 );
41 // Pro PHP components only register on the next request, and
42 // `window.prestoPlayer.isPremium` is captured as a module-level
43 // const in many dashboard files — a reload is the cleanest way
44 // to bring the whole dashboard up in the licensed state.
45 setTimeout( () => window.location.reload(), 600 );
46 } catch ( err ) {
47 toast.error(
48 err.message || __( 'Could not activate license.', 'presto-player' )
49 );
50 }
51 };
52
53 const handleDeactivate = async () => {
54 try {
55 const data = await deactivate();
56 setConfirmDeactivateOpen( false );
57 toast.success(
58 data.message || __( 'License deactivated.', 'presto-player' )
59 );
60 setTimeout( () => window.location.reload(), 600 );
61 } catch ( err ) {
62 setConfirmDeactivateOpen( false );
63 toast.error(
64 err.message || __( 'Could not deactivate license.', 'presto-player' )
65 );
66 }
67 };
68
69 const placeholderText = isActive
70 ? __( 'Your license is activated', 'presto-player' )
71 : __( 'Paste your license key here', 'presto-player' );
72
73 return (
74 <SettingsPageShell
75 title={ __( 'License', 'presto-player' ) }
76 isLoading={ isLoading }
77 >
78 <SectionCard>
79 <Container direction="column" className="gap-2">
80 <Label size="sm">{ __( 'License Key', 'presto-player' ) }</Label>
81 <Container direction="column" className="gap-3 md:flex-row w-full">
82 <Container.Item grow={ 1 } shrink={ 1 } className="w-full">
83 <Input
84 type="text"
85 size="md"
86 placeholder={ placeholderText }
87 value={ isActive ? savedLicenseKey : licenseKey }
88 disabled={ isActive }
89 onChange={ setLicenseKey }
90 className="w-full"
91 />
92 </Container.Item>
93 { isActive ? (
94 <Button
95 variant="outline"
96 destructive
97 onClick={ () => setConfirmDeactivateOpen( true ) }
98 disabled={ isDeactivating }
99 >
100 { __( 'Deactivate', 'presto-player' ) }
101 </Button>
102 ) : (
103 <Button
104 variant="primary"
105 onClick={ handleActivate }
106 disabled={ isActivating || ! licenseKey }
107 loading={ isActivating }
108 >
109 { __( 'Activate', 'presto-player' ) }
110 </Button>
111 ) }
112 </Container>
113 <Text size="xs" className="text-text-tertiary">
114 { __(
115 'Enter the License Key you received when you purchased this product. If you lost the key, you can retrieve it from',
116 'presto-player'
117 ) }{ ' ' }
118 <Text
119 as="a"
120 size="xs"
121 href="https://my.prestomade.com/my-account/"
122 target="_blank"
123 rel="noreferrer"
124 className="text-brand-primary-600 hover:underline"
125 >
126 { __( 'My Account', 'presto-player' ) }
127 </Text>
128 </Text>
129 </Container>
130 </SectionCard>
131
132 <ConfirmDialog
133 open={ confirmDeactivateOpen }
134 title={ __( 'Deactivate license?', 'presto-player' ) }
135 description={ __(
136 'You will lose access to Pro features, automatic updates, and support on this site until you reactivate.',
137 'presto-player'
138 ) }
139 confirmLabel={ __( 'Deactivate', 'presto-player' ) }
140 cancelLabel={ __( 'Cancel', 'presto-player' ) }
141 confirmDestructive
142 onConfirm={ handleDeactivate }
143 onCancel={ () => setConfirmDeactivateOpen( false ) }
144 />
145 </SettingsPageShell>
146 );
147 };
148
149 export default LicensePage;
150