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.
Files changed (120) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/esm/ROUTES.d.ts +2 -0
  3. package/esm/ROUTES.js +1 -0
  4. package/esm/api/index.d.ts +9 -0
  5. package/esm/api/index.js +3 -1
  6. package/esm/auth/AuthController.d.ts +12 -23
  7. package/esm/auth/AuthController.js +12 -31
  8. package/esm/auth/server/AuthController.server.d.ts +11 -11
  9. package/esm/auth/server/AuthController.server.js +99 -34
  10. package/esm/auth/server/handleGuard.d.ts +16 -0
  11. package/esm/auth/server/handleGuard.js +67 -0
  12. package/esm/auth/server/helperFirstly.d.ts +1 -1
  13. package/esm/auth/server/helperFirstly.js +1 -0
  14. package/esm/auth/server/index.d.ts +3 -1
  15. package/esm/auth/server/index.js +3 -1
  16. package/esm/auth/server/module.d.ts +105 -89
  17. package/esm/auth/server/module.js +55 -42
  18. package/esm/auth/server/providers/github.d.ts +4 -2
  19. package/esm/auth/server/providers/github.js +2 -2
  20. package/esm/auth/static/assets/Page-B0XXxe0N.d.ts +6 -0
  21. package/esm/auth/static/assets/Page-B0XXxe0N.js +1 -0
  22. package/esm/auth/static/assets/Page-DdKMiUZn.d.ts +6 -0
  23. package/esm/auth/static/assets/Page-DdKMiUZn.js +20 -0
  24. package/esm/auth/static/assets/Page-UV_hqY7I.d.ts +6 -0
  25. package/esm/auth/static/assets/Page-UV_hqY7I.js +1 -0
  26. package/esm/auth/static/assets/Page-mK42zGEw.css +1 -0
  27. package/esm/auth/static/assets/index-C9jzxOBu.d.ts +151 -0
  28. package/esm/auth/static/assets/index-C9jzxOBu.js +42 -0
  29. package/esm/auth/static/assets/index-DKWpA6v7.css +4 -0
  30. package/esm/auth/static/index.html +11 -11
  31. package/esm/auth/types.d.ts +26 -3
  32. package/esm/bin/cmd.js +423 -152
  33. package/esm/cellsBuildor.js +1 -1
  34. package/esm/common.d.ts +5 -0
  35. package/esm/common.js +8 -0
  36. package/esm/cron/server/index.js +1 -1
  37. package/esm/feedback/FeedbackController.js +58 -53
  38. package/esm/feedback/server/index.d.ts +6 -15
  39. package/esm/feedback/server/index.js +4 -5
  40. package/esm/feedback/types.d.ts +14 -0
  41. package/esm/feedback/types.js +4 -0
  42. package/esm/feedback/ui/DialogIssue.svelte +131 -119
  43. package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -18
  44. package/esm/feedback/ui/DialogIssues.svelte +108 -99
  45. package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -18
  46. package/esm/feedback/ui/DialogMilestones.svelte +40 -34
  47. package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -16
  48. package/esm/feedback/ui/Feedback.svelte +11 -9
  49. package/esm/feedback/ui/Feedback.svelte.d.ts +16 -14
  50. package/esm/index.d.ts +2 -5
  51. package/esm/index.js +2 -8
  52. package/esm/mail/server/index.d.ts +9 -2
  53. package/esm/mail/server/index.js +3 -1
  54. package/esm/mail/templates/DefaultMail.svelte +81 -61
  55. package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -26
  56. package/esm/server/index.d.ts +0 -0
  57. package/esm/server/index.js +1 -0
  58. package/esm/storeItem.d.ts +1 -4
  59. package/esm/storeItem.js +1 -1
  60. package/esm/storeList.d.ts +1 -4
  61. package/esm/sveltekit/server/index.d.ts +3 -9
  62. package/esm/sveltekit/server/index.js +3 -0
  63. package/esm/ui/Button.svelte +112 -89
  64. package/esm/ui/Button.svelte.d.ts +34 -24
  65. package/esm/ui/Clipboardable.svelte +24 -17
  66. package/esm/ui/Clipboardable.svelte.d.ts +34 -23
  67. package/esm/ui/Field.svelte +328 -285
  68. package/esm/ui/Field.svelte.d.ts +15 -8
  69. package/esm/ui/FieldGroup.svelte +112 -91
  70. package/esm/ui/FieldGroup.svelte.d.ts +17 -6
  71. package/esm/ui/Grid.svelte +322 -308
  72. package/esm/ui/Grid.svelte.d.ts +17 -6
  73. package/esm/ui/GridLoading.svelte +28 -27
  74. package/esm/ui/GridLoading.svelte.d.ts +19 -17
  75. package/esm/ui/GridPaginate.svelte +68 -61
  76. package/esm/ui/GridPaginate.svelte.d.ts +21 -19
  77. package/esm/ui/Icon.svelte +116 -80
  78. package/esm/ui/Icon.svelte.d.ts +52 -43
  79. package/esm/ui/Loading.svelte +10 -8
  80. package/esm/ui/Loading.svelte.d.ts +29 -18
  81. package/esm/ui/Tooltip.svelte +38 -35
  82. package/esm/ui/Tooltip.svelte.d.ts +30 -20
  83. package/esm/ui/dialog/DialogForm.svelte +70 -63
  84. package/esm/ui/dialog/DialogForm.svelte.d.ts +18 -16
  85. package/esm/ui/dialog/DialogManagement.svelte +74 -74
  86. package/esm/ui/dialog/DialogManagement.svelte.d.ts +22 -21
  87. package/esm/ui/dialog/DialogPrimitive.svelte +82 -76
  88. package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +35 -25
  89. package/esm/ui/dialog/FormEditAction.svelte +58 -50
  90. package/esm/ui/dialog/FormEditAction.svelte.d.ts +13 -6
  91. package/esm/ui/dialog/dialog.d.ts +1 -4
  92. package/esm/ui/internals/FieldContainer.svelte +24 -17
  93. package/esm/ui/internals/FieldContainer.svelte.d.ts +37 -28
  94. package/esm/ui/internals/Input.svelte +136 -102
  95. package/esm/ui/internals/Input.svelte.d.ts +34 -32
  96. package/esm/ui/internals/Textarea.svelte +60 -52
  97. package/esm/ui/internals/Textarea.svelte.d.ts +31 -28
  98. package/esm/ui/internals/select/MultiSelectMelt.svelte +243 -199
  99. package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +29 -27
  100. package/esm/ui/internals/select/SelectMelt.svelte +254 -219
  101. package/esm/ui/internals/select/SelectMelt.svelte.d.ts +34 -32
  102. package/esm/ui/internals/select/SelectRadio.svelte +39 -33
  103. package/esm/ui/internals/select/SelectRadio.svelte.d.ts +24 -22
  104. package/esm/ui/link/Link.svelte +25 -20
  105. package/esm/ui/link/Link.svelte.d.ts +31 -23
  106. package/esm/ui/link/LinkPlus.svelte +52 -51
  107. package/esm/ui/link/LinkPlus.svelte.d.ts +20 -18
  108. package/esm/vite/index.d.ts +2 -3
  109. package/esm/vite/index.js +33 -26
  110. package/package.json +16 -20
  111. package/esm/auth/static/assets/Page-Bb8bFlrP.d.ts +0 -4
  112. package/esm/auth/static/assets/Page-Bb8bFlrP.js +0 -1
  113. package/esm/auth/static/assets/Page-BxomFlZ8.d.ts +0 -4
  114. package/esm/auth/static/assets/Page-BxomFlZ8.js +0 -1
  115. package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +0 -6
  116. package/esm/auth/static/assets/Page-CaIYu0-y.js +0 -19
  117. package/esm/auth/static/assets/Page-MkYglNtu.css +0 -1
  118. package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +0 -64
  119. package/esm/auth/static/assets/index-Bl0Bk5u0.js +0 -2
  120. package/esm/auth/static/assets/index-R27C_TlP.css +0 -4
