Skip to content

Commit

Permalink
adjust demo
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBTurchyn committed Jul 11, 2023
1 parent d595e7d commit 4ffd198
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def default_url_options
private

def sign_in_for_demo
sign_in(User.first) unless signed_in?
sign_in(User.order('random()').take) unless signed_in?
end

def current_account
Expand Down
1 change: 1 addition & 0 deletions app/javascript/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ window.customElements.define('submission-form', class extends HTMLElement {
authenticityToken: this.dataset.authenticityToken,
canSendEmail: this.dataset.canSendEmail === 'true',
isDirectUpload: this.dataset.isDirectUpload === 'true',
isDemo: this.dataset.isDemo === 'true',
values: reactive(JSON.parse(this.dataset.values)),
attachments: reactive(JSON.parse(this.dataset.attachments)),
fields: JSON.parse(this.dataset.fields)
Expand Down
19 changes: 18 additions & 1 deletion app/javascript/submission_form/completed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
Download
</span>
</button>
<a
v-if="isDemo"
target="_blank"
href="https://github.com/docusealco/docuseal"
class="white-button flex items-center space-x-1 w-full"
>
<IconBrandGithub />
<span>
Star on Github
</span>
</a>
</div>
<div class="text-center mt-4">
Signed with
Expand All @@ -53,13 +64,14 @@
</template>

<script>
import { IconCircleCheck, IconMail, IconDownload, IconInnerShadowTop } from '@tabler/icons-vue'
import { IconCircleCheck, IconBrandGithub, IconMail, IconDownload, IconInnerShadowTop } from '@tabler/icons-vue'
export default {
name: 'FormCompleted',
components: {
IconCircleCheck,
IconInnerShadowTop,
IconBrandGithub,
IconMail,
IconDownload
},
Expand All @@ -68,6 +80,11 @@ export default {
type: String,
required: true
},
isDemo: {
type: Boolean,
required: false,
default: false
},
canSendEmail: {
type: Boolean,
required: false,
Expand Down
6 changes: 6 additions & 0 deletions app/javascript/submission_form/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
</form>
<FormCompleted
v-else
:is-demo="isDemo"
:can-send-email="canSendEmail"
:submitter-slug="submitterSlug"
/>
Expand Down Expand Up @@ -317,6 +318,11 @@ export default {
required: true,
default: false
},
isDemo: {
type: Boolean,
required: true,
default: false
},
values: {
type: Object,
required: false,
Expand Down
1 change: 1 addition & 0 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<% if Docuseal.demo? %><%= render 'shared/demo_alert' %><% end %>
<% if @templates.any? %>
<div class="flex justify-between mb-4 items-center">
<h1 class="text-4xl font-bold">Templates</h1>
Expand Down
1 change: 0 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<body>
<turbo-frame id="modal"></turbo-frame>
<%= render 'shared/navbar' %>
<% if Docuseal.demo? %><%= render 'shared/demo_alert' %><% end %>
<% if flash.present? %><%= render 'shared/flash' %><% end %>
<div class="max-w-6xl mx-auto px-4 md:px-2 mb-8">
<%= yield %>
Expand Down
14 changes: 8 additions & 6 deletions app/views/shared/_demo_alert.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="absolute top-0 w-full h-0">
<div class="max-w-xl mx-auto mt-1.5">
<div class="px-4 py-3 rounded-2xl flex items-center justify-between mx-4 md:mx-0">
<a target="_blank" href="<%= start_form_url(slug: ::Template.first&.slug) %>" class="font-medium w-full text-center underline">
Demo Environment
</a>
<div class="mx-auto mt-1.5">
<div class="py-3 rounded-2xl flex items-center justify-between mx-4 md:mx-0">
<div class="w-full text-center">
<span class="font-bold">DocuSeal Demo Environment</span>
<br>
Feel free to
<a href="<%= new_template_path %>" data-turbo-frame="modal" class="inline underline font-medium">create a new template</a> document form or
<a href="<%= start_form_url(slug: ::Template.first&.slug) %>" target="_blank" class="inline underline font-medium">submit the existing one</a> 😊
</div>
</div>
</div>
10 changes: 10 additions & 0 deletions app/views/shared/_github_button.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<a href="https://github.com/docusealco/docuseal" class="btn btn-neutral btn-sm btn-outline inline-flex items-center justify-center" target="_blank" alt="Star on GitHub" style="height: 37px">
<span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path fill="currentColor" d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
</svg>
</span>
<span class="flex">
<span class="hidden lg:block">Star on&nbsp</span>GitHub
</span>
</a>
16 changes: 11 additions & 5 deletions app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
<%= render 'shared/logo' %>
<span>DocuSeal</span>
</a>
<a href="<%= Docuseal::GITHUB_URL %>" target="_blank" class="inline">
<img alt="GitHub Repo stars" src="https://www.docuseal.co/github-badge.svg" style="height: 22px">
</a>
<% unless Docuseal.demo? %>
<a href="<%= Docuseal::GITHUB_URL %>" target="_blank" class="inline">
<img alt="GitHub Repo stars" src="https://www.docuseal.co/github-badge.svg" style="height: 22px">
</a>
<% end %>
</div>
<% if signed_in? %>
<div class="space-x-6">
<%= link_to 'Settings', settings_profile_index_path, class: 'hidden md:inline font-medium text-lg' %>
<div class="space-x-4 flex items-center">
<% if Docuseal.demo? %>
<%= render 'shared/github_button' %>
<% else %>
<%= link_to 'Settings', settings_profile_index_path, class: 'hidden md:inline font-medium text-lg mr-2' %>
<% end %>
<div class="dropdown dropdown-end">
<label tabindex="0" class="cursor-pointer bg-base-content text-purple-300 rounded-full p-2 w-9 justify-center flex">
<span class="text-sm align-text-top"><%= current_user.initials %></span>
Expand Down
2 changes: 1 addition & 1 deletion app/views/submit_form/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="mx-auto" style="max-width: 1000px">
<div class="relative md:mx-32">
<div id="form_container" class="shadow-md bg-base-100 absolute bottom-0 md:bottom-4 w-full border border-base-200 border p-4 rounded">
<submission-form data-is-direct-upload="<%= Docuseal.active_storage_public? %>" data-submitter-uuid="<%= @submitter.uuid %>" data-submitter-slug="<%= @submitter.slug %>" data-can-send-email="<%= Accounts.can_send_emails?(Struct.new(:id).new(@submitter.submission.template.account_id)) %>" data-attachments="<%= attachments_index.values.select { |e| e.record_id == @submitter.id }.to_json(only: %i[uuid], methods: %i[url filename content_type]) %>" data-fields="<%= @submitter.submission.template.fields.select { |f| f['submitter_uuid'] == @submitter.uuid }.to_json %>" data-values="<%= @submitter.values.to_json %>" data-authenticity-token="<%= form_authenticity_token %>"></submission-form>
<submission-form data-is-demo="<%= Docuseal.demo? %>" data-is-direct-upload="<%= Docuseal.active_storage_public? %>" data-submitter-uuid="<%= @submitter.uuid %>" data-submitter-slug="<%= @submitter.slug %>" data-can-send-email="<%= Accounts.can_send_emails?(Struct.new(:id).new(@submitter.submission.template.account_id)) %>" data-attachments="<%= attachments_index.values.select { |e| e.record_id == @submitter.id }.to_json(only: %i[uuid], methods: %i[url filename content_type]) %>" data-fields="<%= @submitter.submission.template.fields.select { |f| f['submitter_uuid'] == @submitter.uuid }.to_json %>" data-values="<%= @submitter.values.to_json %>" data-authenticity-token="<%= form_authenticity_token %>"></submission-form>
</div>
</div>
</div>
Expand Down
16 changes: 11 additions & 5 deletions app/views/templates/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,19 @@
<% else %>
<div class="card bg-base-200">
<div class="card-body text-center py-16">
<div class="max-w-md mx-auto">
<div class="max-w-lg mx-auto">
<p class="text-3xl font-bold text-base-content mb-4">There are no Submissions</p>
<p class="text-gray-600">Send an invitation to fill and complete the form</p>
<%= link_to new_template_submission_path(@template), class: 'base-button mt-6', data: { turbo_frame: 'modal' } do %>
<%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
<span class="mr-1">Add Recipients</span>
<% end %>
<div class="space-x-2">
<%= link_to new_template_submission_path(@template), class: 'base-button mt-6', data: { turbo_frame: 'modal' } do %>
<%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
<span class="mr-1">Add Recipients</span>
<% end %>
<%= link_to start_form_url(slug: @template.slug), class: 'white-button mt-6', target: '_blank', rel: 'noopener' do %>
<%= svg_icon('writing', class: 'w-6 h-6') %>
<span class="mr-1">Submit it Yourself</span>
<% end %>
</div>
</div>
</div>
</div>
Expand Down
25 changes: 25 additions & 0 deletions lib/accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@
module Accounts
module_function

def create_duplicate(account)
new_account = account.dup

new_user = account.users.first.dup

new_user.account = new_account
new_user.encrypted_password = SecureRandom.hex
new_user.email = "#{SecureRandom.hex}@docuseal.co"

account.templates.each do |template|
new_template = template.dup

new_template.account = new_account
new_template.slug = SecureRandom.base58(10)

new_template.save!

Templates::CloneAttachments.call(template: new_template, original_template: template)
end

new_user.save!(validate: false)

new_account
end

def load_signing_certs(account)
certs =
if Docuseal.multitenant?
Expand Down

0 comments on commit 4ffd198

Please sign in to comment.