Skip to main content
Version: v1 (Current)

Phase 2: Core Modal Components

Historical design/implementation plan. It is retained as background, not a statement that every proposed feature is available. Use the current component/project guides and the deployed editor before following its recipes.

Estimated Effort: 3-4 hours Dependencies: Phase 1 complete Jira: EZ-2206

Overview​

Build the core modal infrastructure including the main AppStoreModal orchestrator, sidebar with search and tags, and the source filter component. This establishes the foundation for the app store UI.

Objectives​

  • Create AppStoreModal.vue main component
  • Implement view state management (browse/details/config)
  • Build AppStoreSidebar.vue with search and tag filtering
  • Build AppStoreSourceFilter.vue with segmented control
  • Set up data loading and error handling
  • Integrate with tableStyleStore for view mode persistence

Implementation Steps​

Step 1: Create Component Directory Structure​

mkdir -p resources/js/Components/Mod/AppStoreModal
touch resources/js/Components/Mod/AppStoreModal/AppStoreModal.vue
touch resources/js/Components/Mod/AppStoreModal/AppStoreSidebar.vue
touch resources/js/Components/Mod/AppStoreModal/AppStoreSourceFilter.vue
touch resources/js/Components/Mod/AppStoreModal/index.js

Step 2: Build AppStoreSourceFilter.vue​

File: resources/js/Components/Mod/AppStoreModal/AppStoreSourceFilter.vue

<template>
<div
ref="btnGroupContainer"
class="btn-group-container bg-primary-9 rounded-pill d-flex position-relative"
>
<!-- Animated slider background -->
<div
class="slider-background rounded-pill position-absolute"
:style="sliderStyles"
></div>

<!-- All Apps Button -->
<button
type="button"
class="slider-btn btn rounded-pill shadow-0 text-primary fw-bold px-3 position-relative"
:class="{ active: modelValue === 'all' }"
@click="$emit('update:modelValue', 'all')"
>
All Apps
</button>

<!-- Public Only Button -->
<button
type="button"
class="slider-btn btn rounded-pill shadow-0 text-primary fw-bold px-3 position-relative"
:class="{ active: modelValue === 'public' }"
@click="$emit('update:modelValue', 'public')"
>
Public Only
</button>

<!-- My Team Only Button -->
<button
type="button"
class="slider-btn btn rounded-pill shadow-0 text-primary fw-bold px-3 position-relative"
:class="{ active: modelValue === 'team' }"
@click="$emit('update:modelValue', 'team')"
>
My Team Only
</button>
</div>
</template>

<script setup>
import { ref, computed, onMounted, watch, nextTick } from 'vue'

const props = defineProps({
modelValue: {
type: String,
default: 'all',
validator: (value) => ['all', 'public', 'team'].includes(value)
}
})

defineEmits(['update:modelValue'])

const btnGroupContainer = ref(null)
const sliderStyles = ref({})

const updateSliderPosition = async () => {
await nextTick()

if (!btnGroupContainer.value) return

const buttons = btnGroupContainer.value.querySelectorAll('.slider-btn')
const activeIndex = ['all', 'public', 'team'].indexOf(props.modelValue)
const activeButton = buttons[activeIndex]

if (activeButton) {
sliderStyles.value = {
width: `${activeButton.offsetWidth}px`,
transform: `translateX(${activeButton.offsetLeft}px)`,
transition: 'transform 0.3s ease, width 0.3s ease'
}
}
}

watch(() => props.modelValue, updateSliderPosition)
onMounted(updateSliderPosition)
</script>

<style scoped>
.btn-group-container {
display: inline-flex;
padding: 4px;
gap: 0;
}

.slider-background {
height: calc(100% - 8px);
top: 4px;
left: 4px;
background: white;
z-index: 0;
pointer-events: none;
}

.slider-btn {
z-index: 1;
border: none;
background: transparent;
transition: color 0.2s ease;
}

.slider-btn:hover {
background: transparent;
}

.slider-btn.active {
color: var(--bs-primary) !important;
}
</style>

Testing:

  • Verify slider animates smoothly between options
  • Check that clicking each button emits the correct value
  • Test that active state shows correctly

Step 3: Build AppStoreSidebar.vue​

File: resources/js/Components/Mod/AppStoreModal/AppStoreSidebar.vue

<template>
<div class="app-store-sidebar border-end bg-light">
<!-- Search Input -->
<div class="search-section p-3 border-bottom">
<div class="position-relative">
<input
:value="search"
type="text"
class="form-control rounded-pill"
placeholder="Search apps..."
@input="$emit('update:search', $event.target.value)"
/>
<FontAwesomeIcon
icon="search"
class="position-absolute top-50 end-0 translate-middle-y me-3 text-muted"
/>
</div>
</div>

<!-- Tags Filter -->
<div class="tags-section p-3">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="text-muted mb-0">Categories</h6>
<button
v-if="selectedTags.length > 0"
type="button"
class="btn btn-sm btn-link text-decoration-none p-0"
@click="$emit('update:selectedTags', [])"
>
Clear
</button>
</div>

<div class="tag-list d-flex flex-column gap-2">
<div
v-for="tag in tags"
:key="tag.id"
class="tag-item px-3 py-2 rounded cursor-pointer user-select-none"
:class="{
'bg-primary text-white': selectedTags.includes(tag.name),
'bg-white border': !selectedTags.includes(tag.name)
}"
@click="toggleTag(tag.name)"
>
{{ tag.name }}
</div>

<div
v-if="tags.length === 0"
class="text-muted text-center small"
>
No categories available
</div>
</div>
</div>
</div>
</template>

<script setup>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

const props = defineProps({
search: {
type: String,
default: ''
},
selectedTags: {
type: Array,
default: () => []
},
tags: {
type: Array,
default: () => []
}
})

const emit = defineEmits(['update:search', 'update:selectedTags'])

const toggleTag = (tagName) => {
const newTags = [...props.selectedTags]
const index = newTags.indexOf(tagName)

if (index > -1) {
newTags.splice(index, 1)
} else {
newTags.push(tagName)
}

emit('update:selectedTags', newTags)
}
</script>

<style scoped>
.app-store-sidebar {
width: 280px;
height: 100%;
overflow-y: auto;
}

.tag-item {
cursor: pointer;
transition: all 0.2s ease;
}

.tag-item:hover {
transform: translateX(4px);
}

.cursor-pointer {
cursor: pointer;
}

.user-select-none {
user-select: none;
}
</style>

Testing:

  • Verify search input updates parent model
  • Check tag selection/deselection works
  • Test clear button appears and works
  • Verify tag hover effects

Step 4: Build AppStoreModal.vue Main Component​

File: resources/js/Components/Mod/AppStoreModal/AppStoreModal.vue

<template>
<!-- Bootstrap Modal -->
<div
class="modal fade app-store-modal"
:class="{ show: isOpen }"
:style="{ display: isOpen ? 'block' : 'none' }"
tabindex="-1"
@click.self="closeModal"
>
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ modalTitle }}</h5>
<button
type="button"
class="btn-close"
@click="closeModal"
></button>
</div>

<div class="modal-body p-0">
<!-- Loading State -->
<div v-if="loading" class="text-center py-5">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p class="text-muted mt-3">Loading apps...</p>
</div>

<!-- Browse View -->
<div v-else-if="currentView === 'browse'" class="d-flex h-100">
<AppStoreSidebar
v-model:search="searchQuery"
v-model:selected-tags="selectedTags"
:tags="availableTags"
/>

<div class="flex-grow-1 d-flex flex-column">
<!-- Source Filter -->
<div class="p-3 border-bottom">
<div class="d-flex justify-content-between align-items-center">
<AppStoreSourceFilter v-model="sourceFilter" />
<div class="text-muted small">
{{ filteredApps.length }} app{{ filteredApps.length !== 1 ? 's' : '' }}
</div>
</div>
</div>

