Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/frontend/apps/drive/src/features/drivers/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type ItemFilters = {
page?: number;
page_size?: number;
workspaces?: WorkspaceType;
is_creator_me?: boolean;
};

export type PaginatedChildrenResult = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.explorer__filters {
display: flex;
align-items: center;
gap: 0.75rem;
}

.explorer__filters__item {
display: flex;
align-items: center;
gap: 0.5em;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { ItemIcon } from "../icons/ItemIcon";
import { getItemTitle } from "../../utils/utils";

const ALL = "all";
const CREATED_BY_ME = "true";
const CREATED_BY_OTHERS = "false";

export const handleFilterChange = (
filters: ItemFilters = {},
Expand Down Expand Up @@ -48,12 +50,34 @@ export const ExplorerFilters = () => {
onFiltersChange?.(handleFilterChange(filters, name, value));
};

const onCreatedByChange = (value: Key | null) => {
if (value === ALL) {
const newFilters = { ...filters };
delete newFilters.is_creator_me;
onFiltersChange?.(newFilters);
} else if (value === CREATED_BY_ME) {
onFiltersChange?.({ ...filters, is_creator_me: true });
} else if (value === CREATED_BY_OTHERS) {
onFiltersChange?.({ ...filters, is_creator_me: false });
}
};

return (
<div className="explorer__filters">
<ExplorerFilterType
value={filters?.type ?? null}
onChange={(value) => onChange("type", value)}
/>
<ExplorerFilterCreatedBy
value={
filters?.is_creator_me === true
? CREATED_BY_ME
: filters?.is_creator_me === false
? CREATED_BY_OTHERS
: null
}
onChange={onCreatedByChange}
/>
</div>
);
};
Expand Down Expand Up @@ -173,3 +197,47 @@ export const ExplorerFilterScope = (props: {
/>
);
};

export const ExplorerFilterCreatedBy = (props: {
value: string | null;
onChange: (value: Key | null) => void;
}) => {
const { t } = useTranslation();

const options: FilterOption[] = useMemo(
() => [
{
label: t("explorer.filters.createdBy.options.me"),
value: CREATED_BY_ME,
render: () => (
<div className="explorer__filters__item">
<span className="material-icons">person</span>
{t("explorer.filters.createdBy.options.me")}
</div>
),
},
{
label: t("explorer.filters.createdBy.options.others"),
value: CREATED_BY_OTHERS,
render: () => (
<div className="explorer__filters__item">
<span className="material-icons">people</span>
{t("explorer.filters.createdBy.options.others")}
</div>
),
showSeparator: true,
},
getResetOption(t),
],
[t]
);

return (
<Filter
label={t("explorer.filters.createdBy.label")}
options={options}
selectedKey={props.value ?? null}
onSelectionChange={props.onChange}
/>
);
};
21 changes: 21 additions & 0 deletions src/frontend/apps/drive/src/features/i18n/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@
},
"workspace": {
"label": "Workspace"
},
"createdBy": {
"label": "Created by",
"options": {
"me": "Me",
"others": "Others"
}
}
},
"tree": {
Expand Down Expand Up @@ -614,6 +621,13 @@
},
"workspace": {
"label": "Espace"
},
"createdBy": {
"label": "Créé par",
"options": {
"me": "Moi",
"others": "Autres"
}
}
},
"tree": {
Expand Down Expand Up @@ -1026,6 +1040,13 @@
},
"workspace": {
"label": "Werkruimte"
},
"createdBy": {
"label": "Gemaakt door",
"options": {
"me": "Mij",
"others": "Anderen"
}
}
},
"tree": {
Expand Down