Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program renaming feature #140

Closed
wants to merge 23 commits into from
Closed

Program renaming feature #140

wants to merge 23 commits into from

Conversation

Molaryy
Copy link
Contributor

@Molaryy Molaryy commented May 8, 2023

Description

I added the fronted for the program rename and also the backend.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the needed labels
  • I have linked this PR to an issue
  • I have linked this PR to a milestone
  • I have linked this PR to a project
  • I have tested this code
  • I have added / updated tests (unit / functionals / end-to-end / ...)
  • I have updated the README and other relevant documents (guides...)
  • I have added sufficient documentation both in code, as well as in the READMEs

@Molaryy Molaryy requested a review from RezaRahemtola May 8, 2023 15:55
@Molaryy Molaryy self-assigned this May 8, 2023
@netlify
Copy link

netlify bot commented May 8, 2023

Deploy Preview for nimble-praline-605cf6 ready!

Name Link
🔨 Latest commit 96d2376
🔍 Latest deploy log https://app.netlify.com/sites/nimble-praline-605cf6/deploys/645bde54c8d8f00009e9a4d4
😎 Deploy Preview https://deploy-preview-140--nimble-praline-605cf6.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.


const ProgramOptionsContent = ({ program }: { program: IPCProgram }): JSX.Element => (
const ProgramOptionsContent = ({ program }: { program: IPCProgram}): JSX.Element => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it's still not properly linted 👀

try {
if (this.account) {
await forget.Publish({
const test = await forget.Publish({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const test = await forget.Publish({
await forget.Publish({

@@ -53,16 +54,15 @@ class Computing {
}
}

public async deleteProgram(programHash: string): Promise<ResponseType> {
public async UpdateDeleteProgram(programHash: string): Promise<ResponseType> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public async UpdateDeleteProgram(programHash: string): Promise<ResponseType> {
public async deleteProgram(programHash: string): Promise<ResponseType> {

This function is only deleting a program, not updating it ?

Comment on lines +80 to +87
const copy = concernedProgram;
await Promise.all(
this.programs.map(async () => {
copy.name = newName;
copy.log.push({
action: `Renamed program to ${newName}`,
date: Date.now(),
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will work 🤔

Maybe something like this:

Suggested change
const copy = concernedProgram;
await Promise.all(
this.programs.map(async () => {
copy.name = newName;
copy.log.push({
action: `Renamed program to ${newName}`,
date: Date.now(),
});
await Promise.all(
this.programs = this.programs.map(async (prog) => {
if (prog.id === concernedProgram.id) {
const newLog = {
action: `Renamed program to ${newName}`,
date: Date.now(),
};
return {...prog, name: newName, logs: [...prog.logs, newLog]}
}
return prog;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw you can remove the async and Promise.all here, nothing is awaited

@@ -82,20 +105,18 @@ class Computing {
if (this.account) {
// remove old program from user's programs array
if (isRedeploy && oldProgramHash) {
const newProgramsArray: IPCProgram[] = this.programs.filter(
const newProgramsArray: IPCProgram[] = this.programs.filter (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const newProgramsArray: IPCProgram[] = this.programs.filter (
const newProgramsArray: IPCProgram[] = this.programs.filter(

@@ -7,11 +7,12 @@ import fileDownload from 'js-file-download';

import { ALEPH_CHANNEL } from 'config/constants';

import type { AggregateType, IPCContact, IPCFile, IPCFolder, ResponseType, UploadResponse } from 'types/types';
import type { AggregateType, IPCContact, IPCFile, IPCFolder, ResponseType, UploadResponse} from 'types/types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import type { AggregateType, IPCContact, IPCFile, IPCFolder, ResponseType, UploadResponse} from 'types/types';
import type { AggregateType, IPCContact, IPCFile, IPCFolder, ResponseType, UploadResponse } from 'types/types';

linting again

Comment on lines +21 to 29
export type ProgramLog = {
action: string;
date: number;
};

export type FileLog = {
action: string;
date: number;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are literally the same type, you can just use a single type Log it will be cleaner

hash: string;
name: string;
createdAt: number;
entrypoint: string;
size: number;
log: ProgramLog[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log: ProgramLog[];
logs: ProgramLog[];

An array of log, adding an s looks better

const textColor = useColorModeValue(textColorMode.light, textColorMode.dark);
const { colorMode } = useColorMode();

const DeleteActualProgram = async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const DeleteActualProgram = async () => {
const deleteActualProgram = async () => {

Use PascalCase only for component names, not for functions 😉

@RezaRahemtola RezaRahemtola deleted the program_renaming branch May 19, 2023 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants