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

The icon correct groups files #4114

Merged
merged 4 commits into from
Apr 29, 2022

Conversation

yenienserrano
Copy link
Member

Description:

In the groups file table, there was a file (agent.conf) that showed you the only read icon and sent you to the view to edit the file, so I separated the show and edit function and added the edit button

Issue:

Test:

  1. Navigate to 'Management/Groups'
  2. Select any group
  3. Select the 'Files' tab within the group details
  4. Use the actions from the agent.conf file

Screenshot:

button

@yenienserrano yenienserrano requested a review from a team April 28, 2022 14:02
@yenienserrano yenienserrano linked an issue Apr 28, 2022 that may be closed by this pull request
color="primary"
/>
</EuiToolTip>
{
item.filename === 'agent.conf' &&
<WzButtonPermissions
Copy link
Member

Choose a reason for hiding this comment

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

thought: I was researching and the button appears in a cell of a table with the group's files. The required permission to read the file is:

  • action: group:read
  • resource: group:id:<group_id>

I didn't see more specific permission to read this file, so we could use a button component that doesn't check the user's permissions. If for any reason, the user's permissions changed and the table was rerender by some reason, the WzButtonPermission could avoid to the user that click on and cause a request error getting the content.

Comment on lines 14 to 56
this.showFile = async(item) => {
let result = await this.groupsHandler.getFileContent(
`/groups/${itemDetail.name}/files/${item.filename}/xml`
);

if (Object.keys(result).length == 0) {
result = '';
}

const data = typeof result === 'object'
? JSON.stringify(result, null, 2)
: result.toString()

const file = {
name: item.filename,
content: data,
isEditable: false,
groupName: itemDetail.name
};

this.tableProps.updateFileContent(file);
}

this.editFile = async (item) => {

let result = await this.groupsHandler.getFileContent(
`/groups/${itemDetail.name}/files/${item.filename}/xml`
);
if (Object.keys(result).length == 0) {
result = '';
}

const data = this.autoFormat(result);

const file = {
name: 'agent.conf',
content: data,
isEditable: true,
groupName: itemDetail.name,
};

this.tableProps.updateFileContent(file);
}
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: These 2 methods seem to be similar, maybe we could refactor them to share the logic.

@Desvelao Desvelao added the type/enhancement Enhancement issue label Apr 29, 2022
Copy link
Contributor

@matiasmoreno876 matiasmoreno876 left a comment

Choose a reason for hiding this comment

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

CR OK ✅
TEST OK ✅

Grabacion.de.pantalla.2022-04-29.a.la.s.11.06.36.mov

Copy link
Member

@Desvelao Desvelao left a comment

Choose a reason for hiding this comment

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

review:
Code review ✔️
Testing ✔️

@Desvelao Desvelao merged commit b4a4c90 into 4.3-7.10 Apr 29, 2022
@Desvelao Desvelao deleted the fix/4064-the-icon-correct-groups-files branch April 29, 2022 14:09
@github-actions
Copy link
Contributor

Jest Test Coverage % values
Statements 4.03% ( 1474 / 36535 )
Branches 1.61% ( 459 / 28471 )
Functions 2.98% ( 266 / 8931 )
Lines 4.08% ( 1426 / 34930 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The icon is not correct in the 'files' section
3 participants