feat: the three folders are created when the main one is chosen, numbered in the flow's order
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m31s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m4s
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m31s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m4s
Tried on a local Kanban with Dropstar's flow: the folders appeared only with the first file, and a listing showed Arte conferida before Arte recebida. - "1. Arte recebida", "2. Arte conferida" and "3. Finalizado" are created as soon as the main folder is chosen or released, and again on every round if someone deletes one - numbered, a folder listing shows them in the order the file moves Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -340,10 +340,12 @@ Dropstar's three folders (asked 2026-10-23, agreed 2026-10-26): the Kanban,
|
|||||||
open in Chrome or Edge on a factory computer that reaches the server's
|
open in Chrome or Edge on a factory computer that reaches the server's
|
||||||
folder, signed in with a profile that sees every order (Gestão), keeps the
|
folder, signed in with a profile that sees every order (Gestão), keeps the
|
||||||
orders' files in three folders it creates inside the one chosen in
|
orders' files in three folders it creates inside the one chosen in
|
||||||
Integrações ("Pastas dos pedidos"): Arte recebida (the file arrives when the
|
Integrações ("Pastas dos pedidos"), numbered to sort in the flow's order:
|
||||||
order does), Arte conferida (the queue; the file moves there with the card
|
"1. Arte recebida" (the file arrives when the order does), "2. Arte
|
||||||
and stays while it prints and is checked in Revisão) and Finalizado (when the
|
conferida" (the queue; the file moves there with the card and stays while it
|
||||||
order is released, kept 30 days there). Correção, a cancellation or a
|
prints and is checked in Revisão) and "3. Finalizado" (when the order is
|
||||||
|
released, kept 30 days there). They are created as soon as the main folder
|
||||||
|
is chosen. Correção, a cancellation or a
|
||||||
deletion takes the file out; a replaced final is swapped. Orders already
|
deletion takes the file out; a replaced final is swapped. Orders already
|
||||||
printing when the folder is chosen are not downloaded. A file someone took
|
printing when the folder is chosen are not downloaded. A file someone took
|
||||||
out is fetched again only when its order moves on (`POST
|
out is fetched again only when its order moves on (`POST
|
||||||
|
|||||||
@@ -222,8 +222,8 @@ try{
|
|||||||
// Approved before the queue: already on this computer, in Arte recebida.
|
// Approved before the queue: already on this computer, in Arte recebida.
|
||||||
const early='DTF-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
|
const early='DTF-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
|
||||||
await kanban.eval('syncFolder(true)');
|
await kanban.eval('syncFolder(true)');
|
||||||
await waitFor(async()=>(await savedFiles('Arte recebida')).some(n=>n.startsWith(early)&&!n.endsWith('.baixando')),'final file saved in Arte recebida',45000);
|
await waitFor(async()=>(await savedFiles('1. Arte recebida')).some(n=>n.startsWith(early)&&!n.endsWith('.baixando')),'final file saved in Arte recebida',45000);
|
||||||
assert.equal((await savedFiles('Arte conferida')).some(n=>n.startsWith(early)),false);
|
assert.equal((await savedFiles('2. Arte conferida')).some(n=>n.startsWith(early)),false);
|
||||||
}
|
}
|
||||||
await waitFor(()=>kanban.eval(`!!document.querySelector('[data-order="${oid}"] [data-move="${state}"]')`),'move to '+title);
|
await waitFor(()=>kanban.eval(`!!document.querySelector('[data-order="${oid}"] [data-move="${state}"]')`),'move to '+title);
|
||||||
await kanban.click(`[data-order="${oid}"] [data-move="${state}"]`);
|
await kanban.click(`[data-order="${oid}"] [data-move="${state}"]`);
|
||||||
@@ -231,28 +231,28 @@ try{
|
|||||||
if(state==='tra'){
|
if(state==='tra'){
|
||||||
// Entering the queue moves its file to Arte conferida, whole and named after the order.
|
// Entering the queue moves its file to Arte conferida, whole and named after the order.
|
||||||
const prefix='DTF-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
|
const prefix='DTF-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
|
||||||
await waitFor(async()=>(await savedFiles('Arte conferida')).some(n=>n.startsWith(prefix)&&!n.endsWith('.baixando')),'final file in Arte conferida',45000);
|
await waitFor(async()=>(await savedFiles('2. Arte conferida')).some(n=>n.startsWith(prefix)&&!n.endsWith('.baixando')),'final file in Arte conferida',45000);
|
||||||
// Other orders the earlier suites left in the queue may still be coming
|
// Other orders the earlier suites left in the queue may still be coming
|
||||||
// down: only once the round ends must no half-written file be left.
|
// down: only once the round ends must no half-written file be left.
|
||||||
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder round finished',60000);
|
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder round finished',60000);
|
||||||
assert.equal((await savedFiles('Arte conferida')).some(n=>n.endsWith('.baixando')),false);
|
assert.equal((await savedFiles('2. Arte conferida')).some(n=>n.endsWith('.baixando')),false);
|
||||||
assert.equal((await savedFiles('Arte recebida')).some(n=>n.startsWith(prefix)),false);
|
assert.equal((await savedFiles('1. Arte recebida')).some(n=>n.startsWith(prefix)),false);
|
||||||
// A file whose order was deleted leaves the folder.
|
// A file whose order was deleted leaves the folder.
|
||||||
await kanban.eval(`(async()=>{const dir=await window.picked.getDirectoryHandle('Arte conferida',{create:true});
|
await kanban.eval(`(async()=>{const dir=await window.picked.getDirectoryHandle('2. Arte conferida',{create:true});
|
||||||
const f=await dir.getFileHandle('pedido-0-item-1-excluido.png',{create:true});
|
const f=await dir.getFileHandle('pedido-0-item-1-excluido.png',{create:true});
|
||||||
const w=await f.createWritable();await w.write('x');await w.close();
|
const w=await f.createWritable();await w.write('x');await w.close();
|
||||||
FOLDER.saved.set(crypto.randomUUID(),{order:crypto.randomUUID(),item:1,name:'pedido-0-item-1-excluido.png',folder:'Arte conferida'});})()`);
|
FOLDER.saved.set(crypto.randomUUID(),{order:crypto.randomUUID(),item:1,name:'pedido-0-item-1-excluido.png',folder:'2. Arte conferida'});})()`);
|
||||||
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder idle',60000);
|
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder idle',60000);
|
||||||
await kanban.eval('syncFolder(true)');
|
await kanban.eval('syncFolder(true)');
|
||||||
await waitFor(async()=>!(await savedFiles('Arte conferida')).includes('pedido-0-item-1-excluido.png'),'deleted order file removed',30000);
|
await waitFor(async()=>!(await savedFiles('2. Arte conferida')).includes('pedido-0-item-1-excluido.png'),'deleted order file removed',30000);
|
||||||
}
|
}
|
||||||
if(state==='fin'){
|
if(state==='fin'){
|
||||||
// Finalized: the file goes to Finalizado, out of the queue.
|
// Finalized: the file goes to Finalizado, out of the queue.
|
||||||
const prefix='DTF-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
|
const prefix='DTF-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
|
||||||
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder idle',60000);
|
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder idle',60000);
|
||||||
await kanban.eval('syncFolder(true)');
|
await kanban.eval('syncFolder(true)');
|
||||||
await waitFor(async()=>(await savedFiles('Finalizado')).some(n=>n.startsWith(prefix)),'final file in Finalizado',30000);
|
await waitFor(async()=>(await savedFiles('3. Finalizado')).some(n=>n.startsWith(prefix)),'final file in Finalizado',30000);
|
||||||
assert.equal((await savedFiles('Arte conferida')).some(n=>n.startsWith(prefix)),false);
|
assert.equal((await savedFiles('2. Arte conferida')).some(n=>n.startsWith(prefix)),false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Undo a mistaken move from the panel: one stage back with an internal reason.
|
// Undo a mistaken move from the panel: one stage back with an internal reason.
|
||||||
|
|||||||
@@ -226,7 +226,8 @@ const BRAVE_FLAG='brave://flags/#file-system-access-api';
|
|||||||
// to Arte conferida (the queue) with the card and stays there while it prints
|
// to Arte conferida (the queue) with the card and stays there while it prints
|
||||||
// and is checked in Revisão, then goes to Finalizado, kept 30 days. Correção,
|
// and is checked in Revisão, then goes to Finalizado, kept 30 days. Correção,
|
||||||
// a cancellation or a deletion takes it out; a replaced final is swapped.
|
// a cancellation or a deletion takes it out; a replaced final is swapped.
|
||||||
const STAGE_FOLDERS={rec:'Arte recebida',tra:'Arte conferida',imp:'Arte conferida',rev:'Arte conferida',fin:'Finalizado'};
|
// Numbered so a folder listing shows them in the flow's order.
|
||||||
|
const STAGE_FOLDERS={rec:'1. Arte recebida',tra:'2. Arte conferida',imp:'2. Arte conferida',rev:'2. Arte conferida',fin:'3. Finalizado'};
|
||||||
const KEEP_FINISHED_DAYS=30;
|
const KEEP_FINISHED_DAYS=30;
|
||||||
const FOLDER={mode:'showDirectoryPicker' in window?'folder':/Firefox\//.test(navigator.userAgent)?'downloads':'none',
|
const FOLDER={mode:'showDirectoryPicker' in window?'folder':/Firefox\//.test(navigator.userAgent)?'downloads':'none',
|
||||||
brave:!!navigator.brave,handle:null,granted:false,downloads:false,
|
brave:!!navigator.brave,handle:null,granted:false,downloads:false,
|
||||||
@@ -320,11 +321,12 @@ async function chooseFolder(){
|
|||||||
FOLDER.handle=handle;FOLDER.granted=true;FOLDER.lastSig=null;FOLDER.error='';FOLDER.last=null;
|
FOLDER.handle=handle;FOLDER.granted=true;FOLDER.lastSig=null;FOLDER.error='';FOLDER.last=null;
|
||||||
FOLDER.saved=await loadSaved();
|
FOLDER.saved=await loadSaved();
|
||||||
await kv.set('folder',handle).catch(()=>{});
|
await kv.set('folder',handle).catch(()=>{});
|
||||||
paintFolder();say('Os arquivos dos pedidos vão ser salvos nas três pastas dentro de “'+handle.name+'”.');syncFolder();
|
await makeStageFolders();
|
||||||
|
paintFolder();say('Pastas '+[...new Set(Object.values(STAGE_FOLDERS))].join(', ')+' criadas dentro de “'+handle.name+'”.');syncFolder(true);
|
||||||
}
|
}
|
||||||
async function releaseFolder(){
|
async function releaseFolder(){
|
||||||
FOLDER.granted=(await FOLDER.handle.requestPermission({mode:'readwrite'}))==='granted';
|
FOLDER.granted=(await FOLDER.handle.requestPermission({mode:'readwrite'}))==='granted';
|
||||||
FOLDER.lastSig=null;FOLDER.error='';paintFolder();if(FOLDER.granted)syncFolder();
|
FOLDER.lastSig=null;FOLDER.error='';if(FOLDER.granted)await makeStageFolders();paintFolder();if(FOLDER.granted)syncFolder(true);
|
||||||
}
|
}
|
||||||
async function forgetFolder(){
|
async function forgetFolder(){
|
||||||
FOLDER.handle=null;FOLDER.granted=false;FOLDER.error='';FOLDER.status='';
|
FOLDER.handle=null;FOLDER.granted=false;FOLDER.error='';FOLDER.status='';
|
||||||
@@ -352,6 +354,8 @@ async function writeWhole(dir,name,source){
|
|||||||
await whole.write(await temp.getFile());await whole.close();await dir.removeEntry(temp.name);}
|
await whole.write(await temp.getFile());await whole.close();await dir.removeEntry(temp.name);}
|
||||||
}
|
}
|
||||||
const stageDir=name=>FOLDER.handle.getDirectoryHandle(name,{create:true});
|
const stageDir=name=>FOLDER.handle.getDirectoryHandle(name,{create:true});
|
||||||
|
// The three folders exist from the moment the main one is chosen, empty or not.
|
||||||
|
const makeStageFolders=()=>Promise.all([...new Set(Object.values(STAGE_FOLDERS))].map(stageDir));
|
||||||
// Remove a saved file from its folder; one already gone (someone took it) is fine.
|
// Remove a saved file from its folder; one already gone (someone took it) is fine.
|
||||||
async function removeSaved(rec){
|
async function removeSaved(rec){
|
||||||
const dir=await stageDir(rec.folder);
|
const dir=await stageDir(rec.folder);
|
||||||
@@ -389,6 +393,7 @@ async function syncFolder(force=false){
|
|||||||
if(!force&&sig===FOLDER.lastSig)return;
|
if(!force&&sig===FOLDER.lastSig)return;
|
||||||
FOLDER.busy=true;
|
FOLDER.busy=true;
|
||||||
try{
|
try{
|
||||||
|
if(stages)await makeStageFolders();
|
||||||
const held=stages?[...new Set([...FOLDER.saved.values()].map(r=>r.order).filter(Boolean))].slice(-1000):[];
|
const held=stages?[...new Set([...FOLDER.saved.values()].map(r=>r.order).filter(Boolean))].slice(-1000):[];
|
||||||
const {files,states}=await api('/queue/folder',{early:stages,held});
|
const {files,states}=await api('/queue/folder',{early:stages,held});
|
||||||
const wanted=new Map(files.map(f=>[f.order+':'+f.item,f]));
|
const wanted=new Map(files.map(f=>[f.order+':'+f.item,f]));
|
||||||
|
|||||||
Reference in New Issue
Block a user