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

chore:removing bulkfyle from mobile-app #3241

Merged
merged 5 commits into from
Oct 25, 2024
Merged

chore:removing bulkfyle from mobile-app #3241

merged 5 commits into from
Oct 25, 2024

Conversation

Sishhhh
Copy link
Contributor

@Sishhhh Sishhhh commented Oct 23, 2024

Clickup

https://app.clickup.com/t/86cwmcry2

Code Coverage

Please add code coverage here

UI Preview

Please add screenshots for UI changes

Summary by CodeRabbit

  • New Features

    • Simplified user interface for expense filing by removing the bulk filing option.
    • Updated action sheets and camera preview functionalities to reflect the removal of bulk filing capabilities.
  • Bug Fixes

    • Adjusted test cases to ensure proper validation of remaining properties related to expense functionalities.
    • Enhanced test coverage for camera preview behavior when the device platform is set to 'web'.
  • Documentation

    • Enhanced clarity in the component's behavior by removing unnecessary input properties and simplifying visibility logic.

Copy link

coderabbitai bot commented Oct 23, 2024

Walkthrough

Arre bhai, kya badlav ho gaye hain! MyExpensesPage aur uske related components mein kaafi saare changes hue hain. isBulkFyleEnabled feature ko hata diya gaya hai, aur ab tests sirf dusre properties jaise isNewReportsFlowEnabled aur isInstaFyleEnabled par focus karte hain. UI components bhi is hisaab se adjust ho gaye hain, aur bulk filing options ko remove kar diya gaya hai. Yeh sab milke structure ko simple banate hain bina core functionality ko badle.

Changes

File Change Summary
src/app/fyle/my-expenses/my-expenses.page.spec.ts Removed references to isBulkFyleEnabled in tests; updated assertions to focus on other properties.
src/app/fyle/my-expenses/my-expenses.page.ts Removed isBulkFyleEnabled$ observable; updated setupActionSheet method to exclude bulk filing.
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.html Changed visibility logic for bulk file upload icon to always render it, removing conditional rendering.
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts Removed @Input() allowBulkFyle; no changes to other internal logic or lifecycle methods.
src/app/shared/components/capture-receipt/capture-receipt.component.html Removed property binding for [allowBulkFyle] in <app-camera-preview> component.
src/app/shared/components/capture-receipt/capture-receipt.component.ts Removed @Input() allowBulkFyle; internal logic remains unchanged, simplifying the component interface.

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • Chethan-Fyle
  • suyashpatil78

Poem

Kya baat hai, expenses ki duniya mein,
Bulk filing gayi, ab sab kuch hai sahi mein!
Properties ab nache, naye flows ke sang,
Tests ki simplicity, sabko kare khush rang!
Receipt haath mein, chalo capture karein,
Aasan safar, sab milke khushiyaan baatein! 🎉


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

@github-actions github-actions bot added the size/S Small PR label Oct 23, 2024
Copy link

@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

🧹 Outside diff range comments (1)
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.html (1)

The shell script results show significant bulk mode functionality still present in both component files. Let me generate the final response:

Arre baap re! Bulk mode ka poora khandan abhi bhi zinda hai!

Dosto, component files mein bulk mode ka sara saman abhi bhi dhoom macha raha hai:

  • camera-preview.component.ts mein:

    • @Input() isBulkMode property
    • @Input() isBulkModePromptShown property
    • changes.isBulkMode ka check
  • capture-receipt.component.ts mein toh full party chal rahi hai:

    • isBulkMode variable
    • showBulkModeToastMessage() function
    • bulkModeToastMessageRef toast notifications
    • onBulkCapture() method
    • Bulk mode tracking code
    • Bulk mode modal creation

Template mein se bulk mode ka UI hatane se kya fayda, jab backend mein sara logic dance kar raha hai? Pehle in sab ko bhi proper tareeke se clean up karna padega, tabhi bulk mode ka retirement party complete hoga! 😄

🔗 Analysis chain

Line range hint 71-94: Arre bhai bhai bhai! Bulk mode ka sara masala abhi bhi pada hai!

Dekho ji, PR ka maksad tha bulkfyle ko completely hatana, lekin code mein abhi bhi bulk mode ke bahut sare tadke masale bache hue hain:

  • Bulk mode switching ka sara logic
  • "Bulk Mode" text displays
  • Bulk mode ke icons
  • isBulkMode variable ka use

Chaliye, ek baar check kar lete hain ki component file mein kya scene hai:

Suggestion hai ki in sab cheezon ko bhi remove kar dein:

-    <div class="camera-preview__bottom-container__icon-block text-center">
-      <ng-container *ngIf="noOfReceipts === 0; else receiptPreviewIcon">
-        <div (click)="onSwitchMode()">
-          <img
-            class="camera-preview__bottom-container__icon-block__icon"
-            [ngClass]="{ 'camera-preview__bottom-container__icon-block--highlight': isBulkModePromptShown }"
-            [src]="isBulkMode ? '../../../../assets/images/single-mode.png' : '../../../../assets/images/bulk-mode.png'"
-            alt="Mode"
-          />
-          <div class="camera-preview__bottom-container__text--secondary">
-            {{ !isBulkMode ? 'Bulk Mode' : 'Single Mode' }}
-          </div>
-        </div>
-      </ng-container>
+    <div class="camera-preview__bottom-container__icon-block text-center">
+      <ng-container *ngIf="noOfReceipts === 0; else receiptPreviewIcon">
+        <div>
+          <img
+            class="camera-preview__bottom-container__icon-block__icon"
+            src="../../../../assets/images/single-mode.png"
+            alt="Mode"
+          />
+          <div class="camera-preview__bottom-container__text--secondary">
+            Single Mode
+          </div>
+        </div>
+      </ng-container>
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Let's investigate the component file for bulk mode references
rg -i "bulk" src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts

# Also check if the parent component still passes bulk mode props
rg -i "bulk" src/app/shared/components/capture-receipt/capture-receipt.component.ts

Length of output: 1424

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 3b8c5ce and 7306ca9.

📒 Files selected for processing (6)
  • src/app/fyle/my-expenses/my-expenses.page.spec.ts (4 hunks)
  • src/app/fyle/my-expenses/my-expenses.page.ts (0 hunks)
  • src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.html (1 hunks)
  • src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts (0 hunks)
  • src/app/shared/components/capture-receipt/capture-receipt.component.html (0 hunks)
  • src/app/shared/components/capture-receipt/capture-receipt.component.ts (0 hunks)
💤 Files with no reviewable changes (4)
  • src/app/fyle/my-expenses/my-expenses.page.ts
  • src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts
  • src/app/shared/components/capture-receipt/capture-receipt.component.html
  • src/app/shared/components/capture-receipt/capture-receipt.component.ts
🧰 Additional context used
🔇 Additional comments (4)
src/app/fyle/my-expenses/my-expenses.page.spec.ts (4)

Line range hint 518-536: Arre bhai bhai, nice test coverage for enabled features!

The test properly verifies that isNewReportsFlowEnabled, isInstaFyleEnabled, isMileageEnabled and isPerDiemEnabled are set correctly when org settings enable these features. Good job with the assertions, ekdum first class!


Line range hint 537-564: Arey waah, disabled features ka test bhi kar liya!

Test verifies that all feature flags are set to false when org settings disable them. Mast comprehensive coverage hai boss!


Line range hint 565-588: Sahi pakde hain edge cases, not allowed features ka test!

Test checks that features are disabled when they are not allowed in org settings, even if enabled. Bilkul detective ki tarah har angle cover kar liya!


Line range hint 589-611: Undefined settings ka test, ekdum solid!

Test verifies that feature flags are set to undefined when org settings are undefined. Edge case testing on point hai guru!

Copy link
Contributor

@Dimple16 Dimple16 left a comment

Choose a reason for hiding this comment

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

Fix lint errors and unit tests

@github-actions github-actions bot added size/M Medium PR and removed size/S Small PR labels Oct 24, 2024
Copy link

@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: 1

🧹 Outside diff range comments (3)
src/app/shared/components/capture-receipt/capture-receipt.component.ts (3)

Line range hint 28-32: Type definition ko thoda aur strict banate hain! 💪

Ye Image type definition ko thoda improve kar sakte hain:

-type Image = Partial<{
+interface Image {
   source: string;
   base64Image: string;
-}>;
+}

Kyunki dono fields hamesha required hain (dekho base64ImagesWithSource.push() calls), toh Partial ki zarurat nahi hai. Interface use karne se code aur readable ho jayega!


Line range hint 391-397: Performance ka chakkar babu bhaiya! 🚀

addPerformanceTrackers method mein unnecessary subscription ho rahi hai:

