Merge pull request #10551 from turbo124/v5-develop

Prevent destructive commands in production
This commit is contained in:
David Bomba 2025-01-20 09:44:45 +11:00 committed by GitHub
commit 18d20c3d3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 162 additions and 255 deletions

View File

@ -120,7 +120,7 @@ jobs:
- name: Migrate Database - name: Migrate Database
run: | run: |
php artisan migrate:fresh --seed --force && php artisan db:seed --force php artisan migrate && php artisan db:seed
- name: Run Testsuite - name: Run Testsuite
run: | run: |

View File

@ -78,7 +78,7 @@ class DemoMode extends Command
{ {
set_time_limit(0); set_time_limit(0);
if (config('ninja.is_docker')) { if (config('ninja.is_docker') || Ninja::isHosted()) {
return; return;
} }

View File

@ -118,12 +118,14 @@ class DocumentsTable extends Component
protected function documents() protected function documents()
{ {
return $this->client()->documents() $client = $this->client();
->where('is_public', true)
->orWhere(function ($query){
$query->whereHasMorph('documentable', [Company::class], function ($q) { return $client->documents()
$q->where('is_public', true); ->where('is_public', true)
->orWhere(function ($query) use ($client) {
$query->whereHasMorph('documentable', [Company::class], function ($q) use ($client) {
$q->where('is_public', true)->where('company_id', $client->company_id);
}); });
}); });

View File

@ -145,6 +145,11 @@ class AppServiceProvider extends ServiceProvider
return $this; return $this;
}); });
//Prevents destructive commands from being run in hosted environments
\DB::prohibitDestructiveCommands(Ninja::isHosted());
} }
public function register(): void public function register(): void

View File

@ -301,10 +301,25 @@ class Purify
} else { } else {
// First, remove ALL attributes from the node // First, remove ALL attributes from the node
while ($node->attributes->length > 0) { // while ($node->attributes->length > 0) {
$attr = $node->attributes->item(0); // $attr = $node->attributes->item(0);
$node->removeAttribute($attr->nodeName); // $node->removeAttribute($attr->nodeName);
// }
if ($node instanceof \DOMElement) {
// Create a list of attributes to remove
$attributes_to_remove = [];
foreach ($node->attributes as $attr) {
$attributes_to_remove[] = $attr->nodeName;
} }
// Remove the attributes
foreach ($attributes_to_remove as $attr_name) {
$node->removeAttribute($attr_name);
}
}
} }
// Then add back only the allowed attributes // Then add back only the allowed attributes

View File

