forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate v2 usages in roles/roles-admin-web
The <clay:management-toolbar-v2 /> tag has been replaced with the <clay:management-toolbar /> tag (which uses clay v3). **Test plan**: - From the global menu, select the **Control Panel** tab - Navigate to **Roles** - Make sure you can: - Create and delete Regular Roles - Create and delete Site Roles - Create and delete Organization Roles - Create and delete Asset Library Roles - Create and delete Account Roles - Create a Regular Role - Select (click) the Regular Role you created previously - Navigate to the **Assignees** tab - Make sure you can add assignees from this role - Make sure you can remove assignees from this role
- Loading branch information
Julien Castelain
committed
Feb 24, 2021
1 parent
dc44ecb
commit 90f89fe
Showing
12 changed files
with
329 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...pps/roles/roles-admin-web/src/main/resources/META-INF/resources/js/EditRoleAssignments.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
import addAssignees from './add_assignees'; | ||
|
||
export default function EditRoleAssignments({ | ||
editRoleAssignmentsURL, | ||
modalSegmentState, | ||
namespace, | ||
portletURL, | ||
roleName, | ||
selectAssigneesURL, | ||
}) { | ||
const checkSessionStorage = () => { | ||
const state = window.sessionStorage.getItem(modalSegmentState); | ||
|
||
if (state === 'open') { | ||
window.sessionStorage.removeItem(modalSegmentState); | ||
|
||
addAssignees({ | ||
editRoleAssignmentsURL, | ||
portletNamespace: namespace, | ||
portletURL, | ||
roleName, | ||
selectAssigneesURL, | ||
}); | ||
} | ||
}; | ||
|
||
window.addEventListener('load', checkSessionStorage); | ||
|
||
return { | ||
dispose() { | ||
window.removeEventListener('load', checkSessionStorage); | ||
}, | ||
}; | ||
} |
97 changes: 97 additions & 0 deletions
97
...n/resources/META-INF/resources/js/EditRoleAssignmentsManagementToolbarPropsTransformer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
import {postForm} from 'frontend-js-web'; | ||
|
||
import addAssignees from './add_assignees'; | ||
|
||
export default function propsTransformer({ | ||
additionalProps: { | ||
assigneeType, | ||
editRoleAssignmentsURL, | ||
portletURL, | ||
roleName, | ||
selectAssigneesURL, | ||
}, | ||
portletNamespace, | ||
...otherProps | ||
}) { | ||
const unsetRoleAssignments = () => { | ||
const form = document.getElementById(`${portletNamespace}fm`); | ||
|
||
if (!form) { | ||
return; | ||
} | ||
|
||
// var assigneeType = '<%= HtmlUtil.escapeJS(tabs2) %>'; | ||
|
||
const ids = Liferay.Util.listCheckedExcept( | ||
form, | ||
`${portletNamespace}allRowIds` | ||
); | ||
|
||
const data = { | ||
assignmentsRedirect: portletURL, | ||
}; | ||
|
||
if (assigneeType === 'segments') { | ||
data.removeSegmentsEntryIds = ids; | ||
} | ||
else if (assigneeType === 'users') { | ||
data.removeUserIds = ids; | ||
} | ||
else { | ||
data.removeGroupIds = ids; | ||
} | ||
|
||
postForm(form, { | ||
data, | ||
url: editRoleAssignmentsURL, | ||
}); | ||
}; | ||
|
||
return { | ||
...otherProps, | ||
onActionButtonClick(event, {item}) { | ||
const action = item.data?.action; | ||
|
||
if (action === 'unsetRoleAssignments') { | ||
unsetRoleAssignments(); | ||
} | ||
}, | ||
onCreateButtonClick() { | ||
addAssignees({ | ||
editRoleAssignmentsURL, | ||
portletNamespace, | ||
portletURL, | ||
roleName, | ||
selectAssigneesURL, | ||
}); | ||
}, | ||
}; | ||
} |
Oops, something went wrong.