Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use detailsUrl to update namespace details #1087

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/src/main/java/org/eclipse/openvsx/UserAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public List<NamespaceJson> getOwnNamespaces() {
if(isOwner) {
json.setMembersUrl(createApiUrl(serverUrl, "user", "namespace", namespace.getName(), "members"));
json.setRoleUrl(createApiUrl(serverUrl, "user", "namespace", namespace.getName(), "role"));
json.setDetailsUrl(createApiUrl(serverUrl, "user", "namespace", namespace.getName(), "details"));
}

return json;
Expand Down
11 changes: 11 additions & 0 deletions server/src/main/java/org/eclipse/openvsx/json/NamespaceJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public static NamespaceJson error(String message) {
@Schema(hidden = true)
private String roleUrl;

@Schema(hidden = true)
private String detailsUrl;

public String getName() {
return name;
}
Expand Down Expand Up @@ -102,4 +105,12 @@ public String getRoleUrl() {
public void setRoleUrl(String roleUrl) {
this.roleUrl = roleUrl;
}

public String getDetailsUrl() {
return detailsUrl;
}

public void setDetailsUrl(String detailsUrl) {
this.detailsUrl = detailsUrl;
}
}
7 changes: 3 additions & 4 deletions webui/src/extension-registry-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class ExtensionRegistryService {
return sendRequest({ abortController, endpoint });
}

async setNamespaceDetails(abortController: AbortController, details: NamespaceDetails): Promise<Readonly<SuccessResult | ErrorResult>> {
async setNamespaceDetails(abortController: AbortController, endpoint: string, details: NamespaceDetails): Promise<Readonly<SuccessResult | ErrorResult>> {
const csrfResponse = await this.getCsrfToken(abortController);
const headers: Record<string, string> = {
'Content-Type': 'application/json;charset=UTF-8'
Expand All @@ -59,7 +59,6 @@ export class ExtensionRegistryService {
headers[csrfToken.header] = csrfToken.value;
}

const endpoint = createAbsoluteURL([this.serverUrl, 'user', 'namespace', details.name, 'details']);
return sendRequest({
abortController,
method: 'POST',
Expand All @@ -70,7 +69,7 @@ export class ExtensionRegistryService {
});
}

async setNamespaceLogo(abortController: AbortController, namespace: string, logoFile: Blob, logoName: string): Promise<Readonly<SuccessResult | ErrorResult>> {
async setNamespaceLogo(abortController: AbortController, endpoint: string, logoFile: Blob, logoName: string): Promise<Readonly<SuccessResult | ErrorResult>> {
const csrfResponse = await this.getCsrfToken(abortController);
const headers: Record<string, string> = {};
if (!isError(csrfResponse)) {
Expand All @@ -80,7 +79,7 @@ export class ExtensionRegistryService {

const form = new FormData();
form.append('file', logoFile, logoName);
const endpoint = createAbsoluteURL([this.serverUrl, 'user', 'namespace', namespace, 'details', 'logo']);
endpoint = createAbsoluteURL([endpoint, 'logo']);
return sendRequest({
abortController,
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions webui/src/extension-registry-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export interface Namespace {
verified: boolean;
membersUrl: UrlString;
roleUrl: UrlString;
detailsUrl: UrlString;
}

export interface NamespaceDetails {
Expand Down
4 changes: 2 additions & 2 deletions webui/src/pages/user/user-namespace-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ export const UserNamespaceDetails: FunctionComponent<UserNamespaceDetailsProps>
? 'https://twitter.com/' + details.socialLinks.twitter
: undefined;

const result = await context.service.setNamespaceDetails(abortController.current, details);
const result = await context.service.setNamespaceDetails(abortController.current, props.namespace.detailsUrl, details);
if (isError(result)) {
throw result;
}

if (logoPreview) {
const logoFile = await (await fetch(logoPreview)).blob();
await context.service.setNamespaceLogo(abortController.current, details.name, logoFile, details.logo as string);
await context.service.setNamespaceLogo(abortController.current, props.namespace.detailsUrl, logoFile, details.logo as string);
await getNamespaceDetails();
} else {
setCurrentDetails(copy(newDetails));
Expand Down
26 changes: 14 additions & 12 deletions webui/src/pages/user/user-settings-namespace-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,20 @@ export const NamespaceDetail: FunctionComponent<NamespaceDetailProps> = props =>
</Grid>
{
props.namespace.membersUrl
? <>
<Grid item>
<UserNamespaceMemberList
setLoadingState={props.setLoadingState}
namespace={props.namespace}
filterUsers={props.filterUsers}
fixSelf={props.fixSelf} />
</Grid>
<Grid item>
<UserNamespaceDetails namespace={props.namespace}/>
</Grid>
</>
? <Grid item>
<UserNamespaceMemberList
setLoadingState={props.setLoadingState}
namespace={props.namespace}
filterUsers={props.filterUsers}
fixSelf={props.fixSelf} />
</Grid>
: null
}
{
props.namespace.detailsUrl
? <Grid item>
<UserNamespaceDetails namespace={props.namespace}/>
</Grid>
: null
}
<Grid item>
Expand Down
Loading