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(constants): add @gauzy/constants package #8745

Merged
merged 3 commits into from
Jan 23, 2025

Conversation

rahul-rocket
Copy link
Collaborator

@rahul-rocket rahul-rocket commented Jan 23, 2025

PR

Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.


Summary by CodeRabbit

Based on the comprehensive changes, here are the release notes:

  • New Package

    • Introduced @gauzy/constants package to centralize default configuration values
  • Constants Consolidation

    • Migrated default constants from @gauzy/contracts to new @gauzy/constants package
    • Added constants for time formats, work hours, bonuses, and activity monitoring settings
  • Dependency Updates

    • Updated multiple packages to depend on @gauzy/constants
    • Refactored import statements across various components and services
  • Build Configuration

    • Added new build scripts for the constants package
    • Updated Docker and project configurations to support the new package
  • Development Improvements

    • Added TypeScript, ESLint, Jest, and npm configuration files for the constants package
    • Introduced documentation and changelog for the new package

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

This pull request introduces a new @gauzy/constants package to centralize default constants across the Gauzy project. The changes involve creating a new package with configuration files, moving default constants from @gauzy/contracts to the new package, updating import statements across multiple components, and modifying build scripts to include the new package. The modifications aim to improve code organization by separating constant definitions into a dedicated package.

Changes

File Change Summary
.deploy/api/Dockerfile Added copy command for packages/constants/package.json
.deploy/webapp/Dockerfile Added copy command for packages/constants/package.json
package.json Added new build scripts for constants package
packages/constants/ Created new package with configuration files, .dockerignore, .gitignore, README.md, etc.
Multiple component files Updated import statements to use @gauzy/constants instead of @gauzy/contracts

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Constants as @gauzy/constants
    participant Contracts as @gauzy/contracts
    participant Components as Application Components

    Dev->>Constants: Create new constants package
    Constants-->>Contracts: Move default constants
    Dev->>Components: Update import statements
    Components->>Constants: Import constants
    Dev->>Package: Update build scripts
Loading

Possibly related PRs

Poem

🐰 Hop, hop, constants unite!
In a package so clean and bright
From contracts they now depart
A new organization's art
CodeRabbit's constants take flight! 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
package.json (1)

259-259: Fix the formatting in docker build script.

There's a missing space after && in the build:package:all:docker script between utils:docker and config:docker.

-		"build:package:all:docker": "yarn run build:package:constants:docker && yarn run build:package:contracts:docker && yarn run build:package:common:docker && yarn run build:package:utils:docker &&yarn run build:package:config:docker && yarn run build:package:plugin:docker && yarn run build:package:auth:docker && yarn run build:package:plugins:pre:docker && yarn run build:package:core:docker && yarn run build:package:plugins:post:docker && yarn run build:package:desktop-lib:docker && yarn run build:package:plugin:integration-wakatime:docker && yarn run build:package:desktop-ui-lib:docker",
+		"build:package:all:docker": "yarn run build:package:constants:docker && yarn run build:package:contracts:docker && yarn run build:package:common:docker && yarn run build:package:utils:docker && yarn run build:package:config:docker && yarn run build:package:plugin:docker && yarn run build:package:auth:docker && yarn run build:package:plugins:pre:docker && yarn run build:package:core:docker && yarn run build:package:plugins:post:docker && yarn run build:package:desktop-lib:docker && yarn run build:package:plugin:integration-wakatime:docker && yarn run build:package:desktop-ui-lib:docker",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a214912 and f02fd16.

