0351d front end linting (#377)

* feat: disable custom script for  trial users

* after lint fix

* frontend linting

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka
2024-04-15 18:39:03 +01:00
committed by GitHub
parent 8d35fc8b1a
commit bcd45ce8a6
228 changed files with 17036 additions and 8744 deletions

View File

@@ -1,45 +1,58 @@
<template>
<div>
<h3 class="font-semibold text-2xl text-gray-900">Danger zone</h3>
<h3 class="font-semibold text-2xl text-gray-900">
Danger zone
</h3>
<p class="text-gray-600 text-sm mt-2">
This will permanently delete your entire account. All your forms, submissions and workspaces will be deleted.
<span class="text-red-500">
This cannot be undone.
</span>
This will permanently delete your entire account. All your forms,
submissions and workspaces will be deleted.
<span class="text-red-500"> This cannot be undone. </span>
</p>
<!-- Submit Button -->
<v-button :loading="loading" class="mt-4" color="red" @click="useAlert().confirm('Do you really want to delete your account?',deleteAccount)">
<v-button
:loading="loading"
class="mt-4"
color="red"
@click="
useAlert().confirm(
'Do you really want to delete your account?',
deleteAccount,
)
"
>
Delete account
</v-button>
</div>
</template>
<script setup>
import { useRouter } from 'vue-router';
import { useRouter } from "vue-router"
const router = useRouter()
const authStore = useAuthStore()
let loading = false
useOpnSeoMeta({
title: 'Account'
title: "Account",
})
definePageMeta({
middleware: "auth"
middleware: "auth",
})
const deleteAccount = () => {
loading = true
opnFetch('/user', {method:'DELETE'}).then(async (data) => {
loading = false
useAlert().success(data.message)
opnFetch("/user", { method: "DELETE" })
.then(async (data) => {
loading = false
useAlert().success(data.message)
authStore.logout()
router.push({ name: 'login' })
}).catch((error) => {
useAlert().error(error.data.message)
loading = false
})
authStore.logout()
router.push({ name: "login" })
})
.catch((error) => {
useAlert().error(error.data.message)
loading = false
})
}
</script>

View File

@@ -1,83 +1,108 @@
<template>
<div>
<h3 class="font-semibold text-2xl text-gray-900">Admin settings</h3>
<h3 class="font-semibold text-2xl text-gray-900">
Admin settings
</h3>
<small class="text-gray-600">Manage settings.</small>
<h3 class="mt-3 text-lg font-semibold mb-4">
Tools
</h3>
<div class="flex flex-wrap mb-5">
<a :href="statsUrl" target="_blank">
<v-button class="mx-1" color="gray" shade="lighter">
Stats
</v-button>
<a
:href="statsUrl"
target="_blank"
>
<v-button
class="mx-1"
color="gray"
shade="lighter"
> Stats </v-button>
</a>
<a :href="horizonUrl" target="_blank">
<v-button class="mx-1" color="gray" shade="lighter">
Horizon
</v-button>
<a
:href="horizonUrl"
target="_blank"
>
<v-button
class="mx-1"
color="gray"
shade="lighter"
> Horizon </v-button>
</a>
</div>
<h3 class="text-lg font-semibold mb-4">
Impersonate User
</h3>
<form @submit.prevent="impersonate" @keydown="form.onKeydown($event)">
<form
@submit.prevent="impersonate"
@keydown="form.onKeydown($event)"
>
<!-- Password -->
<text-input name="identifier" :form="form" label="Identifier"
:required="true" help="User Id, User Email or Form Slug"
<text-input
name="identifier"
:form="form"
label="Identifier"
:required="true"
help="User Id, User Email or Form Slug"
/>
<!-- Submit Button -->
<v-button :loading="loading" class="mt-4">Impersonate User</v-button>
<v-button
:loading="loading"
class="mt-4"
>
Impersonate User
</v-button>
</form>
</div>
</template>
<script setup>
import { useRouter } from 'vue-router';
import {opnFetch} from "~/composables/useOpnApi.js";
import {fetchAllWorkspaces} from "~/stores/workspaces.js";
import { useRouter } from "vue-router"
import { opnFetch } from "~/composables/useOpnApi.js"
import { fetchAllWorkspaces } from "~/stores/workspaces.js"
definePageMeta({
middleware: "moderator"
middleware: "moderator",
})
useOpnSeoMeta({
title: 'Admin'
title: "Admin",
})
const authStore = useAuthStore()
const workspacesStore = useWorkspacesStore()
const router = useRouter()
let form = useForm({
identifier: ''
const form = useForm({
identifier: "",
})
const loading = ref(false)
const runtimeConfig = useRuntimeConfig()
const statsUrl = runtimeConfig.public.apiBase + '/stats'
const horizonUrl = runtimeConfig.public.apiBase + '/horizon'
const statsUrl = runtimeConfig.public.apiBase + "/stats"
const horizonUrl = runtimeConfig.public.apiBase + "/horizon"
const impersonate = () => {
loading.value = true
authStore.startImpersonating()
opnFetch('/admin/impersonate/' + encodeURI(form.identifier)).then(async (data) => {
// Save the token.
authStore.setToken(data.token, false)
opnFetch("/admin/impersonate/" + encodeURI(form.identifier))
.then(async (data) => {
// Save the token.
authStore.setToken(data.token, false)
// Fetch the user.
const userData = await opnFetch('user')
authStore.setUser(userData)
const workspaces = await fetchAllWorkspaces()
workspacesStore.set(workspaces.data.value)
loading.value = false
// Fetch the user.
const userData = await opnFetch("user")
authStore.setUser(userData)
const workspaces = await fetchAllWorkspaces()
workspacesStore.set(workspaces.data.value)
loading.value = false
router.push({ name: 'home' })
}).catch((error) => {
console.error(error)
useAlert().error(error.data.message)
loading.value = false
})
router.push({ name: "home" })
})
.catch((error) => {
console.error(error)
useAlert().error(error.data.message)
loading.value = false
})
}
</script>

View File

@@ -5,11 +5,16 @@
</h3>
<template v-if="user.has_customer_id">
<small class="text-gray-600">Manage your billing. Download invoices, update your plan, or cancel it at any
time.</small>
<small class="text-gray-600">Manage your billing. Download invoices, update your plan, or cancel it
at any time.</small>
<div class="mt-4">
<v-button color="gray" shade="light" :loading="billingLoading" @click.prevent="openBillingDashboard">
<v-button
color="gray"
shade="light"
:loading="billingLoading"
@click.prevent="openBillingDashboard"
>
Manage Subscription
</v-button>
</div>
@@ -20,30 +25,33 @@
</template>
<script setup>
import { computed } from 'vue'
import { useAuthStore } from '../../stores/auth'
import AppSumoBilling from '../../components/vendor/appsumo/AppSumoBilling.vue'
import { computed } from "vue"
import { useAuthStore } from "../../stores/auth"
import AppSumoBilling from "../../components/vendor/appsumo/AppSumoBilling.vue"
useOpnSeoMeta({
title: 'Billing'
title: "Billing",
})
definePageMeta({
middleware: "auth"
middleware: "auth",
})
const authStore = useAuthStore()
let user = computed(() => authStore.user)
const user = computed(() => authStore.user)
let billingLoading = false
const openBillingDashboard = () => {
billingLoading = true
opnFetch('/subscription/billing-portal').then((data) => {
const url = data.portal_url
window.location = url
}).catch((error) => {
useAlert().error(error.data.message)
}).finally(() => {
billingLoading = false
})
opnFetch("/subscription/billing-portal")
.then((data) => {
const url = data.portal_url
window.location = url
})
.catch((error) => {
useAlert().error(error.data.message)
})
.finally(() => {
billingLoading = false
})
}
</script>

View File

@@ -1,7 +1,7 @@
<script setup>
definePageMeta({
redirect: to => {
return { name: 'settings-profile'}
}
redirect: () => {
return { name: "settings-profile" }
},
})
</script>

View File

@@ -5,19 +5,34 @@
</h3>
<small class="text-gray-600">Manage your password.</small>
<form class="mt-3" @submit.prevent="update" @keydown="form.onKeydown($event)">
<form
class="mt-3"
@submit.prevent="update"
@keydown="form.onKeydown($event)"
>
<!-- Password -->
<text-input native-type="password"
name="password" :form="form" label="Password" :required="true"
<text-input
native-type="password"
name="password"
:form="form"
label="Password"
:required="true"
/>
<!-- Password Confirmation-->
<text-input native-type="password"
name="password_confirmation" :form="form" label="Confirm Password" :required="true"
<text-input
native-type="password"
name="password_confirmation"
:form="form"
label="Confirm Password"
:required="true"
/>
<!-- Submit Button -->
<v-button :loading="form.busy" class="mt-4">
<v-button
:loading="form.busy"
class="mt-4"
>
Update password
</v-button>
</form>
@@ -26,23 +41,26 @@
<script setup>
useOpnSeoMeta({
title: 'Password'
title: "Password",
})
definePageMeta({
middleware: "auth"
middleware: "auth",
})
let form = useForm({
password: '',
password_confirmation: ''
const form = useForm({
password: "",
password_confirmation: "",
})
const update = () => {
form.patch('/settings/password').then((response) => {
form.reset()
useAlert().success('Password updated.')
}).catch((error) => {
console.error(error)
})
form
.patch("/settings/password")
.then(() => {
form.reset()
useAlert().success("Password updated.")
})
.catch((error) => {
console.error(error)
})
}
</script>

View File

@@ -5,15 +5,32 @@
</h3>
<small class="text-gray-600">Update your username and manage your account details.</small>
<form class="mt-3" @submit.prevent="update" @keydown="form.onKeydown($event)">
<form
class="mt-3"
@submit.prevent="update"
@keydown="form.onKeydown($event)"
>
<!-- Name -->
<text-input name="name" :form="form" label="Name" :required="true" />
<text-input
name="name"
:form="form"
label="Name"
:required="true"
/>
<!-- Email -->
<text-input name="email" :form="form" label="Email" :required="true" />
<text-input
name="email"
:form="form"
label="Email"
:required="true"
/>
<!-- Submit Button -->
<v-button :loading="form.busy" class="mt-4">
<v-button
:loading="form.busy"
class="mt-4"
>
Save changes
</v-button>
</form>
@@ -25,27 +42,27 @@ const authStore = useAuthStore()
const user = computed(() => authStore.user)
useOpnSeoMeta({
title: 'Profile'
title: "Profile",
})
definePageMeta({
middleware: "auth"
middleware: "auth",
})
let form = useForm({
name: '',
email: ''
const form = useForm({
name: "",
email: "",
})
const update = () => {
form.patch('/settings/profile').then((response) => {
form.patch("/settings/profile").then((response) => {
authStore.updateUser(response)
useAlert().success('Your info has been updated!')
useAlert().success("Your info has been updated!")
})
}
onBeforeMount(() => {
// Fill the form with user data.
form.keys().forEach(key => {
form.keys().forEach((key) => {
form[key] = user.value[key]
})
})

View File

@@ -7,29 +7,48 @@
</h3>
<small class="text-gray-600">Manage your workspaces.</small>
</div>
<v-button color="outline-blue" :loading="loading" @click="workspaceModal=true">
<svg class="inline -mt-1 mr-1 h-4 w-4" viewBox="0 0 14 14" fill="none"
xmlns="http://www.w3.org/2000/svg"
<v-button
color="outline-blue"
:loading="loading"
@click="workspaceModal = true"
>
<svg
class="inline -mt-1 mr-1 h-4 w-4"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M6.99996 1.16699V12.8337M1.16663 7.00033H12.8333" stroke="currentColor" stroke-width="1.67"
stroke-linecap="round" stroke-linejoin="round"
<path
d="M6.99996 1.16699V12.8337M1.16663 7.00033H12.8333"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Create new workspace
</v-button>
</div>
<div v-if="loading" class="w-full text-blue-500 text-center">
<div
v-if="loading"
class="w-full text-blue-500 text-center"
>
<Loader class="h-10 w-10 p-5" />
</div>
<div v-else-if="workspace">
<div class="mt-4 flex group bg-white items-center">
<div class="flex space-x-4 flex-grow items-center">
<img v-if="isUrl(workspace.icon)" :src="workspace.icon" :alt="workspace.name + ' icon'"
class="rounded-full h-12 w-12"
/>
<div v-else class="rounded-2xl bg-gray-100 h-12 w-12 text-2xl pt-2 text-center overflow-hidden"
v-text="workspace.icon"
<img
v-if="isUrl(workspace.icon)"
:src="workspace.icon"
:alt="workspace.name + ' icon'"
class="rounded-full h-12 w-12"
>
<div
v-else
class="rounded-2xl bg-gray-100 h-12 w-12 text-2xl pt-2 text-center overflow-hidden"
v-text="workspace.icon"
/>
<div class="space-y-4 py-1">
<div class="font-bold truncate">
@@ -40,38 +59,70 @@
</div>
<template v-if="customDomainsEnabled">
<text-area-input :form="customDomainsForm" name="custom_domains" class="mt-4" :required="false"
:disabled="!workspace.is_pro"
label="Workspace Custom Domains" wrapper-class="" placeholder="yourdomain.com - 1 per line"
<text-area-input
:form="customDomainsForm"
name="custom_domains"
class="mt-4"
:required="false"
:disabled="!workspace.is_pro"
label="Workspace Custom Domains"
wrapper-class=""
placeholder="yourdomain.com - 1 per line"
/>
<p class="text-gray-500 text-sm">
Read our <a href="#"
@click.prevent="crisp.openHelpdeskArticle('how-to-use-my-own-domain-9m77g7')"
>custom domain instructions</a> to learn how to use your own domain.
Read our
<a
href="#"
@click.prevent="
crisp.openHelpdeskArticle('how-to-use-my-own-domain-9m77g7')
"
>custom domain instructions</a>
to learn how to use your own domain.
</p>
</template>
<div class="flex flex-wrap justify-between gap-2 mt-4">
<v-button v-if="customDomainsEnabled" class="w-full sm:w-auto" :loading="customDomainsLoading"
@click="saveChanges">
<svg class="w-4 h-4 text-white inline mr-1 -mt-1" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg"
<v-button
v-if="customDomainsEnabled"
class="w-full sm:w-auto"
:loading="customDomainsLoading"
@click="saveChanges"
>
<svg
class="w-4 h-4 text-white inline mr-1 -mt-1"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M17 21V13H7V21M7 3V8H15M19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V5C3 4.46957 3.21071 3.96086 3.58579 3.58579C3.96086 3.21071 4.46957 3 5 3H16L21 8V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Save Domains
</v-button>
<v-button v-if="workspaces.length > 1" color="white" class="group w-full sm:w-auto" :loading="loading"
@click="deleteWorkspace(workspace.id)"
<v-button
v-if="workspaces.length > 1"
color="white"
class="group w-full sm:w-auto"
:loading="loading"
@click="deleteWorkspace(workspace.id)"
>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 -mt-1 inline group-hover:text-red-700" fill="none"
viewBox="0 0 24 24" stroke="currentColor"
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 -mt-1 inline group-hover:text-red-700"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
/>
</svg>
Remove workspace
@@ -80,12 +131,24 @@
</div>
<!-- Workspace modal -->
<modal :show="workspaceModal" max-width="lg" @close="workspaceModal=false">
<modal
:show="workspaceModal"
max-width="lg"
@close="workspaceModal = false"
>
<template #icon>
<svg class="w-8 h-8" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-8 h-8"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 8V16M8 12H16M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
@@ -93,18 +156,32 @@
Create Workspace
</template>
<div class="px-4">
<form @submit.prevent="createWorkspace" @keydown="form.onKeydown($event)">
<form
@submit.prevent="createWorkspace"
@keydown="form.onKeydown($event)"
>
<div>
<text-input name="name" class="mt-4" :form="form" :required="true"
label="Workspace Name"
<text-input
name="name"
class="mt-4"
:form="form"
:required="true"
label="Workspace Name"
/>
<text-input name="emoji" class="mt-4" :form="form" :required="false"
label="Emoji"
<text-input
name="emoji"
class="mt-4"
:form="form"
:required="false"
label="Emoji"
/>
</div>
<div class="w-full mt-6">
<v-button :loading="form.busy" class="w-full my-3">
<v-button
:loading="form.busy"
class="w-full my-3"
>
Save
</v-button>
</div>
@@ -115,37 +192,42 @@
</template>
<script setup>
import {watch} from "vue";
import {fetchAllWorkspaces} from "~/stores/workspaces.js";
import { watch } from "vue"
import { fetchAllWorkspaces } from "~/stores/workspaces.js"
const crisp = useCrisp()
const workspacesStore = useWorkspacesStore()
const workspaces = computed(() => workspacesStore.getAll)
let loading = computed(() => workspacesStore.loading)
const loading = computed(() => workspacesStore.loading)
useOpnSeoMeta({
title: 'Workspaces'
title: "Workspaces",
})
definePageMeta({
middleware: "auth"
middleware: "auth",
})
let form = useForm({
name: '',
emoji: ''
const form = useForm({
name: "",
emoji: "",
})
let workspaceModal = ref(false)
let customDomainsForm = useForm({
custom_domain: ''
const workspaceModal = ref(false)
const customDomainsForm = useForm({
custom_domain: "",
})
let customDomainsLoading = ref(false)
const customDomainsLoading = ref(false)
let workspace = computed(() => workspacesStore.getCurrent)
let customDomainsEnabled = computed(() => useRuntimeConfig().public.customDomainsEnabled)
const workspace = computed(() => workspacesStore.getCurrent)
const customDomainsEnabled = computed(
() => useRuntimeConfig().public.customDomainsEnabled,
)
watch(() => workspace, () => {
initCustomDomains()
})
watch(
() => workspace,
() => {
initCustomDomains()
},
)
onMounted(() => {
fetchAllWorkspaces()
@@ -157,56 +239,72 @@ const saveChanges = () => {
customDomainsLoading.value = true
// Update the workspace custom domain
customDomainsForm.put('/open/workspaces/' + workspace.value.id + '/custom-domains', {
data: {
custom_domains: customDomainsForm?.custom_domains?.split('\n')
.map(domain => domain ? domain.trim() : null)
.filter(domain => domain && domain.length > 0)
}
}).then((data) => {
workspacesStore.save(data)
useAlert().success('Custom domains saved.')
}).catch((error) => {
useAlert().error('Failed to update custom domains: ' + error.response.data.message)
}).finally(() => {
customDomainsLoading.value = false
})
customDomainsForm
.put("/open/workspaces/" + workspace.value.id + "/custom-domains", {
data: {
custom_domains: customDomainsForm?.custom_domains
?.split("\n")
.map((domain) => (domain ? domain.trim() : null))
.filter((domain) => domain && domain.length > 0),
},
})
.then((data) => {
workspacesStore.save(data)
useAlert().success("Custom domains saved.")
})
.catch((error) => {
useAlert().error(
"Failed to update custom domains: " + error.response.data.message,
)
})
.finally(() => {
customDomainsLoading.value = false
})
}
const initCustomDomains = () => {
if (!workspace || !workspace.value.custom_domains) return
customDomainsForm.custom_domains = workspace.value?.custom_domains.join('\n')
customDomainsForm.custom_domains = workspace.value?.custom_domains.join("\n")
}
const deleteWorkspace = (workspaceId) => {
if (workspaces.length <= 1) {
useAlert().error('You cannot delete your only workspace.')
useAlert().error("You cannot delete your only workspace.")
return
}
useAlert().confirm('Do you really want to delete this workspace? All forms created in this workspace will be removed.', () => {
opnFetch('/open/workspaces/' + workspaceId, {method: 'DELETE'}).then((data) => {
useAlert().success('Workspace successfully removed.')
workspacesStore.remove(workspaceId)
})
})
useAlert().confirm(
"Do you really want to delete this workspace? All forms created in this workspace will be removed.",
() => {
opnFetch("/open/workspaces/" + workspaceId, { method: "DELETE" }).then(
() => {
useAlert().success("Workspace successfully removed.")
workspacesStore.remove(workspaceId)
},
)
},
)
}
const isUrl = (str) => {
const pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
'(\\#[-a-z\\d_]*)?$', 'i') // fragment locator
const pattern = new RegExp(
"^(https?:\\/\\/)?" + // protocol
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
"((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
"(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
"(\\#[-a-z\\d_]*)?$",
"i",
) // fragment locator
return !!pattern.test(str)
}
const createWorkspace = () => {
form.post('/open/workspaces/create').then((data) => {
form.post("/open/workspaces/create").then((data) => {
workspacesStore.save(data.workspace)
workspacesStore.currentId = data.workspace.id
workspaceModal.value = false
useAlert().success('Workspace successfully created! You are now editing settings for your new workspace.')
useAlert().success(
"Workspace successfully created! You are now editing settings for your new workspace.",
)
})
}
</script>