Skip to content

Commit

Permalink
Merge pull request #568 from rstudio/dotnomad/style-file-exclusion
Browse files Browse the repository at this point in the history
Style FileTree file exclusion tooltip
  • Loading branch information
dotNomad authored Dec 14, 2023
2 parents 98286f8 + 2314e46 commit 872b9f3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions web/src/components/FileTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
self="center left"
:offset="[10, 10]"
>
{{ node.exclusion }}
{{ exclusionDisplay(node.exclusion) }}
</q-tooltip>
</div>
</template>
Expand All @@ -34,7 +34,7 @@ import { QTreeNode } from 'quasar';
import { ref } from 'vue';

import { useApi } from 'src/api';
import { DeploymentFile } from 'src/api/types/files';
import { DeploymentFile, ExclusionMatch, ExclusionMatchSource } from 'src/api/types/files';

const NODE_KEY = 'key';

Expand All @@ -43,8 +43,8 @@ const api = useApi();
const files = ref<QTreeNode[]>([]);
const expanded = ref<string[]>([]);

function fileToTreeNode(file: DeploymentFile): QTreeNode {
const node: QTreeNode = {
function fileToTreeNode(file: DeploymentFile) {
const node: QTreeNode & Pick<DeploymentFile, 'exclusion'> = {
[NODE_KEY]: file.id,
label: file.base,
children: file.files.map(fileToTreeNode),
Expand All @@ -67,6 +67,17 @@ async function getFiles() {
}
}

function exclusionDisplay(match: ExclusionMatch): string {
switch (match.source) {
case ExclusionMatchSource.BUILT_IN:
return 'Automatically ignored by Posit Publisher';
case ExclusionMatchSource.FILE:
return `Ignored by "${match.filePath}" on line ${match.line} with pattern "${match.pattern}"`;
case ExclusionMatchSource.USER:
return 'Ignored by user';
}
}

getFiles();
</script>

Expand Down

0 comments on commit 872b9f3

Please sign in to comment.