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

[DRAFT - In Process] List Variable #44224

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shubhamraj-git
Copy link
Contributor

@shubhamraj-git shubhamraj-git commented Nov 20, 2024

relates: #43709

Screenshot 2024-11-21 at 4 14 56 AM Screenshot 2024-11-21 at 4 15 07 AM

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Nov 20, 2024
Comment on lines +92 to +96
const [filterType, setFilterType] = useState<string | undefined>(undefined);
const [filterOperator, setFilterOperator] = useState<string | undefined>(
undefined,
);
const [filterText, setFilterText] = useState<string>("");
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use searchParams for table state management.

} = useVariableServiceGetVariables({
limit: pagination.pageSize,
offset: pagination.pageIndex * pagination.pageSize,
orderBy,
Copy link
Contributor

Choose a reason for hiding this comment

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

All the filters should be passed to the API in this request. The UI shouldn't filter on its own.

border="1px solid"
borderColor="gray.800"
borderRadius="md"
color="gray.400"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use fg semantic tokens here

https://www.chakra-ui.com/docs/theming/colors

Screenshot 2024-11-21 at 1 49 05 PM

borderColor="gray.800"
borderRadius="md"
color="gray.400"
display="flex"
Copy link
Contributor

Choose a reason for hiding this comment

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

We might just want to use a <Flex> component instead of box if we have to customize it this much.

Also worth looking at HStack. if it works even better


const {
data,
error: VariableError,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
error: VariableError,
error,

Just error is fine. At least we shouldn't capitalize the first letter of a regular variable

</Box>

<HStack>
<Button colorPalette="blue">
Copy link
Contributor

Choose a reason for hiding this comment

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

We can keep these buttons but let's set these as disabled and leave a TODO comment to connect them up later.

import { ErrorAlert } from "src/components/ErrorAlert";
import { CloseButton, Select } from "src/components/ui";

const variablesColumn = (): Array<ColumnDef<VariableResponse>> => [
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just be an array instead of a function that returns an array.

Suggested change
const variablesColumn = (): Array<ColumnDef<VariableResponse>> => [
const columns: Array<ColumnDef<VariableResponse>> = [

},
{
accessorKey: "value",
enableSorting: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
enableSorting: true,

true is the default.

Comment on lines +111 to +142
useEffect(() => {
if (data?.variables) {
let filtered = data.variables;

if (filterText.trim()) {
filtered = filtered.filter((item) => {
const valueToFilter =
filterType === "key" ? item.key : (item.value ?? "");

switch (filterOperator) {
case "contains":
return valueToFilter.includes(filterText);
case "ends_with":
return valueToFilter.endsWith(filterText);
case "equals":
return valueToFilter === filterText;
case "not_ends_with":
return !valueToFilter.endsWith(filterText);
case "not_starts_with":
return !valueToFilter.startsWith(filterText);
case "starts_with":
return valueToFilter.startsWith(filterText);
default:
return true;
}
});
}

setFilteredData(filtered);
} else {
setFilteredData([]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should really update the API to handle this.

<DataTable
columns={variablesColumn()}
data={filteredData}
displayMode="table"
Copy link
Contributor

Choose a reason for hiding this comment

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

table is the default

Suggested change
displayMode="table"

isLoading={isLoading}
modelName="Variable"
onStateChange={setTableURLState}
skeletonCount={undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
skeletonCount={undefined}

We don't need to pass this if we dont want to

</HStack>
</HStack>

<ErrorAlert error={VariableError} />
Copy link
Contributor

Choose a reason for hiding this comment

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

DataTable already has a prop to show errors. Let's move this there

errorMessage={<ErrorAlert error={error} />}

{
children: [
{ element: <Overview />, path: "" },
{ element: <div>Runs</div>, path: "runs" },
{ element: <div>Tasks</div>, path: "tasks" },
{ element: <Events />, path: "events" },
{ element: <Variables />, path: "variables" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ element: <Variables />, path: "variables" },

We don't want to show variables at the Dag level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:UI Related to UI/UX. For Frontend Developers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants