-
Notifications
You must be signed in to change notification settings - Fork 1
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
add sharing step #472
add sharing step #472
Conversation
…-configuration into feature/share-step
Align the search input with the data table component
…-configuration into feature/share-step
…figuration into feature/share-step
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionally tested and it works. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-line comments:
paging: false, | ||
}) | ||
).map(d2Response => { | ||
return d2Response.objects.map(region => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we want "userGroup" here instead of "region".
} | ||
|
||
private extractRegionCode(code: string): string { | ||
return (code.slice(0, 2) || "").toUpperCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment with an example, so the reader knows why are we processing it.
} | ||
|
||
private extractCode(code: string): string { | ||
return (code.split("_")[0] || "").toUpperCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
.compactMap(access => { | ||
if (access.type !== "groups") return undefined; | ||
.filter(access => access.type === "groups") | ||
.map(access => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declarative (nit-picking): after the filter, it's not just an "access", it's a "groupAccess"
@@ -326,6 +330,20 @@ export class DataSetD2Repository implements DataSetRepository { | |||
}; | |||
} | |||
|
|||
private convertSharingGroupsToAccessData(d2UserGroups: Maybe<SharingUserGroup>): AccessData[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method used?
} | ||
|
||
private setAccessPermissionGroup(userGroup: UserGroup): AccessData { | ||
const isAdmin = userGroup.name.split("_")[1]?.toLowerCase() === "administrators"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the same?
$ grep -ir 'name.split("_")' src/
src/webapp/components/dataset-wizard/SummaryDataSet.tsx: return access.name.split("_")[0];
src/domain/entities/DataSet.ts: .compactMap(access => access.name.split("_")[0])
src/domain/entities/DataSet.ts: const isAdmin = userGroup.name.split("_")[1]?.toLowerCase() === "administrators";
src/domain/entities/DataSet.ts
Outdated
const name = project ? `${project.name} DataSet` : ""; | ||
return this._update({ project, name }); | ||
const orgUnits = project ? project.orgsUnits : this.orgUnits; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: orgsUnits -> orgUnits
src/domain/entities/Permission.ts
Outdated
@@ -1,3 +1,4 @@ | |||
import { Permissions } from "$/domain/entities/DataSet"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to move Permissions to this entity?
src/domain/entities/Permission.ts
Outdated
@@ -10,4 +11,14 @@ export class Permission extends Struct<PermissionAttrs>() { | |||
static buildWithOutAccess(): Permission { | |||
return Permission.create({ read: false, write: false }); | |||
} | |||
|
|||
static setDefaultPermissionsForGroups(isAdmin: boolean): Permissions { | |||
const adminDataPermission = Permission.create({ read: true, write: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declarative: adminDataPermission
-> readWritePermission
(name things for what they are, not how they are used / assigned)
const regionsCodes = _(dataSet.access) | ||
.filter(access => access.type === "groups") | ||
.compactMap(access => { | ||
return access.name.split("_")[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of processing the view as a bit of a code smell, do we need to know this here? The solution (if any) depends on the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I follow, do you mean this should be in the domain?
…rove functions names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-line comments:
@@ -5,6 +5,7 @@ import { Region } from "$/domain/entities/Region"; | |||
import { Future, FutureData } from "$/domain/entities/generic/Future"; | |||
import { ConfigRepository } from "$/domain/repositories/ConfigRepository"; | |||
import { D2Api } from "$/types/d2-api"; | |||
import { extractFirstTwoLetters, extractPrefix } from "$/utils/string"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding methods to some utils file in the root folder is only advisable for extremely generic functions. I don't think that's the case. The abstraction we are looking for is not "extractFirstTwoLetters", but some function that references the processing over the code (similar to the naming you had before).
This function is used in data and domain, right? So if this is something the domain must be aware of, let's move the function there, with another name (possible in Region and/or OrgUnit).
src/utils/string.ts
Outdated
* Output: "US" | ||
* | ||
*/ | ||
export function extractPrefix(value: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both functions should be moved, they are not generic string functions, they hold domain knowledge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[code-review] all good by me!
📌 References
📝 Implementation
📹 Screenshots/Screen capture
Sharing settings from project
Project-Configuration-app_create_dataset.webm
Sharing settings from org. units
Project-Configuration-app_sharing_org_units.webm
🔥 Notes to the tester
This pull request depends on the "indicators step PR"
#8696ewgjx
#8696x5ufq