Skip to content

Commit

Permalink
chore: migrated filters.ts to packages
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsikrishnamathala committed Jan 24, 2025
1 parent 0b53912 commit ebdc5e4
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 89 deletions.
53 changes: 53 additions & 0 deletions packages/constants/src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,56 @@ export enum E_SORT_ORDER {
ASC = "asc",
DESC = "desc",
}
export const DATE_AFTER_FILTER_OPTIONS = [
{
name: "1 week from now",
value: "1_weeks;after;fromnow",
},
{
name: "2 weeks from now",
value: "2_weeks;after;fromnow",
},
{
name: "1 month from now",
value: "1_months;after;fromnow",
},
{
name: "2 months from now",
value: "2_months;after;fromnow",
},
];

export const DATE_BEFORE_FILTER_OPTIONS = [
{
name: "1 week ago",
value: "1_weeks;before;fromnow",
},
{
name: "2 weeks ago",
value: "2_weeks;before;fromnow",
},
{
name: "1 month ago",
i18n_name: "date_filters.1_month_ago",
value: "1_months;before;fromnow",
},
];

export const PROJECT_CREATED_AT_FILTER_OPTIONS = [
{
name: "Today",
value: "today;custom;custom",
},
{
name: "Yesterday",
value: "yesterday;custom;custom",
},
{
name: "Last 7 days",
value: "last_7_days;custom;custom",
},
{
name: "Last 30 days",
value: "last_30_days;custom;custom",
},
];
5 changes: 4 additions & 1 deletion packages/i18n/src/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,8 @@
"change_parent_issue": "Change parent issue",
"remove_parent_issue": "Remove parent issue",
"add_parent": "Add parent",
"loading_members": "Loading members..."
"loading_members": "Loading members...",
"common": {
"filters": "Filters"
}
}
5 changes: 4 additions & 1 deletion packages/i18n/src/locales/es/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,8 @@
"remove_parent_issue": "Eliminar problema padre",
"add_parent": "Agregar padre",
"loading_members": "Cargando miembros...",
"inbox": "bandeja de entrada"
"inbox": "bandeja de entrada",
"common": {
"filters": "Filtros"
}
}
5 changes: 4 additions & 1 deletion packages/i18n/src/locales/fr/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,8 @@
"remove_parent_issue": "Supprimer le problème parent",
"add_parent": "Ajouter un parent",
"loading_members": "Chargement des membres...",
"inbox": "Boîte de réception"
"inbox": "Boîte de réception",
"common": {
"filters": "Filtres"
}
}
5 changes: 4 additions & 1 deletion packages/i18n/src/locales/ja/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,8 @@
"remove_parent_issue": "親問題を削除",
"add_parent": "親問題を追加",
"loading_members": "メンバーを読み込んでいます...",
"inbox": "受信箱"
"inbox": "受信箱",
"common": {
"filters": "フィルター"
}
}
5 changes: 4 additions & 1 deletion packages/i18n/src/locales/zh-CN/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,8 @@
"remove_parent_issue": "移除父问题",
"add_parent": "添加父问题",
"loading_members": "正在加载成员...",
"inbox": "收件箱"
"inbox": "收件箱",
"common": {
"filters": "过滤器"
}
}
4 changes: 2 additions & 2 deletions web/core/components/common/applied-filters/date.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { observer } from "mobx-react";
// icons
import { X } from "lucide-react";
// constants
import { DATE_BEFORE_FILTER_OPTIONS } from "@/constants/filters";
// plane constants
import { DATE_BEFORE_FILTER_OPTIONS } from "@plane/constants";
// helpers
import { renderFormattedDate } from "@/helpers/date-time.helper";
import { capitalizeFirstLetter } from "@/helpers/string.helper";
Expand Down
5 changes: 2 additions & 3 deletions web/core/components/common/filters/created-at.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useState } from "react";
import { observer } from "mobx-react";
// components
// plane constants
import { DATE_BEFORE_FILTER_OPTIONS } from "@plane/constants";
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { DATE_BEFORE_FILTER_OPTIONS } from "@/constants/filters";
// helpers
import { isInDateFormat } from "@/helpers/date-time.helper";

Expand Down
2 changes: 1 addition & 1 deletion web/core/components/cycles/applied-filters/date.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observer } from "mobx-react";
import { X } from "lucide-react";
// helpers
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
import { renderFormattedDate } from "@/helpers/date-time.helper";
import { capitalizeFirstLetter } from "@/helpers/string.helper";
// constants
Expand Down
6 changes: 3 additions & 3 deletions web/core/components/cycles/dropdowns/filters/end-date.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from "react";
import { observer } from "mobx-react";

// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
// components
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";

// helpers
import { isInDateFormat } from "@/helpers/date-time.helper";

