Skip to content

Commit

Permalink
DROOLS-5264: Clear selected file when dialog is closed
Browse files Browse the repository at this point in the history
This PR clear the last selected file from file selector widget when the dialog for artifact upload is closed or canceled.

For more details see: https://issues.redhat.com/browse/DROOLS-5264
  • Loading branch information
Jozef Marko committed May 25, 2020
1 parent 3e71767 commit f84c6dc
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ public String getFileName() {
return uploader.getFilename();
}

@Override
public void hide() {
super.hide();
uploader.clear();
}

@Override
public void removeFromParent() {
super.removeFromParent();
uploader.clear();
}

private void showMessage(final String message) {
Window.alert(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2020 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.guvnor.m2repo.client.upload;

import com.google.gwtmockito.GwtMockitoTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.uberfire.ext.widgets.common.client.common.FileUpload;

import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.verify;

@RunWith(GwtMockitoTestRunner.class)
public class UploadFormViewImplTest {

@Mock
private FileUpload uploader;

@Mock
private UploadFormViewImpl testedView;

@Before
public void setUp() throws Exception {
testedView.uploader = uploader;
}

@Test
public void testHide() {
doCallRealMethod().when(testedView).hide();

testedView.hide();

verify(uploader).clear();
}

@Test
public void testRemoveFromParent() {
doCallRealMethod().when(testedView).removeFromParent();

testedView.removeFromParent();

verify(uploader).clear();
}
}

0 comments on commit f84c6dc

Please sign in to comment.