@@ -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
@@ -0,0 +1,5 @@
1
+ import { Log } from '@kitql/helpers';
2
+ export declare const ff_Log: Log;
3
+ export declare const FF_Role: {
4
+ readonly FF_Role_Admin: "FF_Role.Admin";
5
+ };
package/esm/common.js ADDED
@@ -0,0 +1,8 @@
1
+ // ******************************
2
+ // Objects
3
+ import { Log } from '@kitql/helpers';
4
+ // ******************************
5
+ export const ff_Log = new Log('firstly');
6
+ export const FF_Role = {
7
+ FF_Role_Admin: 'FF_Role.Admin',
8
+ };
@@ -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.running ? green('running') : red('stopped')}, next at ${yellow(job.nextDate().toISO())})`);
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 (!FEEDBACK_OPTIONS.GITHUB_API_TOKEN) {
13
- throw new EntityError({ message: 'GITHUB_API_TOKEN not found in .env' });
14
- }
15
- try {
16
- const headers = new Headers({
17
- Authorization: 'Bearer ' + FEEDBACK_OPTIONS.GITHUB_API_TOKEN,
18
- 'Content-Type': 'application/json',
19
- });
20
- const body = stry({ query, variables }, 0);
21
- const response = await fetch(GITHUB_GRAPHQL_ENDPOINT, { method: 'POST', headers, body });
22
- const result = await response.json();
23
- if (result.errors) {
24
- console.error(`result ERRORS`, body, stry(result));
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
- const commentToMinimize = await getGitHub(`mutation AddComment($input: AddCommentInput!) {
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
- input: {
45
- subjectId: issueId,
46
- body: `<pre>\n${JSON.stringify({ author, page }, null, 2)}\n</pre>`,
47
- },
48
- });
49
- await getGitHub(`mutation MinimizeComment($input: MinimizeCommentInput!) {
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
- input: {
58
- subjectId: commentToMinimize.addComment.commentEdge.node.id,
59
- classifier: 'OFF_TOPIC',
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: FEEDBACK_OPTIONS.repo.name,
87
- owner: FEEDBACK_OPTIONS.repo.owner,
88
- filter: FEEDBACK_OPTIONS.milestones?.title_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.replaceAll(FEEDBACK_OPTIONS.milestones?.title_filter ?? '', '').trim(),
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: FEEDBACK_OPTIONS.repo.name,
130
- owner: FEEDBACK_OPTIONS.repo.owner,
135
+ repository: remult.context.feedbackOptions.repo.name,
136
+ owner: remult.context.feedbackOptions.repo.owner,
131
137
  milestoneNumber,
132
138
  filters: {
133
- labels: FEEDBACK_OPTIONS.milestones?.labels_filters ?? [],
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 = FEEDBACK_OPTIONS.highlight_label
140
- ? issue.labels.nodes.some((label) => label.name.includes(FEEDBACK_OPTIONS.highlight_label))
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: FEEDBACK_OPTIONS.repo.name,
185
- owner: FEEDBACK_OPTIONS.repo.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 = FEEDBACK_OPTIONS.highlight_label
213
- ? data.repository.issue.labels.nodes.some((label) => label.name.includes(FEEDBACK_OPTIONS.highlight_label))
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: FEEDBACK_OPTIONS.repo.name,
240
- owner: FEEDBACK_OPTIONS.repo.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 === FEEDBACK_OPTIONS.create_label);
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: (FEEDBACK_OPTIONS.highlight_label
273
- ? labels.filter((c) => c.name !== FEEDBACK_OPTIONS.highlight_label)
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: (FEEDBACK_OPTIONS.highlight_label
304
- ? labels.filter((c) => c.name !== FEEDBACK_OPTIONS.highlight_label)
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
- export {};
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;
@@ -0,0 +1,4 @@
1
+ export const FEEDBACK_OPTIONS = {
2
+ GITHUB_API_TOKEN: '',
3
+ repo: { owner: '', name: '' },
4
+ };
@@ -1,123 +1,135 @@
1
- <script>import { onMount } from "svelte";
2
- import { repo } from "remult";
3
- import { page } from "$app/stores";
4
- import { FeedbackController } from "..";
5
- import { Button, cellBuildor, Field, FilterEntity, Loading } from "../..";
6
- import Textarea from "../../ui/internals/Textarea.svelte";
7
- export let dialogId;
8
- const rmvWarning = dialogId;
9
- export let milestoneId;
10
- export let issueNumber;
11
- let state = "loading";
12
- let issue;
13
- const update = async () => {
14
- state = "loading";
15
- if (issueNumber) {
16
- issue = await FeedbackController.getIssue(issueNumber);
17
- }
18
- state = "done";
19
- };
20
- onMount(async () => {
21
- await update();
22
- });
23
- let title;
24
- let content;
25
- const send = async () => {
26
- state = "loading";
27
- const p = $page.url.pathname + $page.url.search;
28
- if (!issue?.id) {
29
- const result = await FeedbackController.createIssue(milestoneId, title, content, p);
30
- issueNumber = result.number;
31
- } else {
32
- await FeedbackController.addCommentOnIssue(issue.id, content, p, issue.labels);
33
- }
34
- content = "";
35
- await update();
36
- state = "done";
37
- };
38
- const close = async () => {
39
- state = "loading";
40
- await FeedbackController.close(issue.id, issue.labels);
41
- content = "";
42
- await update();
43
- state = "done";
44
- };
45
- const reOpen = async () => {
46
- state = "loading";
47
- await FeedbackController.reOpen(issue.id);
48
- content = "";
49
- await update();
50
- state = "done";
51
- };
52
- const disableButton = (issueNumber2, title2, content2) => {
53
- if (issueNumber2) {
54
- if (content2?.length > 2) {
55
- return false;
56
- }
57
- }
58
- if (title2?.length > 2 && content2?.length > 2) {
59
- return false;
60
- }
61
- return true;
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
- {#if state === 'loading'}
67
- <Loading class="h-12"></Loading>
68
- <Loading class="h-12"></Loading>
69
- <Loading class="h-12"></Loading>
70
- {:else}
71
- {#each issue?.items ?? [] as item}
72
- <div class="chat {item.who ? 'chat-start' : 'chat-end'}">
73
- <div class="avatar chat-image">
74
- <div class="w-10 rounded-full">
75
- <div class="h-10 w-10 {item.who ? 'bg-primary' : 'bg-secondary'}"></div>
76
- </div>
77
- </div>
78
- <div class="chat-header">
79
- {item.who ?? 'Support'}
80
- <time class="text-xs opacity-50"
81
- >{new Date(item.createdAt).toLocaleDateString()} - {new Date(
82
- item.createdAt,
83
- ).toLocaleTimeString()}</time
84
- >
85
- </div>
86
- <div class="chat-bubble prose">{@html item.bodyHTML}</div>
87
- <!-- <div class="chat-footer opacity-50">Delivered</div> -->
88
- </div>
89
- {/each}
90
- {#if issue?.highlight && issue.state === 'OPEN'}
91
- <span class="badge badge-warning">En attente de réponse de TA part 😉, oui 🫵!</span>
92
- {/if}
93
- {#if issueNumber}
94
- <button on:click={update} aria-label="Actualiser" class="divider"></button>
95
- {/if}
96
-
97
- {#if issue?.state === 'CLOSED'}
98
- <div class="flex justify-end">
99
- <Button on:click={reOpen} class="btn-neutral">Re Ouvrir</Button>
100
- </div>
101
- {:else}
102
- {#if issueNumber === null}
103
- <Field cell={cellBuildor(repo(FilterEntity), 'title')} bind:value={title} />
104
- {/if}
105
- <Textarea
106
- bind:value={content}
107
- placeholder="Un peu de détail c'est pas mal... Fais toi Plaiz' (Tu as même le droit d'utiliser le format markdown!)"
108
- ></Textarea>
109
- <div class="flex justify-between">
110
- {#if issueNumber}
111
- <Button on:click={close} tabIndex={-1} class="btn-outline btn-error"
112
- >Clore le feedback</Button
113
- >
114
- {:else}
115
- <div></div>
116
- {/if}
117
- <Button on:click={send} disabled={disableButton(issueNumber, title, content)}
118
- >Envoyer</Button
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
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- dialogId: number;
5
- milestoneId: string;
6
- issueNumber: number | null;
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
- events: {
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
- export {};
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;