app building locally

pull/2620/head
Seth Samuel 2 years ago
parent b188b79834
commit 919f4912e8
  1. 48
      apps/remix-ide/src/app/plugins/file-decorator.ts
  2. 6
      libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-tooltip.tsx
  3. 6
      libs/remix-ui/file-decorators/src/lib/types/index.ts

@ -18,22 +18,20 @@ export class FileDecorator extends Plugin {
constructor() {
super(profile)
}
onActivation(): void {
this.on('filePanel', 'setWorkspace', async () => {
await this.clearAllFileDecorators()
})
}
/**
*
* @param fileStates Array of file states
*/
async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) {
const { from } = this.currentRequest
const workspace = await this.call('filePanel', 'getCurrentWorkspace')
function sortByPath( a: fileDecoration, b: fileDecoration ) {
if ( a.path < b.path ){
return -1;
}
if ( a.path > b.path ){
return 1;
}
return 0;
}
const fileStatesPayload = Array.isArray(fileStates) ? fileStates : [fileStates]
// clear all file states in the previous state of this owner on the files called
fileStatesPayload.forEach((state) => {
@ -47,7 +45,23 @@ export class FileDecorator extends Plugin {
return index == -1
})
const newState = [...filteredState, ...fileStatesPayload].sort(sortByPath)
if (!deepequal(newState, this._fileStates)) {
this._fileStates = newState
this.emit('fileDecoratorsChanged', this._fileStates)
}
}
async clearFileDecorators(path?: string) {
const { from } = this.currentRequest
if (!from) return
const filteredState = this._fileStates.filter((state) => {
if(state.owner != from) return true
if(path && state.path != path) return true
})
const newState = [...filteredState].sort(sortByPath)
if (!deepequal(newState, this._fileStates)) {
this._fileStates = newState
this.emit('fileDecoratorsChanged', this._fileStates)
@ -55,8 +69,18 @@ export class FileDecorator extends Plugin {
}
async clearFileDecorators() {
async clearAllFileDecorators() {
this._fileStates = []
this.emit('fileDecoratorsChanged', [])
}
}
const sortByPath = (a: fileDecoration, b: fileDecoration) => {
if (a.path < b.path) {
return -1;
}
if (a.path > b.path) {
return 1;
}
return 0;
}

@ -9,15 +9,9 @@ const FileDecorationTooltip = (props: {
},
) => {
const getComments = function (fileDecoration: fileDecoration) {
<<<<<<< HEAD
if (fileDecoration.comment) {
const comments = Array.isArray(fileDecoration.comment) ? fileDecoration.comment : [fileDecoration.comment]
return comments.map((comment, index) => {
=======
if (fileDecoration.commment) {
const commments = Array.isArray(fileDecoration.commment) ? fileDecoration.commment : [fileDecoration.commment]
return commments.map((comment, index) => {
>>>>>>> 43bc1038a (add test)
return <div key={index}>{comment}<br></br></div>
})
}

@ -14,17 +14,11 @@ export enum fileDecorationType {
fileStateIcon: string | HTMLDivElement | JSX.Element,
bubble: boolean,
text?: string,
<<<<<<< HEAD
owner?: string,
workspace?: any
tooltip?: string
comment?: string[] | string
=======
owner: string,
workspace?: any
tooltip?: string
commment?: string[] | string
>>>>>>> 43bc1038a (add test)
}
export interface FileType {

Loading…
Cancel
Save