Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Current: Current
Filters: Filters
Override: Override
Storage: Storage
ab-testing-progressive-deploy-conflict: AB testing and progressive deploy cannot be enabled at the same time
account: Account
account-error: Error while updating your account
account-password-error: Error happened, please try again
Expand Down Expand Up @@ -101,6 +102,7 @@ channel-link-fail: Cannot override the channel something wrong happened
channel-linked: Channel override setted
channel-linking: Link to channel
channel-make-now: Make default
channel-progressive-deploy: Enable progressive deploy
channels: Channels
check-email: Please check your email and verify
check-on-web: Check on website
Expand Down Expand Up @@ -136,6 +138,7 @@ devices-using-this-b: Devices using this bundle
disable-ab-testing: Disabled AB testing
disable-auto-downgra: Disable auto downgrade under native
disable-auto-upgrade: Disable auto upgrade above major
disable-progressive-deploy: Disabled progressive deploy
discord: Discord
discover-module-in-a: Discover module in Awesome-capacitor
discover-your-dashbo: Discover your dashboard !
Expand All @@ -145,6 +148,7 @@ download: Download
email: Email
email-address: Email address
enabled-ab-testing: Enabled AB testing
enabled-progressive-deploy: Enabled progressive deploy
encrypted: Encrypted bundles
enter-your-email-add: Enter your email address and we'll send you a link to reset your password.
enter-your-new-passw: Enter your new password and confirm
Expand All @@ -154,6 +158,7 @@ failed: Failed
filters: Filters
first-name: First name
force-version: Force version
force-version-change: Skip progressive deploy
forgot: Forgot
forgot-check-email: Check your email to get the link to reset your password
forgot-success: Password updated successfully
Expand Down Expand Up @@ -191,6 +196,7 @@ login-to-your-accoun: Login to your account
logout: Logout
logs: Logs
lowerCaseError: Should contain lowercase letters
main-bundle-number: Main bundle number
make-normal: Make normal
making-this-channel-: >-
Making this channel "normal" will need you to configure an other channel
Expand Down Expand Up @@ -254,6 +260,10 @@ please-upgrade: Please upgrade your plan to add more users
plugin-version: Plugin version
prediction: Prediction
pro-tip-you-can-copy: 'Pro tip: you can copy the'
progressive-bundle-number: Progressive bundle number
progressive-deploy-option: Select progressive deploy option
progressive-deploy-set-percentage: You cannot set secondary version percentage when progressive deploy is enabled
progressive-percentage: Progressive deploy status
projection: Projections
recommended: Recommended
recommended-for-you: Recommended for you
Expand Down Expand Up @@ -288,7 +298,10 @@ size-not-found: Not found
something-went-wrong-try-again-later: Something went wrong! Try again later.
special-api-access: Special API access
specialError: Should contain special characters
start-new-deploy: Start new progressive deploy
start-using-capgo: 'Start using:'
status-complete: complete
status-failed: failed
stored-externally: stored externally
submit: Submit
support: Support
Expand Down
85 changes: 82 additions & 3 deletions src/pages/app/p/[p]/bundle/[bundle].vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ async function setSecondChannel(channel: Database['public']['Tables']['channels'
.eq('id', channel.id)
}

async function setChannelProgressive(channel: Database['public']['Tables']['channels']['Row'], id: number) {
return supabase
.from('channels')
.update({
secondVersion: id,
version: channel.secondVersion,
secondaryVersionPercentage: 0.1,
})
.eq('id', channel.id)
}

async function setChannelSkipProgressive(channel: Database['public']['Tables']['channels']['Row'], id: number) {
return supabase
.from('channels')
.update({
secondVersion: id,
version: id,
secondaryVersionPercentage: 1,
})
.eq('id', channel.id)
}

async function ASChannelChooser() {
if (!version.value)
return
Expand Down Expand Up @@ -172,14 +194,14 @@ async function ASChannelChooser() {

for (const chan of channels.value) {
const v: number = chan.version as any
if (!chan.enableAbTesting) {
if (!chan.enableAbTesting && !chan.enable_progressive_deploy) {
buttons.push({
text: chan.name,
selected: version.value.id === v,
handler: async () => { await normalHandler(chan) },
})
}
else {
else if (chan.enableAbTesting && !chan.enable_progressive_deploy) {
buttons.push({
text: `${chan.name}-A`,
selected: version.value.id === v,
Expand All @@ -197,6 +219,63 @@ async function ASChannelChooser() {
},
})
}
else {
buttons.push({
text: `${chan.name}`,
selected: version.value.id === chan.secondVersion,
handler: async () => {
const newButtons = []
newButtons.push({
text: t('start-new-deploy'),
selected: false,
handler: async () => {
if (!version.value)
return

try {
await setChannelProgressive(chan, version.value.id)
await getChannels()
}
catch (error) {
console.error(error)
toast.error(t('cannot-test-app-some'))
}
},
})

newButtons.push({
text: t('force-version-change'),
selected: false,
handler: async () => {
if (!version.value)
return
try {
await setChannelSkipProgressive(chan, version.value.id)
await getChannels()
}
catch (error) {
console.error(error)
toast.error(t('cannot-test-app-some'))
}
},
})

newButtons.push({
text: t('button-cancel'),
role: 'cancel',
handler: () => {
// console.log('Cancel clicked')
},
})

displayStore.actionSheetOption = {
header: t('progressive-deploy-option'),
buttons: newButtons,
}
displayStore.showActionSheet = true
},
})
}
}
buttons.push({
text: t('button-cancel'),
Expand Down Expand Up @@ -395,7 +474,7 @@ function hideString(str: string) {
<InfoRow v-if="version_meta?.uninstalls" :label="t('uninstall')" :value="version_meta.uninstalls.toLocaleString()" />
<InfoRow v-if="version_meta?.fails" :label="t('fail')" :value="version_meta.fails.toLocaleString()" />
<!-- <InfoRow v-if="version_meta?.installs && version_meta?.fails" :label="t('percent-fail')" :value="failPercent" /> -->
<InfoRow v-if="channel" :label="t('channel')" :value="channel!.enableAbTesting ? (secondaryChannel ? `${channel!.name}-B` : `${channel!.name}-A`) : channel!.name" :is-link="true" @click="openChannel()" />
<InfoRow v-if="channel" :label="t('channel')" :value="(channel!.enableAbTesting || channel!.enable_progressive_deploy) ? (secondaryChannel ? `${channel!.name}-B` : `${channel!.name}-A`) : channel!.name" :is-link="true" @click="openChannel()" />
<InfoRow v-else :label="t('channel')" :value="t('set-bundle')" :is-link="true" @click="openChannel()" />
<!-- session_key -->
<InfoRow v-if="version.session_key" :label="t('session_key')" :value="hideString(version.session_key)" :is-link="true" @click="copyToast(version?.session_key || '')" />
Expand Down
67 changes: 65 additions & 2 deletions src/pages/app/p/[p]/channel/[channel].vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ async function getChannel() {
android,
updated_at,
enableAbTesting,
enable_progressive_deploy,
secondaryVersionPercentage,
secondVersion (
name,
Expand Down Expand Up @@ -277,6 +278,11 @@ async function enableAbTesting() {

const val = !channel.value.enableAbTesting

if (val && channel.value.enable_progressive_deploy) {
toast.error(t('ab-testing-progressive-deploy-conflict'))
return
}

const { error } = await supabase
.from('channels')
.update({ enableAbTesting: val })
Expand All @@ -291,6 +297,33 @@ async function enableAbTesting() {
}
}

async function enableProgressiveDeploy() {
if (!channel.value)
return

const val = !channel.value.enable_progressive_deploy

if (val && channel.value.enableAbTesting) {
toast.error(t('ab-testing-progressive-deploy-conflict'))
return
}

const { error } = await supabase
.from('channels')
.update({ enable_progressive_deploy: val, secondVersion: val ? channel.value.version.id : undefined })
.eq('id', id.value)

if (error) {
console.error(error)
}
else {
channel.value.enable_progressive_deploy = val
toast.success(val ? t('enabled-progressive-deploy') : t('disable-progressive-deploy'))
}

await reload()
}

const debouncedSetSecondaryVersionPercentage = debounce (async (percentage: number) => {
const { error } = await supabase
.from('channels')
Expand All @@ -301,10 +334,24 @@ const debouncedSetSecondaryVersionPercentage = debounce (async (percentage: numb
console.error(error)
}, 500, { leading: true, trailing: true, maxWait: 500 })

const debouncedInformAboutProgressiveDeployPercentageSet = debounce(() => {
toast.error(t('progressive-deploy-set-percentage'))
}, 500, { leading: true, trailing: true, maxWait: 500 })

async function setSecondaryVersionPercentage(percentage: number) {
if (channel.value?.enable_progressive_deploy)
return

secondaryVersionPercentage.value = percentage
await debouncedSetSecondaryVersionPercentage(percentage)
}

function onMouseDownSecondaryVersionSlider(event: MouseEvent) {
if (channel.value?.enable_progressive_deploy) {
debouncedInformAboutProgressiveDeployPercentageSet()
event.preventDefault()
}
}
</script>

<template>
Expand All @@ -315,11 +362,16 @@ async function setSecondaryVersionPercentage(percentage: number) {
<dl class="divide-y divide-gray-500">
<InfoRow :label="t('name')" :value="channel.name" />
<!-- Bundle Number -->
<InfoRow v-if="!channel.enableAbTesting" :label="t('bundle-number')" :value="channel.version.name" :is-link="true" @click="channel.version.name !== 'unknown' ? openBundle : ''" />
<template v-else>
<InfoRow v-if="!channel.enableAbTesting && !channel.enable_progressive_deploy" :label="t('bundle-number')" :value="channel.version.name" :is-link="true" @click="openBundle()" />
<template v-else-if="channel.enableAbTesting && !channel.enable_progressive_deploy">
<InfoRow :label="`${t('bundle-number')} A`" :value="channel.version.name" :is-link="true" @click="openBundle" />
<InfoRow :label="`${t('bundle-number')} B`" :value="channel.secondVersion.name" :is-link="true" @click="openSecondBundle" />
</template>
<template v-else>
<InfoRow :label="`${t('main-bundle-number')}`" :value="(channel.secondaryVersionPercentage !== 1) ? channel.version.name : channel.secondVersion.name" :is-link="true" @click="openBundle" />
<InfoRow :label="`${t('progressive-bundle-number')}`" :value="(channel.secondaryVersionPercentage !== 1) ? channel.secondVersion.name : channel.version.name" :is-link="true" @click="openSecondBundle" />
<InfoRow v-id="channel.enable_progressive_deploy" :label="`${t('progressive-percentage')}`" :value="(channel.secondaryVersionPercentage === 1) ? t('status-complete') : (channel.secondaryVersionPercentage !== 0 ? `${((channel.secondaryVersionPercentage * 100) | 0)}%` : t('status-failed'))" />
</template>
<!-- Created At -->
<InfoRow :label="t('created-at')" :value="formatDate(channel.created_at)" />
<!-- Last Update -->
Expand Down Expand Up @@ -421,6 +473,16 @@ async function setSecondaryVersionPercentage(percentage: number) {
/>
</template>
</k-list-item>
<k-list-item label :title="t('channel-progressive-deploy')" class="text-lg text-gray-700 dark:text-gray-200">
<template #after>
<k-toggle
class="-my-1 k-color-success"
component="div"
:checked="channel?.enable_progressive_deploy"
@change="enableProgressiveDeploy()"
/>
</template>
</k-list-item>
<k-list-item label :title="`${t('channel-ab-testing-percentage')}: ${secondaryVersionPercentage}%`" class="text-lg text-gray-700 dark:text-gray-200">
<template #after>
<k-range
Expand All @@ -429,6 +491,7 @@ async function setSecondaryVersionPercentage(percentage: number) {
component="div"
:step="5"
@input="(e: any) => (setSecondaryVersionPercentage(parseInt(e.target.value, 10)))"
@mousedown="onMouseDownSecondaryVersionSlider"
/>
</template>
</k-list-item>
Expand Down
15 changes: 11 additions & 4 deletions src/types/supabase.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,14 @@ export interface Database {
created_by: string
disableAutoUpdateToMajor: boolean
disableAutoUpdateUnderNative: boolean
enable_progressive_deploy: boolean
enableAbTesting: boolean
id: number
ios: boolean
name: string
public: boolean
secondaryVersionPercentage: number
secondVersion: number | null
secondVersion: number
updated_at: string
version: number
}
Expand All @@ -437,15 +438,16 @@ export interface Database {
created_by: string
disableAutoUpdateToMajor?: boolean
disableAutoUpdateUnderNative?: boolean
enable_progressive_deploy?: boolean
enableAbTesting?: boolean
id?: number
ios?: boolean
name: string
public?: boolean
secondaryVersionPercentage?: number
secondVersion?: number | null
secondVersion?: number
updated_at?: string
version: number
version?: number
}
Update: {
allow_dev?: boolean
Expand All @@ -458,13 +460,14 @@ export interface Database {
created_by?: string
disableAutoUpdateToMajor?: boolean
disableAutoUpdateUnderNative?: boolean
enable_progressive_deploy?: boolean
enableAbTesting?: boolean
id?: number
ios?: boolean
name?: string
public?: boolean
secondaryVersionPercentage?: number
secondVersion?: number | null
secondVersion?: number
updated_at?: string
version?: number
}
Expand Down Expand Up @@ -1163,6 +1166,10 @@ export interface Database {
}
Returns: number
}
delete_user: {
Args: {}
Returns: void
},
convert_bytes_to_mb: {
Args: {
byt: number
Expand Down
5 changes: 4 additions & 1 deletion supabase/functions/_utils/supabase.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ export interface Database {
created_by: string
disableAutoUpdateToMajor: boolean
disableAutoUpdateUnderNative: boolean
enableAbTesting: boolean
enableAbTesting: boolean,
enable_progressive_deploy?: boolean
id: number
ios: boolean
name: string
Expand All @@ -438,6 +439,7 @@ export interface Database {
disableAutoUpdateToMajor?: boolean
disableAutoUpdateUnderNative?: boolean
enableAbTesting?: boolean
enable_progressive_deploy?: boolean
id?: number
ios?: boolean
name: string
Expand All @@ -459,6 +461,7 @@ export interface Database {
disableAutoUpdateToMajor?: boolean
disableAutoUpdateUnderNative?: boolean
enableAbTesting?: boolean
enable_progressive_deploy?: boolean
id?: number
ios?: boolean
name?: string
Expand Down
Loading