Fix custom domain setting + fix maxFileSize preview
This commit is contained in:
parent
ff701fe433
commit
c0f01f4b84
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Workspace\CustomDomainRequest;
|
||||
use App\Http\Resources\WorkspaceResource;
|
||||
use App\Models\Workspace;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Service\WorkspaceHelper;
|
||||
|
@ -19,7 +19,7 @@ class WorkspaceController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$this->authorize('viewAny', Workspace::class);
|
||||
return Auth::user()->workspaces;
|
||||
return WorkspaceResource::collection(Auth::user()->workspaces);
|
||||
}
|
||||
|
||||
public function listUsers(Request $request, $workspaceId)
|
||||
|
@ -34,7 +34,7 @@ class WorkspaceController extends Controller
|
|||
{
|
||||
$request->workspace->custom_domains = $request->customDomains;
|
||||
$request->workspace->save();
|
||||
return $request->workspace;
|
||||
return new WorkspaceResource($request->workspace);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
|
|
|
@ -7,6 +7,8 @@ use Illuminate\Support\Facades\Auth;
|
|||
|
||||
class WorkspaceResource extends JsonResource
|
||||
{
|
||||
public static $wrap = null;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
|
@ -15,10 +17,8 @@ class WorkspaceResource extends JsonResource
|
|||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'is_enterprise' => $this->is_enterprise,
|
||||
'is_pro' => $this->is_pro,
|
||||
];
|
||||
return array_merge(parent::toArray($request), [
|
||||
'max_file_size' => $this->max_file_size / 1000000,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ export default {
|
|||
const workingFormStore = useWorkingFormStore()
|
||||
return {
|
||||
workingFormStore,
|
||||
currentWorkspace: computed(() => useWorkspacesStore().getCurrent),
|
||||
selectedFieldIndex: computed(() => workingFormStore.selectedFieldIndex),
|
||||
showEditFieldSidebar: computed(() => workingFormStore.showEditFieldSidebar)
|
||||
}
|
||||
|
@ -299,7 +300,7 @@ export default {
|
|||
}
|
||||
} else if (field.type === 'files' || (field.type === 'url' && field.file_upload)) {
|
||||
inputProperties.multiple = (field.multiple !== undefined && field.multiple)
|
||||
inputProperties.mbLimit = this.form.max_file_size
|
||||
inputProperties.mbLimit = this.currentWorkspace.max_file_size ?? this.form.max_file_size
|
||||
inputProperties.accept = (this.form.is_pro && field.allowed_file_types) ? field.allowed_file_types : ''
|
||||
} else if (field.type === 'number' && field.is_rating) {
|
||||
inputProperties.numberOfStars = parseInt(field.rating_max_value)
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
</div>
|
||||
|
||||
<template v-if="customDomainsEnabled">
|
||||
<text-area-input v-model="customDomains" name="custom_domain" class="mt-4" :required="false"
|
||||
<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"
|
||||
/>
|
||||
|
@ -135,7 +135,9 @@ let form = useForm({
|
|||
emoji: ''
|
||||
})
|
||||
let workspaceModal = ref(false)
|
||||
let customDomains = ''
|
||||
let customDomainsForm = useForm({
|
||||
custom_domain: ''
|
||||
})
|
||||
let customDomainsLoading = ref(false)
|
||||
|
||||
let workspace = computed(() => workspacesStore.getCurrent)
|
||||
|
@ -153,12 +155,14 @@ onMounted(() => {
|
|||
const saveChanges = () => {
|
||||
if (customDomainsLoading.value) return
|
||||
customDomainsLoading.value = true
|
||||
|
||||
// Update the workspace custom domain
|
||||
opnFetch('/open/workspaces/' + workspace.value.id + '/custom-domains', {
|
||||
method: 'PUT',
|
||||
custom_domains: customDomains.split('\n')
|
||||
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.')
|
||||
|
@ -171,7 +175,7 @@ const saveChanges = () => {
|
|||
|
||||
const initCustomDomains = () => {
|
||||
if (!workspace || !workspace.value.custom_domains) return
|
||||
customDomains = workspace.value.custom_domains.join('\n')
|
||||
customDomainsForm.custom_domains = workspace.value.custom_domains.join('\n')
|
||||
}
|
||||
|
||||
const deleteWorkspace = (workspaceId) => {
|
||||
|
|
Loading…
Reference in New Issue