Skip to content

Commit

Permalink
chore: merge staging into master (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley authored Jun 26, 2023
2 parents 22d0ac4 + f1f4128 commit 84ee111
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 44 deletions.
16 changes: 13 additions & 3 deletions app/Http/Livewire/ExchangeTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,20 @@ public function render(): View

public function getExchanges(): Collection
{
return Exchange::orderBy('name')
->filterByType($this->type)
return Exchange::filterByType($this->type)
->filterByPair($this->pair)
->get();
->get()
->sort(function ($a, $b) {
if ($b->volume === null) {
return -1;
}

if ($a->volume === null) {
return 1;
}

return intval($b->volume) - intval($a->volume);
});
}

public function setFilter(string $param, string $value): void
Expand Down
4 changes: 2 additions & 2 deletions public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"/js/app.js": "/js/app.js?id=4a03d8e6bbf1c480e3ffaf1a01fde4ad",
"/js/clipboard.js": "/js/clipboard.js?id=80d900f861e2aacb0e23e914068d0de9",
"/js/manifest.js": "/js/manifest.js?id=d7f05315a876420076a2066217d34e8f",
"/css/app.css": "/css/app.css?id=a45b091ec2361b66b05e2717c2430b56",
"/css/app.css": "/css/app.css?id=128b2a9e8e1cf4bab64b0b94efbfe59e",
"/js/vendor.js": "/js/vendor.js?id=a0fbceff2e2c3da1c0b24a701d9c2403",
"/images/errors/401.svg": "/images/errors/401.svg?id=f0752ffe6436f6cb98210be88dd36eb5",
"/images/errors/401_dark.svg": "/images/errors/401_dark.svg?id=ade1bb3ec92d4001f1af918885b2b5c7",
Expand Down
21 changes: 21 additions & 0 deletions resources/css/_tables.css
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,27 @@ body.table-compact-until-lg .arrow-direction {
@apply bg-theme-secondary-200 dark:bg-black !important;
}

.table-container
table
> tbody
> tr:first-child
> td.hoverable-cell
> div.table-cell-bg {
@apply border-0;
}

@media (max-width: 1279px) {
.table-encapsulated table > tbody > tr > td.hoverable-cell {
@apply align-top;
}
}

@screen 2xl {
.table-encapsulated table > tbody > tr > td.hoverable-cell {
@apply align-middle;
}
}

/* Filter */

.table-filter-item__checkbox:hover input[type="checkbox"] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class="text-center"
<div class="flex flex-col font-semibold text-theme-secondary-900 dark:text-theme-secondary-200">
<x-tables.rows.desktop.encapsulated.balance :model="$wallet" />

<span class="mt-1 text-xs font-semibold lg:hidden text-theme-secondary-500">
<span class="mt-1 text-xs font-semibold text-theme-secondary-500 md-lg:hidden">
@if($useVoteWeight)
<x-tables.rows.desktop.vote-percentage :model="$wallet" />
@else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<x-wallet.overview.item
:title="trans('pages.wallet.delegate_info')"
:masked-message="trans('pages.wallet.delegate.not_registered_text')"
class="hidden md-lg:block"
>
<x-wallet.overview.item-entry
:title="trans('pages.wallet.delegate.rank')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,30 @@
$isHigh = ! $isMedium && $wallet->isActive() && $productivity >= config('arkscan.productivity.warning');
@endphp

<x-wallet.overview.item-entry
:title="trans('pages.wallet.delegate.productivity_title')"
:has-empty-value="! $wallet->isDelegate() || $wallet->isResigned()"
>
<x-wallet.overview.item-entry :title="trans('pages.wallet.delegate.productivity_title')">
<x-slot name="value">
<div @class([
'flex items-center space-x-2',
'text-theme-secondary-500 dark:text-theme-secondary-700' => ! $wallet->isActive(),
'text-theme-danger-700 dark:text-theme-danger-400' => $isLow,
'text-theme-warning-700' => $isMedium,
'text-theme-success-700 dark:text-theme-success-500' => $isHigh,
])>
<div>
<x-percentage>
{{ $productivity }}
</x-percentage>
</div>

@unless($wallet->isResigned())
<div @class([
'w-4 h-4 rounded-full border',
'border-theme-secondary-200 bg-theme-secondary-400 dark:border-theme-secondary-800 dark:bg-theme-secondary-700' => ! $wallet->isActive(),
'border-theme-danger-200 bg-theme-danger-700 dark:border-theme-danger-700 dark:bg-theme-danger-400' => $isLow,
'border-theme-warning-200 bg-theme-warning-700 dark:border-theme-warning-800 dark:bg-theme-warning-700' => $isMedium,
'border-theme-success-200 bg-theme-success-700 dark:border-theme-success-600 dark:bg-theme-success-500' => $isHigh,
])></div>
</div>
'flex items-center space-x-2',
'text-theme-secondary-500 dark:text-theme-secondary-700' => ! $wallet->isActive(),
'text-theme-danger-700 dark:text-theme-danger-400' => $isLow,
'text-theme-warning-700' => $isMedium,
'text-theme-success-700 dark:text-theme-success-500' => $isHigh,
])>
<div>
<x-percentage>
{{ $productivity }}
</x-percentage>
</div>