@ -13,6 +13,9 @@
font-family: $font_name, Helvetica, sans-serif; font-family: $font_name, Helvetica, sans-serif;
font-size: $font_size !important; font-size: $font_size !important;
zoom: 80%; zoom: 80%;
margin: 0;
padding: 0;
} }
table tr td, table tr, th { table tr td, table tr, th {
@ -20,7 +23,9 @@
} }
body, html { html {
width: 210mm;
height: 200mm;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
@ -163,11 +168,11 @@
padding: 1.5rem; padding: 1.5rem;
} }
[data-ref="table"] > tbody > tr > td:last-child { td.right-radius {
text-align: right; text-align: right !important;
} }
[data-ref="table"] > tbody > tr > td:first-child { td.left-radius{
font-weight: bold; font-weight: bold;
} }
@ -299,62 +304,11 @@
margin-top: 1rem; margin-top: 1rem;
} }
[data-ref='product_table-product.item-td']{ [data-ref='product_table-product.description-th'] {
font-weight: bold; width:30%;
}
[data-ref='product_table-product.item-th']{
width: 10%;
}
[data-ref='product_table-product.unit_cost-th'],
[data-ref='product_table-product.quantity-th']{
width: 12%;
}
[data-ref='product_table-product.product1-th'],
[data-ref='product_table-product.product2-th'],
[data-ref='product_table-product.product3-th'],
[data-ref='product_table-product.product4-th'],
[data-ref='product_table-product.tax1-th'] {
width: 10%;
}
[data-ref='product_table-product.line_total-th'],
[data-ref='product_table-product.line_total-td'],
[data-ref='task_table-task.line_total-th'],
[data-ref='task_table-task.line_total-td'] {
width: 12%;
text-align: right !important;
padding-right: 1rem !important;
}
[data-ref='product_table-product.description-th'],
[data-ref='task_table-task.description-th'] {
overflow-wrap: break-word; overflow-wrap: break-word;
min-width: 150px !important;
} }
[data-ref='task_table-task.hours-th'],
[data-ref='task_table-task.discount-th'],
[data-ref='task_table-task.cost-th'],
[data-ref='task_table-task.quantity-th'],
[data-ref='task_table-task.task1-th'],
[data-ref='task_table-task.task2-th'],
[data-ref='task_table-task.task3-th'],
[data-ref='task_table-task.task4-th'] {
width: 12%;
}
[data-ref='task_table-task.service-th']{
width: 10%;
}
[data-ref='task_table-task.tax1-th'] {
width: 10%;
}
.left-radius { .left-radius {
padding-left: 1rem; padding-left: 1rem;
text-align: right; text-align: right;

View File

@ -158,17 +158,17 @@
background-color: #f5f5f5; background-color: #f5f5f5;
} }
[data-ref="table"]>thead>tr>th:last-child {
text-align: right;
}
[data-ref="table"]>tbody>tr>td { [data-ref="table"]>tbody>tr>td {
border-bottom: 1px solid #e6e6e6; border-bottom: 1px solid #e6e6e6;
padding: 0.75rem; padding: 0.75rem;
} }
[data-ref="table"]>tbody>tr>td:last-child { th.right-radius {
text-align: right; text-align: right !important;
}
td.right-radius {
text-align: right !important;
} }
[data-ref="table"]>tbody>tr:nth-child(even) { [data-ref="table"]>tbody>tr:nth-child(even) {
@ -285,10 +285,8 @@
margin-top: 40px; margin-top: 40px;
} }
[data-element='product_table-product.description-td'], [data-ref='product_table-product.description-th'] {
td { width: 35%;
min-width: 100%;
max-width: 300px;
overflow-wrap: break-word; overflow-wrap: break-word;
} }

View File

