Skip to content

Commit

Permalink
merge #2716, #2712, and #2718 from master to jetty-1.12.x branch (#2721)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Avetisyan <hga@yahooinc.com>
  • Loading branch information
havetisyan authored Sep 9, 2024
1 parent a1f7b24 commit 1b0af83
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
12 changes: 6 additions & 6 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion ui/src/components/group/GroupRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ class GroupRow extends React.Component {
this.props.router.push(route, route);
}

// opens new tab on cmd + click or ctrl + click
onClickNewTabFunction(route, args) {
if(args.metaKey || args.ctrlKey) {
args.view.open(args.view.origin + route, '_blank', 'noopener,norefferer');
} else {
this.props.router.push(route, route);
}
}

onSubmitDelete() {
let groupName = this.state.deleteName;
if (
Expand Down Expand Up @@ -154,7 +163,7 @@ class GroupRow extends React.Component {
let color = this.props.color;
let idx = this.props.idx;

let clickMembers = this.onClickFunction.bind(
let clickMembers = this.onClickNewTabFunction.bind(
this,
`/domain/${this.props.domain}/group/${this.state.name}/members`
);
Expand Down
11 changes: 10 additions & 1 deletion ui/src/components/role/RoleRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ class RoleRow extends React.Component {
this.props.router.push(route, route);
}

// opens new tab on cmd + click or ctrl + click
onClickNewTabFunction(route, args) {
if(args.metaKey || args.ctrlKey) {
args.view.open(args.view.origin + route, '_blank', 'noopener,norefferer');
} else {
this.props.router.push(route, route);
}
}

onSubmitDelete(domain) {
let roleName = this.state.deleteName;
if (
Expand Down Expand Up @@ -173,7 +182,7 @@ class RoleRow extends React.Component {
let color = this.props.color;
let idx = this.props.idx;

let clickMembers = this.onClickFunction.bind(
let clickMembers = this.onClickNewTabFunction.bind(
this,
`/domain/${this.props.domain}/role/${this.state.name}/members`
);
Expand Down
42 changes: 30 additions & 12 deletions ui/src/components/tag/TagList.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class TagList extends React.Component {
AppUtils.deepClone(this.props.collectionDetails),
this.props.category
);
collectionMeta.tags = AppUtils.deepClone(this.state.tags);
this.updateMetaOnAdd(collectionMeta, tagKey, tagValues, csrf);
}
updateMetaOnAdd(meta, tagKey, tagValues, csrf) {
Expand All @@ -144,7 +145,7 @@ class TagList extends React.Component {
meta.tags[tagKey] = {};
meta.tags[tagKey].list = tagValues;
let successMessage = tagKey;
this.updateMeta(meta, csrf, successMessage, false);
this.updateMeta(meta, csrf, successMessage, false, (tags) => tags);
}

onSubmitDeleteTag() {
Expand All @@ -153,8 +154,10 @@ class TagList extends React.Component {
AppUtils.deepClone(this.props.collectionDetails),
this.props.category
);
collectionMeta.tags = AppUtils.deepClone(this.state.tags);
this.updateMetaOnDelete(collectionMeta, csrf);
}

updateMetaOnDelete(meta, csrf) {
if (this.state.deleteTagValue) {
//delete specific tag value
Expand All @@ -163,13 +166,18 @@ class TagList extends React.Component {
);
meta.tags[this.state.deleteTagName].list.splice(tagValIdx, 1);
} else {
//delete entire tag
delete meta.tags[this.state.deleteTagName];
if (Object.keys(meta.tags).length === 1) {
// setup last tag for deletion - backend will delete it if list is empty
meta.tags[this.state.deleteTagName] = {list:[]};
} else {
//delete entire tag
delete meta.tags[this.state.deleteTagName];
}
}
let successMessage = this.state.deleteTagValue
? `Successfully deleted ${this.state.deleteTagValue} from tag ${this.state.deleteTagName}`
: `Successfully deleted tag ${this.state.deleteTagName}`;
this.updateMeta(meta, csrf, successMessage, true);
this.updateMeta(meta, csrf, successMessage, true, this.removeLastTagIfEmptyForUI);
}

metaObject(collectionDetails, category) {
Expand Down Expand Up @@ -221,7 +229,7 @@ class TagList extends React.Component {
return collectionDetails;
}

updateMeta(meta, csrf, successMessage, showSuccess = true) {
updateMeta(meta, csrf, successMessage, showSuccess = true, prepareTagsForUI) {
let auditRef =
'Updated ' +
this.props.category +
Expand All @@ -237,26 +245,25 @@ class TagList extends React.Component {
csrf,
this.state.category
)
.then(() => this.reloadTags(successMessage, showSuccess))
.then(() => this.reloadTags(successMessage, showSuccess, prepareTagsForUI(meta.tags)))
.catch((err) => {
this.setState({
errorMessage: RequestUtils.xhrErrorCheckHelper(err),
});
});
}

reloadTags(successMessage, showSuccess = true) {
// if (this.state.category === 'domain') {
reloadTags(successMessage, showSuccess = true, newTagsState) {
this.updateStateAfterReload(
this.props.collectionDetails,
newTagsState,
successMessage,
showSuccess
);
}

updateStateAfterReload(data, successMessage, showSuccess = true) {
updateStateAfterReload(tags, successMessage, showSuccess = true) {
this.setState({
tags: data.tags || {},
tags: tags || {},
showSuccess,
successMessage,
showDelete: false,
Expand Down Expand Up @@ -289,7 +296,7 @@ class TagList extends React.Component {
const left = 'left';
const center = 'center';
let rows = '';
const clonedTags = AppUtils.deepClone(this.props.tags || {});
const clonedTags = AppUtils.deepClone(this.state.tags || {});
let categoryObject =
this.state.category !== 'domain'
? this.props.category === 'policy'
Expand Down Expand Up @@ -407,6 +414,17 @@ class TagList extends React.Component {
</TagsSectionDiv>
);
}

// if only one tag left without values in the list - remove it for UI
removeLastTagIfEmptyForUI(newTagsState) {
if (Object.keys(newTagsState).length === 1
&& this.state.deleteTagName
&& newTagsState.hasOwnProperty(this.state.deleteTagName)
&& newTagsState[this.state.deleteTagName].list.length === 0) {
return {};
}
return newTagsState;
}
}

const mapStateToProps = (state, props) => {
Expand Down

0 comments on commit 1b0af83

Please sign in to comment.