Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/Http/Resources/GalleryConfigs/InitConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ public function __construct()
// Homepage
$this->default_homepage = request()->configs()->getValueAsString('home_page_default');
$this->is_timeline_page_enabled = request()->configs()->getValueAsBool('timeline_page_enabled');
$this->is_contact_form_enabled = request()->configs()->getValueAsBool('contact_form_enabled');

// Pagination settings
$this->photos_pagination_mode = request()->configs()->getValueAsEnum('photos_pagination_ui_mode', PaginationMode::class);
Expand Down
26 changes: 26 additions & 0 deletions app/Http/Resources/Rights/ModulesRightsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
use App\Contracts\Models\AbstractAlbum;
use App\Factories\AlbumFactory;
use App\Image\Watermarker;
use App\Models\ContactMessage;
use App\Models\Photo;
use App\Policies\AlbumPolicy;
use App\Repositories\ConfigManager;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;
Expand All @@ -29,6 +31,8 @@ class ModulesRightsResource extends Data
public bool $is_photo_timeline_enabled = false;
public bool $is_mod_renamer_enabled = false;
public bool $is_mod_webshop_enabled = false;
public bool $is_contact_enabled = false;
public int $messages_count = 0;

public function __construct()
{
Expand All @@ -41,6 +45,7 @@ public function __construct()
$this->is_photo_timeline_enabled = $this->isTimelinePhotosEnabled($is_logged_in);
$this->is_mod_renamer_enabled = $this->isRenamerEnabled();
$this->is_mod_webshop_enabled = $this->isWebshopEnabled();
$this->isContactEnabled();
}

/**
Expand Down Expand Up @@ -183,4 +188,25 @@ private function isWebshopEnabled(): bool

return request()->configs()->getValueAsBool('webshop_enabled');
}

/**
* Check if contact is enabled and set the messages count.
*
* @return void
*/
private function isContactEnabled(): void
{
if (!resolve(ConfigManager::class)->getValueAsBool('contact_form_enabled')) {
return;
}

$this->is_contact_enabled = true;

// Only show this information to administrators.
if (Auth::user()?->may_administrate !== true) {
return;
}

$this->messages_count = ContactMessage::query()->where('is_read', '=', false)->toBase()->count();
}
}
16 changes: 5 additions & 11 deletions resources/js/composables/contextMenus/leftMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,8 @@ export function useLeftMenu(
const { user } = storeToRefs(authStore);

const { initData, left_menu_open } = storeToRefs(LeftMenuStateStore);
const {
clockwork_url,
is_se_enabled,
is_se_preview_enabled,
is_se_info_hidden,
is_favourite_enabled,
is_timeline_page_enabled,
is_contact_form_enabled,
} = storeToRefs(lycheeStore);
const { clockwork_url, is_se_enabled, is_se_preview_enabled, is_se_info_hidden, is_favourite_enabled, is_timeline_page_enabled } =
storeToRefs(lycheeStore);
const openLycheeAbout = ref(false);
const logsEnabled = ref(true);

Expand Down Expand Up @@ -132,7 +125,7 @@ export function useLeftMenu(
label: "left-menu.contact",
icon: "pi pi-envelope",
route: "/contact",
access: is_contact_form_enabled.value && !canSeeAdmin.value,
access: initData.value.modules.is_contact_enabled && !canSeeAdmin.value,
},
{
label: "left-menu.admin",
Expand Down Expand Up @@ -166,7 +159,8 @@ export function useLeftMenu(
label: "left-menu.messages",
icon: "pi pi-inbox",
route: "/contact-messages",
access: is_contact_form_enabled.value,
access: initData.value.modules.is_contact_enabled,
num: initData.value.modules.messages_count,
},
{
label: "diagnostics.title",
Expand Down
3 changes: 3 additions & 0 deletions resources/js/lychee.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ declare namespace App.Enum {
export type FlowStrategy = "auto" | "opt-in";
export type ImageOverlayType = "none" | "desc" | "date" | "exif";
export type JobStatus = 0 | 1 | 2 | 3;
export type LandingBackgroundModeType = "static" | "photo_id" | "random" | "latest_album_cover" | "random_from_album";
export type LicenseType =
| "none"
| "reserved"
Expand Down Expand Up @@ -953,6 +954,8 @@ declare namespace App.Http.Resources.Rights {
is_photo_timeline_enabled: boolean;
is_mod_renamer_enabled: boolean;
is_mod_webshop_enabled: boolean;
is_contact_enabled: boolean;
messages_count: number;
};
export type PhotoRightsResource = {
can_edit: boolean;
Expand Down
13 changes: 12 additions & 1 deletion resources/js/menus/LeftMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
<template v-if="item.access">
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
<a v-ripple :href="href" v-bind="props.action" @click="navigate">
<PiMiniIcon :key="item.icon" :icon="item.icon" />
<OverlayBadge v-if="item.num > 0" severity="primary" :pt:badge:class="' outline-0'">
<PiMiniIcon :key="item.icon" :icon="item.icon" />
</OverlayBadge>
<PiMiniIcon :key="item.icon" :icon="item.icon" v-else />
<span class="ml-2">
<!-- @vue-ignore -->
{{ $t(item.label) }}
Expand Down Expand Up @@ -123,6 +126,7 @@ import { usePhotosStore } from "@/stores/PhotosState";
import { useAlbumsStore } from "@/stores/AlbumsState";
import { useAlbumStore } from "@/stores/AlbumState";
import { usePhotoStore } from "@/stores/PhotoState";
import OverlayBadge from "primevue/overlaybadge";

const leftMenuState = useLeftMenuStateStore();
const route = useRoute();
Expand Down Expand Up @@ -177,3 +181,10 @@ watch(
},
);
</script>

<style lang="css">
.p-overlaybadge .p-badge {
outline: 0;
transform: translate(30%, -20%);
}
</style>
5 changes: 0 additions & 5 deletions resources/js/stores/LycheeState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export const useLycheeStateStore = defineStore("lychee-store", {
// menu stuff
clockwork_url: "" as null | string,

// Contact stuff
is_contact_form_enabled: false,

// Timeline settings
is_timeline_left_border_visible: true,

Expand Down Expand Up @@ -230,8 +227,6 @@ export const useLycheeStateStore = defineStore("lychee-store", {
this.albums_infinite_scroll_threshold = data.albums_infinite_scroll_threshold;

this.default_album_protection = data.default_album_protection;

this.is_contact_form_enabled = data.is_contact_form_enabled;
})
.catch((error) => {
// In this specific case, even though it has been possibly disabled, we really need to see the error.
Expand Down
Loading