@ -8,7 +8,8 @@
} }
html { html {
width: 210mm;
height: 200mm;
} }
body { body {
@ -19,7 +20,9 @@
zoom: 80%; zoom: 80%;
} }
table tr td, table tr, th { table tr td,
table tr,
th {
font-size: $font_size !important; font-size: $font_size !important;
} }
@ -37,6 +40,10 @@
padding: 0; padding: 0;
} }
#qr-bill{
width:100% !important;
}
.header-container { .header-container {
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
@ -74,17 +81,15 @@
padding-left: 1rem; padding-left: 1rem;
margin-bottom: 1rem; margin-bottom: 1rem;
font-weight: bold; font-weight: bold;
font-size:120%;
color: var(--primary-color); color: var(--primary-color);
} }
.client-and-entity-wrapper { .client-and-entity-wrapper {
padding: 1rem; padding: 1rem;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: 1fr 1fr 1fr;
border-top: 1px solid #d8d8d8; border-top: 1px solid #d8d8d8;
border-bottom: 1px solid #d8d8d8; border-bottom: 1px solid #d8d8d8;
width:100%;
} }
#entity-details { #entity-details {
@ -105,6 +110,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
line-height: var(--line-height); line-height: var(--line-height);
padding-right: 30px;
} }
#client-details> :first-child { #client-details> :first-child {
@ -120,7 +126,7 @@
[data-ref="table"] { [data-ref="table"] {
margin-top: 1rem; margin-top: 1rem;
margin-bottom: 5px; margin-bottom: 5px;
width: 100%; min-width: 100%;
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
@ -137,7 +143,7 @@
[data-ref="table"]>thead>tr>th { [data-ref="table"]>thead>tr>th {
font-size: 1.1rem; font-size: 1.1rem;
padding-bottom: 1rem; padding-bottom: 1.5rem;
padding-left: 1rem; padding-left: 1rem;
} }
@ -156,6 +162,10 @@
text-align: right; text-align: right;
} }
[data-ref='product_table-product.item-td']{
color: var(--primary-color);
}
[data-ref="table"]>tbody>tr:nth-child(odd) { [data-ref="table"]>tbody>tr:nth-child(odd) {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
@ -192,18 +202,12 @@
margin-bottom: calc(.75rem * var(--tw-space-y-reverse)); margin-bottom: calc(.75rem * var(--tw-space-y-reverse));
} }
#table-totals #table-totals>* [data-element='product-table-balance-due-label'],
> * #table-totals>* [data-element='product-table-balance-due'] {
[data-element='product-table-balance-due-label'],
#table-totals
> *
[data-element='product-table-balance-due'] {
font-weight: bold; font-weight: bold;
} }
#table-totals #table-totals>* [data-element='product-table-balance-due'] {
> *
[data-element='product-table-balance-due'] {
color: var(--primary-color); color: var(--primary-color);
} }
@ -245,51 +249,23 @@
.repeating-footer-space { .repeating-footer-space {
height: 10px; height: 10px;
} }
.repeating-header { .repeating-header {
position: fixed; position: fixed;
top: 0; top: 0;
} }
.repeating-footer { .repeating-footer {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
} }
[data-ref='task_table-task.description-th'], [data-ref='product_table-product.description-td'], td {
[data-ref='task_table-task.description-td'], min-width: 100%;
[data-ref='product_table-product.description-th'], max-width: 300px;
[data-ref='product_table-product.description-td'] {
min-width: 150px !important;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
[data-ref='product_table-product.item-td']{
color: var(--primary-color);
}
[data-ref='product_table-product.item-th'],
[data-ref='product_table-product.unit_cost-th'],
[data-ref='product_table-product.quantity-th'],
[data-ref='product_table-product.line_total-th'] {
width: 12%;
}
[data-ref='product_table-product.tax1-th'] {
width: 10%;
}
[data-ref='task_table-task.hours-th'],
[data-ref='task_table-task.service-th'],
[data-ref='task_table-task.discount-th'],
[data-ref='task_table-task.cost-th'],
[data-ref='task_table-task.quantity-th'],
[data-ref='task_table-task.line_total-th'] {
width: 12%;
}
[data-ref='task_table-task.tax1-th'] {
width: 10%;
}
.stamp { .stamp {
transform: rotate(12deg); transform: rotate(12deg);
color: #555; color: #555;
@ -334,13 +310,7 @@
color: #505050; color: #505050;
} }
.pqrcode { .pqrcode {}
}
#qr-bill{
width:100% !important;
}
/** Useful snippets, uncomment to enable. **/ /** Useful snippets, uncomment to enable. **/
@ -431,5 +401,4 @@ $entity_images
<div class="repeating-footerx" id="footer"> <div class="repeating-footerx" id="footer">
<p data-ref="total_table-footer">$entity_footer</p> <p data-ref="total_table-footer">$entity_footer</p>
</div> </div>

View File

@ -147,8 +147,8 @@
[data-ref='product_table-product.description-th'], [data-ref='product_table-product.description-th'],
[data-ref='product_table-product.description-td'] { [data-ref='task_table-task.description-th'] {
min-width: 150px !important; width: 35% !important;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
@ -156,42 +156,6 @@
color: var(--primary-color); color: var(--primary-color);
} }
[data-ref='product_table-product.item-th'],
[data-ref='product_table-product.unit_cost-th'],
[data-ref='product_table-product.quantity-th'] {
width: 12%;
}
[data-ref='product_table-product.tax1-th'] {
width: 6%;
}
[data-ref='product_table-product.line_total-th'] {
width: 10%;
}
[data-ref='task_table-task.description-th'],
[data-ref='task_table-task.description-td'] {
min-width: 100px !important;
overflow-wrap: break-word;
}
[data-ref='task_table-task.hours-th'],
[data-ref='task_table-task.service-th'],
[data-ref='task_table-task.discount-th'],
[data-ref='task_table-task.cost-th'],
[data-ref='task_table-task.quantity-th'] {
width: 12%;
}
[data-ref='task_table-task.tax1-th'] {
width: 6%;
}
[data-ref='task_table-task.line_total-th'] {
width: 10%;
}
[data-ref="table"] > thead { [data-ref="table"] > thead {
text-align: left; text-align: left;
} }
@ -201,12 +165,12 @@
padding: 1rem; padding: 1rem;
} }
[data-ref="table"] > thead > tr > th:last-child { th.right-radius {
text-align: right; text-align: right !important;
} }
[data-ref="table"] > tbody > tr > td:last-child { td.right-radius {
text-align: right; text-align: right !important;
} }
[data-ref="table"] > tbody > tr > td { [data-ref="table"] > tbody > tr > td {