Skip to content

Conversation

@zhuje
Copy link
Contributor

@zhuje zhuje commented Dec 4, 2025

JIRA

https://issues.redhat.com/browse/OU-1004

Screenshot 2025-12-03 at 9 00 33 PM
ou1004-list-perses-dashboards.mov

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Dec 4, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 4, 2025

@zhuje: This pull request references OU-1004 which is a valid jira issue.

Details

In response to this:

JIRA

https://issues.redhat.com/browse/OU-1004

Screenshot 2025-12-03 at 9 00 33 PM
ou1004-list-perses-dashboards.mov

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 4, 2025
@zhuje zhuje force-pushed the ou1004-list-dashboards-pr branch 2 times, most recently from 36881db to be8bd6c Compare December 5, 2025 23:31
@zhuje zhuje force-pushed the ou1004-list-dashboards-pr branch from 27f7498 to 2648502 Compare December 8, 2025 23:05
@zhuje zhuje force-pushed the ou1004-list-dashboards-pr branch 2 times, most recently from 02614bc to fe7041f Compare December 18, 2025 02:59
@zhuje zhuje force-pushed the ou1004-list-dashboards-pr branch from 6c5da8d to fa6da57 Compare December 18, 2025 21:28
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we have 2 files called datasource-api.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed one of the files to differentiate them. /web/src/components/dashboards/perses/perses/datasource-cache-api.ts

name: entity.metadata.name,
});

const response = await consoleFetch(url, {
Copy link
Contributor

Choose a reason for hiding this comment

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

The console fetch has a put method, so we don't have to set the method manually

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use consoleFetchJSON.put(...).

Comment on lines 44 to 46
mutationFn: (dashboard) => {
return updateDashboard(dashboard);
},
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
mutationFn: (dashboard) => {
return updateDashboard(dashboard);
},
mutationFn: updateDashboard,

const HTTPMethodPUT = 'PUT';
const HTTPHeader: Record<string, string> = {
'Content-Type': 'application/json',
Accept: 'application/json',
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 use the consoleFetchJSON, please explore the SDK types this will allow you to see what is available and how to use it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use consoleFetchJSON.put(...).

defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be retry: false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this can be false instead of 0. I updated it in the latest commit.

Comment on lines 60 to 85
sortBy && direction
? [...data].sort((a, b) => {
let aValue: any;
let bValue: any;

if (sortBy === 'name') {
aValue = a.name.label;
bValue = b.name.label;
} else if (sortBy === 'created') {
aValue = a.createdAt;
bValue = b.createdAt;
} else if (sortBy === 'modified') {
aValue = a.updatedAt;
bValue = b.updatedAt;
} else {
aValue = a[sortBy];
bValue = b[sortBy];
}

if (direction === 'asc') {
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
} else {
return aValue > bValue ? -1 : aValue < bValue ? 1 : 0;
}
})
: data;
Copy link
Contributor

Choose a reason for hiding this comment

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

This function will be more readable and maintainable with an early exit:

if(!sortBy || !direction) return data;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this makes it much more readable. Updated in the latest commit.

@zhuje zhuje force-pushed the ou1004-list-dashboards-pr branch from 610f670 to 9a9d158 Compare December 19, 2025 18:46
@jgbernalp
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 19, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 19, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jgbernalp, zhuje

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants