pull/5370/head
filip mertens 3 years ago committed by iamsethsamuel
parent d3e26161f1
commit 44f0433061
  1. 39
      apps/remix-ide/src/app/plugins/file-decorator.ts
  2. 4
      libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx
  3. 4
      libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx
  4. 6
      libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-tooltip.tsx
  5. 4
      libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx
  6. 6
      libs/remix-ui/file-decorators/src/lib/helper/index.tsx
  7. 7
      libs/remix-ui/file-decorators/src/lib/types/index.ts

@ -8,7 +8,11 @@ import { fileDecoration } from '@remix-ui/file-decorators'
const profile = { const profile = {
name: 'fileDecorator', name: 'fileDecorator',
desciption: 'Keeps decorators of the files', desciption: 'Keeps decorators of the files',
<<<<<<< HEAD
methods: ['setFileDecorators', 'clearFileDecorators', 'clearAllFileDecorators'], methods: ['setFileDecorators', 'clearFileDecorators', 'clearAllFileDecorators'],
=======
methods: ['setFileDecorators', 'clearFileDecorators'],
>>>>>>> 43bc1038a (add test)
events: ['fileDecoratorsChanged'], events: ['fileDecoratorsChanged'],
version: '0.0.1' version: '0.0.1'
} }
@ -18,6 +22,7 @@ export class FileDecorator extends Plugin {
constructor() { constructor() {
super(profile) super(profile)
} }
<<<<<<< HEAD
onActivation(): void { onActivation(): void {
this.on('filePanel', 'setWorkspace', async () => { this.on('filePanel', 'setWorkspace', async () => {
@ -25,33 +30,61 @@ export class FileDecorator extends Plugin {
}) })
} }
=======
>>>>>>> 43bc1038a (add test)
/** /**
* *
* @param fileStates Array of file states * @param fileStates Array of file states
*/ */
async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) { async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) {
<<<<<<< HEAD
const { from } = this.currentRequest const { from } = this.currentRequest
const workspace = await this.call('filePanel', 'getCurrentWorkspace') 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;
}
>>>>>>> 43bc1038a (add test)
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) => {
state.workspace = workspace state.workspace = workspace
<<<<<<< HEAD
state.owner = from state.owner = from
}) })
const filteredState = this._fileStates.filter((state) => { const filteredState = this._fileStates.filter((state) => {
const index = fileStatesPayload.findIndex((payloadFileState: fileDecoration) => { const index = fileStatesPayload.findIndex((payloadFileState: fileDecoration) => {
return from == state.owner && payloadFileState.path == state.path return from == state.owner && payloadFileState.path == state.path
=======
})
const filteredState = this._fileStates.filter((state) => {
const index = fileStatesPayload.findIndex((payloadFileState: fileDecoration) => {
return payloadFileState.owner == state.owner && payloadFileState.path == state.path
>>>>>>> 43bc1038a (add test)
}) })
return index == -1 return index == -1
}) })
const newState = [...filteredState, ...fileStatesPayload].sort(sortByPath) const newState = [...filteredState, ...fileStatesPayload].sort(sortByPath)
<<<<<<< HEAD
=======
>>>>>>> 43bc1038a (add test)
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)
} }
} }
<<<<<<< HEAD
async clearFileDecorators(path?: string) { async clearFileDecorators(path?: string) {
const { from } = this.currentRequest const { from } = this.currentRequest
if (!from) return if (!from) return
@ -83,4 +116,10 @@ const sortByPath = (a: fileDecoration, b: fileDecoration) => {
return 1; return 1;
} }
return 0; return 0;
=======
async clearFileDecorators() {
this._fileStates = []
this.emit('fileDecoratorsChanged', [])
}
>>>>>>> 43bc1038a (add test)
} }