<!-- Grid/List placeholder (will be built in Phase 3) -->
<div class="p-4 flex-grow-1 overflow-auto">
<p class="text-muted">Grid/List view will be added in Phase 3</p>
<div class="row g-3">
<div
v-for="app in filteredApps"
:key="app.id"
class="col-md-4"
>
<div class="card">
<div class="card-body">
<h6>{{ app.name }}</h6>
<p class="small text-muted">{{ app.short_description }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<!-- Details View (placeholder) -->
<div v-else-if="currentView === 'details'" class="p-4">
<p class="text-muted">Details view will be added in Phase 4</p>
<button type="button" class="btn btn-light" @click="backToBrowse">
Back to Browse
</button>
</div>

<!-- Config View (placeholder) -->
<div v-else-if="currentView === 'config'" class="p-4">
<p class="text-muted">Config view will be added in Phase 5</p>
<button type="button" class="btn btn-light" @click="backToBrowse">
Back to Browse
</button>
</div>
</div>
</div>
</div>
</div>
<div v-if="isOpen" class="modal-backdrop fade show"></div>
</template>

<script setup>
import { ref, computed, watch } from 'vue'
import { useToast } from '@/Composables/useToast'
import http from '@/Services/http'
import route from '@/Composables/useZiggy'
import AppStoreSidebar from './AppStoreSidebar.vue'
import AppStoreSourceFilter from './AppStoreSourceFilter.vue'

const props = defineProps({
project: {
type: Object,
required: true
},
existingAppNames: {
type: Array,
default: () => []
}
})

const toast = useToast()

// View state management
const currentView = ref('browse') // 'browse' | 'details' | 'config'
const viewHistory = ref([])
const isOpen = ref(false)
const loading = ref(false)

// Data
const allApps = ref([])
const availableTags = ref([])

// Filters
const searchQuery = ref('')
const selectedTags = ref([])
const sourceFilter = ref('all')

// Modal title based on current view
const modalTitle = computed(() => {
if (currentView.value === 'details') return 'App Details'
if (currentView.value === 'config') return 'Add App to Project'
return 'App Store'
})

// Filtered apps based on search and tags
const filteredApps = computed(() => {
let apps = allApps.value

// Search filter (name only)
if (searchQuery.value) {
const query = searchQuery.value.toLowerCase()
apps = apps.filter(app =>
app.name.toLowerCase().includes(query)
)
}

// Tags filter (OR logic - show if has ANY selected tag)
if (selectedTags.value.length > 0) {
apps = apps.filter(app =>
app.tags.some(tag => selectedTags.value.includes(tag))
)
}

return apps
})

// Public method to open modal
const openModal = () => {
isOpen.value = true
document.body.classList.add('modal-open')
loadInitialData()
}

// Close modal
const closeModal = () => {
isOpen.value = false
document.body.classList.remove('modal-open')
resetModal()
}

// Reset modal state
const resetModal = () => {
currentView.value = 'browse'
viewHistory.value = []
searchQuery.value = ''
selectedTags.value = []
sourceFilter.value = 'all'
}

// Load initial app list and tags
const loadInitialData = async () => {
loading.value = true
try {
const [appsRes, tagsRes] = await Promise.all([
http.get(route('dashboard.plugins.pages.index', {
app_store: true,
project: props.project.slug,
source: sourceFilter.value
})),
http.get(route('dashboard.system-tags.index', {
class: 'app-store'
}))
])

allApps.value = appsRes.data
availableTags.value = tagsRes.data
} catch (err) {
toast.error('Failed to load app store data')
console.error(err)
} finally {
loading.value = false
}
}

// Reload apps when source filter changes
watch(sourceFilter, async () => {
if (!isOpen.value) return

loading.value = true
try {
const res = await http.get(route('dashboard.plugins.pages.index', {
app_store: true,
project: props.project.slug,
source: sourceFilter.value
}))
allApps.value = res.data
} catch (err) {
toast.error('Failed to load apps')
console.error(err)
} finally {
loading.value = false
}
})

// Navigate back
const backToBrowse = () => {
const previousView = viewHistory.value.pop()
currentView.value = previousView || 'browse'
}

// Expose openModal for parent component
defineExpose({
openModal
})
</script>

<style scoped>
.app-store-modal .modal-dialog {
max-width: 1200px;
}

.modal.show {
background-color: rgba(0, 0, 0, 0.5);
}

.modal-body {
min-height: 600px;
}
</style>

Testing:

  • Verify modal opens and closes correctly
  • Check that body gets modal-open class
  • Test loading state displays
  • Verify source filter changes reload data
  • Test search and tag filtering
  • Check view navigation works

Step 5: Create Index Export File​

File: resources/js/Components/Mod/AppStoreModal/index.js

export { default } from './AppStoreModal.vue'

Step 6: Update Pages Index to Use AppStoreModal​

File: resources/js/Dashboard/Pages/Admin/Projects/Pages/Index.vue

<script setup>
import AppStoreModal from '@/Components/Mod/AppStoreModal'

// ... existing code ...

const createConfig = {
component: AppStoreModal,
create: {
route: "dashboard.project.pages.store",
params: { project: props.project.slug }
},
modalProps: {
project: props.project,
existingAppNames: props.data.data.map(page => page.name)
}
}
</script>

Step 7: Manual Testing Checklist​

Open the modal:

  1. Navigate to /dashboard/{project}/pages
  2. Click create button (should show app store modal instead of old dialog)

Test Source Filter:

  1. Click "All Apps" - should show combined list
  2. Click "Public Only" - should show only public apps
  3. Click "My Team Only" - should show only team apps
  4. Verify spinner shows during filter changes

Test Sidebar:

  1. Type in search - should filter apps by name
  2. Click tags - should filter apps by selected tags
  3. Select multiple tags - should show apps with ANY tag
  4. Click "Clear" - should deselect all tags

Test Modal:

  1. Close button works
  2. Click outside modal closes it
  3. Body scroll is locked when open
  4. Modal resets state on close

Acceptance Criteria​

  • AppStoreModal opens and displays correctly
  • Source filter changes between all/public/team with animation
  • Source filter triggers API reload with correct parameter
  • Sidebar search filters apps by name
  • Sidebar tags filter with OR logic
  • Clear button removes all tag selections
  • Modal closes properly and resets state
  • Loading states show during API calls
  • Error toast shows on API failure

Files Created​

  • resources/js/Components/Mod/AppStoreModal/AppStoreModal.vue
  • resources/js/Components/Mod/AppStoreModal/AppStoreSidebar.vue
  • resources/js/Components/Mod/AppStoreModal/AppStoreSourceFilter.vue
  • resources/js/Components/Mod/AppStoreModal/index.js

Files Modified​

  • resources/js/Dashboard/Pages/Admin/Projects/Pages/Index.vue

Next Phase​

After this phase is complete and manual testing passes, proceed to Phase 3: Browse View Components.