Skip to content

Conversation

@aaronm-2112
Copy link
Member

@aaronm-2112 aaronm-2112 commented Dec 10, 2024

Summary by Sourcery

Add support for guest contributors in SDOA's end-to-end curation mode, allowing them to bypass certain permission steps. Enhance role checking logic to prevent ineligible actions for users with specific roles. Improve logging for better dataset management insights and update CI workflows to accommodate new branch naming.

New Features:

  • Introduce guest contributor support in SDOA's end-to-end curation mode, allowing users with guest roles to skip certain permission designation steps.

Enhancements:

  • Improve dataset role checking to determine if a user is ineligible for certain actions based on their role, such as 'editor'.
  • Enhance logging for user roles and dataset sorting to provide better insights during dataset management.

CI:

  • Update CI workflows to trigger builds on the 'guest-contributor-fixes' branch instead of 'folder-build'.

aaronm-2112 and others added 22 commits December 2, 2024 15:14
@fairdataihub-bot
Copy link

Thank you for submitting this pull request! We appreciate your contribution to the project. Before we can merge it, we need to review the changes you've made to ensure they align with our code standards and meet the requirements of the project. We'll get back to you as soon as we can with feedback. Thanks again!

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 10, 2024

Reviewer's Guide by Sourcery

This PR implements guest contributor support in SDOA's end-to-end curation mode. The changes focus on handling user roles and permissions, particularly for guest editors, and includes modifications to dataset metadata management and UI flow control based on user roles.

Sequence diagram for checking user role and skipping pages

sequenceDiagram
    participant User
    participant UI
    participant API
    participant Client

    User->>UI: Clicks on a page
    UI->>API: getDatasetRole(dataset-name)
    API-->>UI: Returns role
    alt User is editor
        UI->>UI: Set ineligible to true
        UI-->>User: Skip page
    else User is not editor
        UI->>Client: getUserInformation()
        Client-->>UI: Returns user info
        UI->>Client: get user organizations
        Client-->>UI: Returns organizations
        alt User is guest
            UI->>UI: Skip permissions tab
        else User is not guest
            UI->>UI: Unskip permissions tab
        end
    end
Loading

File-Level Changes

Change Details Files
Added role-based access control for dataset editing
  • Added checks for editor role to determine editing eligibility
  • Modified permission checks to include editor role in edit permissions
  • Added function to check if user is a workspace guest
  • Skip permissions designation page for guest users
src/renderer/src/scripts/guided-mode/guided-curate-dataset.js
src/pyflask/permissions/permissions.py
src/renderer/src/scripts/globals.js
Enhanced dataset metadata handling
  • Added dataset role verification before metadata updates
  • Modified dataset filtering to exclude viewers but include editors
  • Updated dataset information retrieval to use dataset ID consistently
src/pyflask/manageDatasets/manage_datasets.py
src/pyflask/organizeDatasets/organize_datasets.py
Improved error handling and logging
  • Added logging for user roles
  • Updated error handling in API calls
  • Removed unnecessary console.log statements
src/renderer/src/scripts/others/api/api.js
src/renderer/src/scripts/others/renderer.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@aaronm-2112 aaronm-2112 requested review from JacobiClark and removed request for bvhpatel December 10, 2024 20:58
@fairdataihub-bot
Copy link

Thanks for making updates to your pull request. Our team will take a look and provide feedback as soon as possible. Please wait for any GitHub Actions to complete before editing your pull request. If you have any additional questions or concerns, feel free to let us know. Thank you for your contributions!

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @aaronm-2112 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider removing debug console.log statements before merging (e.g. 'DOing this resume logic', 'About to save progress', etc)
  • There's significant code duplication in the role-checking logic across multiple functions (guidedAddDatasetTags, guidedAddDatasetLicense, etc). Consider extracting this into a reusable helper function
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

}
}

if (ineligible) return { shouldShow: false };
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ineligible) return { shouldShow: false };
if (ineligible) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

}
}

if (ineligible) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ineligible) return;
if (ineligible) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

}
}

if (ineligible) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ineligible) return;
if (ineligible) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

}
}

if (ineligible) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ineligible) return;
if (ineligible) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

}
}

if (ineligible) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ineligible) return;
if (ineligible) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

}
}

if (ineligible) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ineligible) return;
if (ineligible) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

@sonarqubecloud
Copy link

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