<div @class([
'w-4 h-4 rounded-full border',
'border-theme-secondary-200 bg-theme-secondary-400 dark:border-theme-secondary-800 dark:bg-theme-secondary-700' => ! $wallet->isActive(),
'border-theme-danger-200 bg-theme-danger-700 dark:border-theme-danger-700 dark:bg-theme-danger-400' => $isLow,
'border-theme-warning-200 bg-theme-warning-700 dark:border-theme-warning-800 dark:bg-theme-warning-700' => $isMedium,
'border-theme-success-200 bg-theme-success-700 dark:border-theme-success-600 dark:bg-theme-success-500' => $isHigh,
])></div>
</div>
@endunless
</x-slot>
</x-wallet.overview.item-entry>
2 changes: 1 addition & 1 deletion resources/views/components/wallet/overview/item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'maskedMessage' => null,
])

<div class="flex flex-col flex-1 p-6 space-y-3 border-t-4 md:p-0 md:border-0 dark:border-black border-theme-secondary-200">
<div {{ $attributes->class('flex flex-col flex-1 p-6 space-y-3 border-t-4 md:p-0 md:border-0 dark:border-black border-theme-secondary-200') }}>
<div class="flex justify-between font-semibold dark:text-theme-secondary-500">
{{ $title }}

Expand Down
13 changes: 6 additions & 7 deletions resources/views/components/wallet/overview/wallet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@

<x-wallet.overview.item-entry :title="trans('pages.wallet.value')">
<x-slot name="value">
<span>{{ $wallet->balanceFiat() }}</span>
@if (Network::canBeExchanged())
<span>{{ $wallet->balanceFiat() }}</span>

@if (ExplorerNumberFormatter::isFiat(Settings::currency()))
<span>{{ Settings::currency() }}</span>
@if (ExplorerNumberFormatter::isFiat(Settings::currency()))
<span>{{ Settings::currency() }}</span>
@endif
@endif
</x-slot>
</x-wallet.overview.item-entry>

<x-wallet.overview.item-entry
:title="trans('pages.wallet.voting_for')"
:has-empty-value="$wallet->vote() === null"
>
<x-wallet.overview.item-entry :title="trans('pages.wallet.voting_for')">
<x-slot name="value">
@if ($wallet->vote())
<x-general.identity-iconless :model="$wallet->vote()" />
Expand Down
8 changes: 4 additions & 4 deletions resources/views/livewire/wallet-qr-code.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
@class($class)
>
<x-general.dropdown.dropdown
width="max-w-[320px] px-4"
width="w-full sm:max-w-[320px] px-4"
active-button-class=""
dropdown-padding=""
dropdown-wrapper-class="w-full"
dropdown-background="bg-white dark:bg-theme-secondary-900"
dropdown-background="bg-white border border-transparent dark:shadow-lg-dark dark:bg-theme-secondary-900 dark:border-theme-secondary-800"
:close-on-click="false"
on-close="() => showOptions = false"
buttonClass="p-2 w-full focus-visible:ring-inset button button-secondary button-icon"
Expand Down Expand Up @@ -76,8 +76,8 @@ class="font-normal"
/>
</div>

