240
240
</div >
241
241
242
242
<div v-else-if =" generatedMessage" class =" flex items-center gap-2" >
243
- <OverflowMenu :options =" stageOptions" class =" bg-transparent p-0" >
244
- <ButtonStyled circular >
245
- <button v-tooltip =" `Stages`" >
246
- <ListBulletedIcon />
247
- </button >
248
- </ButtonStyled >
249
-
250
- <template
251
- v-for =" opt in stageOptions .filter (
252
- (opt ) => ' id' in opt && ' text' in opt && ' icon' in opt ,
253
- ) "
254
- #[opt .id ]
255
- :key =" opt .id "
256
- >
257
- <component :is =" opt.icon" v-if =" opt.icon" class =" mr-2" />
258
- {{ opt.text }}
259
- </template >
260
- </OverflowMenu >
261
243
<ButtonStyled >
262
244
<button @click =" goBackToStages" >
263
245
<LeftArrowIcon aria-hidden =" true" />
@@ -368,18 +350,23 @@ import {
368
350
DropdownSelect ,
369
351
MarkdownEditor ,
370
352
} from " @modrinth/ui" ;
371
- import { type Project , renderHighlightedString , type ModerationJudgements } from " @modrinth/utils" ;
353
+ import {
354
+ type Project ,
355
+ renderHighlightedString ,
356
+ type ModerationJudgements ,
357
+ type ModerationModpackItem ,
358
+ } from " @modrinth/utils" ;
372
359
import { computedAsync , useLocalStorage } from " @vueuse/core" ;
373
- import type {
374
- Action ,
375
- MultiSelectChipsAction ,
376
- DropdownAction ,
377
- ButtonAction ,
378
- ToggleAction ,
379
- ConditionalButtonAction ,
380
- Stage ,
360
+ import {
361
+ type Action ,
362
+ type MultiSelectChipsAction ,
363
+ type DropdownAction ,
364
+ type ButtonAction ,
365
+ type ToggleAction ,
366
+ type ConditionalButtonAction ,
367
+ type Stage ,
368
+ finalPermissionMessages ,
381
369
} from " @modrinth/moderation" ;
382
- import { finalPermissionMessages } from " @modrinth/moderation/data/modpack-permissions-stage" ;
383
370
import * as prettier from " prettier" ;
384
371
import ModpackPermissionsFlow from " ./ModpackPermissionsFlow.vue" ;
385
372
import KeybindsModal from " ./ChecklistKeybindsModal.vue" ;
@@ -411,7 +398,6 @@ const done = ref(false);
411
398
412
399
function handleModpackPermissionsComplete() {
413
400
modpackPermissionsComplete .value = true ;
414
- nextStage ();
415
401
}
416
402
417
403
const emit = defineEmits <{
@@ -815,6 +801,31 @@ const isAnyVisibleInputs = computed(() => {
815
801
});
816
802
});
817
803
804
+ function getModpackFilesFromStorage(): {
805
+ interactive: ModerationModpackItem [];
806
+ permanentNo: ModerationModpackItem [];
807
+ } {
808
+ try {
809
+ const sessionData = sessionStorage .getItem (` modpack-permissions-data-${props .project .id } ` );
810
+ const interactive = sessionData ? (JSON .parse (sessionData ) as ModerationModpackItem []) : [];
811
+
812
+ const permanentNoData = sessionStorage .getItem (
813
+ ` modpack-permissions-permanent-no-${props .project .id } ` ,
814
+ );
815
+ const permanentNo = permanentNoData
816
+ ? (JSON .parse (permanentNoData ) as ModerationModpackItem [])
817
+ : [];
818
+
819
+ return {
820
+ interactive: interactive || [],
821
+ permanentNo: permanentNo || [],
822
+ };
823
+ } catch (error ) {
824
+ console .warn (" Failed to parse session storage modpack data:" , error );
825
+ return { interactive: [], permanentNo: [] };
826
+ }
827
+ }
828
+
818
829
async function assembleFullMessage() {
819
830
const messageParts: MessagePart [] = [];
820
831
@@ -1084,13 +1095,14 @@ async function generateMessage() {
1084
1095
const baseMessage = await assembleFullMessage ();
1085
1096
let fullMessage = baseMessage ;
1086
1097
1087
- if (
1088
- props .project .project_type === " modpack" &&
1089
- Object .keys (modpackJudgements .value ).length > 0
1090
- ) {
1091
- const modpackMessage = generateModpackMessage (modpackJudgements .value );
1092
- if (modpackMessage ) {
1093
- fullMessage = baseMessage ? ` ${baseMessage }\n\n ${modpackMessage } ` : modpackMessage ;
1098
+ if (props .project .project_type === " modpack" ) {
1099
+ const modpackFilesData = getModpackFilesFromStorage ();
1100
+
1101
+ if (modpackFilesData .interactive .length > 0 || modpackFilesData .permanentNo .length > 0 ) {
1102
+ const modpackMessage = generateModpackMessage (modpackFilesData );
1103
+ if (modpackMessage ) {
1104
+ fullMessage = baseMessage ? ` ${baseMessage }\n\n ${modpackMessage } ` : modpackMessage ;
1105
+ }
1094
1106
}
1095
1107
}
1096
1108
@@ -1121,25 +1133,32 @@ async function generateMessage() {
1121
1133
}
1122
1134
}
1123
1135
1124
- function generateModpackMessage(judgements : ModerationJudgements ) {
1136
+ function generateModpackMessage(allFiles : {
1137
+ interactive: ModerationModpackItem [];
1138
+ permanentNo: ModerationModpackItem [];
1139
+ }) {
1125
1140
const issues = [];
1126
1141
1127
- const attributeMods = [];
1128
- const noMods = [];
1129
- const permanentNoMods = [];
1130
- const unidentifiedMods = [];
1131
-
1132
- for ( const [, judgement] of Object . entries ( judgements )) {
1133
- if (judgement .status === " with-attribution " ) {
1134
- attributeMods . push ( judgement . file_name );
1135
- } else if ( judgement . status === " no " ) {
1136
- noMods . push ( judgement . file_name );
1137
- } else if (judgement .status === " permanent- no" ) {
1138
- permanentNoMods .push (judgement .file_name );
1139
- } else if (judgement .status === " unidentified " ) {
1140
- unidentifiedMods .push (judgement .file_name );
1142
+ const attributeMods: string [] = [];
1143
+ const noMods: string [] = [];
1144
+ const permanentNoMods: string [] = [];
1145
+ const unidentifiedMods: string [] = [];
1146
+
1147
+ allFiles . interactive . forEach (( file ) => {
1148
+ if (file .status === " unidentified " ) {
1149
+ if ( file . approved === " no " ) {
1150
+ unidentifiedMods . push ( file . file_name );
1151
+ }
1152
+ } else if (file .status === " with-attribution " && file . approved === " no" ) {
1153
+ attributeMods .push (file .file_name );
1154
+ } else if (file .status === " no " && file . approved === " no " ) {
1155
+ noMods .push (file .file_name );
1141
1156
}
1142
- }
1157
+ });
1158
+
1159
+ allFiles .permanentNo .forEach ((file ) => {
1160
+ permanentNoMods .push (file .file_name );
1161
+ });
1143
1162
1144
1163
if (
1145
1164
attributeMods .length > 0 ||
@@ -1149,6 +1168,12 @@ function generateModpackMessage(judgements: ModerationJudgements) {
1149
1168
) {
1150
1169
issues .push (" ## Copyrighted content" );
1151
1170
1171
+ if (unidentifiedMods .length > 0 ) {
1172
+ issues .push (
1173
+ ` ${finalPermissionMessages .unidentified }\n ${unidentifiedMods .map ((mod ) => ` - ${mod } ` ).join (" \n " )} ` ,
1174
+ );
1175
+ }
1176
+
1152
1177
if (attributeMods .length > 0 ) {
1153
1178
issues .push (
1154
1179
` ${finalPermissionMessages [" with-attribution" ]}\n ${attributeMods .map ((mod ) => ` - ${mod } ` ).join (" \n " )} ` ,
@@ -1164,12 +1189,6 @@ function generateModpackMessage(judgements: ModerationJudgements) {
1164
1189
` ${finalPermissionMessages [" permanent-no" ]}\n ${permanentNoMods .map ((mod ) => ` - ${mod } ` ).join (" \n " )} ` ,
1165
1190
);
1166
1191
}
1167
-
1168
- if (unidentifiedMods .length > 0 ) {
1169
- issues .push (
1170
- ` ${finalPermissionMessages .unidentified }\n ${unidentifiedMods .map ((mod ) => ` - ${mod } ` ).join (" \n " )} ` ,
1171
- );
1172
- }
1173
1192
}
1174
1193
1175
1194
return issues .join (" \n\n " );
0 commit comments