@ -5,7 +5,11 @@ import { fileDecoration } from '../../types'
const FileDecorationCustomIcon = (props: { const FileDecorationCustomIcon = (props: {
fileDecoration: fileDecoration fileDecoration: fileDecoration
}) => { }) => {
<<<<<<< HEAD
return <><span data-id={`file-decoration-custom-${props.fileDecoration.path}`} className={`${props.fileDecoration.fileStateIconClass} pr-2`}> return <><span data-id={`file-decoration-custom-${props.fileDecoration.path}`} className={`${props.fileDecoration.fileStateIconClass} pr-2`}>
=======
return <><span className={`${props.fileDecoration.fileStateIconClass}pr-2`}>
>>>>>>> 43bc1038a (add test)
{props.fileDecoration.fileStateIcon} {props.fileDecoration.fileStateIcon}
</span></> </span></>
} }

@ -7,7 +7,11 @@ const FileDecorationErrorIcon = (props: {
fileDecoration: fileDecoration fileDecoration: fileDecoration
}) => { }) => {
return <> return <>
<<<<<<< HEAD
<span data-id={`file-decoration-error-${props.fileDecoration.path}`} className={`${props.fileDecoration.fileStateIconClass} text-danger pr-2`}>{props.fileDecoration.text}</span> <span data-id={`file-decoration-error-${props.fileDecoration.path}`} className={`${props.fileDecoration.fileStateIconClass} text-danger pr-2`}>{props.fileDecoration.text}</span>
=======
<span className={`${props.fileDecoration.fileStateIconClass} text-danger pr-2`}>{props.fileDecoration.text}</span>
>>>>>>> 43bc1038a (add test)
</> </>
} }

@ -9,9 +9,15 @@ const FileDecorationTooltip = (props: {
}, },
) => { ) => {
const getComments = function (fileDecoration: fileDecoration) { const getComments = function (fileDecoration: fileDecoration) {
<<<<<<< HEAD
if (fileDecoration.comment) { if (fileDecoration.comment) {
const comments = Array.isArray(fileDecoration.comment) ? fileDecoration.comment : [fileDecoration.comment] const comments = Array.isArray(fileDecoration.comment) ? fileDecoration.comment : [fileDecoration.comment]
return comments.map((comment, index) => { 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> return <div key={index}>{comment}<br></br></div>
}) })
} }

@ -5,7 +5,11 @@ import { fileDecoration } from '../../types'
const FileDecorationWarningIcon = (props: { const FileDecorationWarningIcon = (props: {
fileDecoration: fileDecoration fileDecoration: fileDecoration
}) => { }) => {
<<<<<<< HEAD
return <><span data-id={`file-decoration-warning-${props.fileDecoration.path}`} className={`${props.fileDecoration.fileStateIconClass} text-warning pr-2`}>{props.fileDecoration.text}</span></> return <><span data-id={`file-decoration-warning-${props.fileDecoration.path}`} className={`${props.fileDecoration.fileStateIconClass} text-warning pr-2`}>{props.fileDecoration.text}</span></>
=======
return <><span className={`${props.fileDecoration.fileStateIconClass} text-warning pr-2`}>{props.fileDecoration.text}</span></>
>>>>>>> 43bc1038a (add test)
} }
export default FileDecorationWarningIcon export default FileDecorationWarningIcon

@ -2,9 +2,15 @@ import React from "react"
import { fileDecoration } from "../types" import { fileDecoration } from "../types"
export const getComments = function (fileDecoration: fileDecoration) { export const getComments = function (fileDecoration: fileDecoration) {
<<<<<<< HEAD
if(fileDecoration.comment){ if(fileDecoration.comment){
const comments = Array.isArray(fileDecoration.comment) ? fileDecoration.comment : [fileDecoration.comment] const comments = Array.isArray(fileDecoration.comment) ? fileDecoration.comment : [fileDecoration.comment]
return comments.map((comment, index) => { 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> return <div key={index}>{comment}<br></br></div>
}) })
} }

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

Loading…
Cancel
Save