app building locally

pull/5370/head
iamsethsamuel 2 years ago
parent 1d71d9f21b
commit a73313758b
  1. 46
      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() { constructor() {
super(profile) super(profile)
} }
onActivation(): void {
this.on('filePanel', 'setWorkspace', async () => {
await this.clearAllFileDecorators()
})
}
/** /**
* *
* @param fileStates Array of file states * @param fileStates Array of file states
*/ */
async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) { async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) {
const { from } = this.currentRequest
const workspace = await this.call('filePanel', 'getCurrentWorkspace') 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] const fileStatesPayload = Array.isArray(fileStates) ? fileStates : [fileStates]
// clear all file states in the previous state of this owner on the files called // clear all file states in the previous state of this owner on the files called
fileStatesPayload.forEach((state) => { fileStatesPayload.forEach((state) => {
@ -48,6 +46,22 @@ export class FileDecorator extends Plugin {
}) })
const newState = [...filteredState, ...fileStatesPayload].sort(sortByPath) 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)) { if (!deepequal(newState, this._fileStates)) {
this._fileStates = newState this._fileStates = newState
this.emit('fileDecoratorsChanged', this._fileStates) this.emit('fileDecoratorsChanged', this._fileStates)
@ -55,8 +69,18 @@ export class FileDecorator extends Plugin {
} }
async clearFileDecorators() { async clearAllFileDecorators() {
this._fileStates = [] this._fileStates = []
this.emit('fileDecoratorsChanged', []) 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) { 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) { if (fileDecoration.commment) {
const commments = Array.isArray(fileDecoration.commment) ? fileDecoration.commment : [fileDecoration.commment] const commments = Array.isArray(fileDecoration.commment) ? fileDecoration.commment : [fileDecoration.commment]
return commments.map((comment, index) => { return commments.map((comment, index) => {
>>>>>>> 43bc1038a (add test)
return <div key={index}>{comment}<br></br></div> return <div key={index}>{comment}<br></br></div>
}) })
} }

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

Loading…
Cancel
Save