javascript – Errors while creating stories for a React component in a Next.js + Flow Setup

I’m trying to create stories (for storybook version 6.0.0-beta.37) for a component (called Editor) within a complex web-application involving React, Next.js, the Flow transpiler and many more.

There’s both an Editor component as well as a component EditorWithTranslation = withTranslation(Editor) where withTranslation wraps its argument with the consumer of a translation-context. I tried to create a component for both Editor and EditorWithTranslation.

The story for the Editor component doesn’t use contexts but it just passes the translation property as such:

// @flow

import React from 'react';

import Editor, { type EditorProps } from './Editor';

export default {
    component: Editor,
    title: 'Editor',
    includeStories: /.*Story$/,
};

export const editorDefaultProps: EditorProps = {
    foo: 'foo-test',

    translation: {
        bar: 'bar-test',
    },
};

export function EditorDefaultStory() {
    return <Editor {...editorDefaultProps} />;
}

When I attempt to display the “Canvas” tab of this story from storybooks web-interface, this error message is shown:

Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: undefined. You
likely forgot to export your component from the file it’s defined in,
or you might have mixed up default and named imports.

Check the render method of storyFn.

What does this error message mean? What’s going on? How can I fix the error?

The story for EditorWithTranslation wraps the component with a provider of the translation-context, using a decorator:

// @flow

import React from 'react';

import EditorWithTranslation, { type EditorWithTranslationProps as EditorWithTranslationDefaultProps } from './EditorWithTranslation';

import { Provider as TranslationProvider } from '../../translation/Context';

export default {
    component: EditorWithTranslation,
    title: 'EditorWithTranslation',
    includeStories: /.*Story$/,
    decorators: ((storyFn: any) => <TranslationProvider>{storyFn()}</TranslationProvider>),
    // I also tried this but I think it leads to the same error:
    //decorators: ((StoryFn: any) => <TranslationProvider><StoryFn/></TranslationProvider>), 
};

export const editorWithTranslationDefaultProps: EditorWithTranslationDefaultProps = {
    foo: 'foo-test',
};

export const EditorWithTranslationDefaultStory = () => <EditorWithTranslation {...editorWithTranslationDefaultProps} />;

Attempting to display the “Canvas” tab of this story, leads to the following error message:

can’t access lexical declaration `Provider’ before initialization

What does this error message mean? What’s going on? How can I fix the error?

I also tried to understand the cause of these errors by creating a separate, minimal sample project with React, Next.js, Flow and Storybook but the errors didn’t occur and everything worked fine.

Add a Flow button in a SharePoint library

I have recently added a Flow button in a SharePoint Library. I found the code on internet (I have no experience in JSON).

I would like the button to be visible if:

  1. Document status (choice column) is different than Approved
  2. Approvers (person column) is not empty
  3. Ready for Approval (boolean column) is True

I could implement only one condition: Document status (choice column) is different than Approved

But I wonder how can I add the other 2 conditions?

Any help would more than appreciated.

The code looks like this:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "span",
  "style": {
    "color": "#001f00"
  },
  "children": (
    {
      "elmType": "button",
      "style": {
        "border": "light",
        "background-color": "Orange",
        "color": "#001f00",
        "cursor": "pointer",
        "visibility": {
          "operator": "?",
          "operands": (
            {
              "operator": "!=",
              "operands": (
                "($Document_x0020_status)",
                "Approved",
              )
            },
            "visible",
            "hidden"
          )
        }
      },
      "txtContent": "Send to Approval",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{"id": "53c665d0-ce12-4148-aa5a-c7202557ea78"}"
      }
    }
  )
}

powerapp – How to send JSON data to Power Apps from Power Automate (MS Flow)

I am getting the list Item attachments using the Get Attachments action in the flow.

As the output, I have the JSON object which contains the information of attachments.

Now, I want to send this JSON to the Power Apps.

Respond to Power Apps action allows us to send only single items, not objects.

How can I achieve the above?

Note: Please suggest a way which does not contain the use of a premium connector.

Update Task in Project Online using Flow

I am working in a test scenario on which I need to update the Task Name of a specific project to a different value, using Power Automate.

I created a flow to checkout my project, update the task with a HTTP Request, and checkin and publish the project.

In the HTTP Request I am referring both the Project and Task ID. Just as the flow below:

enter image description here

After the executing of this flow I am getting the Status code 200 in the output of the HTTP request, but nothing occurrs to the task.

enter image description here

Am I doing something wrong?

Regards.

compilers – Uses of irreducible control flow

What are some applications where irreducible control flow is required*?

I’m particularly interested in programming language features that will be tricky to efficiently compile if the compile target does not permit irreducible control flow. For example, a programming language offering GOTO will generate irreducible control flow for some programs. What other language constructs are like this? For example, is irreducible control flow required to implement resumable exceptions?

I’m also interested in application-level uses of irreducible control flow.

(*: irreducible control flow graphs (CFGs) can be converted to reducible CFGs at some cost, and also some compiler optimizations can convert reducible CFGs to irreducible CFGs, so what I mean is that the original, unoptimized CFG produced by the source code is irreducible. Less formally, I mean that the “programmer’s intent” naturally includes irreducible control flow)

sharepoint online – How can we permanently delete the file using Microsoft flow?

You can delete the file(s) permanently using REST API “HTTP DELETE”.

$.ajax({  
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfilebyserverrelativeurl('/Shared%20Documents')",  
        type: "POST",  
        contentType: "application/json;odata=verbose",  
        headers: {  
            "Accept": "application/json;odata=verbose",  
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),  
            "IF-MATCH": "*",  
            "X-HTTP-Method": "DELETE",  
        },  
        success: function(data) {  
            alert("success");  
        },  
        error: function(data) {  
            alert("failed");  
        }  
    });  

You can send the items to the Recycle Bin by adding “/recycle()” to the API URL.

A successful Delete returns no data. A successful recycle() returns the GUID for the recycled item.

Reference

python – Image sampling in Keras ImageDataGenerator flow methods

The flow methods provided by the ImageDataGenerator class provides two flow methods:

  • flow(x, y)
  • flow_from_directory(directory)

How can I use something similar to the parameter target_size: tuple of integers, default: (256, 256). The dimensions to which all images found will be resized in flow(x, y)?

The data I have loaded in is formatted as:

  • x_test (number of images 30, channels 15, height 2220, width 2220)
  • y_test (number of images 30, channels 15, height 2220, width 2220)

My model accepts the input of (3, 224, 224). I would like to sample image segments of 224×224 from the images to train the model with, however, I do not want to resize the images. What is a method of achieving this?

sharepoint list – Microsoft flow to trigger email when condition is met

Looking at the screenshot , when two fields are updating to ‘Yes’ in one go , both the conditions are resulting to true at the same time and the update action used after Send email action might conflicts due to which , when flow is running again after first email and before the second email , it is sending another email.

Try to use Switch condition instead of simple Condition you have used , where you write third condition in addition to above 2 conditions.

The condition will be –

Mail to be sent to Maths == ‘Yes’ and Mail to be sent to Science ==
‘Yes’ and IsmailsentMaths == ‘No’ and IsmailsentSci == ‘No’

By this, the flow will perform action for this third condition only and will not go to the two individual conditions for Maths and Science at the same time.

Refer this for how to use Switch in Flow.

list – MS Flow: ticks function behaves different if fed with a string than with a string variable containing the same string

Addendum/Preface
I tried a lot to process a date in the form yyyy-MM-dd coming from two columns of a custom list. I read dozens of articles about dealing with dates in flows and processing SP lists containing dates. I tried virtually every canonical method for comparing the strings, reformatting the date to UTC, reformatting it manually or converting to ticks directly. None has worked.

A short snippet of the data coming from the “evil” list, which I took from the debug view of the “get elements” action. It looks pretty normal.

{
  "@odata.etag": ""1"",
  "ItemInternalId": "1",
  "ID": 1,
  "Title": "a",
  "Starttag": "2020-06-01",
  "Endtag": "2020-06-24",
  "{Identifier}": "Lists%252fZeitabschnitttest%252f1_.000",
  "{IsFolder}": false,
  "{Thumbnail}": {
    "Large": null,
    "Medium": null,
    "Small": null
  },

The columns in the custom list are in standard date format supplied by the sharepoint site columns of a fresh setup sitecollection.

In my original version question described a single method, which is very close to the core of the problem, I think.

Original Question
So, I deleted my last post about a complicated flow, because I have tracked down the problem to a very small detail.

It started when a date from a custom list could not be compared with a date from a calendar. I have tried many and it boils down to this:

I have a created a string variable. I fed it with a concatenation of the date from the list and a time string to make it more ISO8601ish. The variable contains then a string like:

2020-06-01T00:00:00.00001Z

while

2020-06-01

was the string part from the list and

T00:00:00.00001Z

was my addendum.
When I shovel that variable into the ticks()-Function,

ticks(variables('Startdate_ref_aux'))

I get an error Message complaining about the parameter not being adherent to ISO 8601.
Also the string in the error message shows only the added portion of the string, i.e. “T00:00:00.00001Z”.
When looking at the error message, I can see, the string in the variable is correct.

But now comes the really strange part:
When I replace the variable by it’s content i.e. I copy the value from the debug window, paste it into an editor and paste it back directly into the ticks() function:

ticks(2020-06-01T00:00:00.00001Z)

It works without any problems. But as it is a constant now and not a variable, my flow doesn’t make sense any longer. Are there hidden characters inside that evaporate on copy and paste? And if so, how can I do that within the flow?

What else have I tried?

  • I tried to compare the strings directly, which doesn’t work at all. Typical error message is: The date from the list is of Type “0” (strange), while the date from the calender is of type “string” (as expected).
  • I tried to convert it to ticks directly, error message complains that the given date doesn’t adhere ISO 8601, because it is “”.
  • I tried to convert it as above, see main part of the question.
  • I tried to use the more comfortable actions instead of the expressions for manipulating the variables. But I learned the “actions” doing the same as their “expression” counterparts are probably only graphical wrappers for the “expression”, because the error messages are the very same ones.
  • I also tried to remove non-printing characters by using substring(). But substring also refuses to work on that date, saying the received parameter is of type “0” instead of “string”.
  • I wanted to parse the string character by character, using split(). But the implementation of split is soooo bad, it can’t work without a delimiting parameter! Hey guys at M$: Did you ever look at other languages like PERL or Python before you released that concoction of prehistoric functions?
  • I tried to use trim() to remove dangerous characters at the beginning and the end of the string, but it refuses to work for the same reasons.
  • So M$ implements a broken readout of SP date columns but gives no means to repair the broken strings. How’s that?
  • I changed the columns back to Date+Time but the problem stays the same.
  • I tried to make a calculated column of the date to compile it into as a string, but sharepoint itself refuses, because of invalid data types (huh?). Making an integer calculated column from the date works, but makes little sense.

Everything boils down to this:
If a date is pulled from my custom list, it throws an error at any function expecting a timestring or in most cases even a string as input. No matter, what I do with this string before, including adding characters or copying from variable to variable. When I (human) read and type the content of that variable back into another variable, all time processing functions will work without any complains.

My conclusion is, the string is poisoned by a non printing character. It even could be something evil like EOL or EOF. How else could I explain, that copy and pasting to an editor and back to the variable the incriminated string solves the problem at the time processing functions?

This would mean, that either the custom list’s storage of dates is corrupt or the implementation of the flow’s readout function is buggy. If so, where can I address that problem at M$?

In PERL there’s the chomp() function which removes non-printing characters from a string. Does something similar exist here?

programming languages – An expression in the first line of the control flow statement

Is there a term or some short wording to refer to an expression in the “first” line of the control flow statement?

func() {
  if (a == b) {
    var = 1 + 1
    return True
  } else {
    var = 5 + 5
    return False
  }
}
if ((a == b)
 && (c == d)) {
  ...
}

In the first example, the term/wording should “match” a == b, True, and False. It should not match 1 + 1 and 5 + 5.

In the second example, it should match (a == b) && (c == d).

I used to use “control flow statement expression”, but I do not think this term is accurate.