Skip to content

Commit 2590714

Browse files
committed
fixed shared imports in signals
Signed-off-by: RAWx18 <rawx18.dev@gmail.com>
1 parent 8efc1b3 commit 2590714

28 files changed

+2480
-390
lines changed

frontend/src/modules/signals/components/SignalsPlatformsDrawers.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
import useVuelidate from '@vuelidate/core';
3838
import { required } from '@vuelidate/validators';
3939
import AppFormItem from '@/shared/form/form-item.vue';
40-
import platformOptions from '@/modules/signals/constants/signals-platforms.json';
40+
import platformOptions from '@/shared/signals/constants/signals-platforms.json';
4141
4242
const emit = defineEmits(['update:platforms']);
4343
const props = defineProps({

frontend/src/modules/signals/components/SignalsPublishedDate.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<script setup>
1717
import { defineEmits, defineProps, computed } from 'vue';
18-
import datePublishedOptions from '@/modules/signals/constants/signals-date-published.json';
18+
import datePublishedOptions from '@/shared/signals/constants/signals-date-published.json';
1919
2020
const emit = defineEmits(['update:datePublished']);
2121
const props = defineProps({
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<template>
2+
<div class="cross-edition-example">
3+
<div v-if="!areDependenciesLoaded()" class="loading">
4+
Loading dependencies...
5+
</div>
6+
7+
<div v-else-if="dependencyLoadError" class="error">
8+
Error loading dependencies: {{ dependencyLoadError.message }}
9+
</div>
10+
11+
<div v-else class="content">
12+
<h3>Cross-Edition Component Example</h3>
13+
14+
<!-- Use resolved dependencies -->
15+
<div class="platform-info">
16+
<h4>Available Platforms:</h4>
17+
<ul>
18+
<li v-for="platform in availablePlatforms" :key="platform.id">
19+
{{ platform.name }} ({{ platform.id }})
20+
</li>
21+
</ul>
22+
</div>
23+
24+
<div class="features">
25+
<h4>Available Features:</h4>
26+
<ul>
27+
<li>Community Signals: ✅</li>
28+
<li>Premium Features: {{ hasPremiumFeatures ? '✅' : '❌' }}</li>
29+
<li>Sentinel Access: {{ hasSentinelFeatures ? '✅' : '❌' }}</li>
30+
</ul>
31+
</div>
32+
33+
<!-- Dynamic component loading example -->
34+
<div class="dynamic-components">
35+
<h4>Dynamic Components:</h4>
36+
<component
37+
v-if="signalsListComponent"
38+
:is="signalsListComponent"
39+
:signals="exampleSignals"
40+
/>
41+
</div>
42+
</div>
43+
</div>
44+
</template>
45+
46+
<script setup>
47+
import { ref, computed, onMounted } from 'vue';
48+
import { createCrossEditionMixin } from '@/shared/signals/utils/ComponentLoader';
49+
50+
// Define dependencies needed by this component
51+
const dependencyConfig = {
52+
platformConstants: {
53+
type: 'constants',
54+
name: 'platforms',
55+
},
56+
signalsService: {
57+
type: 'service',
58+
},
59+
signalsHelpers: {
60+
type: 'utility',
61+
name: 'SignalsHelpers',
62+
},
63+
signalsFormatters: {
64+
type: 'utility',
65+
name: 'SignalsFormatters',
66+
},
67+
};
68+
69+
// Use the cross-edition mixin
70+
const crossEditionMixin = createCrossEditionMixin(dependencyConfig);
71+
72+
// Component data
73+
const exampleSignals = ref([]);
74+
const signalsListComponent = ref(null);
75+
76+
// Computed properties
77+
const availablePlatforms = computed(() => {
78+
const platformConstants = getDependency('platformConstants');
79+
return platformConstants?.platforms || [];
80+
});
81+
82+
// Methods from mixin
83+
const { getDependency, areDependenciesLoaded } = crossEditionMixin.methods;
84+
const { crossEditionDependencies, dependenciesLoaded, dependencyLoadError } = crossEditionMixin.data();
85+
86+
// Component-specific data
87+
const hasPremiumFeatures = ref(false);
88+
const hasSentinelFeatures = ref(false);
89+
90+
// Load dynamic components
91+
onMounted(async () => {
92+
try {
93+
// Load signals list component dynamically
94+
const { loadSignalsComponent } = await import('@/shared/signals/utils/ComponentLoader');
95+
signalsListComponent.value = await loadSignalsComponent('SignalsList', 'components', 'list')();
96+
97+
// Check for premium features (this would be determined by actual feature flags)
98+
hasPremiumFeatures.value = false; // Community edition
99+
hasSentinelFeatures.value = false; // Community edition
100+
101+
// Load some example signals
102+
const signalsService = getDependency('signalsService');
103+
if (signalsService) {
104+
try {
105+
const response = await signalsService.query({}, null, 5, 0);
106+
exampleSignals.value = response.rows || [];
107+
} catch (error) {
108+
console.warn('Could not load example signals:', error);
109+
}
110+
}
111+
} catch (error) {
112+
console.error('Error in component setup:', error);
113+
}
114+
});
115+
116+
// Apply mixin lifecycle
117+
crossEditionMixin.created?.();
118+
</script>
119+
120+
<style scoped>
121+
.cross-edition-example {
122+
padding: 20px;
123+
border: 1px solid #ddd;
124+
border-radius: 8px;
125+
margin: 20px 0;
126+
}
127+
128+
.loading, .error {
129+
text-align: center;
130+
padding: 20px;
131+
}
132+
133+
.error {
134+
color: #d32f2f;
135+
background-color: #ffebee;
136+
border-radius: 4px;
137+
}
138+
139+
.platform-info, .features, .dynamic-components {
140+
margin: 20px 0;
141+
}
142+
143+
.platform-info ul, .features ul {
144+
list-style-type: disc;
145+
margin-left: 20px;
146+
}
147+
148+
h3 {
149+
color: #1976d2;
150+
margin-bottom: 20px;
151+
}
152+
153+
h4 {
154+
color: #424242;
155+
margin-bottom: 10px;
156+
}
157+
</style>

frontend/src/modules/signals/components/list/SignalsEmailDigestDrawer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ import {
250250
mapState,
251251
} from '@/shared/vuex/vuex.helpers';
252252
import Message from '@/shared/message/message';
253-
import platformOptions from '@/modules/signals/constants/signals-platforms.json';
253+
import platformOptions from '@/shared/signals/constants/signals-platforms.json';
254254
import AppFormItem from '@/shared/form/form-item.vue';
255255
import formChangeDetector from '@/shared/form/form-change';
256256
import elementChangeDetector from '@/shared/form/element-change';

frontend/src/modules/signals/components/list/SignalsResultCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ import {
195195
import { useStore } from 'vuex';
196196
import moment from 'moment';
197197
import { formatDateToTimeAgo } from '@/utils/date';
198-
import platformOptions from '@/modules/signals/constants/signals-platforms.json';
198+
import platformOptions from '@/shared/signals/constants/signals-platforms.json';
199199
import { withHttp } from '@/utils/string';
200200
import { mapGetters } from '@/shared/vuex/vuex.helpers';
201-
import { SignalsService } from '@/modules/signals/services/signalsService';
201+
import { SignalsService } from '@/shared/signals/services/SignalsService';
202202
203203
const props = defineProps({
204204
signal: {

frontend/src/modules/signals/components/list/SignalsSettings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127

128128
<script setup>
129129
import { ref, computed } from 'vue';
130-
import platformOptions from '@/modules/signals/constants/signals-platforms.json';
130+
import platformOptions from '@/shared/signals/constants/signals-platforms.json';
131131
import SignalsEmailDigestCard from './SignalsEmailDigestCard.vue';
132132
import SignalsSettingsDrawer from './SignalsSettingsDrawer.vue';
133133
import { mapGetters } from '@/shared/vuex/vuex.helpers';
Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,3 @@
1-
{
2-
"platforms": [
3-
{
4-
"id": "github",
5-
"name": "GitHub",
6-
"icon": "github",
7-
"color": "#333",
8-
"enabled": true
9-
},
10-
{
11-
"id": "discord",
12-
"name": "Discord",
13-
"icon": "discord",
14-
"color": "#5865F2",
15-
"enabled": true
16-
},
17-
{
18-
"id": "slack",
19-
"name": "Slack",
20-
"icon": "slack",
21-
"color": "#4A154B",
22-
"enabled": true
23-
},
24-
{
25-
"id": "twitter",
26-
"name": "Twitter",
27-
"icon": "twitter",
28-
"color": "#1DA1F2",
29-
"enabled": true
30-
},
31-
{
32-
"id": "linkedin",
33-
"name": "LinkedIn",
34-
"icon": "linkedin",
35-
"color": "#0077B5",
36-
"enabled": true
37-
},
38-
{
39-
"id": "reddit",
40-
"name": "Reddit",
41-
"icon": "reddit",
42-
"color": "#FF4500",
43-
"enabled": true
44-
}
45-
]
46-
}
1+
// Re-export the shared constants
2+
export { default as platformOptions } from '@/shared/signals/constants/signals-platforms.json';
3+
export { default as datePublishedOptions } from '@/shared/signals/constants/signals-date-published.json';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Re-export the shared base mixin
2+
export { default } from '@/shared/signals/mixins/signalsBaseMixin';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Re-export the shared permissions mixin
2+
export { default } from '@/shared/signals/mixins/signalsPermissionsMixin';
Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,2 @@
1-
// Community Edition Signals Permissions Service
2-
// This will be populated during service migration
3-
4-
import Permissions from '@/security/permissions';
5-
6-
class SignalsPermissions {
7-
constructor() {
8-
// Initialize permissions
9-
}
10-
11-
// Check if user can read signals
12-
canRead(user) {
13-
// Permission logic will be implemented during migration
14-
// return user && user.permissions.includes(Permissions.values.signalsRead);
15-
return true; // Placeholder - community edition allows read access
16-
}
17-
18-
// Check if user can write signals
19-
canWrite(user) {
20-
// Permission logic will be implemented during migration
21-
// return user && user.permissions.includes(Permissions.values.signalsWrite);
22-
return true; // Placeholder - community edition allows write access
23-
}
24-
25-
// Check if user can delete signals
26-
canDelete(user) {
27-
// Permission logic will be implemented during migration
28-
// return user && user.permissions.includes(Permissions.values.signalsDelete);
29-
return true; // Placeholder - community edition allows delete access
30-
}
31-
32-
// Check if user can access premium features (sentinel)
33-
canAccessPremium(user) {
34-
// This should always return false for community edition
35-
// Premium features are handled separately
36-
return false;
37-
}
38-
39-
// Get available permissions for current user
40-
getAvailablePermissions(user) {
41-
const permissions = [];
42-
43-
if (this.canRead(user)) {
44-
permissions.push('read');
45-
}
46-
47-
if (this.canWrite(user)) {
48-
permissions.push('write');
49-
}
50-
51-
if (this.canDelete(user)) {
52-
permissions.push('delete');
53-
}
54-
55-
return permissions;
56-
}
57-
}
58-
59-
export default new SignalsPermissions();
1+
// Re-export the shared permissions service
2+
export { default } from '@/shared/signals/services/SignalsPermissions';

0 commit comments

Comments
 (0)