📒 Files selected for processing (35)
  • .deploy/api/Dockerfile (2 hunks)
  • .deploy/webapp/Dockerfile (1 hunks)
  • apps/desktop/src/package.json (1 hunks)
  • apps/gauzy/src/app/pages/employees/edit-employee/edit-employee-profile/edit-employee-settings/edit-employee-other-settings.component.ts (2 hunks)
  • apps/gauzy/src/app/pages/organizations/edit-organization/edit-organization-settings/edit-organization-other-settings/edit-organization-other-settings.component.ts (3 hunks)
  • apps/server-api/src/package.json (2 hunks)
  • apps/server/src/package.json (2 hunks)
  • package.json (2 hunks)
  • packages/constants/.dockerignore (1 hunks)
  • packages/constants/.gitignore (1 hunks)
  • packages/constants/.npmignore (1 hunks)
  • packages/constants/CHANGELOG.md (1 hunks)
  • packages/constants/README.md (1 hunks)
  • packages/constants/eslint.config.js (1 hunks)
  • packages/constants/jest.config.ts (1 hunks)
  • packages/constants/package.json (1 hunks)
  • packages/constants/project.json (1 hunks)
  • packages/constants/src/index.ts (1 hunks)
  • packages/constants/src/lib/organization.ts (1 hunks)
  • packages/constants/tsconfig.json (1 hunks)
  • packages/constants/tsconfig.lib.json (1 hunks)
  • packages/constants/tsconfig.spec.json (1 hunks)
  • packages/contracts/src/lib/organization.model.ts (0 hunks)
  • packages/core/package.json (1 hunks)
  • packages/core/src/lib/employee-statistics/employee-statistics.service.ts (1 hunks)
  • packages/core/src/lib/invite/invite.service.ts (1 hunks)
  • packages/core/src/lib/organization/organization.entity.ts (2 hunks)
  • packages/core/src/lib/organization/organization.seed.ts (11 hunks)
  • packages/core/src/lib/tenant/tenant.entity.ts (1 hunks)
  • packages/ui-core/package.json (1 hunks)
  • packages/ui-core/shared/src/lib/organizations/organizations-step-form/organizations-step-form.component.ts (1 hunks)
  • packages/ui-core/shared/src/lib/report/charts/line-chart/line-chart.component.ts (1 hunks)
  • packages/ui-core/shared/src/lib/timesheet/gauzy-filters/timezone-filter/timezone-filter.component.ts (1 hunks)
  • packages/ui-core/shared/src/lib/user/edit-profile-form/edit-profile-form.component.ts (2 hunks)
  • tsconfig.json (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/contracts/src/lib/organization.model.ts
✅ Files skipped from review due to trivial changes (21)
  • packages/constants/CHANGELOG.md
  • packages/constants/.npmignore
  • packages/constants/src/index.ts
  • packages/constants/.dockerignore
  • packages/ui-core/shared/src/lib/organizations/organizations-step-form/organizations-step-form.component.ts
  • packages/constants/.gitignore
  • packages/ui-core/shared/src/lib/timesheet/gauzy-filters/timezone-filter/timezone-filter.component.ts
  • packages/constants/README.md
  • apps/gauzy/src/app/pages/employees/edit-employee/edit-employee-profile/edit-employee-settings/edit-employee-other-settings.component.ts
  • packages/constants/package.json
  • packages/core/src/lib/invite/invite.service.ts
  • packages/constants/tsconfig.lib.json
  • packages/ui-core/shared/src/lib/user/edit-profile-form/edit-profile-form.component.ts
  • packages/core/src/lib/employee-statistics/employee-statistics.service.ts
  • packages/constants/tsconfig.json
  • packages/ui-core/shared/src/lib/report/charts/line-chart/line-chart.component.ts
  • packages/constants/jest.config.ts
  • apps/desktop/src/package.json
  • packages/constants/project.json
  • apps/server/src/package.json
  • apps/server-api/src/package.json
👮 Files not reviewed due to content moderation or server errors (3)
  • packages/core/src/lib/organization/organization.entity.ts
  • packages/core/src/lib/organization/organization.seed.ts
  • apps/gauzy/src/app/pages/organizations/edit-organization/edit-organization-settings/edit-organization-other-settings/edit-organization-other-settings.component.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: test
  • GitHub Check: build
🔇 Additional comments (13)
packages/constants/eslint.config.js (1)

1-19: LGTM! ESLint configuration is well structured.

The configuration properly extends the base config and correctly sets up JSON file handling with appropriate parser and rules.

packages/constants/src/lib/organization.ts (2)

1-4: Consider adding validation for time format values.

While the time formats array is correct, consider adding runtime validation to ensure only 12 or 24 are used throughout the application.


38-57: Verify the activity monitoring constants are in sync with UI components.

The inactivity limits, proof durations, and screenshot frequencies should align with UI dropdowns and form controls.

✅ Verification successful

Constants are properly synchronized with UI components

The activity monitoring constants are correctly integrated with UI dropdowns in both desktop and organization settings:

  • Desktop UI uses screenshot frequency options in period selection dropdown
  • Organization settings properly binds all three constants to their respective nb-select dropdowns
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for UI components using these constants
rg -g '*.{ts,html}' -e 'DEFAULT_INACTIVITY_TIME_LIMITS' -e 'DEFAULT_ACTIVITY_PROOF_DURATIONS' -e 'DEFAULT_SCREENSHOT_FREQUENCY_OPTIONS'

Length of output: 2030


Script:

#!/bin/bash
# Check the HTML templates for these components and their usage of the variables
echo "=== Desktop UI Settings Template ==="
cat packages/desktop-ui-lib/src/lib/settings/settings.component.html || echo "File not found"

echo -e "\n=== Organization Settings Template ==="
cat apps/gauzy/src/app/pages/organizations/edit-organization/edit-organization-settings/edit-organization-other-settings/edit-organization-other-settings.component.html || echo "File not found"

# Also check the component files for any value transformations
echo -e "\n=== Component Implementation Details ==="
cat packages/desktop-ui-lib/src/lib/settings/settings.component.ts
cat apps/gauzy/src/app/pages/organizations/edit-organization/edit-organization-settings/edit-organization-other-settings/edit-organization-other-settings.component.ts

Length of output: 87357


Script:

#!/bin/bash
# Check specific component implementations
echo "=== Desktop Settings Component ==="
rg -A 10 "periodOption =" packages/desktop-ui-lib/src/lib/settings/settings.component.ts

echo -e "\n=== Organization Settings Component ==="
rg -A 10 "listOfInactivityLimits|listOfActivityProofDuration|screenshotFrequencyOptions" apps/gauzy/src/app/pages/organizations/edit-organization/edit-organization-settings/edit-organization-other-settings/edit-organization-other-settings.component.ts

Length of output: 1367

packages/core/src/lib/tenant/tenant.entity.ts (1)

4-5: LGTM! Import statement correctly updated.

The constant has been properly imported from the new @gauzy/constants package and is correctly used in the entity definition.

apps/gauzy/src/app/pages/organizations/edit-organization/edit-organization-settings/edit-organization-other-settings/edit-organization-other-settings.component.ts (2)

10-20: LGTM! Comprehensive import of required constants.

The imports are well-organized and include all necessary constants from the new @gauzy/constants package.


88-88: LGTM! Proper initialization using imported constant.

The screenshotFrequencyOptions is correctly initialized using DEFAULT_SCREENSHOT_FREQUENCY_OPTIONS.

packages/constants/tsconfig.spec.json (1)

1-9: LGTM! Well-structured TypeScript test configuration.

The configuration properly:

  • Extends the base tsconfig
  • Sets up CommonJS module system
  • Includes necessary type definitions
  • Specifies correct test file patterns
tsconfig.json (1)

12-12: LGTM! Correct path mapping for the new constants package.

The path mapping for @gauzy/constants is properly configured and follows the existing pattern used for other packages.

packages/ui-core/package.json (1)

55-55: LGTM! Dependency added correctly.

The @gauzy/constants dependency is properly added with semantic versioning and correct placement.

packages/core/package.json (1)

46-46: LGTM! Dependency added correctly.

The @gauzy/constants dependency is properly added with semantic versioning and correct placement.

.deploy/webapp/Dockerfile (1)

94-94: LGTM! Package file copied correctly.

The constants package.json is properly copied with correct permissions and placement in the build process.

.deploy/api/Dockerfile (1)

139-139: LGTM! Package file copied correctly in both stages.

The constants package.json is properly copied in both the dependencies and prodDependencies stages with correct permissions.

Also applies to: 195-195

package.json (1)

146-148: LGTM! Build scripts added correctly.

The new build scripts for the constants package follow the established pattern with proper environment variables and memory allocation.

@rahul-rocket rahul-rocket merged commit 5ad818d into develop Jan 23, 2025
14 of 16 checks passed
@rahul-rocket rahul-rocket deleted the feat/constants-package branch January 23, 2025 11:09
Copy link

nx-cloud bot commented Jan 23, 2025

View your CI Pipeline Execution ↗ for commit f02fd16.

Command Status Duration Result
nx build desktop-ui-lib --configuration=develop... ❌ Failed 24s View ↗
nx build desktop-ui-lib --configuration=production ❌ Failed 24s View ↗
nx build plugin-integration-wakatime ✅ Succeeded 5s View ↗
nx build desktop-lib ✅ Succeeded 6s View ↗
nx build desktop-window ✅ Succeeded 2s View ↗
nx build desktop-core ✅ Succeeded <1s View ↗
nx build plugin-videos ✅ Succeeded <1s View ↗
nx build plugin-integration-upwork ✅ Succeeded <1s View ↗
Additional runs (48) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-01-23 11:37:49 UTC

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.

1 participant