<div>
<div class="p-2 rounded-lg border border-theme-secondary-300 dark:border-theme-secondary-300 dark:bg-theme-secondary-300">
<div class="flex flex-col items-center">
<div class="inline-block p-2 rounded-lg border sm:block border-theme-secondary-300 dark:border-theme-secondary-300 dark:bg-theme-secondary-300">
{!! $this->code !!}
</div>

Expand Down
28 changes: 27 additions & 1 deletion tests/Feature/Http/Controllers/ShowWalletControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\Wallet;
use App\Services\Cache\DelegateCache;
use App\Services\Cache\NetworkCache;
use Illuminate\Support\Facades\Config;

it('should render the page without any errors', function () {
$this->withoutExceptionHandling();
Expand Down Expand Up @@ -45,6 +46,8 @@
});

it('should not double up currency for crypto', function () {
Config::set('arkscan.networks.development.canBeExchanged', true);

Settings::shouldReceive('currency')
->andReturn('BTC')
->shouldReceive('get')
Expand All @@ -54,14 +57,17 @@

$response = $this
->get(route('wallet', $wallet))
->assertSee($wallet->username);
->assertSee($wallet->username)
->assertSee('0 BTC');

$content = preg_replace('/\s+/', ' ', str_replace("\n", '', strip_tags($response->getContent())));

expect($content)->not->toContain('0 BTC BTC Voting For');
});

it('should show currency symbol and code for crypto', function () {
Config::set('arkscan.networks.development.canBeExchanged', true);

Settings::shouldReceive('currency')
->andReturn('GBP')
->shouldReceive('get')
Expand All @@ -77,3 +83,23 @@

expect($content)->toContain('£0.00 GBP Voting For');
});

it('should not show overview value if cannot be exchanged', function () {
Config::set('arkscan.networks.development.canBeExchanged', false);

Settings::shouldReceive('currency')
->andReturn('GBP')
->shouldReceive('get')
->andReturnNull();

$wallet = Wallet::factory()->create();

$this
->get(route('wallet', $wallet))
->assertSee($wallet->username)
->assertSeeInOrder([
'Value',
'N/A',
'Voting For',
]);
});
54 changes: 54 additions & 0 deletions tests/Feature/Http/Livewire/ExchangeTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,57 @@
->assertSet('pair', 'all')
->assertSet('type', 'all');
});

it('sort by volume descending by default', function () {
Exchange::factory()->create([
'name' => 'Exchange 1',
'volume' => '23',
]);

Exchange::factory()->create([
'name' => 'Exchange 2',
'volume' => '45123.01231',
]);

Exchange::factory()->create([
'name' => 'Exchange 3',
'volume' => '1000000.01',
]);

Exchange::factory()->create([
'name' => 'Exchange 4',
'volume' => null,
]);

Exchange::factory()->create([
'name' => 'Exchange 5',
'volume' => null,
]);

Livewire::test(ExchangeTable::class)
->assertSeeInOrder([
'Exchange 3',
'Exchange 2',
'Exchange 1',
'Exchange 4',
'Exchange 5',
]);
});

it('sort handle empty volumes while sorting ', function () {
Exchange::factory()->create([
'name' => 'Exchange 4',
'volume' => null,
]);

Exchange::factory()->create([
'name' => 'Exchange 5',
'volume' => '123.45',
]);

Livewire::test(ExchangeTable::class)
->assertSeeInOrder([
'Exchange 4',
'Exchange 5',
]);
});

0 comments on commit 84ee111

Please sign in to comment.