Skip to content

Commit

Permalink
replaced ErrorDialog with generalized ConfirmationDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasLukasczyk committed Jul 16, 2024
1 parent 019e547 commit 1f10c12
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 97 deletions.
10 changes: 3 additions & 7 deletions packages/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,11 @@ const openLocalArc = async (path: string | null | void) =>{
iProps.error = true;
return;
}
const git_initialized = await window.ipc.invoke('GitService.run',{
args: [`status`],
cwd: path
});
ArcControlService.props.arc.git_initialized = git_initialized[0];
if(!ArcControlService.props.arc.git_initialized){
if(!ArcControlService.props.git_initialized){
$q.dialog({
component: ConfirmationDialog,
componentProps: {
title: `Warning`,
msg: `ARC is not a Git repository.<br>Do you want to initialize Git?`,
ok_text: 'Initialize Git',
ok_icon: 'sym_r_folder_data',
Expand All @@ -97,7 +93,7 @@ const openLocalArc = async (path: string | null | void) =>{
args: ['init','-b','main'],
cwd: path
});
dialogProps.state = response[0] ? 1 : 2;
dialogProps.state=response[0]?1:2;
});
}
};
Expand Down
16 changes: 13 additions & 3 deletions packages/renderer/src/ArcControlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ export const Workflows = 'workflows';
let init: {
arc_root: undefined | string ,
busy: boolean,
arc: null | ARC
arc: null | ARC,
git_initialized: boolean
} = {
arc_root: undefined ,
busy: false,
arc: null
arc: null,
git_initialized: false
}

