firstly 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/esm/ROUTES.d.ts +2 -0
- package/esm/ROUTES.js +1 -0
- package/esm/api/index.d.ts +9 -0
- package/esm/api/index.js +3 -1
- package/esm/auth/AuthController.d.ts +12 -23
- package/esm/auth/AuthController.js +12 -31
- package/esm/auth/server/AuthController.server.d.ts +11 -11
- package/esm/auth/server/AuthController.server.js +99 -34
- package/esm/auth/server/handleGuard.d.ts +16 -0
- package/esm/auth/server/handleGuard.js +67 -0
- package/esm/auth/server/helperFirstly.d.ts +1 -1
- package/esm/auth/server/helperFirstly.js +1 -0
- package/esm/auth/server/index.d.ts +3 -1
- package/esm/auth/server/index.js +3 -1
- package/esm/auth/server/module.d.ts +105 -89
- package/esm/auth/server/module.js +55 -42
- package/esm/auth/server/providers/github.d.ts +4 -2
- package/esm/auth/server/providers/github.js +2 -2
- package/esm/auth/static/assets/Page-B0XXxe0N.d.ts +6 -0
- package/esm/auth/static/assets/Page-B0XXxe0N.js +1 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.d.ts +6 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.js +20 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.d.ts +6 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.js +1 -0
- package/esm/auth/static/assets/Page-mK42zGEw.css +1 -0
- package/esm/auth/static/assets/index-C9jzxOBu.d.ts +151 -0
- package/esm/auth/static/assets/index-C9jzxOBu.js +42 -0
- package/esm/auth/static/assets/index-DKWpA6v7.css +4 -0
- package/esm/auth/static/index.html +11 -11
- package/esm/auth/types.d.ts +26 -3
- package/esm/bin/cmd.js +423 -152
- package/esm/cellsBuildor.js +1 -1
- package/esm/common.d.ts +5 -0
- package/esm/common.js +8 -0
- package/esm/cron/server/index.js +1 -1
- package/esm/feedback/FeedbackController.js +58 -53
- package/esm/feedback/server/index.d.ts +6 -15
- package/esm/feedback/server/index.js +4 -5
- package/esm/feedback/types.d.ts +14 -0
- package/esm/feedback/types.js +4 -0
- package/esm/feedback/ui/DialogIssue.svelte +131 -119
- package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogIssues.svelte +108 -99
- package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogMilestones.svelte +40 -34
- package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -16
- package/esm/feedback/ui/Feedback.svelte +11 -9
- package/esm/feedback/ui/Feedback.svelte.d.ts +16 -14
- package/esm/index.d.ts +2 -5
- package/esm/index.js +2 -8
- package/esm/mail/server/index.d.ts +9 -2
- package/esm/mail/server/index.js +3 -1
- package/esm/mail/templates/DefaultMail.svelte +81 -61
- package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -26
- package/esm/server/index.d.ts +0 -0
- package/esm/server/index.js +1 -0
- package/esm/storeItem.d.ts +1 -4
- package/esm/storeItem.js +1 -1
- package/esm/storeList.d.ts +1 -4
- package/esm/sveltekit/server/index.d.ts +3 -9
- package/esm/sveltekit/server/index.js +3 -0
- package/esm/ui/Button.svelte +112 -89
- package/esm/ui/Button.svelte.d.ts +34 -24
- package/esm/ui/Clipboardable.svelte +24 -17
- package/esm/ui/Clipboardable.svelte.d.ts +34 -23
- package/esm/ui/Field.svelte +328 -285
- package/esm/ui/Field.svelte.d.ts +15 -8
- package/esm/ui/FieldGroup.svelte +112 -91
- package/esm/ui/FieldGroup.svelte.d.ts +17 -6
- package/esm/ui/Grid.svelte +322 -308
- package/esm/ui/Grid.svelte.d.ts +17 -6
- package/esm/ui/GridLoading.svelte +28 -27
- package/esm/ui/GridLoading.svelte.d.ts +19 -17
- package/esm/ui/GridPaginate.svelte +68 -61
- package/esm/ui/GridPaginate.svelte.d.ts +21 -19
- package/esm/ui/Icon.svelte +116 -80
- package/esm/ui/Icon.svelte.d.ts +52 -43
- package/esm/ui/Loading.svelte +10 -8
- package/esm/ui/Loading.svelte.d.ts +29 -18
- package/esm/ui/Tooltip.svelte +38 -35
- package/esm/ui/Tooltip.svelte.d.ts +30 -20
- package/esm/ui/dialog/DialogForm.svelte +70 -63
- package/esm/ui/dialog/DialogForm.svelte.d.ts +18 -16
- package/esm/ui/dialog/DialogManagement.svelte +74 -74
- package/esm/ui/dialog/DialogManagement.svelte.d.ts +22 -21
- package/esm/ui/dialog/DialogPrimitive.svelte +82 -76
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +35 -25
- package/esm/ui/dialog/FormEditAction.svelte +58 -50
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +13 -6
- package/esm/ui/dialog/dialog.d.ts +1 -4
- package/esm/ui/internals/FieldContainer.svelte +24 -17
- package/esm/ui/internals/FieldContainer.svelte.d.ts +37 -28
- package/esm/ui/internals/Input.svelte +136 -102
- package/esm/ui/internals/Input.svelte.d.ts +34 -32
- package/esm/ui/internals/Textarea.svelte +60 -52
- package/esm/ui/internals/Textarea.svelte.d.ts +31 -28
- package/esm/ui/internals/select/MultiSelectMelt.svelte +243 -199
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +29 -27
- package/esm/ui/internals/select/SelectMelt.svelte +254 -219
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +34 -32
- package/esm/ui/internals/select/SelectRadio.svelte +39 -33
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +24 -22
- package/esm/ui/link/Link.svelte +25 -20
- package/esm/ui/link/Link.svelte.d.ts +31 -23
- package/esm/ui/link/LinkPlus.svelte +52 -51
- package/esm/ui/link/LinkPlus.svelte.d.ts +20 -18
- package/esm/vite/index.d.ts +2 -3
- package/esm/vite/index.js +33 -26
- package/package.json +16 -20
- package/esm/auth/static/assets/Page-Bb8bFlrP.d.ts +0 -4
- package/esm/auth/static/assets/Page-Bb8bFlrP.js +0 -1
- package/esm/auth/static/assets/Page-BxomFlZ8.d.ts +0 -4
- package/esm/auth/static/assets/Page-BxomFlZ8.js +0 -1
- package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +0 -6
- package/esm/auth/static/assets/Page-CaIYu0-y.js +0 -19
- package/esm/auth/static/assets/Page-MkYglNtu.css +0 -1
- package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +0 -64
- package/esm/auth/static/assets/index-Bl0Bk5u0.js +0 -2
- package/esm/auth/static/assets/index-R27C_TlP.css +0 -4
package/esm/cellsBuildor.js
CHANGED
|
@@ -99,7 +99,7 @@ export const buildWhere = (entity, defaultWhere, fields_filter, fields_search, o
|
|
|
99
99
|
}
|
|
100
100
|
for (const field of fields_filter) {
|
|
101
101
|
// if there is a value
|
|
102
|
-
if (obj[field.key]) {
|
|
102
|
+
if (obj && obj[field.key]) {
|
|
103
103
|
const rfi = getRelationFieldInfo(field);
|
|
104
104
|
if (field.inputType === 'checkbox') {
|
|
105
105
|
// @ts-ignore
|
package/esm/common.d.ts
ADDED
package/esm/common.js
ADDED
package/esm/cron/server/index.js
CHANGED
|
@@ -58,7 +58,7 @@ export const cron = (jobsInfos) => {
|
|
|
58
58
|
l.push(message);
|
|
59
59
|
if (with_metadata) {
|
|
60
60
|
// If the job is "stopped", there will still be a next date, but it will not fire it. The job has to start.
|
|
61
|
-
l.push(`(${job.
|
|
61
|
+
l.push(`(${job.isActive ? green('running') : red('stopped')}, next at ${yellow(job.nextDate().toISO())})`);
|
|
62
62
|
}
|
|
63
63
|
if (isSuccess) {
|
|
64
64
|
m.log.success(l.join(' '));
|
|
@@ -6,32 +6,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Allow, BackendMethod, EntityError, remult } from 'remult';
|
|
8
8
|
import { stry } from '@kitql/helpers';
|
|
9
|
-
import { FEEDBACK_OPTIONS } from './server';
|
|
10
|
-
const GITHUB_GRAPHQL_ENDPOINT = 'https://api.github.com/graphql';
|
|
11
9
|
async function getGitHub(query, variables) {
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
if (import.meta.env.SSR) {
|
|
11
|
+
if (!remult.context.feedbackOptions.GITHUB_API_TOKEN) {
|
|
12
|
+
console.error(`GITHUB_API_TOKEN not found in .env`);
|
|
13
|
+
throw new EntityError({ message: 'Feedback module not well configured' });
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const headers = new Headers({
|
|
17
|
+
Authorization: 'Bearer ' + remult.context.feedbackOptions.GITHUB_API_TOKEN,
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
});
|
|
20
|
+
const body = stry({ query, variables }, 0);
|
|
21
|
+
const GITHUB_GRAPHQL_ENDPOINT = 'https://api.github.com/graphql';
|
|
22
|
+
const response = await fetch(GITHUB_GRAPHQL_ENDPOINT, { method: 'POST', headers, body });
|
|
23
|
+
const result = await response.json();
|
|
24
|
+
if (result.errors) {
|
|
25
|
+
console.error(`result ERRORS`, body, stry(result));
|
|
26
|
+
}
|
|
27
|
+
return result.data;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error(`error`, error);
|
|
25
31
|
}
|
|
26
|
-
return result.data;
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error(`error`, error);
|
|
30
32
|
}
|
|
31
33
|
return null;
|
|
32
34
|
}
|
|
33
35
|
async function addMetaData(issueId, author, page) {
|
|
34
|
-
|
|
36
|
+
if (import.meta.env.SSR) {
|
|
37
|
+
const commentToMinimize = await getGitHub(`mutation AddComment($input: AddCommentInput!) {
|
|
35
38
|
addComment(input: $input) {
|
|
36
39
|
commentEdge {
|
|
37
40
|
node {
|
|
@@ -41,12 +44,12 @@ async function addMetaData(issueId, author, page) {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
`, {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
input: {
|
|
48
|
+
subjectId: issueId,
|
|
49
|
+
body: `<pre>\n${JSON.stringify({ author, page }, null, 2)}\n</pre>`,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
await getGitHub(`mutation MinimizeComment($input: MinimizeCommentInput!) {
|
|
50
53
|
minimizeComment(input: $input) {
|
|
51
54
|
minimizedComment {
|
|
52
55
|
isMinimized
|
|
@@ -54,11 +57,12 @@ async function addMetaData(issueId, author, page) {
|
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
`, {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
input: {
|
|
61
|
+
subjectId: commentToMinimize.addComment.commentEdge.node.id,
|
|
62
|
+
classifier: 'OFF_TOPIC',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
67
|
export class FeedbackController {
|
|
64
68
|
static async getMilestones() {
|
|
@@ -83,14 +87,16 @@ export class FeedbackController {
|
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
`, {
|
|
86
|
-
repository:
|
|
87
|
-
owner:
|
|
88
|
-
filter:
|
|
90
|
+
repository: remult.context.feedbackOptions.repo.name,
|
|
91
|
+
owner: remult.context.feedbackOptions.repo.owner,
|
|
92
|
+
filter: remult.context.feedbackOptions.milestones?.title_filter ?? '',
|
|
89
93
|
});
|
|
90
94
|
return data.repository.milestones.nodes.map((c) => {
|
|
91
95
|
return {
|
|
92
96
|
...c,
|
|
93
|
-
title: c.title
|
|
97
|
+
title: c.title
|
|
98
|
+
.replaceAll(remult.context.feedbackOptions.milestones?.title_filter ?? '', '')
|
|
99
|
+
.trim(),
|
|
94
100
|
};
|
|
95
101
|
});
|
|
96
102
|
}
|
|
@@ -126,18 +132,18 @@ export class FeedbackController {
|
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
`, {
|
|
129
|
-
repository:
|
|
130
|
-
owner:
|
|
135
|
+
repository: remult.context.feedbackOptions.repo.name,
|
|
136
|
+
owner: remult.context.feedbackOptions.repo.owner,
|
|
131
137
|
milestoneNumber,
|
|
132
138
|
filters: {
|
|
133
|
-
labels:
|
|
139
|
+
labels: remult.context.feedbackOptions.milestones?.labels_filters ?? [],
|
|
134
140
|
states: [issueState],
|
|
135
141
|
},
|
|
136
142
|
issueOrder,
|
|
137
143
|
});
|
|
138
144
|
return data.repository.milestone.issues.nodes.map((issue) => {
|
|
139
|
-
const hasWaitingForAnswerLabel =
|
|
140
|
-
? issue.labels.nodes.some((label) => label.name.includes(
|
|
145
|
+
const hasWaitingForAnswerLabel = remult.context.feedbackOptions.highlight_label
|
|
146
|
+
? issue.labels.nodes.some((label) => label.name.includes(remult.context.feedbackOptions.highlight_label))
|
|
141
147
|
: false;
|
|
142
148
|
return {
|
|
143
149
|
id: issue.id,
|
|
@@ -181,8 +187,8 @@ export class FeedbackController {
|
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
189
|
`, {
|
|
184
|
-
repository:
|
|
185
|
-
owner:
|
|
190
|
+
repository: remult.context.feedbackOptions.repo.name,
|
|
191
|
+
owner: remult.context.feedbackOptions.repo.owner,
|
|
186
192
|
issueNumber,
|
|
187
193
|
});
|
|
188
194
|
const items = [];
|
|
@@ -200,8 +206,7 @@ export class FeedbackController {
|
|
|
200
206
|
items[items.length - 1].public = true;
|
|
201
207
|
}
|
|
202
208
|
else {
|
|
203
|
-
const nbEye = comments[i].reactionGroups.find((c) => c.content === 'EYES')?.reactors
|
|
204
|
-
.totalCount;
|
|
209
|
+
const nbEye = comments[i].reactionGroups.find((c) => c.content === 'EYES')?.reactors.totalCount;
|
|
205
210
|
items.push({
|
|
206
211
|
bodyHTML: comments[i].bodyHTML,
|
|
207
212
|
createdAt: new Date(comments[i].createdAt),
|
|
@@ -209,8 +214,8 @@ export class FeedbackController {
|
|
|
209
214
|
});
|
|
210
215
|
}
|
|
211
216
|
}
|
|
212
|
-
const hasWaitingForAnswerLabel =
|
|
213
|
-
? data.repository.issue.labels.nodes.some((label) => label.name.includes(
|
|
217
|
+
const hasWaitingForAnswerLabel = remult.context.feedbackOptions.highlight_label
|
|
218
|
+
? data.repository.issue.labels.nodes.some((label) => label.name.includes(remult.context.feedbackOptions.highlight_label))
|
|
214
219
|
: false;
|
|
215
220
|
const toRet = {
|
|
216
221
|
id: data.repository.issue.id,
|
|
@@ -236,11 +241,11 @@ export class FeedbackController {
|
|
|
236
241
|
}
|
|
237
242
|
}
|
|
238
243
|
}`, {
|
|
239
|
-
repository:
|
|
240
|
-
owner:
|
|
244
|
+
repository: remult.context.feedbackOptions.repo.name,
|
|
245
|
+
owner: remult.context.feedbackOptions.repo.owner,
|
|
241
246
|
});
|
|
242
247
|
const repoInfoData = repoInfo.repository;
|
|
243
|
-
const create_label = repoInfoData.labels.nodes.find((c) => c.name ===
|
|
248
|
+
const create_label = repoInfoData.labels.nodes.find((c) => c.name === remult.context.feedbackOptions.create_label);
|
|
244
249
|
const newIssue = await getGitHub(`mutation CreateIssue($input: CreateIssueInput!) {
|
|
245
250
|
createIssue(input: $input) {
|
|
246
251
|
issue {
|
|
@@ -269,8 +274,8 @@ export class FeedbackController {
|
|
|
269
274
|
};
|
|
270
275
|
const inputIssue = {
|
|
271
276
|
id: issueId,
|
|
272
|
-
labelIds: (
|
|
273
|
-
? labels.filter((c) => c.name !==
|
|
277
|
+
labelIds: (remult.context.feedbackOptions.highlight_label
|
|
278
|
+
? labels.filter((c) => c.name !== remult.context.feedbackOptions.highlight_label)
|
|
274
279
|
: labels).map((c) => c.id),
|
|
275
280
|
};
|
|
276
281
|
await getGitHub(`mutation AddComment($inputComment: AddCommentInput!, $inputIssue: UpdateIssueInput!) {
|
|
@@ -300,8 +305,8 @@ export class FeedbackController {
|
|
|
300
305
|
};
|
|
301
306
|
const inputIssue = {
|
|
302
307
|
id: issueId,
|
|
303
|
-
labelIds: (
|
|
304
|
-
? labels.filter((c) => c.name !==
|
|
308
|
+
labelIds: (remult.context.feedbackOptions.highlight_label
|
|
309
|
+
? labels.filter((c) => c.name !== remult.context.feedbackOptions.highlight_label)
|
|
305
310
|
: labels).map((c) => c.id),
|
|
306
311
|
};
|
|
307
312
|
await getGitHub(`mutation CloseIssue($inputIssue: UpdateIssueInput!, $inputClose: CloseIssueInput!) {
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { Module } from '../../api';
|
|
2
|
-
type FeedbackOptions
|
|
3
|
-
GITHUB_API_TOKEN: string;
|
|
4
|
-
repo: {
|
|
5
|
-
owner: string;
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
milestones?: {
|
|
9
|
-
title_filter?: string;
|
|
10
|
-
labels_filters?: string[];
|
|
11
|
-
};
|
|
12
|
-
highlight_label?: string;
|
|
13
|
-
create_label?: string;
|
|
14
|
-
};
|
|
15
|
-
export declare let FEEDBACK_OPTIONS: FeedbackOptions;
|
|
2
|
+
import type { FeedbackOptions } from '../types';
|
|
16
3
|
export declare const feedback: (o: FeedbackOptions) => Module;
|
|
17
|
-
|
|
4
|
+
declare module 'remult' {
|
|
5
|
+
interface RemultContext {
|
|
6
|
+
feedbackOptions: FeedbackOptions;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import { remult } from 'remult';
|
|
1
2
|
import { Module } from '../../api';
|
|
2
3
|
import { FeedbackController } from '../FeedbackController';
|
|
3
|
-
export let FEEDBACK_OPTIONS = {
|
|
4
|
-
GITHUB_API_TOKEN: '',
|
|
5
|
-
repo: { owner: '', name: '' },
|
|
6
|
-
};
|
|
7
4
|
export const feedback = (o) => {
|
|
8
|
-
FEEDBACK_OPTIONS = o;
|
|
9
5
|
return new Module({
|
|
10
6
|
name: 'feedback',
|
|
11
7
|
controllers: [FeedbackController],
|
|
8
|
+
initRequest: async (kitEvent, op) => {
|
|
9
|
+
remult.context.feedbackOptions = o;
|
|
10
|
+
},
|
|
12
11
|
});
|
|
13
12
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type FeedbackOptions = {
|
|
2
|
+
GITHUB_API_TOKEN: string;
|
|
3
|
+
repo: {
|
|
4
|
+
owner: string;
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
milestones?: {
|
|
8
|
+
title_filter?: string;
|
|
9
|
+
labels_filters?: string[];
|
|
10
|
+
};
|
|
11
|
+
highlight_label?: string;
|
|
12
|
+
create_label?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const FEEDBACK_OPTIONS: FeedbackOptions;
|
|
@@ -1,123 +1,135 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
|
|
4
|
+
import { repo } from 'remult'
|
|
5
|
+
|
|
6
|
+
import { page } from '$app/stores'
|
|
7
|
+
|
|
8
|
+
import { FeedbackController } from '..'
|
|
9
|
+
import { Button, cellBuildor, Field, FilterEntity, Loading, type ResolvedType } from '../..'
|
|
10
|
+
import Textarea from '../../ui/internals/Textarea.svelte'
|
|
11
|
+
|
|
12
|
+
export let dialogId: number
|
|
13
|
+
const rmvWarning = dialogId
|
|
14
|
+
|
|
15
|
+
export let milestoneId: string
|
|
16
|
+
export let issueNumber: number | null
|
|
17
|
+
|
|
18
|
+
let state: 'loading' | 'done' = 'loading'
|
|
19
|
+
|
|
20
|
+
let issue: ResolvedType<ReturnType<typeof FeedbackController.getIssue>> | undefined
|
|
21
|
+
|
|
22
|
+
const update = async () => {
|
|
23
|
+
state = 'loading'
|
|
24
|
+
if (issueNumber) {
|
|
25
|
+
issue = await FeedbackController.getIssue(issueNumber)
|
|
26
|
+
}
|
|
27
|
+
state = 'done'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onMount(async () => {
|
|
31
|
+
await update()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
let title: ''
|
|
35
|
+
let content: ''
|
|
36
|
+
const send = async () => {
|
|
37
|
+
state = 'loading'
|
|
38
|
+
|
|
39
|
+
const p = $page.url.pathname + $page.url.search
|
|
40
|
+
if (!issue?.id) {
|
|
41
|
+
const result = await FeedbackController.createIssue(milestoneId, title, content, p)
|
|
42
|
+
issueNumber = result.number
|
|
43
|
+
} else {
|
|
44
|
+
await FeedbackController.addCommentOnIssue(issue.id, content, p, issue.labels)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
content = ''
|
|
48
|
+
await update()
|
|
49
|
+
state = 'done'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const close = async () => {
|
|
53
|
+
state = 'loading'
|
|
54
|
+
await FeedbackController.close(issue!.id, issue!.labels)
|
|
55
|
+
content = ''
|
|
56
|
+
await update()
|
|
57
|
+
state = 'done'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const reOpen = async () => {
|
|
61
|
+
state = 'loading'
|
|
62
|
+
await FeedbackController.reOpen(issue!.id)
|
|
63
|
+
content = ''
|
|
64
|
+
await update()
|
|
65
|
+
state = 'done'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const disableButton = (issueNumber: number | null, title: string, content: string) => {
|
|
69
|
+
if (issueNumber) {
|
|
70
|
+
if (content?.length > 2) {
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (title?.length > 2 && content?.length > 2) {
|
|
75
|
+
return false
|
|
76
|
+
}
|
|
77
|
+
return true
|
|
78
|
+
}
|
|
63
79
|
</script>
|
|
64
80
|
|
|
65
81
|
<div class="mb-4 grid gap-4">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
>
|
|
120
|
-
</div>
|
|
121
|
-
{/if}
|
|
122
|
-
{/if}
|
|
82
|
+
{#if state === 'loading'}
|
|
83
|
+
<Loading class="h-12"></Loading>
|
|
84
|
+
<Loading class="h-12"></Loading>
|
|
85
|
+
<Loading class="h-12"></Loading>
|
|
86
|
+
{:else}
|
|
87
|
+
{#each issue?.items ?? [] as item}
|
|
88
|
+
<div class="chat {item.who ? 'chat-start' : 'chat-end'}">
|
|
89
|
+
<div class="avatar chat-image">
|
|
90
|
+
<div class="w-10 rounded-full">
|
|
91
|
+
<div class="h-10 w-10 {item.who ? 'bg-primary' : 'bg-secondary'}"></div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="chat-header">
|
|
95
|
+
{item.who ?? 'Support'}
|
|
96
|
+
<time class="text-xs opacity-50"
|
|
97
|
+
>{new Date(item.createdAt).toLocaleDateString()} - {new Date(
|
|
98
|
+
item.createdAt,
|
|
99
|
+
).toLocaleTimeString()}</time
|
|
100
|
+
>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="chat-bubble prose">{@html item.bodyHTML}</div>
|
|
103
|
+
<!-- <div class="chat-footer opacity-50">Delivered</div> -->
|
|
104
|
+
</div>
|
|
105
|
+
{/each}
|
|
106
|
+
{#if issue?.highlight && issue.state === 'OPEN'}
|
|
107
|
+
<span class="badge badge-warning">En attente de réponse de TA part 😉, oui 🫵!</span>
|
|
108
|
+
{/if}
|
|
109
|
+
{#if issueNumber}
|
|
110
|
+
<button on:click={update} aria-label="Actualiser" class="divider"></button>
|
|
111
|
+
{/if}
|
|
112
|
+
|
|
113
|
+
{#if issue?.state === 'CLOSED'}
|
|
114
|
+
<div class="flex justify-end">
|
|
115
|
+
<Button on:click={reOpen} class="btn-neutral">Re Ouvrir</Button>
|
|
116
|
+
</div>
|
|
117
|
+
{:else}
|
|
118
|
+
{#if issueNumber === null}
|
|
119
|
+
<Field cell={cellBuildor(repo(FilterEntity), 'title')} bind:value={title} />
|
|
120
|
+
{/if}
|
|
121
|
+
<Textarea
|
|
122
|
+
bind:value={content}
|
|
123
|
+
placeholder="Un peu de détail c'est pas mal... Fais toi Plaiz' (Tu as même le droit d'utiliser le format markdown!)"
|
|
124
|
+
></Textarea>
|
|
125
|
+
<div class="flex justify-between">
|
|
126
|
+
{#if issueNumber}
|
|
127
|
+
<Button on:click={close} tabIndex={-1} class="btn-outline btn-error">Clore le feedback</Button>
|
|
128
|
+
{:else}
|
|
129
|
+
<div></div>
|
|
130
|
+
{/if}
|
|
131
|
+
<Button on:click={send} disabled={disableButton(issueNumber, title, content)}>Envoyer</Button>
|
|
132
|
+
</div>
|
|
133
|
+
{/if}
|
|
134
|
+
{/if}
|
|
123
135
|
</div>
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
7
11
|
};
|
|
8
|
-
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type DialogIssueProps = typeof __propDef.props;
|
|
16
|
-
export type DialogIssueEvents = typeof __propDef.events;
|
|
17
|
-
export type DialogIssueSlots = typeof __propDef.slots;
|
|
18
|
-
export default class DialogIssue extends SvelteComponent<DialogIssueProps, DialogIssueEvents, DialogIssueSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
19
13
|
}
|
|
20
|
-
|
|
14
|
+
declare const DialogIssue: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
dialogId: number;
|
|
16
|
+
milestoneId: string;
|
|
17
|
+
issueNumber: number | null;
|
|
18
|
+
}, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, string>;
|
|
21
|
+
type DialogIssue = InstanceType<typeof DialogIssue>;
|
|
22
|
+
export default DialogIssue;
|