Skip to content

Commit 133915f

Browse files
committed
Get Upload page ready for Mythic to finish
1 parent ef39227 commit 133915f

File tree

4 files changed

+73
-42
lines changed

4 files changed

+73
-42
lines changed

packages/cyberstorm-forms/src/forms/UploadPackageForm.module.css

+27
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,30 @@
1313
flex-direction: row;
1414
gap: var(--gap--16);
1515
}
16+
17+
.submit > :last-child {
18+
flex-grow: 1;
19+
}
20+
21+
.teamContentWrapper {
22+
display: flex;
23+
flex-direction: column;
24+
gap: var(--space--12);
25+
}
26+
27+
.createTeamModalLink {
28+
color: #39e9aa;
29+
font-weight: var(--font-weight-medium);
30+
background: transparent;
31+
}
32+
33+
.createTeamSentence {
34+
display: flex;
35+
flex-direction: row;
36+
gap: var(--space--8);
37+
color: var(--text-tertiary, #9c9cc4);
38+
font-weight: var(--font-weight-semibold);
39+
40+
font-size: 0.875rem;
41+
line-height: 1.7;
42+
}

packages/cyberstorm-forms/src/forms/UploadPackageForm.tsx

+35-37
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,26 @@ export function UploadPackageForm(props: UploadPackageFormProps) {
4747
successMessage: "Package submitted",
4848
});
4949

50-
// Parse categories to the right format for form
51-
function communityCategoriesParse(
50+
// Parse communities to the right format for form
51+
function communitiesParse(
5252
selected: {
5353
label: string;
5454
value: string;
55-
}[],
56-
onChange: (selected: { [key: string]: string[] }) => void
55+
}[]
5756
) {
58-
const communityCategories: { [key: string]: string[] } = {};
59-
selected.map((x) => (communityCategories[x.value] = [x.value]));
60-
onChange(communityCategories);
57+
return selected.map((x) => x.value);
6158
}
6259

63-
// Parse communities to the right format for form
64-
function communitiesParse(
60+
// Parse categories to the right format for form
61+
function communityCategoriesParse(
6562
selected: {
6663
label: string;
6764
value: string;
68-
}[],
69-
onChange: (selected: string[]) => void
65+
}[]
7066
) {
71-
onChange(selected.map((x) => x.value));
67+
const communityCategories: { [key: string]: string[] } = {};
68+
selected.map((x) => (communityCategories[x.value] = [x.value]));
69+
return communityCategories;
7270
}
7371

7472
return (
@@ -87,41 +85,41 @@ export function UploadPackageForm(props: UploadPackageFormProps) {
8785
<div className={styles.line} />
8886
<SettingItem
8987
title="Team"
90-
description="No teams available?"
91-
additionalLeftColumnContent={
92-
<Dialog.Root
93-
title="Create Team"
94-
trigger={
95-
<Button.Root colorScheme="primary" paddingSize="large">
96-
<Button.ButtonLabel>Create team</Button.ButtonLabel>
97-
<Button.ButtonIcon>
98-
<FontAwesomeIcon icon={faPlus} />
99-
</Button.ButtonIcon>
100-
</Button.Root>
101-
}
102-
>
103-
<CreateTeamForm />
104-
</Dialog.Root>
105-
}
88+
description="Select the team you want your package to be associated with."
10689
content={
107-
<FormSelectSearch
108-
name="team"
109-
schema={uploadPackageFormSchema}
110-
options={props.teams.map((t) => t.name)}
111-
placeholder="Choose a team..."
112-
/>
90+
<div className={styles.teamContentWrapper}>
91+
<FormSelectSearch
92+
name="team"
93+
schema={uploadPackageFormSchema}
94+
options={props.teams.map((t) => t.name)}
95+
placeholder="Choose a team..."
96+
/>
97+
<div className={styles.createTeamSentence}>
98+
<span>No teams available?</span>
99+
<Dialog.Root
100+
title="Create Team"
101+
trigger={
102+
<button className={styles.createTeamModalLink}>
103+
Create Team
104+
</button>
105+
}
106+
>
107+
<CreateTeamForm />
108+
</Dialog.Root>
109+
</div>
110+
</div>
113111
}
114112
/>
115113
<SettingItem
116114
title="Communities"
117-
description="Select communities you want your package to be listed under. Current community is selected by default."
115+
description="Select communities you want your package to be listed under."
118116
content={
119117
<FormMultiSelectSearch
120118
name="communities"
121119
schema={uploadPackageFormSchema}
122120
options={options}
123121
placeholder="Choose community..."
124-
onChangeParse={communitiesParse}
122+
fieldFormFormatParser={communitiesParse}
125123
/>
126124
}
127125
/>
@@ -134,7 +132,7 @@ export function UploadPackageForm(props: UploadPackageFormProps) {
134132
schema={uploadPackageFormSchema}
135133
options={options}
136134
placeholder="Choose categories..."
137-
onChangeParse={communityCategoriesParse}
135+
fieldFormFormatParser={communityCategoriesParse}
138136
/>
139137
}
140138
/>

packages/thunderstore-api/src/fetch/packageUpload.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type PackageUploadApiArgs = {
77
team: string;
88
community_categories: { [key: string]: string[] };
99
communities: string[];
10-
has_nsfw_content: boolean;
10+
has_nsfw_content?: boolean;
1111
};
1212

1313
export function packageUpload(
@@ -17,12 +17,18 @@ export function packageUpload(
1717
const path = "api/experimental/submission/submit/";
1818

1919
// TODO: Add these datas in form
20-
const todoData = { ...data, upload_uuid: "123", author_name: "root" };
20+
const todoData = {
21+
...data,
22+
upload_uuid: "123",
23+
author_name: "root",
24+
};
2125

2226
return apiFetch2({
2327
config,
2428
path,
25-
method: "POST",
26-
body: JSON.stringify(todoData),
29+
request: {
30+
method: "POST",
31+
body: JSON.stringify(todoData),
32+
},
2733
});
2834
}

packages/ts-api-react-forms/src/schema.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export const uploadPackageFormSchema = z.object({
1313
team: z.string(),
1414
community_categories: z.record(z.array(z.string())),
1515
communities: z.array(z.string()).nonempty(),
16-
has_nsfw_content: z.boolean(),
16+
has_nsfw_content: z.boolean().default(false),
1717
});

0 commit comments

Comments
 (0)