Skip to content

Commit

Permalink
feat: refactored both popups
Browse files Browse the repository at this point in the history
Signed-off-by: SimoneFiorani <[email protected]>
  • Loading branch information
sfiorani committed Dec 16, 2024
1 parent 30a00df commit 34ca13e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ public class SnapshotDownloadModal extends Composite {
private static SnapshotDownloadModalUiBinder uiBinder = GWT.create(SnapshotDownloadModalUiBinder.class);
private static final Messages MSGS = GWT.create(Messages.class);

private static final String SELECT_ALL_PIDS_SELECTION = "Select All Pids";
private static final String REMOVE_ALL_PIDS_SELECTION = "Remove All Pids";

interface SnapshotDownloadModalUiBinder extends UiBinder<Widget, SnapshotDownloadModal> {
}

@UiField
Paragraph downloadModalDescription;
@UiField
Paragraph formatModalHint;
@UiField
ScrollPanel pidSelectionScrollPanel;
@UiField
Anchor selectOrRemoveAllAnchor;
Expand Down Expand Up @@ -80,7 +79,6 @@ public SnapshotDownloadModal() {
this.pidSelectionScrollPanel.setVisible(false);
this.selectOrRemoveAllAnchor.setVisible(false);
this.noPidSelectedError.setVisible(false);
this.noPidSelectedError.setText("Please select at least one pid from the list");

this.cancelButton.addClickHandler(this::onCancelClick);

Expand All @@ -89,6 +87,7 @@ public SnapshotDownloadModal() {
public void show(Consumer<SnapshotDownloadOptions> consumer) {
this.snapshotDownloadConsumer = consumer;
this.modal.setTitle(MSGS.deviceWiregraphDownloadModalTitle());
this.downloadModalDescription.setText(MSGS.deviceWiregraphDownloadModalHint());
initWiregraphDownloadButtons();
this.modal.show();
}
Expand Down Expand Up @@ -127,7 +126,7 @@ private void initSnapshotSelectAllAnchor() {
this.anchorClickHandler.removeHandler();
}
this.areAllPidsSelected = true;
this.selectOrRemoveAllAnchor.setText(REMOVE_ALL_PIDS_SELECTION);
this.selectOrRemoveAllAnchor.setText(MSGS.removeAllAnchorText());
this.anchorClickHandler = this.selectOrRemoveAllAnchor.addClickHandler(this::selectOrRemoveAllSelection);
this.selectOrRemoveAllAnchor.setVisible(true);
}
Expand Down Expand Up @@ -204,8 +203,8 @@ private Optional<List<String>> getSelectedPids() {
List<String> selectedPids = new ArrayList<>();
this.pidPanel.iterator().forEachRemaining(pid -> {
CheckBox checkBox = (CheckBox) pid;
if (checkBox.getValue().booleanValue() && !checkBox.getText().equals(SELECT_ALL_PIDS_SELECTION)
&& !checkBox.getText().equals(REMOVE_ALL_PIDS_SELECTION)) {
if (checkBox.getValue().booleanValue() && !checkBox.getText().equals(MSGS.selectAllAnchorText())
&& !checkBox.getText().equals(MSGS.removeAllAnchorText())) {
selectedPids.add(checkBox.getText());
}
});
Expand Down Expand Up @@ -247,9 +246,9 @@ private void checkAllPidsSelected() {

private void updateSelectOrRemoveAllText() {
if (this.areAllPidsSelected) {
this.selectOrRemoveAllAnchor.setText(REMOVE_ALL_PIDS_SELECTION);
this.selectOrRemoveAllAnchor.setText(MSGS.removeAllAnchorText());
} else {
this.selectOrRemoveAllAnchor.setText(SELECT_ALL_PIDS_SELECTION);
this.selectOrRemoveAllAnchor.setText(MSGS.selectAllAnchorText());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
<b:FieldSet>
<b:FormGroup>
<b.html:Paragraph ui:field="downloadModalDescription" />
<b.html:Paragraph ui:field="formatModalHint" text="{msgs.formatDownloadHint}" />
<g:ScrollPanel ui:field="pidSelectionScrollPanel"></g:ScrollPanel>
<b:FormLabel addStyleNames="{style.channel-name-validation-label}" ui:field="noPidSelectedError" />
<b:FormLabel addStyleNames="{style.channel-name-validation-label}" ui:field="noPidSelectedError" text="{msgs.downloadSnapshotError}" />
</b:FormGroup>
</b:FieldSet>
</g:FormPanel>
<b:Anchor ui:field="selectOrRemoveAllAnchor" />
</b:ModalBody>
<b:ModalFooter>
<b.html:Paragraph text="Choose the format in which the file will be downloaded" />
<b:Button addStyleNames="fa" type="PRIMARY" ui:field= "cancelButton" text="{msgs.cancelButton}" />
<b:Button addStyleNames="fa" type="PRIMARY" ui:field="downloadJson" text="{msgs.downloadSnapshotJsonButton}" />
<b:Button addStyleNames="fa" type="PRIMARY" ui:field="downloadXml" text="{msgs.downloadSnapshotXmlButton}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,14 @@ deviceSnapshotsNone=No Snapshots Available
deviceSnapshotRollbackConfirm=Are you sure you want to rollback to a previous configuration? During the rollback operation, the device will disconnect and reconnect. If a timeout is encountered during the reload of the device configuration, please refresh it manually.
deviceSnapshotDownloadModalTitle=Snapshot download
deviceWiregraphDownloadModalTitle=Wiregraph snapshot download
deviceSnapshotDownloadModalHint=Select pids of the service configurations that will be included in the downloaded snapshot.
deviceSnapshotDownloadModalHint=Select the PIDs for the service configurations that will be downloaded locally.
deviceWiregraphDownloadModalHint=Download partial snapshot containing the configuration of the current wiregraph.
formatDownloadHint=The configurations can be exported either as JSON or XML format.
downloadSnapshotXmlButton=Download as XML
downloadSnapshotJsonButton=Download as JSON
downloadSnapshotError=Please select at least one pid from the list
selectAllAnchorText=Select All Pids
removeAllAnchorText=Remove All Pids

netIntro=Select a Network Interface and configure it. DHCP Server and NAT can be configured only for interfaces enabled for LAN usage. When applying your changes, your connection to the gateway may be lost depending on your network configuration changes.
netInterfaceName=Interface Name
Expand Down

0 comments on commit 34ca13e

Please sign in to comment.