Skip to content

Commit

Permalink
Fix directory link (line#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox authored Aug 20, 2024
1 parent 9f7a771 commit df9c1fb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,8 @@ protected HttpResponse doGet(ServiceRequestContext ctx, HttpRequest req) {
// Serve all web resources except for '/app'.
sb.route()
.pathPrefix("/")
.exclude("/app")
.exclude("prefix:/app")
.exclude("prefix:/api")
.build(FileService.builder(CentralDogma.class.getClassLoader(),
"com/linecorp/centraldogma/webapp")
.cacheControl(ServerCacheControl.REVALIDATED)
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/dogma/features/file/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const FileList = <Data extends object>({
fontWeight={'semibold'}
href={
info.row.original.type === 'DIRECTORY'
? `${directoryPath}${info.getValue()}`
? `${directoryPath}/${info.getValue()}`
: `${slug}/${info.getValue()}`
}
>
Expand Down
12 changes: 6 additions & 6 deletions webapp/tests/dogma/feature/file/FileList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ describe('FileList', () => {
);
});

it('has `${directoryPath}${folderName.slice(1)}` on the view icon when the type is a directory', () => {
it('has `${directoryPath}/${folderName.slice(1)}` on the view icon when the type is a directory', () => {
const { container } = renderWithProviders(<FileList {...expectedProps} />);
const actionCell = container.querySelector('tbody').lastChild.firstChild.lastChild;
const folderName = '/mydir';
expect(actionCell).toHaveAttribute('href', `${expectedProps.directoryPath}${folderName.slice(1)}`);
expect(actionCell).toHaveAttribute('href', `${expectedProps.directoryPath}/${folderName.slice(1)}`);
});

it('links to `${projectName}/repos/${repoName}/files/head{fileName}` when the type is non-directory', () => {
Expand Down Expand Up @@ -123,11 +123,11 @@ describe('FileList', () => {
expect(expectedProps.copySupport.handleAsCurlCommand).toHaveBeenCalledTimes(1);
});

it('links to `${directoryPath}${folderName.slice(1)}` when the type is a directory', () => {
it('links to `${directoryPath}/${folderName.slice(1)}` when the type is a directory', () => {
const { container } = renderWithProviders(<FileList {...expectedProps} />);
const firstCell = container.querySelector('tbody').lastChild.firstChild.firstChild;
const folderName = '/mydir';
expect(firstCell).toHaveAttribute('href', `${expectedProps.directoryPath}${folderName.slice(1)}`);
expect(firstCell).toHaveAttribute('href', `${expectedProps.directoryPath}/${folderName.slice(1)}`);
});

it('calls handleCopyApiUrl when copy API URL button is clicked', () => {
Expand Down Expand Up @@ -158,10 +158,10 @@ describe('FileList', () => {
expect(expectedProps.copySupport.handleAsCurlCommand).toHaveBeenCalledTimes(1);
});

it('links to `${directoryPath}${folderName.slice(1)}` when the type is a directory', () => {
it('links to `${directoryPath}/${folderName.slice(1)}` when the type is a directory', () => {
const { container } = renderWithProviders(<FileList {...expectedProps} />);
const firstCell = container.querySelector('tbody').lastChild.firstChild.firstChild;
const folderName = '/mydir';
expect(firstCell).toHaveAttribute('href', `${expectedProps.directoryPath}${folderName.slice(1)}`);
expect(firstCell).toHaveAttribute('href', `${expectedProps.directoryPath}/${folderName.slice(1)}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.linecorp.armeria.common.AggregatedHttpResponse;
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.HttpStatus;
import com.linecorp.centraldogma.server.CentralDogmaBuilder;
import com.linecorp.centraldogma.testing.junit.CentralDogmaExtension;
import com.linecorp.centraldogma.xds.group.v1.XdsGroupServiceGrpc.XdsGroupServiceBlockingStub;

Expand All @@ -39,7 +40,15 @@
final class XdsGroupServiceTest {

@RegisterExtension
static final CentralDogmaExtension dogma = new CentralDogmaExtension();
static final CentralDogmaExtension dogma = new CentralDogmaExtension() {
@Override
protected void configure(CentralDogmaBuilder builder) {
// To see if it's working when the web app is enabled.
// When webAppEnabled is true, we add additional services that might affect service bind path.
// https://github.com/line/centraldogma/blob/a4e58931ac98e8b6e9e470033ba04ee60180b135/server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java#L863
builder.webAppEnabled(true);
}
};

@Test
void createGroupViaHttp() {
Expand Down

0 comments on commit df9c1fb

Please sign in to comment.