Skip to content

Commit

Permalink
Fix UI quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
ggodlewski committed Sep 26, 2024
1 parent a2cf19d commit 9cec1e9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
6 changes: 3 additions & 3 deletions apps/ui/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var(--bs-table-hover-bg);

.files-list__item > i {
display: inline-block;
width: 0px;
width: 0;
padding-right: 20px;
}

Expand Down Expand Up @@ -203,9 +203,9 @@ a[disabled] {
padding: 2em 0 2em 3em;
}

.prism-editor__editor {
.prism-editor__editor, .prism-editor-wrapper {
font-size: 16px;
font-family: monospace !important;
font-family: monospace;
}
pre.prism-editor__editor {
overflow-x: scroll; /* Adds a horizontal scrollbar when necessary */
Expand Down
12 changes: 10 additions & 2 deletions apps/ui/src/components/DangerSettings.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="container mainbar__content-height" v-if="drive_config.config">
<div class="container mainbar__content-height" v-if="config">
<StatusToolBar :active-tab="activeTab" />

<div class="overflow-scroll d-flex flex-row mt-3">
Expand All @@ -15,7 +15,7 @@
<h4>Git</h4>

<button class="btn btn-warning" type="button" @click="resetToLocal">Reset to local</button>
<button v-if="drive_config.remote_url" class="btn btn-warning" type="button" @click="resetToRemote">Reset to remote</button>
<button v-if="remote_url" class="btn btn-warning" type="button" @click="resetToRemote">Reset to remote</button>
<button class="btn btn-warning" type="button" @click="removeUntracked">Remove untracked files</button>
<button class="btn btn-danger" type="button" @click="nukeGitDir()"><i class="fa-solid fa-explosion"></i> Nuke .git directory</button>

Expand Down Expand Up @@ -45,6 +45,14 @@ export default {
type: String
},
drive_config: {}
},
computed: {
config() {
return this.drive_config?.config || {};
},
remote_url() {
return this.drive_config?.remote_url || '';
}
}
};
</script>
7 changes: 5 additions & 2 deletions apps/ui/src/components/GitSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export default {
}
},
computed: {
public_key() {
return this.drive_config?.public_key || '';
},
github_url() {
const remote_url = this.remote_url || '';
if (remote_url.startsWith('[email protected]:')) {
Expand All @@ -108,7 +111,7 @@ export default {
});
await response.json();
await this.$root.changeDrive(this.driveId);
await this.emit('changed');
await this.$emit('changed');
},
async saveAndReset() {
await this.save();
Expand All @@ -123,7 +126,7 @@ export default {
method: 'post'
});
await this.emit('changed');
await this.$emit('changed');
}
}
};
Expand Down
7 changes: 6 additions & 1 deletion apps/ui/src/components/prismFix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ Prism.hooks.add('before-highlight', function (env) {
});

Prism.hooks.add('wrap', function (env) {
function removeHash(url) {
url = (url || '').replace(/#.*$/, '');
return url;
}

if ('url' === env.type) {
env.tag = 'a';
env.attributes.href = env.content;
env.attributes.href = removeHash(env.content);
env.attributes['data-to-rewrite'] = 'true';
}
if (/-link$/.test(env.type)) {
Expand Down
1 change: 1 addition & 0 deletions src/containers/server/routes/ConfigController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class ConfigController extends Controller {

const gitScanner = new GitScanner(this.logger, transformedFileSystem.getRealPath(), '[email protected]');
await gitScanner.initialize();
await gitScanner.setSafeDirectory();

const googleFileSystem = await this.filesService.getSubFileService(driveId, '');
const userConfigService = new UserConfigService(googleFileSystem);
Expand Down
11 changes: 11 additions & 0 deletions src/git/GitScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export class GitScanner {

let [ stdout, stderr ] = [ null, null ];

if (!opts.env) {
opts.env = {};
}
if (!opts.env['HOME']) {
opts.env['HOME'] = process.env.HOME;
}

try {
await new Promise((resolve, reject) => {
exec(command, { cwd: this.rootPath, env: opts.env, maxBuffer: 1024 * 1024 }, (error, stdoutResult, stderrResult) => {
Expand Down Expand Up @@ -622,6 +629,10 @@ export class GitScanner {
}
}

async setSafeDirectory() {
await this.exec('git config --global --add safe.directory ' + this.rootPath);
}

async getBranchCommit(branch: string): Promise<string> {
try {
const res = await this.exec(`git rev-parse ${branch}`, { skipLogger: true });
Expand Down

0 comments on commit 9cec1e9

Please sign in to comment.