Skip to content

Commit 59c2d0b

Browse files
authored
Fix the TypeError in dataset Share Access. (#3309)
### Purpose: Currently, when entering someone else's email in the dataset Share Access, the console displays an error: TypeError: Cannot read properties of undefined. The reason is that the dataset does not have the allOwners property, causing it to remain undefined. ### Changes: Added a new backend API for datasets to retrieve the owners' emails of datasets that the current user can access. The frontend passes the returned values into the Share Access component. ### Demo: before: ![image](https://github.com/user-attachments/assets/3440f902-7137-4e15-a240-991f06f40496) after: ![image](https://github.com/user-attachments/assets/0a7067e7-ed94-4a29-81ac-12b4aa63f079)
1 parent c4736fb commit 59c2d0b

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

core/file-service/src/main/scala/edu/uci/ics/texera/service/resource/DatasetResource.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import jakarta.ws.rs._
4949
import jakarta.ws.rs.core.{MediaType, Response, StreamingOutput}
5050
import org.jooq.{DSLContext, EnumType}
5151

52+
import java.util
5253
import java.io.{InputStream, OutputStream}
5354
import java.net.URLDecoder
5455
import java.nio.charset.StandardCharsets
@@ -1033,6 +1034,26 @@ class DatasetResource {
10331034
records.getValues(DATASET_USER_ACCESS.UID)
10341035
}
10351036

1037+
/**
1038+
* This method returns all owner user names of the dataset that the user has access to
1039+
*
1040+
* @return OwnerName[]
1041+
*/
1042+
@GET
1043+
@RolesAllowed(Array("REGULAR", "ADMIN"))
1044+
@Path("/user-dataset-owners")
1045+
def retrieveOwners(@Auth user: SessionUser): util.List[String] = {
1046+
context
1047+
.selectDistinct(USER.EMAIL)
1048+
.from(USER)
1049+
.join(DATASET)
1050+
.on(DATASET.OWNER_UID.eq(USER.UID))
1051+
.join(DATASET_USER_ACCESS)
1052+
.on(DATASET_USER_ACCESS.DID.eq(DATASET.DID))
1053+
.where(DATASET_USER_ACCESS.UID.eq(user.getUid))
1054+
.fetchInto(classOf[String])
1055+
}
1056+
10361057
private def fetchDatasetVersions(ctx: DSLContext, did: Integer): List[DatasetVersion] = {
10371058
ctx
10381059
.selectFrom(DATASET_VERSION)

core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export class ListItemComponent implements OnInit, OnChanges {
201201
writeAccess: this.entry.accessLevel === "WRITE",
202202
type: "dataset",
203203
id: this.entry.id,
204+
allOwners: await firstValueFrom(this.datasetService.retrieveOwners()),
204205
},
205206
nzFooter: null,
206207
nzTitle: "Share this dataset with others",

core/gui/src/app/dashboard/service/user/dataset/dataset.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,4 +377,8 @@ export class DatasetService {
377377
public getDatasetOwners(did: number): Observable<number[]> {
378378
return this.http.get<number[]>(`${AppSettings.getApiEndpoint()}/${DATASET_GET_OWNERS_URL}?did=${did}`);
379379
}
380+
381+
public retrieveOwners(): Observable<string[]> {
382+
return this.http.get<string[]>(`${AppSettings.getApiEndpoint()}/${DATASET_GET_OWNERS_URL}`);
383+
}
380384
}

0 commit comments

Comments
 (0)