function relative_to_absolute_path(relativePath: string) {
Expand Down Expand Up @@ -69,6 +71,13 @@ const ArcControlService = {
arc.SetISAFromContracts(contracts);
ArcControlService.props.arc = arc;
ArcControlService.props.arc_root = arc_root;

const git_initialized = await window.ipc.invoke('GitService.run',{
args: [`status`],
cwd: arc_root
});
ArcControlService.props.git_initialized = git_initialized[0];

ArcControlService.props.busy = false;
console.log(arc);
return true;
Expand Down Expand Up @@ -153,7 +162,8 @@ const ArcControlService = {
arc_root + '/.gitignore'
);
if(!ignore_exists)
contracts.push(gitignoreContract);
contracts.push(
);

await ArcControlService.handleARCContracts(contracts, arc, arc_root);

Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/components/ToolbarButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits(['clicked']);
const enabled = ()=>{
return (!props.requiresARC || ArcControlService.props.arc_root) && (!props.requiresUser || appProperties.user) && (!props.requiresGit || (ArcControlService.props.arc && ArcControlService.props.arc.git_initialized));
return (!props.requiresARC || ArcControlService.props.arc_root) && (!props.requiresUser || appProperties.user) && (!props.requiresGit || ArcControlService.props.git_initialized);
}
</script>
Expand Down
26 changes: 14 additions & 12 deletions packages/renderer/src/dialogs/ConfirmationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
import { useDialogPluginComponent } from 'quasar';
export interface Props {
title: String,
msg: String,
ok_text: String,
ok_icon: String,
ok_color: String,
cancel_text: String,
cancel_icon: String,
cancel_color: String
ok_text?: String,
ok_icon?: String,
ok_color?: String,
cancel_text?: String,
cancel_icon?: String,
cancel_color?: String
};
const props = withDefaults(defineProps<Props>(), {
title: '',
msg: '',
ok_text: 'OK',
ok_icon: 'check_circle',
ok_color: 'secondary',
cancel_text: 'Cancel',
cancel_icon: 'cancel',
cancel_color: 'secondary'
cancel_text: '',
cancel_icon: '',
cancel_color: ''
});
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent();
Expand All @@ -29,7 +31,7 @@ const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginC
<q-dialog ref="dialogRef" persistent>
<q-card class="q-dialog-plugin" style="width:auto;max-width:50vw;">
<q-card-section>
<div class="text-h6">Confirm</div>
<div class="text-h6">{{props.title}}</div>
</q-card-section>

<q-card-section class="row no-wrap items-center" style="padding:0 2em 0 0.5em;">
Expand All @@ -38,8 +40,8 @@ const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginC
</q-card-section>

<q-card-actions align="right" style="margin:0 1.5em 1.5em;">
<q-btn :color='props.ok_color' :icon='props.ok_icon' :label='props.ok_text' @click='onDialogOK' class='text-weight-bold'/>
<q-btn :color='props.cancel_color' :icon='props.cancel_icon' :label='props.cancel_text' @click='onDialogCancel' class='text-weight-bold'/>
<q-btn v-if='props.ok_text' :color='props.ok_color' :icon='props.ok_icon' :label='props.ok_text' @click='onDialogOK' class='text-weight-bold'/>
<q-btn v-if='props.cancel_text' :color='props.cancel_color' :icon='props.cancel_icon' :label='props.cancel_text' @click='onDialogCancel' class='text-weight-bold'/>
</q-card-actions>
</q-card>

Expand Down
32 changes: 0 additions & 32 deletions packages/renderer/src/dialogs/ErrorDialog.vue

This file was deleted.

3 changes: 1 addition & 2 deletions packages/renderer/src/dialogs/GitDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ defineEmits([
]);
const processGitStream = async row=>{
if(props.state===1) return;
const last_row = iProps.rows[iProps.rows.length-1];
let replace = false;
for(let p of [
Expand All @@ -47,7 +46,7 @@ const processGitStream = async row=>{
iProps.rows.push(row);
};
onMounted( ()=>{
onMounted( ()=>{
iProps.rows = [''];
window.ipc.on('GitService.MSG', processGitStream);
});
Expand Down
16 changes: 9 additions & 7 deletions packages/renderer/src/views/ArcTreeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ConfirmationDialog from '../dialogs/ConfirmationDialog.vue';
import StringDialog from '../dialogs/StringDialog.vue';
import AddProtocolDialog from '../dialogs/AddProtocolDialog.vue';
import GitDialog from '../dialogs/GitDialog.vue';
import ErrorDialog from '../dialogs/ErrorDialog.vue';
import { useQuasar } from 'quasar'
import {ArcStudy, ArcAssay} from '@nfdi4plants/arctrl';
import IdentifierDialog from '../dialogs/IdentifierDialog.vue';
Expand Down Expand Up @@ -385,9 +384,10 @@ const onCellContextMenu = async (e,node) => {
cwd: ArcControlService.props.arc_root
});
if(!response[0]) return $q.dialog({
component: ErrorDialog,
component: ConfirmationDialog,
componentProps: {
error: 'Unable to determine remote name'
title: 'Error',
msg: 'Unable to determine remote name'
}
});
const remote_name = response[1].split('\n')[0];
Expand All @@ -396,9 +396,10 @@ const onCellContextMenu = async (e,node) => {
cwd: ArcControlService.props.arc_root
});
if(!response[0]) return $q.dialog({
component: ErrorDialog,
component: ConfirmationDialog,
componentProps: {
error: 'Unable to determine remote url'
title: 'Error',
msg: 'Unable to determine remote url'
}
});
const remote_url = response[1].split('\n')[0];
Expand All @@ -407,9 +408,10 @@ const onCellContextMenu = async (e,node) => {
const patched_remote_url = patchRemote(remote_url);
if(!patched_remote_url){
return $q.dialog({
component: ErrorDialog,
component: ConfirmationDialog,
componentProps: {
error: 'LFS download requires login'
title: 'Error',
msg: 'LFS download requires login'
}
});
}
Expand Down
4 changes: 1 addition & 3 deletions packages/renderer/src/views/GitCommitView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ interface Props {
email: string,
msg: string
}
}
};
const iProps : Props = reactive({
git_status: [],
Expand Down Expand Up @@ -171,7 +170,6 @@ const isTrackedWithLFS = item=>{
};
const reset = async()=>{
const dialogProps = reactive({
title: 'Resetting ARC',
ok_title: 'Ok',
Expand Down
44 changes: 17 additions & 27 deletions packages/renderer/src/views/GitSyncView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import AppProperties from '../AppProperties.ts';
import AddRemoteDialog from '../dialogs/AddRemoteDialog.vue';
import GitDialog from '../dialogs/GitDialog.vue';
import ConfirmationDialog from '../dialogs/ConfirmationDialog.vue';
import { useQuasar } from 'quasar'
const $q = useQuasar();
const iProps = reactive({
git_status: [],
error: '',
use_lfs: true,
Expand All @@ -26,11 +26,6 @@ const iProps = reactive({
userListener: ()=>{}
});
const raiseError = err => {
iProps.error = err;
return false;
};
const getStatus = async()=>{
const response = await window.ipc.invoke('GitService.run', {
args: [`status`,`-z`,`-u`],
Expand Down Expand Up @@ -77,18 +72,20 @@ const patchRemote = url => {
: url;
};
const push = async()=>{
iProps.error = '';
if(!iProps.remote)
return raiseError('Pushing requires remote.');
if(!AppProperties.user)
return raiseError('Pushing requires login.');
const showError = async msg=>{
$q.dialog({
component: ConfirmationDialog,
componentProps: {
title: 'Error',
msg: msg
}
});
};
const push = async()=>{
await getStatus();
if(iProps.git_status.length>0)
return raiseError('Commit changes before pushing.');
return showError('Commit changes before pulling.');
const dialogProps = reactive({
title: 'Pushing ARC',
Expand All @@ -100,9 +97,10 @@ const push = async()=>{
$q.dialog({
component: GitDialog,
componentProps: dialogProps
}).onOk(async ()=>{
await checkRemotes();
});
let response = null;
// get current branch
Expand Down Expand Up @@ -143,19 +141,12 @@ const push = async()=>{
});
dialogProps.state=1;
await checkRemotes();
};
const pull = async()=>{
iProps.error = '';
if(!iProps.remote)
return raiseError('Pulling requires remote.');
await getStatus();
if(iProps.git_status.length>0)
return raiseError('Commit changes before pulling.');
return showError('Commit changes before pulling.');
const dialogProps = reactive({
title: 'Pulling ARC',
Expand All @@ -167,6 +158,8 @@ const pull = async()=>{
$q.dialog({
component: GitDialog,
componentProps: dialogProps
}).onOk(async ()=>{
await checkRemotes();
});
let response = null;
Expand Down Expand Up @@ -207,8 +200,6 @@ const pull = async()=>{
});
dialogProps.state=1;
await checkRemotes();
};
const checkRemotes = async()=>{
Expand Down Expand Up @@ -254,7 +245,6 @@ const getRemotes = async()=>{
};
const init = async()=>{
iProps.error = '';
await getRemotes();
await checkRemotes();
};
Expand Down
7 changes: 4 additions & 3 deletions packages/renderer/src/views/LoginView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ArcCommanderService from '../ArcCommanderService.ts';
import AppProperties from '../AppProperties.ts';
import SelectionDialog from '../dialogs/SelectionDialog.vue';
import UserDialog from '../dialogs/UserDialog.vue';
import ErrorDialog from '../dialogs/ErrorDialog.vue';
import ConfirmationDialog from '../dialogs/ConfirmationDialog.vue';
import { useQuasar } from 'quasar'
const $q = useQuasar();
Expand All @@ -16,9 +16,10 @@ const authenticate = async host=>{
if(res) return;
$q.dialog({
component: ErrorDialog,
component: ConfirmationDialog,
componentProps: {
error: `Unable to authenticate at host "${host}"`,
title: 'Error',
msg: `Unable to authenticate at host "${host}"`
}
});
};
Expand Down

0 comments on commit 1f10c12

Please sign in to comment.