Expand Down
7 changes: 3 additions & 4 deletions web/core/components/cycles/dropdowns/filters/start-date.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from "react";
import { observer } from "mobx-react";

// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
// components
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";

// helpers
import { isInDateFormat } from "@/helpers/date-time.helper";

Expand All @@ -17,7 +17,6 @@ type Props = {

export const FilterStartDate: React.FC<Props> = observer((props) => {
const { appliedFilters, handleUpdate, searchQuery } = props;

const [previewEnabled, setPreviewEnabled] = useState(true);
const [isDateFilterModalOpen, setIsDateFilterModalOpen] = useState(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { observer } from "mobx-react";
// icons
import { X } from "lucide-react";
// helpers
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
import { renderFormattedDate } from "@/helpers/date-time.helper";
import { capitalizeFirstLetter } from "@/helpers/string.helper";
// constants
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState } from "react";
import { observer } from "mobx-react";

// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
// components
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";

type Props = {
appliedFilters: string[] | null;
Expand All @@ -15,7 +14,6 @@ type Props = {

export const FilterStartDate: React.FC<Props> = observer((props) => {
const { appliedFilters, handleUpdate, searchQuery } = props;

const [previewEnabled, setPreviewEnabled] = useState(true);
const [isDateFilterModalOpen, setIsDateFilterModalOpen] = useState(false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState } from "react";
import { observer } from "mobx-react";

// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
// components
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";

type Props = {
appliedFilters: string[] | null;
Expand Down
2 changes: 1 addition & 1 deletion web/core/components/modules/applied-filters/date.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { observer } from "mobx-react";
// icons
import { X } from "lucide-react";
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
// helpers
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";
import { renderFormattedDate } from "@/helpers/date-time.helper";
import { capitalizeFirstLetter } from "@/helpers/string.helper";
// constants
Expand Down
6 changes: 3 additions & 3 deletions web/core/components/modules/dropdowns/filters/start-date.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from "react";
import { observer } from "mobx-react";

// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
// components
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";

// helpers
import { isInDateFormat } from "@/helpers/date-time.helper";

Expand Down
5 changes: 2 additions & 3 deletions web/core/components/modules/dropdowns/filters/target-date.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState } from "react";
import { observer } from "mobx-react";

// plane constants
import { DATE_AFTER_FILTER_OPTIONS } from "@plane/constants";
// components
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { DATE_AFTER_FILTER_OPTIONS } from "@/constants/filters";
// helpers
import { isInDateFormat } from "@/helpers/date-time.helper";

Expand Down
4 changes: 3 additions & 1 deletion web/core/components/pages/header/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback } from "react";
import { observer } from "mobx-react";
import { ListFilter } from "lucide-react";
import { useTranslation } from "@plane/i18n";
import { TPageFilterProps, TPageNavigationTabs } from "@plane/types";
// components
import { Header, EHeaderVariant } from "@plane/ui";
Expand All @@ -25,6 +26,7 @@ type Props = {

export const PagesListHeaderRoot: React.FC<Props> = observer((props) => {
const { pageType, projectId, workspaceSlug } = props;
const { t } = useTranslation();
// store hooks
const { filters, updateFilters, clearAllFilters } = useProjectPages();
const {
Expand Down Expand Up @@ -69,7 +71,7 @@ export const PagesListHeaderRoot: React.FC<Props> = observer((props) => {
/>
<FiltersDropdown
icon={<ListFilter className="h-3 w-3" />}
title="Filters"
title={t("common.filters")}
placement="bottom-end"
isFiltersApplied={isFiltersApplied}
>
Expand Down
2 changes: 1 addition & 1 deletion web/core/components/project/applied-filters/date.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observer } from "mobx-react";
import { X } from "lucide-react";
// helpers
import { PROJECT_CREATED_AT_FILTER_OPTIONS } from "@/constants/filters";
import { PROJECT_CREATED_AT_FILTER_OPTIONS } from "@plane/constants";
import { renderFormattedDate } from "@/helpers/date-time.helper";
import { capitalizeFirstLetter } from "@/helpers/string.helper";
// constants
Expand Down
5 changes: 3 additions & 2 deletions web/core/components/project/dropdowns/filters/created-at.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useState } from "react";
import { observer } from "mobx-react";
// plane constants
import { PROJECT_CREATED_AT_FILTER_OPTIONS } from "@plane/constants";
// components
import { DateFilterModal } from "@/components/core";
import { FilterHeader, FilterOption } from "@/components/issues";
// constants
import { PROJECT_CREATED_AT_FILTER_OPTIONS } from "@/constants/filters";

// helpers
import { isInDateFormat } from "@/helpers/date-time.helper";

Expand Down
52 changes: 0 additions & 52 deletions web/core/constants/filters.ts

This file was deleted.

0 comments on commit ebdc5e4

Please sign in to comment.