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

add sharing step #472

Merged
merged 9 commits into from
Jan 13, 2025
Merged

Conversation

eperedo
Copy link
Contributor

@eperedo eperedo commented Dec 5, 2024

📌 References

📝 Implementation

  • If project is selected hide the share step. Use the project code (first two digits) to get the users groups associated.
  • If project is not selected show the share step. By default show countries from the org. units selected in the "Setup" step.

📹 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

Copy link
Contributor

@MiquelAdell MiquelAdell left a 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!

Base automatically changed from feature/add-indicators to development-project-configurator December 17, 2024 10:14
Copy link
Collaborator

@tokland tokland left a 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 => ({
Copy link
Collaborator

@tokland tokland Dec 16, 2024

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();
Copy link
Collaborator

@tokland tokland Dec 16, 2024

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();
Copy link
Collaborator

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 => {
Copy link
Collaborator

@tokland tokland Dec 16, 2024

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[] {
Copy link
Collaborator

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";
Copy link
Collaborator

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";

const name = project ? `${project.name} DataSet` : "";
return this._update({ project, name });
const orgUnits = project ? project.orgsUnits : this.orgUnits;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: orgsUnits -> orgUnits

@@ -1,3 +1,4 @@
import { Permissions } from "$/domain/entities/DataSet";
Copy link
Collaborator

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?

@@ -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 });
Copy link
Collaborator

@tokland tokland Dec 20, 2024

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];
Copy link
Collaborator

@tokland tokland Dec 20, 2024

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.

Copy link
Contributor Author

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?

@eperedo eperedo requested a review from tokland January 6, 2025 22:41
Copy link
Collaborator

@tokland tokland left a 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";
Copy link
Collaborator

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).

* Output: "US"
*
*/
export function extractPrefix(value: string): string {
Copy link
Collaborator

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.

@eperedo eperedo requested a review from tokland January 7, 2025 20:21
Copy link
Collaborator

@tokland tokland left a 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!

@MiquelAdell MiquelAdell merged commit d6f91fa into development-project-configurator Jan 13, 2025
1 check passed
@MiquelAdell MiquelAdell deleted the feature/share-step branch January 13, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants