You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mohammadreza-92 (via GitHub)" <gi...@apache.org> on 2025/11/13 12:55:38 UTC

[PR] Feat/persian calendar [superset]

mohammadreza-92 opened a new pull request, #36100:
URL: https://github.com/apache/superset/pull/36100

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] Feat/persian calendar [superset]

Posted by "mohammadreza-92 (via GitHub)" <gi...@apache.org>.
mohammadreza-92 closed pull request #36100: Feat/persian calendar
URL: https://github.com/apache/superset/pull/36100


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] Feat/persian calendar [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #36100:
URL: https://github.com/apache/superset/pull/36100#discussion_r2523377124


##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/ActionButtons/index.tsx:
##########
@@ -110,6 +121,17 @@ const ActionButtons = ({
   filterBarOrientation = FilterBarOrientation.Vertical,
   chartCustomizationItems,
 }: ActionButtonsProps) => {
+  // Check if locale is Persian (fa) for RTL support
+  const isRTL = useMemo(() => {
+    // Check document direction
+    if (typeof document !== 'undefined' && document.documentElement) {
+      return document.documentElement.dir === 'rtl' || 
+             document.documentElement.lang === 'fa' ||
+             document.documentElement.lang?.startsWith('fa');
+    }
+    return false;
+  }, []);

Review Comment:
   ### RTL Detection Logic Should Be Extracted <sub>![category Design](https://img.shields.io/badge/Design-0d9488)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   RTL detection logic is tightly coupled with the component and contains hardcoded language checks specific to Persian (fa). This violates the Single Responsibility Principle and makes the code less maintainable and reusable.
   
   
   ###### Why this matters
   If RTL requirements change or new languages need RTL support, changes would be required in multiple places. The component is also taking on the responsibility of language/direction detection which should be handled at a higher level.
   
   ###### Suggested change ∙ *Feature Preview*
   Create a custom hook or utility function for RTL detection:
   ```typescript
   const useRTL = () => {
     return useMemo(() => {
       return i18n.getDirection() === 'rtl';
     }, [i18n.language]);
   };
   ```
   Then in the component:
   ```typescript
   const isRTL = useRTL();
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bfec9fd1-1d23-4aa9-9675-06ee3331c5bc/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bfec9fd1-1d23-4aa9-9675-06ee3331c5bc?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bfec9fd1-1d23-4aa9-9675-06ee3331c5bc?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bfec9fd1-1d23-4aa9-9675-06ee3331c5bc?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bfec9fd1-1d23-4aa9-9675-06ee3331c5bc)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:fe14f980-e085-49ff-9084-204a8e5e7421 -->
   
   
   [](fe14f980-e085-49ff-9084-204a8e5e7421)



##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/ActionButtons/index.tsx:
##########
@@ -110,6 +121,17 @@ const ActionButtons = ({
   filterBarOrientation = FilterBarOrientation.Vertical,
   chartCustomizationItems,
 }: ActionButtonsProps) => {
+  // Check if locale is Persian (fa) for RTL support
+  const isRTL = useMemo(() => {
+    // Check document direction
+    if (typeof document !== 'undefined' && document.documentElement) {
+      return document.documentElement.dir === 'rtl' || 
+             document.documentElement.lang === 'fa' ||
+             document.documentElement.lang?.startsWith('fa');
+    }
+    return false;
+  }, []);

Review Comment:
   ### Incomplete RTL language detection <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The RTL detection logic is hardcoded to only check for Persian language ('fa') and doesn't support other RTL languages like Arabic ('ar'), Hebrew ('he'), or Urdu ('ur').
   
   
   ###### Why this matters
   This will cause incorrect layout behavior for users of other RTL languages, as the component will render in LTR mode instead of RTL mode for non-Persian RTL languages.
   
   ###### Suggested change ∙ *Feature Preview*
   Replace the hardcoded Persian check with a comprehensive RTL language detection:
   
   ```typescript
   const isRTL = useMemo(() => {
     // Check document direction
     if (typeof document !== 'undefined' && document.documentElement) {
       const rtlLanguages = ['ar', 'he', 'fa', 'ur', 'ps', 'sd', 'ku', 'dv'];
       const lang = document.documentElement.lang?.toLowerCase();
       return document.documentElement.dir === 'rtl' || 
              (lang && rtlLanguages.some(rtlLang => lang.startsWith(rtlLang)));
     }
     return false;
   }, []);
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4bd8f541-9d62-4cdf-819c-14b5a54a90b3/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4bd8f541-9d62-4cdf-819c-14b5a54a90b3?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4bd8f541-9d62-4cdf-819c-14b5a54a90b3?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4bd8f541-9d62-4cdf-819c-14b5a54a90b3?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4bd8f541-9d62-4cdf-819c-14b5a54a90b3)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:37bdfc0c-30ce-42cc-9920-2926dd7d7e69 -->
   
   
   [](37bdfc0c-30ce-42cc-9920-2926dd7d7e69)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] Feat/persian calendar [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on PR #36100:
URL: https://github.com/apache/superset/pull/36100#issuecomment-3531501249

   Korbit doesn't automatically review large (3000+ lines changed) pull requests such as this one. If you want me to review anyway, use `/korbit-review`.
   
   
   [](d082e500-646c-44dd-9738-d0dd36e6ea49)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] Feat/persian calendar [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #36100:
URL: https://github.com/apache/superset/pull/36100#discussion_r2523404937


##########
superset-frontend/src/explore/components/controls/DateFilterControl/components/PersianCalendarFrame.tsx:
##########
@@ -0,0 +1,446 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { css, NO_TIME_RANGE, styled, t } from '@superset-ui/core';
+// eslint-disable-next-line no-restricted-imports
+import { Button } from '@superset-ui/core/components/Button';
+import { Radio } from '@superset-ui/core/components/Radio';
+import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
+import type { Dayjs } from 'dayjs';
+import {
+  formatPersianDate,
+  getCurrentPersianDate,
+  gregorianToPersian,
+  persianToGregorian,
+} from 'src/utils/persianCalendar';
+import { JalaliDatePicker } from './JalaliDatePicker';
+
+type PersianCalendarRangeType =
+  | 'last_7_days'
+  | 'last_30_days'
+  | 'last_90_days'
+  | 'last_year'
+  | 'custom_range';
+
+interface RangeDefinition {
+  key: PersianCalendarRangeType;
+  label: string;
+  labelFa: string;
+  timeRange?: string;
+}
+
+const PERSIAN_RANGE_LABELS: Record<PersianCalendarRangeType, string> = {
+  last_7_days: '۷ روز گذشته',
+  last_30_days: '۳۰ روز گذشته',
+  last_90_days: '۹۰ روز گذشته',
+  last_year: 'یک سال گذشته',
+  custom_range: 'بازه سفارشی',
+};
+
+const RANGE_DEFINITIONS: RangeDefinition[] = [
+  {
+    key: 'last_7_days',
+    label: t('Last 7 days'),
+    labelFa: PERSIAN_RANGE_LABELS.last_7_days,
+    timeRange: 'Last 7 days',
+  },
+  {
+    key: 'last_30_days',
+    label: t('Last 30 days'),
+    labelFa: PERSIAN_RANGE_LABELS.last_30_days,
+    timeRange: 'Last 30 days',
+  },
+  {
+    key: 'last_90_days',
+    label: t('Last 90 days'),
+    labelFa: PERSIAN_RANGE_LABELS.last_90_days,
+    timeRange: 'Last 90 days',
+  },
+  {
+    key: 'last_year',
+    label: t('Last year'),
+    labelFa: PERSIAN_RANGE_LABELS.last_year,
+    timeRange: 'Last year',
+  },
+  {
+    key: 'custom_range',
+    label: t('Custom range'),
+    labelFa: PERSIAN_RANGE_LABELS.custom_range,
+  },
+];
+
+const RANGE_VALUE_TO_KEY = new Map(
+  RANGE_DEFINITIONS.filter(def => def.timeRange).map(def => [
+    def.timeRange as string,
+    def.key,
+  ]),
+);
+
+const RANGE_KEY_TO_VALUE = new Map(
+  RANGE_DEFINITIONS.filter(def => def.timeRange).map(def => [
+    def.key,
+    def.timeRange as string,
+  ]),
+);
+
+const DEFAULT_RANGE: PersianCalendarRangeType = 'last_7_days';
+
+const PERSIAN_TEXT = {
+  title: 'فیلتر تقویم شمسی',
+  selectTimeRange: 'انتخاب بازه زمانی',
+  chooseCustomRange: 'انتخاب بازه دلخواه',
+  selectRangePlaceholder: 'بازه تاریخ را انتخاب کنید',
+  startToToday: 'تنظیم شروع روی امروز',
+  endToToday: 'تنظیم پایان روی امروز',
+  selectedRangeLabel: 'بازه انتخاب‌شده (جلالی)',
+  currentDateLabel: 'تاریخ جلالی امروز',
+};
+
+const PERSIAN_DIGITS = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
+
+const toPersianDigits = (value: string) =>
+  value.replace(/\d/g, digit => PERSIAN_DIGITS[Number(digit)]);
+
+const MIN_GREGORIAN_YEAR = 1700;
+
+interface FrameComponentProps {
+  onChange: (value: string) => void;
+  value?: string;
+}
+
+const Container = styled.div<{ $isRTL: boolean }>`
+  ${({ theme, $isRTL }) => css`
+    padding: ${theme.padding}px;
+    direction: ${$isRTL ? 'rtl' : 'ltr'};
+    text-align: ${$isRTL ? 'right' : 'left'};
+  `}
+`;
+
+const SectionTitle = styled.h3`
+  ${({ theme }) => css`
+    margin: 0 0 ${theme.marginSM}px;
+    font-size: ${theme.fontSize}px;
+    font-weight: ${theme.fontWeightStrong};
+  `}
+`;
+
+const SectionLabel = styled.div`
+  ${({ theme }) => css`
+    margin-bottom: ${theme.marginXS}px;
+    font-size: ${theme.fontSizeSM}px;
+    font-weight: ${theme.fontWeightStrong};
+  `}
+`;
+
+const SummaryCard = styled.div<{ $variant?: 'default' | 'info' }>`
+  ${({ theme, $variant = 'default' }) => css`
+    margin-top: ${theme.marginSM}px;
+    padding: ${theme.paddingSM}px;
+    border-radius: ${theme.borderRadius}px;
+    border: 1px solid ${
+      $variant === 'info' ? theme.colorPrimaryBorder : theme.colorBorder
+    };
+    background-color: ${
+      $variant === 'info' ? theme.colorPrimaryBgHover : theme.colorBgContainer
+    };
+  `}
+`;
+
+const PickerActions = styled.div`
+  ${({ theme }) => css`
+    display: flex;
+    gap: ${theme.marginXS}px;
+    margin-top: ${theme.marginXS}px;
+    justify-content: flex-end;
+    flex-wrap: wrap;
+  `}
+`;
+
+const RadioGroup = styled(Radio.Group)`
+  width: 100%;
+`;
+
+const RadioList = styled.div`
+  display: flex;
+  flex-direction: column;
+  gap: ${({ theme }) => theme.marginXS}px;
+`;
+
+export function PersianCalendarFrame({
+  onChange,
+  value,
+}: FrameComponentProps) {
+  const [selectedRange, setSelectedRange] = useState<PersianCalendarRangeType>(
+    DEFAULT_RANGE,
+  );
+  const [customStartDate, setCustomStartDate] = useState<Dayjs | null>(null);
+  const [customEndDate, setCustomEndDate] = useState<Dayjs | null>(null);
+  const [currentPersianDate] = useState(getCurrentPersianDate());
+
+  const isRTL = useMemo(() => {
+    if (typeof document === 'undefined') {
+      return true;
+    }
+    const doc = document.documentElement;
+    if (doc?.dir === 'rtl' || doc?.lang?.startsWith('fa')) {
+      return true;
+    }
+    if (typeof navigator !== 'undefined' && navigator.language?.startsWith('fa')) {
+      return true;
+    }
+    return true;
+  }, []);

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>RTL logic always true</b></div>
   <div id="fix">
   
   The `isRTL` hook always returns `true`, forcing RTL layout even for LTR languages like English. This breaks the UI direction for non-Persian users, causing text and elements to align incorrectly. Change the final `return true;` to `return false;` to enable RTL only when the document direction is RTL or the language is Persian/Farsi.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
     const isRTL = useMemo(() => {
       if (typeof document === 'undefined') {
         return true;
       }
       const doc = document.documentElement;
       if (doc?.dir === 'rtl' || doc?.lang?.startsWith('fa')) {
         return true;
       }
       if (typeof navigator !== 'undefined' && navigator.language?.startsWith('fa')) {
         return true;
       }
       return false;
     }, []);
   ````
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a href=https://github.com/apache/superset/pull/36100#issuecomment-3527687196>#9ecc65</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/webpack.proxy-config.js:
##########
@@ -162,16 +162,20 @@ module.exports = newManifest => {
     onProxyRes(proxyResponse, request, response) {
       try {
         copyHeaders(proxyResponse, response);
-        if (isHTML(response)) {
+        if (isHTML(proxyResponse)) {
           processHTML(proxyResponse, response);
         } else {
           proxyResponse.pipe(response);
         }
-        response.flushHeaders();
+        if (!response.headersSent) {
+          response.flushHeaders();
+        }
       } catch (e) {
-        response.setHeader('content-type', 'text/plain');
-        response.write(`Error requesting ${request.path} from proxy:\n\n`);
-        response.end(e.stack);
+        if (!response.headersSent) {

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incomplete error response handling</b></div>
   <div id="fix">
   
   The catch block's error handling logic is flawed: when `response.headersSent` is true, it skips writing the error message and ending the response entirely. This can happen if an error is thrown after `response.flushHeaders()` executes, leaving clients with incomplete responses or hanging connections. The `response.write()` and `response.end()` calls should be moved outside the `headersSent` check to ensure errors are always handled, while keeping `setHeader()` conditional to avoid runtime errors. This affects the `onProxyRes` function used in webpack's proxy middleware, where proper error responses are crucial for development reliability.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    -      } catch (e) {
    -        if (!response.headersSent) {
    -          response.setHeader('content-type', 'text/plain');
    -          response.write(`Error requesting ${request.path} from proxy:\\n\\n`);
    -          response.end(e.stack);
    -        }
    +      } catch (e) {
    +        if (!response.headersSent) {
    +          response.setHeader('content-type', 'text/plain');
    +        }
    +        response.write(`Error requesting ${request.path} from proxy:\\n\\n`);
    +        response.end(e.stack);
   ```
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a href=https://github.com/apache/superset/pull/36100#issuecomment-3527687196>#9ecc65</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/src/explore/components/controls/DateFilterControl/components/PersianCalendarFrame.tsx:
##########
@@ -0,0 +1,446 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { css, NO_TIME_RANGE, styled, t } from '@superset-ui/core';
+// eslint-disable-next-line no-restricted-imports
+import { Button } from '@superset-ui/core/components/Button';
+import { Radio } from '@superset-ui/core/components/Radio';
+import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
+import type { Dayjs } from 'dayjs';
+import {
+  formatPersianDate,
+  getCurrentPersianDate,
+  gregorianToPersian,
+  persianToGregorian,
+} from 'src/utils/persianCalendar';
+import { JalaliDatePicker } from './JalaliDatePicker';
+
+type PersianCalendarRangeType =
+  | 'last_7_days'
+  | 'last_30_days'
+  | 'last_90_days'
+  | 'last_year'
+  | 'custom_range';
+
+interface RangeDefinition {
+  key: PersianCalendarRangeType;
+  label: string;
+  labelFa: string;
+  timeRange?: string;
+}
+
+const PERSIAN_RANGE_LABELS: Record<PersianCalendarRangeType, string> = {
+  last_7_days: '۷ روز گذشته',
+  last_30_days: '۳۰ روز گذشته',
+  last_90_days: '۹۰ روز گذشته',
+  last_year: 'یک سال گذشته',
+  custom_range: 'بازه سفارشی',
+};
+
+const RANGE_DEFINITIONS: RangeDefinition[] = [
+  {
+    key: 'last_7_days',
+    label: t('Last 7 days'),
+    labelFa: PERSIAN_RANGE_LABELS.last_7_days,
+    timeRange: 'Last 7 days',
+  },
+  {
+    key: 'last_30_days',
+    label: t('Last 30 days'),
+    labelFa: PERSIAN_RANGE_LABELS.last_30_days,
+    timeRange: 'Last 30 days',
+  },
+  {
+    key: 'last_90_days',
+    label: t('Last 90 days'),
+    labelFa: PERSIAN_RANGE_LABELS.last_90_days,
+    timeRange: 'Last 90 days',
+  },
+  {
+    key: 'last_year',
+    label: t('Last year'),
+    labelFa: PERSIAN_RANGE_LABELS.last_year,
+    timeRange: 'Last year',
+  },
+  {
+    key: 'custom_range',
+    label: t('Custom range'),
+    labelFa: PERSIAN_RANGE_LABELS.custom_range,
+  },
+];
+
+const RANGE_VALUE_TO_KEY = new Map(
+  RANGE_DEFINITIONS.filter(def => def.timeRange).map(def => [
+    def.timeRange as string,
+    def.key,
+  ]),
+);
+
+const RANGE_KEY_TO_VALUE = new Map(
+  RANGE_DEFINITIONS.filter(def => def.timeRange).map(def => [
+    def.key,
+    def.timeRange as string,
+  ]),
+);
+
+const DEFAULT_RANGE: PersianCalendarRangeType = 'last_7_days';
+
+const PERSIAN_TEXT = {
+  title: 'فیلتر تقویم شمسی',
+  selectTimeRange: 'انتخاب بازه زمانی',
+  chooseCustomRange: 'انتخاب بازه دلخواه',
+  selectRangePlaceholder: 'بازه تاریخ را انتخاب کنید',
+  startToToday: 'تنظیم شروع روی امروز',
+  endToToday: 'تنظیم پایان روی امروز',
+  selectedRangeLabel: 'بازه انتخاب‌شده (جلالی)',
+  currentDateLabel: 'تاریخ جلالی امروز',
+};
+
+const PERSIAN_DIGITS = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
+
+const toPersianDigits = (value: string) =>
+  value.replace(/\d/g, digit => PERSIAN_DIGITS[Number(digit)]);
+
+const MIN_GREGORIAN_YEAR = 1700;
+
+interface FrameComponentProps {
+  onChange: (value: string) => void;
+  value?: string;
+}
+
+const Container = styled.div<{ $isRTL: boolean }>`
+  ${({ theme, $isRTL }) => css`
+    padding: ${theme.padding}px;
+    direction: ${$isRTL ? 'rtl' : 'ltr'};
+    text-align: ${$isRTL ? 'right' : 'left'};
+  `}
+`;
+
+const SectionTitle = styled.h3`
+  ${({ theme }) => css`
+    margin: 0 0 ${theme.marginSM}px;
+    font-size: ${theme.fontSize}px;
+    font-weight: ${theme.fontWeightStrong};
+  `}
+`;
+
+const SectionLabel = styled.div`
+  ${({ theme }) => css`
+    margin-bottom: ${theme.marginXS}px;
+    font-size: ${theme.fontSizeSM}px;
+    font-weight: ${theme.fontWeightStrong};
+  `}
+`;
+
+const SummaryCard = styled.div<{ $variant?: 'default' | 'info' }>`
+  ${({ theme, $variant = 'default' }) => css`
+    margin-top: ${theme.marginSM}px;
+    padding: ${theme.paddingSM}px;
+    border-radius: ${theme.borderRadius}px;
+    border: 1px solid ${
+      $variant === 'info' ? theme.colorPrimaryBorder : theme.colorBorder
+    };
+    background-color: ${
+      $variant === 'info' ? theme.colorPrimaryBgHover : theme.colorBgContainer
+    };
+  `}
+`;
+
+const PickerActions = styled.div`
+  ${({ theme }) => css`
+    display: flex;
+    gap: ${theme.marginXS}px;
+    margin-top: ${theme.marginXS}px;
+    justify-content: flex-end;
+    flex-wrap: wrap;
+  `}
+`;
+
+const RadioGroup = styled(Radio.Group)`
+  width: 100%;
+`;
+
+const RadioList = styled.div`
+  display: flex;
+  flex-direction: column;
+  gap: ${({ theme }) => theme.marginXS}px;
+`;
+
+export function PersianCalendarFrame({
+  onChange,
+  value,
+}: FrameComponentProps) {
+  const [selectedRange, setSelectedRange] = useState<PersianCalendarRangeType>(
+    DEFAULT_RANGE,
+  );
+  const [customStartDate, setCustomStartDate] = useState<Dayjs | null>(null);
+  const [customEndDate, setCustomEndDate] = useState<Dayjs | null>(null);
+  const [currentPersianDate] = useState(getCurrentPersianDate());
+
+  const isRTL = useMemo(() => {
+    if (typeof document === 'undefined') {
+      return true;
+    }
+    const doc = document.documentElement;
+    if (doc?.dir === 'rtl' || doc?.lang?.startsWith('fa')) {
+      return true;
+    }
+    if (typeof navigator !== 'undefined' && navigator.language?.startsWith('fa')) {
+      return true;
+    }
+    return true;
+  }, []);
+
+  const shouldUsePersianText = useMemo(() => {
+    if (typeof document !== 'undefined') {
+      const doc = document.documentElement;
+      if (doc?.lang?.startsWith('fa')) {
+        return true;
+      }
+    }
+    if (typeof navigator !== 'undefined' && navigator.language?.startsWith('fa')) {
+      return true;
+    }
+    return true;
+  }, []);

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Persian text logic always true</b></div>
   <div id="fix">
   
   The `shouldUsePersianText` hook always returns `true`, displaying Persian text even for non-Persian languages. This confuses users in other locales by showing labels in Farsi. Update the final `return true;` to `return false;` to use Persian text only when the language is Persian/Farsi.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
     const shouldUsePersianText = useMemo(() => {
       if (typeof document !== 'undefined') {
         const doc = document.documentElement;
         if (doc?.lang?.startsWith('fa')) {
           return true;
         }
       }
       if (typeof navigator !== 'undefined' && navigator.language?.startsWith('fa')) {
         return true;
       }
       return false;
     }, []);
   ````
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a href=https://github.com/apache/superset/pull/36100#issuecomment-3527687196>#9ecc65</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] Feat/persian calendar [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on PR #36100:
URL: https://github.com/apache/superset/pull/36100#issuecomment-3529139491

   @mohammadreza-92 can you add more details to what your PR is trying to do. Moving it to a draft until this is addressed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] Feat/persian calendar [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #36100:
URL: https://github.com/apache/superset/pull/36100#issuecomment-3527687196

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org