frappe-ui 0.1.110 → 0.1.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frappe-ui",
3
- "version": "0.1.110",
3
+ "version": "0.1.112",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -4,15 +4,15 @@
4
4
  class="m-2 flex flex-col gap-3 shadow-sm rounded-lg py-2.5 px-3 bg-surface-white text-base"
5
5
  >
6
6
  <div class="flex flex-col gap-1">
7
- <div class="inline-flex gap-2 items-center font-medium">
7
+ <div class="inline-flex gap-1 items-center font-medium">
8
8
  <FeatherIcon class="h-4" name="info" />
9
9
  {{ trialTitle }}
10
10
  </div>
11
- <div class="text-ink-gray-7 text-sm font-normal leading-5">
11
+ <div class="text-ink-gray-7 text-p-sm">
12
12
  {{ trialMessage }}
13
13
  </div>
14
14
  </div>
15
- <Button :label="'Upgrade plan'" theme="blue" @click="openBillingPage">
15
+ <Button :label="'Upgrade plan'" theme="blue" @click="upgradePlan">
16
16
  <template #prefix>
17
17
  <LightningIcon class="size-4" />
18
18
  </template>
@@ -35,23 +35,27 @@ const props = defineProps({
35
35
 
36
36
  const trialEndDays = ref(0)
37
37
  const showBanner = ref(false)
38
+ const baseEndpoint = ref('https://frappecloud.com')
39
+ const siteName = ref('')
38
40
 
39
41
  const trialTitle = computed(() => {
40
42
  return trialEndDays.value > 1
41
43
  ? 'Trial ends in ' + trialEndDays.value + ' days'
42
- : 'Trial will end tomorrow'
44
+ : 'Trial ends tomorrow'
43
45
  })
44
46
 
45
47
  const trialMessage = 'Upgrade to a paid plan for uninterrupted services'
46
48
 
47
49
  createResource({
48
50
  url: 'frappe.integrations.frappe_providers.frappecloud_billing.current_site_info',
49
- cache: 'currentSiteInfo',
51
+ cache: 'current_site_info_data',
50
52
  auto: true,
51
53
  onSuccess: (data) => {
52
54
  trialEndDays.value = calculateTrialEndDays(data.trial_end_date)
55
+ baseEndpoint.value = data.base_url
56
+ siteName.value = data.site_name
53
57
  showBanner.value =
54
- window.setup_complete && data.plan.is_trial_plan && trialEndDays.value > 0
58
+ data.setup_complete && data.plan.is_trial_plan && trialEndDays.value > 0
55
59
  },
56
60
  })
57
61
 
@@ -65,7 +69,10 @@ function calculateTrialEndDays(trialEndDate) {
65
69
  return diffDays
66
70
  }
67
71
 
68
- function openBillingPage() {
69
- window.location.href = '/billing'
72
+ function upgradePlan() {
73
+ window.open(
74
+ `${baseEndpoint.value}/dashboard/sites/${siteName.value}`,
75
+ '_blank',
76
+ )
70
77
  }
71
78
  </script>
@@ -8,6 +8,9 @@ interface UploadOptions {
8
8
  method?: string
9
9
  type?: string
10
10
  upload_endpoint?: string
11
+ optimize?: boolean
12
+ max_width?: number
13
+ max_height?: number
11
14
  }
12
15
 
13
16
  type EventListenerOption = 'start' | 'progress' | 'finish' | 'error'
@@ -129,6 +132,16 @@ class FileUploadHandler {
129
132
  form_data.append('type', options.type)
130
133
  }
131
134
 
135
+ if (options.optimize) {
136
+ form_data.append('optimize', '1')
137
+ if (options.max_width) {
138
+ form_data.append('max_width', options.max_width.toString())
139
+ }
140
+ if (options.max_height) {
141
+ form_data.append('max_height', options.max_height.toString())
142
+ }
143
+ }
144
+
132
145
  xhr.send(form_data)
133
146
  })
134
147
  }