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

feat: ✨ dashboard page #123

Merged
merged 4 commits into from
Dec 16, 2024
Merged

feat: ✨ dashboard page #123

merged 4 commits into from
Dec 16, 2024

Conversation

slugb0t
Copy link
Member

@slugb0t slugb0t commented Dec 16, 2024

Summary by Sourcery

Add a new dashboard page for users to manage repositories and organizations, enhance CWL file validation with improved logging, refactor UI components for better readability, update package version, and suppress output in CI workflows.

New Features:

  • Introduce a new dashboard page for users to view and manage their repositories and organizations.

Enhancements:

  • Improve the CWL file validation process by adding detailed logging and error handling.
  • Refactor the UI components for better readability and maintainability, including the use of consistent formatting and structure.

Build:

  • Update the package version to 3.2.1 in package.json.

CI:

  • Suppress output for the 'yarn prisma:migrate:deploy' command in CI workflows.

Documentation:

  • Add a new dashboard page documentation link in the UI.

megasanjay and others added 4 commits December 13, 2024 16:36
* 🐛 fix: update sorting on updated time

* ⚰️ chore: remove yarn.lock

* 💄 style: uipdate profile ui
* ✨ feat: add a dashboard page

* 🐛 fix: remove old code

* 🐛 fix: add response checks

* refactor: ♻️ dashboard link in nav directs to /dashboard

* refactor: ♻️ update variables for GET /dashboard api

---------

Co-authored-by: slugb0t <wheresdorian@gmail.com>
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!

Copy link

sourcery-ai bot commented Dec 16, 2024

Reviewer's Guide by Sourcery

This PR implements significant changes to improve the dashboard functionality and user experience. The changes include code formatting updates, navigation improvements, and the addition of a new dashboard landing page. The implementation focuses on better organization of user and organization data, enhanced error handling, and improved UI components.

Class Diagram for Dashboard API Changes

classDiagram
    class DashboardAPI {
        +fetchUserOrgs(user: User)
        +fetchOrgDetails(user: User)
        +combineOrgs(orgsOne, orgsTwo)
        +uniqueOrgs(combinedOrgs)
    }
    class User {
        +id: String
        +username: String
        +github_id: String
        +access_token: String
    }
    DashboardAPI --> User: uses
    note for DashboardAPI "Handles fetching and combining user and organization data from GitHub API"
Loading

Class Diagram for CWL Validation Process

classDiagram
    class CWLValidation {
        +getCWLFiles(context, owner, repository)
        +validateCWLFile(downloadUrl)
        +applyCWLTemplate(subjects, baseTemplate, repository, owner, context)
    }
    class Repository {
        +id: String
        +name: String
    }
    class CWLFile {
        +path: String
        +validation_status: String
        +validation_message: String
    }
    CWLValidation --> Repository: interacts with
    CWLValidation --> CWLFile: processes
    note for CWLValidation "Manages CWL file retrieval, validation, and template application"
Loading

File-Level Changes

Change Details Files
Added new dashboard landing page with user and organization overview
  • Created new dashboard index page with user account section
  • Added organizations section to display all user's organizations
  • Implemented organization card layout with avatar and action buttons
  • Added API endpoint to fetch user organizations data
ui/pages/dashboard/index.vue
ui/server/api/dashboard/index.get.ts
Updated navigation and routing behavior
  • Modified dashboard link in header to point to new dashboard index
  • Updated GitHub callback to redirect to user's dashboard
  • Added breadcrumb navigation improvements
  • Added empty state for repositories list
ui/layouts/default.vue
ui/server/routes/login/github/callback.get.ts
ui/pages/dashboard/[owner]/index.vue
Enhanced CWL file handling and validation
  • Added logging for CWL file discovery
  • Improved error handling in CWL validation
  • Updated code formatting and structure
bot/cwl/index.js
Improved UI components and styling
  • Updated profile page token purge section layout
  • Added NEmpty component registration
  • Improved responsive design in dashboard layouts
ui/pages/profile.vue
ui/components.d.ts

Possibly linked issues


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

@slugb0t slugb0t merged commit 79afe73 into main Dec 16, 2024
4 checks passed
Copy link

Thanks for closing this pull request! If you have any further questions, please feel free to open a new issue. We are always happy to help!

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

@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 @slugb0t - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

resolve(cwlObject)
} catch (error) {
console.log('Error getting CWL files:', error)
throw new Error(
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Error constructor usage is incorrect - subsequent arguments will be ignored

The Error constructor only uses the first argument as the message. Consider concatenating the message and stringified error like: new Error(\Error getting the CWL files: ${JSON.stringify(error)}`)`

@@ -21,74 +21,82 @@
* @returns {Array} - Array of CWL files in the repository
*/
export function getCWLFiles(context, owner, repository) {
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider simplifying the searchDirectory function by removing the redundant Promise wrapper and using a single try/catch block.

The searchDirectory function can be simplified by removing the redundant Promise wrapper and consolidating error handling. Here's a cleaner approach:

export async function getCWLFiles(context, owner, repository) {
  logwatch.info('Checking for CWL files in the repository...')

  const cwlObject = {
    contains_cwl_files: false,
    files: [],
    removed_files: []
  }

  async function searchDirectory(path) {
    const repoContent = await context.octokit.repos.getContent({
      owner,
      path,
      repo: repository.name
    })

    for (const file of repoContent.data) {
      if (file.type === 'file' && file.name.endsWith('.cwl')) {
        cwlObject.files.push(file)
      }
      if (file.type === 'dir') {
        await searchDirectory(file.path)
      }
    }
  }

  try {
    await searchDirectory('')

    const existingCWL = await dbInstance.cwlValidation.findUnique({
      where: { repository_id: repository.id }
    })

    if (existingCWL?.contains_cwl_files) {
      cwlObject.contains_cwl_files = existingCWL.contains_cwl_files
    }

    cwlObject.contains_cwl_files = cwlObject.files.length > 0
    return cwlObject

  } catch (error) {
    if (error.status === 404) {
      return cwlObject // Repository is empty
    }
    logwatch.error({
      message: 'Error finding CWL files throughout the repository:',
      error
    }, true)
    throw error
  }
}

Key improvements:

  • Removed redundant Promise wrapper since async functions return promises
  • Consolidated error handling into a single try/catch block
  • Flattened the code structure while maintaining all error cases
  • Kept all existing functionality intact

@sourcery-ai sourcery-ai bot mentioned this pull request Feb 26, 2025
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.

2 participants