Skip to content

Commit

Permalink
[WIP] delete button in FS view
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Mar 10, 2024
1 parent 7684b8e commit c893d37
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/viewProviders/RokuFileSystemViewViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,15 @@ export class RokuFileSystemViewViewProvider extends BaseRdbViewProvider {
await vscode.commands.executeCommand('workbench.action.files.setActiveEditorReadonlyInSession');
return true;
});

this.addMessageCommandCallback(ViewProviderCommand.deleteRokuFile, async (message) => {
const pathContentsInfo = message.context;
await this.dependencies.rtaManager.onDeviceComponent.deleteFile({
path: pathContentsInfo.path
});

await vscode.commands.executeCommand(VscodeCommand.rokuFileSystemViewRefresh);
return true;
});
}
}
1 change: 1 addition & 0 deletions src/viewProviders/ViewProviderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum ViewProviderCommand {
getStoredRokuAppOverlays = 'getStoredRokuAppOverlays',
getWorkspaceState = 'getWorkspaceState',
openRokuFile = 'openRokuFile',
deleteRokuFile = 'deleteRokuFile',
runRokuAutomationConfig = 'runRokuAutomationConfig',
sendMessageToWebviews = 'sendMessageToWebviews',
setManualIpAddress = 'setManualIpAddress',
Expand Down
11 changes: 10 additions & 1 deletion webviews/src/views/RokuFileSystemView/FileSystemEntry.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<script lang="ts">
import { File, Database, Folder } from 'svelte-codicons';
import { File, Database, Folder, Trash } from 'svelte-codicons';
import { createEventDispatcher } from 'svelte';
import type { PathContentsInfo } from '../../shared/types';
const dispatch = createEventDispatcher();
Expand All @@ -17,6 +17,10 @@
dispatch('open', entry);
}
function onDeleteClick() {
dispatch('delete', entry);
}
function padNum(number: number) {
return number.toString().padStart(2, '0');
}
Expand Down Expand Up @@ -74,4 +78,9 @@
<vscode-data-grid-cell grid-column="5">{formatDate(entry.ctime)}</vscode-data-grid-cell>
{/if}
{/if}
{#if entry.permissions === "rw" && (entry.type === 'directory' || entry.type === 'file')}
<vscode-data-grid-cell grid-column="6">
<vscode-button on:click={onDeleteClick}><Trash/></vscode-button>
</vscode-data-grid-cell>
{/if}
</vscode-data-grid-row>
24 changes: 17 additions & 7 deletions webviews/src/views/RokuFileSystemView/RokuFileSystemView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,35 @@
name?: true,
size?: true,
dateModified?: true,
dateCreated?: true
dateCreated?: true,
delete?: true
};
$:{
if(containerWidth > 600) {
gridTemplateColumns = '24px 6fr 2fr 4fr 4fr'
gridTemplateColumns = '24px 6fr 2fr 4fr 4fr 1fr'
columnsToShow = {
name: true,
size: true,
dateModified: true,
dateCreated: true
dateCreated: true,
delete: true
}
} else if(containerWidth > 400) {
gridTemplateColumns = '24px 6fr 2fr 4fr 0'
gridTemplateColumns = '24px 6fr 2fr 4fr 0 0'
columnsToShow = {
name: true,
size: true,
dateModified: true,
}
} else if(containerWidth > 300) {
gridTemplateColumns = '24px 6fr 2fr 0 0'
gridTemplateColumns = '24px 6fr 2fr 0 0 0'
columnsToShow = {
name: true,
size: true
}
} else {
gridTemplateColumns = '24px 6fr 0 0 0'
gridTemplateColumns = '24px 6fr 0 0 0 0'
columnsToShow = {
name: true
}
Expand Down Expand Up @@ -102,6 +104,11 @@
}
}
function onDelete(event: CustomEvent<PathContentsInfo>) {
const pathContentsInfo = event.detail;
intermediary.sendCommand(ViewProviderCommand.deleteRokuFile, pathContentsInfo);
}
/**
* Handles retrieving info about the current path from the Roku device and updating the UI accordingly
* @param path the path we want to update the UI based on
Expand Down Expand Up @@ -296,10 +303,13 @@
{#if columnsToShow.dateCreated}
<SortableGridHeader on:click={onSortColumnChange} title="Date Created" column={5} />
{/if}
{#if columnsToShow.delete}
<vscode-data-grid-cell grid-column="6">Delete</vscode-data-grid-cell>
{/if}
</vscode-data-grid-row>

{#each currentPathContentsInfo as entry}
<FileSystemEntry on:open={onOpen} entry={entry} columnsToShow={columnsToShow} />
<FileSystemEntry on:open={onOpen} on:delete{onDelete} entry={entry} columnsToShow={columnsToShow} />
{/each}
</vscode-data-grid>
</div>
Expand Down

0 comments on commit c893d37

Please sign in to comment.