@@ -2,10 +2,11 @@ import { __ } from '@common/helpers/i18nwrap'
22import request from '@common/helpers/request'
33import config from '@config/config'
44import LucideIcn from '@icons/LucideIcn'
5- import { Badge , Button , Space , Typography } from 'antd'
5+ import If from '@utilities/If'
6+ import { Badge , Button , Space , Tag , Typography } from 'antd'
67import Title from 'antd/es/typography/Title'
78import { useEffect , useRef } from 'react'
8- import { useSearchParam } from 'react-use'
9+ import { useAsync , useSearchParam } from 'react-use'
910
1011import LicenseActivationNotice from './LicenseActivationNotice.pro'
1112import CheckNewUpdate from './SupportPage/CheckNewUpdate'
@@ -27,17 +28,34 @@ const getCurrentBuildCodeName = (): string | undefined => {
2728 const scripts = [ ...document . scripts ]
2829 for ( const sc of scripts ) {
2930 if ( sc . src . includes ( 'bit-pi' ) && sc . src . includes ( 'main' ) ) {
30- return sc ?. src ?. split ( '/' ) ?. at ( - 1 ) ?. replace ( 'main' , '' ) ?. replace ( '.js' , '' )
31- ?. replaceAll ( '-' , ' ' )
31+ return sc ?. src
32+ ?. split ( '/' )
33+ ?. at ( - 1 )
34+ ?. replace ( 'main' , '' )
35+ ?. replace ( '.js' , '' )
36+ ?. split ( '-' )
37+ . filter ( Boolean )
38+ . join ( '-' )
3239 }
3340 }
3441}
3542
3643export default function License ( { pluginSlug } : { pluginSlug : string } ) {
3744 const aboutPlugin = pluginInfo . plugins [ pluginSlug as keyof typeof pluginInfo . plugins ]
3845 const licenseKey = useRef ( useSearchParam ( 'licenseKey' ) )
46+ const freeBuildCodeName = useAsync ( async ( ) => {
47+ const res = await fetch ( `/wp-content/plugins/${ config . PLUGIN_SLUG } /assets/build-code-name.txt` )
48+ const text = await res . text ( )
49+ return text
50+ } )
3951
40- const buildCodeName = getCurrentBuildCodeName ( )
52+ const proBuildCodeName = useAsync ( async ( ) => {
53+ const res = await fetch ( `/wp-content/plugins/${ config . PRO_SLUG } /assets/build-code-name.txt` )
54+ const text = await res . text ( )
55+ return text
56+ } )
57+
58+ const currentBuildCodeName = getCurrentBuildCodeName ( )
4159
4260 const {
4361 FREE_VERSION : freeVersion ,
@@ -82,13 +100,24 @@ export default function License({ pluginSlug }: { pluginSlug: string }) {
82100 return (
83101 < div className = "mb-12" >
84102 < Title level = { 5 } > { __ ( 'License & Activation' ) } </ Title >
85- < Typography . Text className = "mb-2 inline-block text-xs" type = "secondary" >
86- { __ ( 'Build Code Name:' ) } { buildCodeName }
87- </ Typography . Text >
103+
104+ < If conditions = { currentBuildCodeName === '.tsx' } >
105+ < Tag className = "mb-2 font-bold" color = "blue" >
106+ { __ ( 'Dev Version On' ) }
107+ </ Tag >
108+ </ If >
109+
88110 < div className = "mb-2" >
89111 { __ ( 'Version' ) } : { freeVersion }
112+ < Typography . Text className = "ml-2 text-xs" type = "secondary" >
113+ { __ ( 'Code Name: ' ) }
114+ { freeBuildCodeName ?. value }
115+ < If conditions = { freeBuildCodeName ?. value === currentBuildCodeName } >
116+ < LucideIcn className = "ml-1" name = "check" />
117+ </ If >
118+ </ Typography . Text >
90119 </ div >
91- { ! hasProPlugin && (
120+ < If conditions = { ! hasProPlugin } >
92121 < div className = "mb-2" >
93122 < Space className = "mb-2" >
94123 < div >
@@ -109,11 +138,19 @@ export default function License({ pluginSlug }: { pluginSlug: string }) {
109138
110139 < CheckNewUpdate />
111140 </ div >
112- ) }
113- { hasProPlugin && (
141+ </ If >
142+
143+ < If conditions = { hasProPlugin } >
114144 < div className = "mb-2" >
115145 < div className = "mb-2" >
116- { __ ( 'Pro Version' ) } : { proVersion }
146+ { __ ( 'Pro Version' ) } : { proVersion } { ' ' }
147+ < Typography . Text className = "ml-2 text-xs" type = "secondary" >
148+ { __ ( 'Code Name: ' ) }
149+ { proBuildCodeName ?. value }
150+ < If conditions = { proBuildCodeName ?. value === currentBuildCodeName } >
151+ < LucideIcn className = "ml-1" name = "check" />
152+ </ If >
153+ </ Typography . Text >
117154 </ div >
118155
119156 < CheckNewUpdate />
@@ -146,7 +183,7 @@ export default function License({ pluginSlug }: { pluginSlug: string }) {
146183 ) }
147184 </ div >
148185 </ div >
149- ) }
186+ </ If >
150187 </ div >
151188 )
152189}
0 commit comments