addPerformanceTrackers(): void {
-   this.orgService.getOrgs().subscribe((orgs) => {
+   this.orgService.getOrgs().pipe(
+     take(1)
+   ).subscribe((orgs) => {

Ek baar performance track karne ke baad baar baar subscription ki kya zarurat? take(1) operator use karke subscription ko limit kar dete hain! 😎


Based on the shell script results, I can now provide a final response:

Arre bhai, bulk functionality ko completely hatana hi padega! 🎯

Dekho, search results se clear ho gaya hai ki bulk functionality ka removal org settings level se shuru hona chahiye. Code mein ye saare references mil gaye hain:

  • Core models mein BulkFyleSettings interface (org_user_settings.model.ts)
  • Org settings mein bulk_fyle_settings configuration
  • UI components mein bulk mode ke controls
  • Templates mein isBulkMode bindings

Aur capture-receipt component mein toh bulk mode ka poora setup hai:

  • Camera preview mein bulk mode toggle
  • Bulk mode toast messages
  • Bulk capture workflow

Ye PR incomplete hai kyunki:

  1. Org settings level se bulk fyle ka removal nahi hua
  2. UI se bulk mode ke controls abhi bhi maujood hain
  3. Core models mein bulk fyle ke interfaces abhi bhi hain

Ek proper cleanup ke liye in sab files ko touch karna padega. Bulk functionality ko properly hatane ke liye systematic approach chahiye, starting from the data models down to the UI.

🔗 Analysis chain

Line range hint 1-500: Arre bhai bhai bhai! Bulk functionality toh abhi bhi zinda hai! 🤔

Dekho ji, PR ka objective hai "removing bulkfyle from mobile-app", lekin code mein bulk capture ka sara functionality abhi bhi maujood hai. For example:

  • isBulkMode property
  • onBulkCapture() method
  • Bulk mode toast messages
  • Bulk receipt preview modal

Let's verify if bulk functionality should be completely removed:

If bulk functionality needs to be removed as per PR objective, here's what needs to be cleaned up:

- isBulkMode: boolean;
- bulkModeToastMessageRef: MatSnackBarRef<ToastMessageComponent>;
- showBulkModeToastMessage(): void {...}
- onSwitchMode(): void {...}
- onBulkCapture(): void {...}

Aur bhi bahut saare changes honge, lekin pehle ye clear karna padega - kya bulk functionality ko completely remove karna hai ya sirf isBulkFyleEnabled flag ko? 🤔

Main ek comprehensive cleanup PR generate kar sakta hoon bulk functionality ko remove karne ke liye. Batao, kya ye helpful rahega? 😊

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other bulk-related code in the codebase
echo "Searching for bulk-related code..."
rg -i "bulk.*fyle|bulkfyle" --type ts

# Search for bulk mode UI elements in templates
echo "Searching for bulk mode UI elements..."
rg -i "bulkMode|bulk-mode" --type html

Length of output: 6192

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 7306ca9 and d5f410e.

📒 Files selected for processing (2)
  • src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts (5 hunks)
  • src/app/shared/components/capture-receipt/capture-receipt.component.ts (1 hunks)
🧰 Additional context used
🪛 Biome
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts

[error] 103-103: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (2)
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts (2)

59-59: Waah! TypeScript ke guru, kya baat hai!

Return types add kar diye, code ko ekdum clean and type-safe bana diya. Typescript compiler ko bhi khushi ho gayi hogi!

Also applies to: 80-80, 99-99, 107-107, 119-119, 132-132, 137-137, 141-141, 146-146, 151-151, 157-157, 162-162


Line range hint 16-16: Bulk feature ka cleanup adhura lag raha hai, dost!

While allowBulkFyle has been removed, I notice we still have other bulk-related properties and logic:

  • isBulkMode input property
  • Bulk mode change handling in ngOnChanges

Let's verify if these should also be removed for consistency.

Also applies to: 162-168

//Stop camera only if it is in RUNNING state
if (this.cameraState === CameraState.RUNNING) {
this.cameraState = CameraState.STOPPING;
from(this.cameraPreviewService.stop()).subscribe((_) => (this.cameraState = CameraState.STOPPED));
from(this.cameraPreviewService.stop()).subscribe(() => (this.cameraState = CameraState.STOPPED));
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Arre bhai bhai bhai, thoda readable banate hain!

Assignment ko expression ke andar rakhna thoda confusing hai. Chalo ise alag line mein likhte hain.

Here's a cleaner way to write it:

-      from(this.cameraPreviewService.stop()).subscribe(() => (this.cameraState = CameraState.STOPPED));
+      from(this.cameraPreviewService.stop()).subscribe(() => {
+        this.cameraState = CameraState.STOPPED;
+      });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from(this.cameraPreviewService.stop()).subscribe(() => (this.cameraState = CameraState.STOPPED));
from(this.cameraPreviewService.stop()).subscribe(() => {
this.cameraState = CameraState.STOPPED;
});
🧰 Tools
🪛 Biome

[error] 103-103: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Copy link

@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

🧹 Outside diff range comments (1)
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.spec.ts (1)

Line range hint 236-251: Oho! Bulk mode ke test cases abhi bhi party mein invited hain!

Dekho bhai, PR ka maksad hai bulkFyle ko remove karna, lekin yeh test cases abhi bhi bulk mode ke liye nach rahe hain. Inko bhi vida kar dena chahiye!

Cleanup karne ke liye yeh changes zaruri hain:

-  describe('ngOnChanges():', () => {
-    it('should show message if bulk mode is turned on', fakeAsync(() => {
-      component.ngOnChanges({
-        isBulkMode: new SimpleChange(false, true, true),
-      });
-
-      expect(component.showModeChangedMessage).toEqual(true);
-      tick(1500);
-      expect(component.showModeChangedMessage).toEqual(false);
-    }));
-
-    it('should not change state if no change detected', () => {
-      component.showModeChangedMessage = false;
-
-      component.ngOnChanges({});
-      expect(component.showModeChangedMessage).toEqual(false);
-    });
-  });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between d5f410e and d6ce6ac.

📒 Files selected for processing (1)
  • src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.spec.ts (1 hunks)
🔇 Additional comments (1)
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.spec.ts (1)

93-102: Arre wah! Zabardast web platform test case likha hai!

Test case ekdum sahi hai, lekin ek choti si baat check kar len - kya humne component ke template mein web platform ke liye koi special UI handling toh nahi bhool gaye?

✅ Verification successful

The previous command might have failed because we were too specific. Let's check the actual implementation to understand if there are any platform-specific UI considerations that need testing.


Arre bhai bhai bhai! Sab ekdum first class hai!

Dekho, maine code ka full inspection kar liya hai aur kya pata chala:

  • Web platform ke liye UI mein koi special handling ki zarurat hi nahi hai
  • Component automatically handle kar raha hai platform differences:
    • Web pe permissions check skip karta hai
    • Flash mode sirf non-web platforms pe show hota hai (*ngIf="flashMode" and if (this.devicePlatform !== 'web'))
    • Camera preview ka basic UI sabke liye same hai

Matlab test case bilkul sahi hai, aur implementation bhi perfect! Koi tension nahi lene ka, code ekdum solid hai! 😄

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any web-specific UI elements or conditions in the template
rg -g "*.html" "devicePlatform === 'web'" src/app/shared/components/capture-receipt/camera-preview/

Length of output: 107


Script:

#!/bin/bash
# Let's check the template file directly to see all UI conditions
fd "camera-preview.component.html" src/app/shared/components/capture-receipt/ --exec cat {}

# Also check the component file to understand platform-specific logic
fd "camera-preview.component.ts" src/app/shared/components/capture-receipt/ --exec cat {}

Length of output: 9335

Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between d6ce6ac and b931606.

📒 Files selected for processing (1)
  • src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.spec.ts (3 hunks)
🔇 Additional comments (2)
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.spec.ts (2)

94-103: Arre wah! Web platform ke liye naya test case, ekdum first class! 🎯

Bahut badhiya test case add kiya hai web platform ke liye. Camera permissions ka chakkar hi nahi, seedha preview shuru!


Line range hint 1-235: Test coverage ka full package, lekin ek choti si baat! 🤔

Bhai test coverage toh mast hai, lekin PR objectives mein code coverage report ki baat ki thi.

Let's check if the coverage report is available:

Coverage report nahi mil raha toh main help kar sakta hun generate karne mein. Batao, karna hai kya?

@@ -211,16 +223,16 @@ describe('CameraPreviewComponent', () => {
isBulkMode: new SimpleChange(false, true, true),
});

expect(component.showModeChangedMessage).toEqual(true);
expect(component.showModeChangedMessage).toBeTrue();
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Assertion ka style update kar diya, smart move! 👌

.toEqual(true/false) se .toBeTrue()/.toBeFalse() mein change kar diya. Ekdum sahi kiya boss! Ye wala syntax boolean assertions ke liye zyada specific hai.

Ek suggestion hai, baaki test cases mein bhi boolean assertions ko isi tarah update kar sakte hain, consistency ke liye. Karna hai kya?

Also applies to: 228-228, 235-235

@Sishhhh Sishhhh requested a review from Dimple16 October 24, 2024 14:13
Copy link

Unit Test Coverage % values
Statements 95.85% ( 19133 / 19961 )
Branches 91.1% ( 10530 / 11558 )
Functions 94.27% ( 5712 / 6059 )
Lines 95.88% ( 18263 / 19047 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Medium PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants