Skip to content

Commit b39d6a4

Browse files
Scott DoverScott Dover
authored andcommitted
chore: disable recycle bin support for sas server
1 parent feccc59 commit b39d6a4

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

client/src/components/ContentNavigator/ContentDataProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ class ContentDataProvider
315315
return success;
316316
}
317317

318+
public canRecycleResource(item: ContentItem): boolean {
319+
return this.model.canRecycleResource(item);
320+
}
321+
318322
public async recycleResource(item: ContentItem): Promise<boolean> {
319323
if (!(await closeFileIfOpen(item))) {
320324
return false;

client/src/components/ContentNavigator/ContentModel.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Uri } from "vscode";
44

55
import { ALL_ROOT_FOLDERS, Messages } from "./const";
66
import { ContentAdapter, ContentItem } from "./types";
7+
import { isItemInRecycleBin } from "./utils";
78

89
export class ContentModel {
910
private contentAdapter: ContentAdapter;
@@ -139,11 +140,20 @@ export class ContentModel {
139140
return await this.contentAdapter.getFolderPathForItem(contentItem);
140141
}
141142

143+
public canRecycleResource(item: ContentItem): boolean {
144+
return (
145+
this.contentAdapter.recycleItem &&
146+
this.contentAdapter.restoreItem &&
147+
!isItemInRecycleBin(item) &&
148+
item.permission.write
149+
);
150+
}
151+
142152
public async recycleResource(item: ContentItem) {
143-
return await this.contentAdapter.recycleItem(item);
153+
return await this.contentAdapter?.recycleItem(item);
144154
}
145155

146156
public async restoreResource(item: ContentItem) {
147-
return await this.contentAdapter.restoreItem(item);
157+
return await this.contentAdapter?.restoreItem(item);
148158
}
149159
}

client/src/components/ContentNavigator/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
ContentSourceType,
3030
FileManipulationEvent,
3131
} from "./types";
32-
import { isContainer as getIsContainer, isItemInRecycleBin } from "./utils";
32+
import { isContainer as getIsContainer } from "./utils";
3333

3434
const fileValidator = (value: string): string | null =>
3535
/^([^/<>;\\{}?#]+)\.\w+$/.test(
@@ -93,7 +93,7 @@ class ContentNavigator implements SubscriptionProvider {
9393
async (resource: ContentItem) => {
9494
const isContainer = getIsContainer(resource);
9595
const moveToRecycleBin =
96-
!isItemInRecycleBin(resource) && resource.permission.write;
96+
this.contentDataProvider.canRecycleResource(resource);
9797
if (
9898
!moveToRecycleBin &&
9999
!(await window.showWarningMessage(

client/src/components/ContentNavigator/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ export interface ContentAdapter {
9090
item: ContentItem,
9191
targetParentFolderUri: string,
9292
) => Promise<boolean>;
93-
recycleItem: (item: ContentItem) => Promise<{ newUri?: Uri; oldUri?: Uri }>;
93+
recycleItem?: (item: ContentItem) => Promise<{ newUri?: Uri; oldUri?: Uri }>;
9494
removeItemFromFavorites: (item: ContentItem) => Promise<boolean>;
9595
renameItem: (
9696
item: ContentItem,
9797
newName: string,
9898
) => Promise<ContentItem | undefined>;
99-
restoreItem: (item: ContentItem) => Promise<boolean>;
99+
restoreItem?: (item: ContentItem) => Promise<boolean>;
100100
updateContentOfItem(uri: Uri, content: string): Promise<void>;
101101
}
102102

client/src/connection/rest/RestSASServerAdapter.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright © 2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
43
import { FileType, Uri } from "vscode";
54

65
import { AxiosResponse } from "axios";
@@ -343,16 +342,6 @@ class RestSASServerAdapter implements ContentAdapter {
343342
return !!this.filePropertiesToContentItem(response.data);
344343
}
345344

346-
public async recycleItem(
347-
item: ContentItem,
348-
): Promise<{ newUri?: Uri; oldUri?: Uri }> {
349-
await this.deleteItem(item);
350-
return {
351-
newUri: getSasServerUri(item, true),
352-
oldUri: getSasServerUri(item),
353-
};
354-
}
355-
356345
public async removeItemFromFavorites(item: ContentItem): Promise<boolean> {
357346
throw new Error("Method not implemented.");
358347
}
@@ -379,10 +368,6 @@ class RestSASServerAdapter implements ContentAdapter {
379368
return this.filePropertiesToContentItem(response.data);
380369
}
381370

382-
public async restoreItem(item: ContentItem): Promise<boolean> {
383-
throw new Error("Method not implemented.");
384-
}
385-
386371
public async updateContentOfItem(uri: Uri, content: string): Promise<void> {
387372
const filePath = this.trimComputePrefix(getResourceId(uri));
388373
return await this.updateContentOfItemAtPath(filePath, content);

0 commit comments

Comments
 (0)