Skip to content

Commit

Permalink
upstream: b=main,r=9c91df40b581179a8da177f2c54085bf6065862b,t=2024-02…
Browse files Browse the repository at this point in the history
…-02-1342-47865
  • Loading branch information
sonatype-zion committed Feb 2, 2024
1 parent 51396c2 commit 1027f68
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public class RaptureWebResourceBundle

private final String cacheBuster;

private final boolean designInput;

public final static String PROPERTY_WEBRESOURCES_CACHEBUSTER = "nexus.webresources.cachebuster";

@Inject
Expand All @@ -94,14 +96,16 @@ public RaptureWebResourceBundle(final ApplicationVersion applicationVersion,
final TemplateHelper templateHelper,
final List<UiPluginDescriptor> pluginDescriptors,
final List<org.sonatype.nexus.rapture.UiPluginDescriptor> extJsPluginDescriptors,
@Nullable @Named("${" + PROPERTY_WEBRESOURCES_CACHEBUSTER + "}") final String cacheBuster)
@Nullable @Named("${" + PROPERTY_WEBRESOURCES_CACHEBUSTER + "}") final String cacheBuster,
@Named("${nexus.design.input:-false}") final boolean designInput)
{
this.applicationVersion = checkNotNull(applicationVersion);
this.servletRequestProvider = checkNotNull(servletRequestProvider);
this.stateComponentProvider = checkNotNull(stateComponentProvider);
this.templateHelper = checkNotNull(templateHelper);
this.pluginDescriptors = checkNotNull(pluginDescriptors);
this.extJsPluginDescriptors = checkNotNull(extJsPluginDescriptors);
this.designInput = designInput;
if (cacheBuster == null) {
this.cacheBuster = applicationVersion.getBuildTimestamp();
} else {
Expand Down Expand Up @@ -185,6 +189,7 @@ protected byte[] generate() throws IOException {
.set("styles", getStyles())
.set("scripts", getScripts())
.set("util", new TemplateUtil())
.set("designInput", designInput)
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
document.getElementById('loading-msg').innerHTML=msg;
}
</script>
#if ( $designInput )
<script type="text/javascript" src="https://clm-staging.sonatype.com/user-telemetry-rm.js"></script>
#end
#macro(message $text)
<script type="text/javascript">progressMessage('$text');</script>
#end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setup() {
underTest =
new RaptureWebResourceBundle(applicationVersion, Providers.of(httpServletRequest), Providers.of(stateComponent),
templateHelper, asList(new UiPluginDescriptorImpl()),
asList(new ExtJsUiPluginDescriptorImpl("test-1"), new ExtJsUiPluginDescriptorImpl("test-2")), null);
asList(new ExtJsUiPluginDescriptorImpl("test-1"), new ExtJsUiPluginDescriptorImpl("test-2")), null, false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public class StorageAttributes
{
@ApiModelProperty(value = "Blob store used to store repository contents", example = "default")
@ApiModelProperty(value = "Blob store used to store repository contents", example = "default", required = true)
@NotEmpty
protected String blobStoreName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
NxButton,
} from '@sonatype/react-shared-components';

import {ExtJS} from '@sonatype/nexus-ui-plugin';

import UIStrings from '../../../../../constants/UIStrings';
import {
faSync,
Expand All @@ -33,8 +35,6 @@ import {

import './SupportZipHa.scss';

import {URL} from './NodeCardHelper';

const {SUPPORT_ZIP: LABELS} = UIStrings;

export default function NodeCard({actor, createZip, isBlobStoreConfigured}) {
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function NodeCard({actor, createZip, isBlobStoreConfigured}) {

return (
<NxP className="nxrm-p-zip-updated">
<NxTextLink href={URL.downloadZipFile(data.blobRef)} download>
<NxTextLink href={ExtJS.urlOf(`service/rest/wonderland/download/${data.blobRef}`)} download>
{LABELS.DOWNLOAD_ZIP}
<br />
{formatDate(new Date(data.lastUpdated))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@
import React from 'react';
import {spawn} from 'xstate';
import {render, screen} from '@testing-library/react';
import {ExtJS} from '@sonatype/nexus-ui-plugin';
import userEvent from '@testing-library/user-event';
import NodeCard from './NodeCard';
import NodeCardTestData from './NodeCard.testdata';
import UIStrings from '../../../../../constants/UIStrings';
import NodeCardMachine from './NodeCardMachine';
const {SUPPORT_ZIP: LABELS} = UIStrings;

jest.mock('@sonatype/nexus-ui-plugin', () => ({
...jest.requireActual('@sonatype/nexus-ui-plugin'),
ExtJS: {
state: jest.fn().mockReturnValue({
getValue: jest.fn(),
}),
urlOf: jest.fn().mockImplementation((path) => '/' + path)
},
}));

describe('NodeCard', function () {
const testNodes = NodeCardTestData;
const ACTIVE_NODE_INDEX = 0;
Expand All @@ -36,6 +47,7 @@ describe('NodeCard', function () {
noZipCreated: () => screen.getByText(LABELS.NO_ZIP_CREATED),
zipCreate: () => screen.getByText(LABELS.GENERATE_NEW_ZIP_FILE),
zipCreating: () => screen.getByText(LABELS.CREATING_ZIP),
zipLink: () => screen.getByRole('link'),
errorMessage: () => screen.getByText(LABELS.GENERATE_ERROR),
retryButton: () => screen.getByRole('button', {name: LABELS.RETRY}),
};
Expand Down Expand Up @@ -73,9 +85,30 @@ describe('NodeCard', function () {

expect(selectors.nodeHostName(node.hostname)).toBeInTheDocument();
expect(selectors.generateZipStatus()).toBeInTheDocument();
expect(screen.getByRole('link')).toHaveTextContent(
expect(selectors.zipLink()).toHaveTextContent(
'Download Zip Generated2022-5-7 0:0:0 (GMT-0500)'
);
expect(selectors.zipLink()).toHaveAttribute(
'href', '/service/rest/wonderland/download/http://download.com?support-zip.zip'
);
});

it('renders zip link with context path when provided', () => {
jest
.spyOn(Date.prototype, 'toTimeString')
.mockReturnValue('00:00:00 GMT-0500 (Standard Time)');

ExtJS.urlOf.mockImplementation((path) => '/test/' + path);

const node = testNodes[ZIP_CREATED_NODE_INDEX];
renderView(node);

expect(selectors.zipLink()).toHaveTextContent(
'Download Zip Generated2022-5-7 0:0:0 (GMT-0500)'
);
expect(selectors.zipLink()).toHaveAttribute(
'href', '/test/service/rest/wonderland/download/http://download.com?support-zip.zip'
);
});

it('renders zip is not created', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
import Axios from 'axios';
import {APIConstants} from '@sonatype/nexus-ui-plugin';

const downloadZipFile = (blobRef) =>
`/service/rest/wonderland/download/${blobRef}`;

export const cleanNode = async (nodeId) => {
return await Axios.delete(
APIConstants.REST.INTERNAL.CLEAR_SUPPORT_ZIP_HISTORY + nodeId
);
};

export const URL = {
downloadZipFile,
};
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export default {
RELEASE_TYPE_DESCRIPTION: 'Remove components that are of the following release type:',
ASSET_NAME_DESCRIPTION: 'Remove components that have at least one asset name matching the following regular expression pattern:',

LAST_UPDATED_SUB_LABEL: 'Components published over “x” days ago (e.g 0-999 )',
LAST_DOWNLOADED_SUB_LABEL: 'Components downloaded in “x” amount of days (e.g 0-999 )',
LAST_UPDATED_SUB_LABEL: 'Components published over “x” days ago (e.g 1-999)',
LAST_DOWNLOADED_SUB_LABEL: 'Components downloaded in “x” amount of days (e.g 1-999)',

PLACEHOLDER: 'e.g 100 days',

Expand Down
2 changes: 1 addition & 1 deletion revision.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b=main,r=46438642abd802c3c81f8fa04ea6cec54a55aab5,t=2024-01-26-1343-01840
b=main,r=9c91df40b581179a8da177f2c54085bf6065862b,t=2024-02-02-1342-47865

0 comments on commit 1027f68

Please sign in to comment.