Skip to content

Conversation

@tomratcliffe
Copy link
Contributor

@tomratcliffe tomratcliffe commented Sep 2, 2025

What is this feature?
Migrates updateFolder logic to use app platform APIs when feature toggle is enabled

Does some additional simplification of tests and handlers to remove mocks

Why do we need this feature?
So we can consume app platform APIs for folder actions

Which issue(s) does this PR fix?:
Fixes #109538

Comment on lines +31 to +33
labels: {
'grafana.app/deprecatedInternalID': id ?? '123',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to send this ever

'grafana.app/updatedBy': 'user:2',
'grafana.app/managedBy': 'user',
'grafana.app/updatedTimestamp': '2024-01-01T00:00:00Z',
'grafana.app/folder': folder.kind === 'folder' ? folder.parentUID : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

the only annotation you will need/want to send is:

grafana.app/folder

the rest are managed internally

Comment on lines +21 to +22
uid: folder.uid,
creationTimestamp: '2023-01-01T00:00:00Z',
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
uid: folder.uid,
creationTimestamp: '2023-01-01T00:00:00Z',

do not send uid or creationTimestamp -- they are handled server side

@tomratcliffe
Copy link
Contributor Author

@ryantxu Thanks for taking a look! The code you commented on is actually for a mock API that is used in tests - so it's good that your concerns are all about seemingly doing things that only the API should worry about 🙌

It's just making mock handlers that we want to behave in the same way that the API should do. The implementation may not be perfect, and there is hardcoded data, but it's all for tests/mocking out so it isn't performing any faulty app logic (I hope!)


// save an existing folder (e.g. rename)
saveFolder: builder.mutation<FolderDTO, FolderDTO>({
saveFolder: builder.mutation<FolderDTO, Pick<FolderDTO, 'uid' | 'title' | 'version' | 'parentUid'>>({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing API didn't use any more than this, so we were requiring more properties to be passed in/boxing ourselves in to always having to use the full folder object

@tomratcliffe tomratcliffe marked this pull request as ready for review September 2, 2025 14:52
@tomratcliffe tomratcliffe requested review from a team as code owners September 2, 2025 14:52
@tomratcliffe tomratcliffe requested review from Clarity-89, aocenas, eledobleefe and samsch and removed request for a team September 2, 2025 14:52
@github-actions github-actions bot added this to the 12.2.x milestone Sep 2, 2025
}

export function useUpdateFolder() {
const [updateFolder, result] = useReplaceFolderMutation();
Copy link
Member

Choose a reason for hiding this comment

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

Would probably just add a comment that replace and update are the same thing, otherwise this is a bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on conversations in #app-platform channel, I'll consolidate these to both use replace (perhaps in a follow up PR to tidy the hooks and tests up)

@@ -0,0 +1,65 @@
/** Expected constant response from `/api/search/sorting` */
export const SORT_OPTIONS = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an enterprise response, I think OSS only has alphabetical sort, would that be enough for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I didn't know about that distinction. Will slim it down to just the alphabetical options

/** Renders test component with a button that will create a new folder */
export const setupCreateFolder = () => render(<TestCreationComponent />);

/** Renders test component with a button that will allows updating a folder */
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
/** Renders test component with a button that will allows updating a folder */
/** Renders test component with a button that will allow updating a folder */


it('selecting an item hides the filters and shows the actions instead', async () => {
render(<BrowseDashboardsPage queryParams={{}} />);
const { user } = render(<BrowseDashboardsPage queryParams={{}} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Copy link
Contributor

@Clarity-89 Clarity-89 left a comment

Choose a reason for hiding this comment

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

🙌

@tomratcliffe tomratcliffe merged commit 95080d9 into main Sep 3, 2025
106 checks passed
@tomratcliffe tomratcliffe deleted the folders/update-folder-app-platform branch September 3, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Folders: Migrate update folder to new folder API

4 participants